Python 3.x 在Python 3.6中重新加载模型时缺少Tensorflow变量/图形键

Python 3.x 在Python 3.6中重新加载模型时缺少Tensorflow变量/图形键,python-3.x,tensorflow,conv-neural-network,Python 3.x,Tensorflow,Conv Neural Network,错误消息: NotFoundError:从检查点还原失败。这很可能是由于检查点中缺少变量名或其他图形键造成的。请确保您没有根据检查点更改预期的图形。原始错误: """ PLACEHOLDER """ x=tf.placeholder(tf.float32,shape=[None,784]) y_true=tf.placeholder(tf.float32,shape=[None,4]) Weight=tf.global_variables() bias=tf.global_variables

错误消息:

NotFoundError:从检查点还原失败。这很可能是由于检查点中缺少变量名或其他图形键造成的。请确保您没有根据检查点更改预期的图形。原始错误:

""" PLACEHOLDER """
x=tf.placeholder(tf.float32,shape=[None,784])
y_true=tf.placeholder(tf.float32,shape=[None,4])


Weight=tf.global_variables()
bias=tf.global_variables()

""" LAYERS:"""

"the image input layer 28*28 input"
x_image = tf.reshape(x,[-1,28,28,1])

"""first convolution, using 6*6 filter, and then max pooling 2by2, final 
output will have depth 32
here we are calculating 32 features
"""
convo_1 = convolutional_layer(x_image,shape=[6,6,1,32])
convo_1_pooling = max_pool_2by2(convo_1)

"""first convolution, using 6*6 filter, and then max pooling 2by2, final 
output will have 64
features hence depth 64
"""
convo_2 = convolutional_layer(convo_1_pooling,shape=[6,6,32,64])
convo_2_pooling = max_pool_2by2(convo_2)

"flattening the output of the last pooling layer to fuly connect it"
convo_2_flat = tf.reshape(convo_2_pooling,[-1,7*7*64])
Wt,bs=normal_full_layer(convo_2_flat,1024)#1024 nodes in the final layer

full_layer_one = tf.nn.relu(tf.matmul(convo_2_flat,Wt)+bs)

# NOTE THE PLACEHOLDER HERE!
hold_prob = tf.placeholder(tf.float32)
full_one_dropout = tf.nn.dropout(full_layer_one,keep_prob=hold_prob) 

Weight, bias= normal_full_layer(full_one_dropout,2)

y_pred=tf.matmul(full_one_dropout,Weight)+bias

"""INITIALIZE VARIABLES"""
init = tf.global_variables_initializer()

"""Add ops to save and restore all the variables"""
saver = tf.train.Saver()

"""Later, launch the model, use the saver to restore variables from disk, 
and
# do some work with the model"""

with tf.Session() as sess:
   # Restore variables from disk.
   saver.restore(sess,SAVE_PATH)
   print("Model restored.")

如果您使用spyder,请重新启动内核!它可以很好地工作


这是调用一个保存模型的代码,因此在计算了yyPrd之后,我还没有使用计算丢失函数(我已经删除了代码的一部分)。我只希望输入的x数组i的预测y值数组。请考虑添加更多的细节。