从张量流中的检查点恢复时出错

时间:2017-06-06 13:14:50

标签: tensorflow

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)]]

1 个答案:

答案 0 :(得分:0)

看起来您定义的模型与您保存的模型有某种不同。尝试使用saver = tf.train.import_meta_graph('your_model_name.meta')而不是在neural_network_model()中手动构建图表。

相关问题