Tensorflow模型恢复问题

时间:2018-09-13 13:04:52

标签: python tensorflow conda

在Tensorflow的RNN模型恢复期间,我一直发现以下问题。该模型运行良好,但是恢复存在问题。下面是我的代码。可能是什么问题。我已经删除并清理了所有上一个会话,但是仍然存在相同的问题。

saver = tf.train.import_meta_graph(os.path.join(logs_path, 
'Multi_Layer_RNN_model.ckpt-499999.meta'))

with tf.Session() as sess:
    ckpt = tf.train.get_checkpoint_state(logs_path)
    saver.restore(sess, tf.train.latest_checkpoint(logs_path))  

错误

InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [105,400] rhs shape= [111,400]
     [[Node: save/Assign_11 = Assign[T=DT_FLOAT, _class=["loc:@rnn/lstm_cell/kernel"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](rnn/lstm_cell/kernel/RMSProp_1, save/RestoreV2:11)]]

Caused by op 'save/Assign_11', defined at:
  File "C:\Users\ADMN\AppData\Local\conda\conda\envs\tensorflow\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\ADMN\AppData\Local\conda\conda\envs\tensorflow\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\ADMN\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\ipykernel_launcher.py", line 16, in <module>
    app.launch_new_instance()
  File "C:\Users\ADMN\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
    app.start()
  .................

1 个答案:

答案 0 :(得分:0)

在第一行中,您有以下原因:

awk -F, 'NR < 4 {print "<tr><td>" $2 "</td></tr>"}' "$TEXT_FILE" >> "$HTML_FILE"

您似乎在神经网络之间具有不同的矢量/张量维度。