2017-06-06 67 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

相關問題