我正在基于这个Github项目进行神经网络着色实验:
在colorize.py文件中,我在创建保护程序之前添加了以下代码:
ckpt_reader = tf.train.NewCheckpointReader(saved_path)
ckpt_vars = ckpt_reader.get_variable_to_shape_map()
print (ckpt_vars)
然而,当我执行colorize.py来恢复模型并着色测试图像时,它会将存储的模型打印为字典:
{'generator/conv8e/bias': [512], 'generator/conv8e/batch_normalization/scale': [512], 'generator/conv8e/batch_normalization/offset': [512], 'generator/conv8d/weights': [4, 4, 2, 64], 'generator/conv7e/weights': [4, 4, 512, 512], 'generator/conv7e/batch_normalization/scale': [512], 'generator/conv7e/batch_normalization/offset': [512], 'generator/conv7d/weights': [4, 4, 64, 128], 'generator/conv7d/bias': [64], 'generator/conv7d/batch_normalization/offset': [1], 'generator/conv4e/batch_normalization/scale': [512], 'generator/conv6e/batch_normalization/offset': [512], 'generator/conv6e/bias': [512], 'generator/conv6d/batch_normalization/offset': [1], 'generator/conv4e/bias': [512], 'generator/conv6e/weights': [4, 4, 512, 512], 'generator/conv5e/weights': [4, 4, 512, 512], 'generator/conv5d/weights': [4, 4, 256, 512], 'generator/conv5e/batch_normalization/scale': [512], 'generator/conv5d/batch_normalization/offset': [1], 'generator/conv6d/weights': [4, 4, 128, 256], 'generator/conv4e/weights': [4, 4, 256, 512], 'generator/conv7d/batch_normalization/scale': [1], 'generator/conv4e/batch_normalization/offset': [512], 'generator/conv5d/batch_normalization/scale': [1], 'generator/conv4d/batch_normalization/scale': [1], 'generator/conv3e/weights': [4, 4, 128, 256], 'generator/conv5e/bias': [512], 'generator/conv2e/batch_normalization/scale': [128], 'generator/conv4d/bias': [512], 'generator/conv3d/batch_normalization/offset': [1], 'generator/conv3e/bias': [256], 'generator/conv5d/bias': [256], 'generator/conv3d/weights': [4, 4, 512, 512], 'generator/conv4d/weights': [4, 4, 512, 512], 'generator/conv6d/bias': [128], 'generator/conv3d/batch_normalization/scale': [1], 'generator/conv3e/batch_normalization/offset': [256], 'generator/conv6d/batch_normalization/scale': [1], 'generator/conv5e/batch_normalization/offset': [512], 'generator/conv2e/batch_normalization/offset': [128], 'generator/conv2e/bias': [128], 'generator/conv1d/bias': [512], 'generator/conv2d/weights': [4, 4, 512, 512], 'generator/conv2d/batch_normalization/scale': [1], 'generator/conv3e/batch_normalization/scale': [256], 'generator/conv2e/weights': [4, 4, 64, 128], 'generator/conv7e/bias': [512], 'generator/conv6e/batch_normalization/scale': [512], 'generator/conv1d/batch_normalization/offset': [1], 'generator/conv8d/bias': [2], 'generator/conv1e/weights': [4, 4, 1, 64], 'generator/conv1d/weights': [4, 4, 512, 512], 'generator/conv3d/bias': [512], 'generator/conv1e/bias': [64], 'generator/conv1d/batch_normalization/scale': [1], 'generator/conv8e/weights': [4, 4, 512, 512], 'generator/conv4d/batch_normalization/offset': [1], 'generator/conv2d/bias': [512], 'generator/conv2d/batch_normalization/offset': [1]}
但是抱怨在检查点文件中找不到以下变量:
W tensorflow/core/framework/op_kernel.cc:993] Not found: Key generator/conv4d/batch_normalization/generator/conv4d/batch_normalization/moments/normalize/variance/ExponentialMovingAverage not found in checkpoint
等等。
存储的模型及其变量适用于generator.py.
所以我的问题是模型将如何以及在何处存储一个名为:
的变量发电机/ conv4d / batch_normalization /发电机/ conv4d / batch_normalization /时刻/正常化/方差/ ExponentialMovingAverage
由于这个长名称变量未正确存储,因此可能出错。
谢谢。