下载群里的小黄鸡200轮model,运行test.py出现错误
来源:10-5 第一种模型训练(5)

yhappy
2019-07-04
下载群里的小黄鸡200轮model,运行test.py出现错误
2019-07-04 19:00:06.287769: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
try load model from ./model/s2ss_chatbot.ckpt
Traceback (most recent call last):
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\client\session.py”, line 1334, in _do_call
return fn(*args)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\client\session.py”, line 1319, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\client\session.py”, line 1407, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [128,3549] rhs shape= [128,5998]
[[{{node save/Assign_7}} = Assign[T=DT_FLOAT, _class=[“loc:@decoder/decoder_output_projection/kernel”], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](decoder/decoder_output_projection/kernel, save/RestoreV2:7)]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\training\saver.py”, line 1546, in restore
{self.saver_def.filename_tensor_name: save_path})
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\client\session.py”, line 929, in run
run_metadata_ptr)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\client\session.py”, line 1152, in _run
feed_dict_tensor, options, run_metadata)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\client\session.py”, line 1328, in _do_run
run_metadata)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\client\session.py”, line 1348, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [128,3549] rhs shape= [128,5998]
[[node save/Assign_7 (defined at C:\Users\lenovo\PycharmProjects\chatbot\sequence_to_sequence.py:139) = Assign[T=DT_FLOAT, _class=[“loc:@decoder/decoder_output_projection/kernel”], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](decoder/decoder_output_projection/kernel, save/RestoreV2:7)]]
Caused by op ‘save/Assign_7’, defined at:
File “C:/Users/lenovo/PycharmProjects/chatbot/test.py”, line 70, in
main()
File “C:/Users/lenovo/PycharmProjects/chatbot/test.py”, line 67, in main
test(json.load(open(‘params.json’)))
File “C:/Users/lenovo/PycharmProjects/chatbot/test.py”, line 33, in test
**params
File “C:\Users\lenovo\PycharmProjects\chatbot\sequence_to_sequence.py”, line 122, in init
self.build_model()
File “C:\Users\lenovo\PycharmProjects\chatbot\sequence_to_sequence.py”, line 139, in build_model
self.saver = tf.train.Saver()
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\training\saver.py”, line 1102, in init
self.build()
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\training\saver.py”, line 1114, in build
self._build(self._filename, build_save=True, build_restore=True)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\training\saver.py”, line 1151, in _build
build_save=build_save, build_restore=build_restore)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\training\saver.py”, line 795, in _build_internal
restore_sequentially, reshape)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\training\saver.py”, line 428, in _AddRestoreOps
assign_ops.append(saveable.restore(saveable_tensors, shapes))
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\training\saver.py”, line 119, in restore
self.op.get_shape().is_fully_defined())
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\state_ops.py”, line 221, in assign
validate_shape=validate_shape)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\gen_state_ops.py”, line 64, in assign
use_locking=use_locking, name=name)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\op_def_library.py”, line 787, in _apply_op_helper
op_def=op_def)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\util\deprecation.py”, line 488, in new_func
return func(*args, **kwargs)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py”, line 3274, in create_op
op_def=op_def)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py”, line 1770, in init
self._traceback = tf_stack.extract_stack()
InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [128,3549] rhs shape= [128,5998]
[[node save/Assign_7 (defined at C:\Users\lenovo\PycharmProjects\chatbot\sequence_to_sequence.py:139) = Assign[T=DT_FLOAT, _class=[“loc:@decoder/decoder_output_projection/kernel”], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](decoder/decoder_output_projection/kernel, save/RestoreV2:7)]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “C:/Users/lenovo/PycharmProjects/chatbot/test.py”, line 70, in
main()
File “C:/Users/lenovo/PycharmProjects/chatbot/test.py”, line 67, in main
test(json.load(open(‘params.json’)))
File “C:/Users/lenovo/PycharmProjects/chatbot/test.py”, line 39, in test
model_pred.load(sess, save_path)
File “C:\Users\lenovo\PycharmProjects\chatbot\sequence_to_sequence.py”, line 627, in load
self.saver.restore(sess, save_path)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\training\saver.py”, line 1582, in restore
err, “a mismatch between the current graph and the graph”)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:
Assign requires shapes of both tensors to match. lhs shape= [128,3549] rhs shape= [128,5998]
[[node save/Assign_7 (defined at C:\Users\lenovo\PycharmProjects\chatbot\sequence_to_sequence.py:139) = Assign[T=DT_FLOAT, _class=[“loc:@decoder/decoder_output_projection/kernel”], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](decoder/decoder_output_projection/kernel, save/RestoreV2:7)]]
Caused by op ‘save/Assign_7’, defined at:
File “C:/Users/lenovo/PycharmProjects/chatbot/test.py”, line 70, in
main()
File “C:/Users/lenovo/PycharmProjects/chatbot/test.py”, line 67, in main
test(json.load(open(‘params.json’)))
File “C:/Users/lenovo/PycharmProjects/chatbot/test.py”, line 33, in test
**params
File “C:\Users\lenovo\PycharmProjects\chatbot\sequence_to_sequence.py”, line 122, in init
self.build_model()
File “C:\Users\lenovo\PycharmProjects\chatbot\sequence_to_sequence.py”, line 139, in build_model
self.saver = tf.train.Saver()
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\training\saver.py”, line 1102, in init
self.build()
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\training\saver.py”, line 1114, in build
self._build(self._filename, build_save=True, build_restore=True)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\training\saver.py”, line 1151, in _build
build_save=build_save, build_restore=build_restore)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\training\saver.py”, line 795, in _build_internal
restore_sequentially, reshape)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\training\saver.py”, line 428, in _AddRestoreOps
assign_ops.append(saveable.restore(saveable_tensors, shapes))
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\training\saver.py”, line 119, in restore
self.op.get_shape().is_fully_defined())
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\state_ops.py”, line 221, in assign
validate_shape=validate_shape)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\gen_state_ops.py”, line 64, in assign
use_locking=use_locking, name=name)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\op_def_library.py”, line 787, in _apply_op_helper
op_def=op_def)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\util\deprecation.py”, line 488, in new_func
return func(*args, **kwargs)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py”, line 3274, in create_op
op_def=op_def)
File “C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py”, line 1770, in init
self._traceback = tf_stack.extract_stack()
InvalidArgumentError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:
Assign requires shapes of both tensors to match. lhs shape= [128,3549] rhs shape= [128,5998]
[[node save/Assign_7 (defined at C:\Users\lenovo\PycharmProjects\chatbot\sequence_to_sequence.py:139) = Assign[T=DT_FLOAT, _class=[“loc:@decoder/decoder_output_projection/kernel”], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](decoder/decoder_output_projection/kernel, save/RestoreV2:7)]]
1回答
-
Mr_Ricky
2019-07-11
你这个问题是模型在预测时候参数不一样导致的,可以检查下参数。
00