从tensorflow中的检查点还原时出错

从tensorflow中的检查点还原时出错,tensorflow,Tensorflow,这是我正在编写的代码示例。我已将model.ckpt保存在与我的文件相同的目录中 但是,当我运行代码时,会出现一个错误,提示: 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_epoch

这是我正在编写的代码示例。我已将
model.ckpt
保存在与我的文件相同的目录中

但是,当我运行代码时,会出现一个错误,提示:

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

看起来您定义的模型与您保存的模型有些不同。尝试使用
saver=tf.train.import\u meta\u graph('your\u model\u name.meta')
而不是在
neural\u network\u model()。运行train_neural_network现在给我的错误是ValueError:没有为任何变量提供梯度,请检查您的图形,查看变量之间不支持梯度的ops。
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)]]