2017-06-06 116 views
1
def test_neural_network(): 
    prediction = neural_network_model(x) 
    with tf.Session() as sess: 
     sess.run(tf.global_variables_initializer()) 
     for epoch in range(hm_epochs): 
      saver.restore(sess, './model.ckpt') 
     # more code here 

这是我正在处理的代码示例。我已将model.ckpt保存在与我的文件相同的目录中。从张量流中的检查点恢复时出错

然而,当我运行代码,我得到一个错误说:

InvalidArgumentError (see above for traceback): Expected to restore a tensor of type float, got a tensor of type int32 instead: tensor_name = Variable 
[[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]] 

回答

0

它看起来像你的模型定义是你救了一个有些不同。尝试使用saver = tf.train.import_meta_graph('your_model_name.meta')而不是在neural_network_model()中手动生成图。

+0

我使用了saver = tf.train.Saver()。运行train_neural_network现在给我错误说ValueError:没有为任何变量提供梯度,检查您的图表不支持变量之间梯度的操作。 – rjmessibarca