我有一个名为cnn-bn-relu的函数,该函数执行一系列卷积-批处理-归一化-Relu并返回输出。从上面的函数中获得训练有素的模型,我正在尝试不仅使用测试图像而且还使用它的增强副本来测试模型
步骤1。将原始图像输入到函数cnn-bn-relu
test_reconstructed_image_1_output=cnn-bn-relu(test_image_1,weights_layer_1,weights_layer_2,weights_layer_3,weights_layer_4)
步骤2。接下来将其扩展副本传递给函数cnn-bn-relu
test_reconstructed_aug_image_1_output=cnn-bn-relu(test_aug_image_1,weights_layer_1,weights_layer_2,weights_layer_3,weights_layer_4)
经过以上两个步骤,我恢复了训练后的模型权重,并尝试获取步骤1和步骤2的输出。但是,我得到了以下错误
NotFoundError(请参阅上面的回溯):从检查点还原失败了这很可能是由于变量名或其他图形键检查点缺少的内容。请确保您没有根据检查点更改了期望的图形。原始错误:
我发现计算图像的增强副本与原始图像的卷积会导致上述错误,但是我不知道如何解决。
下面是我使用的代码。
Step 1:
Reading the images from tensorflow record using dataset api
test_dataset = (tf.data.TFRecordDataset(test_tfrecords_filename_label)
.map(read_and_decode,num_parallel_calls=multiprocessing.cpu_count())
.prefetch(1))
iterator = test_dataset.make_one_shot_iterator()
test_image_1,aug_test_image_1= iterator.get_next()
Step 2:
# Calculating convolution for original image
test_reconstructed_image_1_output=cnn-bn-relu(test_image_1,weights_layer_1,weights_layer_2,weights_layer_3,weights_layer_4)
# Calculating convolution for augmented copy of original image
test_reconstructed_aug_image_1_output=cnn-bn-relu(test_patches_image_1,weights_layer_1,weights_layer_2,weights_layer_3,weights_layer_4)
Step 3:restoring the model and running the tensorflow session
saver1 = tf.train.Saver()
sess1 = tf.Session()
saver1.restore(sess1, "model.ckpt")
for i in range(0,3):
output_1,output_2 = sess1.run( test_reconstructed_image_1_output,test_reconstructed_aug_image_1)
上面的代码产生上述错误。
If i comment the line
test_reconstructed_aug_image_1_output=cnn-bn- relu(test_patches_image_1,weights_layer_1,weights_layer_2,weights_layer_3,weights_layer_4)
and replace
for i in range(0,3):
output_1,output_2 = sess1.run(
test_reconstructed_image_1_output,test_reconstructed_aug_image_1)
with
for i in range(0,3):
output_1= sess1.run( test_reconstructed_image_1_output)
我没有收到错误。
任何人都可以指导我如何修改代码以同时获得output_1和output_2时没有错误。
我正在尝试做与您所做的类似的事情,并且遇到了相同的问题。我想知道您是否找到解决方案?