这是代码,我使用的是 TensorFlow 1.0.0 和 python 3.5。我正在使用康奈尔电影对话语料库训练 seq2seq 聊天机器人。我已成功将 weights.ckpt 文件保存在目录中。 在此处输入图像描述
# Loading the weights and Running the session
checkpoint = "./chatbot_weights.ckpt"
session = tf.InteractiveSession()
session.run(tf.global_variables_initializer())
saver = tf.train.Saver()
saver.restore(session, checkpoint)
我收到此错误,但我不明白为什么我的 weigts 文件无法加载
Traceback (most recent call last):
File "<ipython-input-5-7e1221f761c6>", line 5, in <module>
saver.restore(session, checkpoint)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tensorflow\python\training\saver.py", line 1439, in restore
{self.saver_def.filename_tensor_name: save_path})
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tensorflow\python\client\session.py", line 767, in run
run_metadata_ptr)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tensorflow\python\client\session.py", line 965, in _run
feed_dict_string, options, run_metadata)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tensorflow\python\client\session.py", line 1015, in _do_run
target_list, options, run_metadata)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tensorflow\python\client\session.py", line 1035, in _do_call
raise type(e)(node_def, op, message)
NotFoundError: NewRandomAccessFile failed to Create/Open: ./chatbot_weights.ckpt.data-00000-of-00001 : The system cannot find the file specified.
[[Node: save/RestoreV2_52 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/RestoreV2_52/tensor_names, save/RestoreV2_52/shape_and_slices)]]
Caused by op 'save/RestoreV2_52', defined at:
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\spyder\utils\ipython\start_kernel.py", line 269, in <module>
main()
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\spyder\utils\ipython\start_kernel.py", line 265, in main
kernel.start()
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\ipykernel\kernelapp.py", line 486, in start
self.io_loop.start()
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tornado\platform\asyncio.py", line 127, in start
self.asyncio_loop.run_forever()
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\asyncio\base_events.py", line 421, in run_forever
self._run_once()
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\asyncio\base_events.py", line 1425, in _run_once
handle._run()
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\asyncio\events.py", line 127, in _run
self._callback(*self._args)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tornado\platform\asyncio.py", line 117, in _handle_events
handler_func(fileobj, events)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tornado\stack_context.py", line 276, in null_wrapper
return fn(*args, **kwargs)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\zmq\eventloop\zmqstream.py", line 450, in _handle_events
self._handle_recv()
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\zmq\eventloop\zmqstream.py", line 480, in _handle_recv
self._run_callback(callback, msg)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\zmq\eventloop\zmqstream.py", line 432, in _run_callback
callback(*args, **kwargs)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tornado\stack_context.py", line 276, in null_wrapper
return fn(*args, **kwargs)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\ipykernel\kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\ipykernel\kernelbase.py", line 233, in dispatch_shell
handler(stream, idents, msg)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\ipykernel\kernelbase.py", line 399, in execute_request
user_expressions, allow_stdin)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\ipykernel\ipkernel.py", line 208, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\ipykernel\zmqshell.py", line 537, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\IPython\core\interactiveshell.py", line 2662, in run_cell
raw_cell, store_history, silent, shell_futures)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\IPython\core\interactiveshell.py", line 2785, in _run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\IPython\core\interactiveshell.py", line 2903, in run_ast_nodes
if self.run_code(code, result):
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\IPython\core\interactiveshell.py", line 2963, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-5-7e1221f761c6>", line 4, in <module>
saver = tf.train.Saver()
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tensorflow\python\training\saver.py", line 1051, in __init__
self.build()
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tensorflow\python\training\saver.py", line 1081, in build
restore_sequentially=self._restore_sequentially)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tensorflow\python\training\saver.py", line 675, in build
restore_sequentially, reshape)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tensorflow\python\training\saver.py", line 402, in _AddRestoreOps
tensors = self.restore_op(filename_tensor, saveable, preferred_shard)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tensorflow\python\training\saver.py", line 242, in restore_op
[spec.tensor.dtype])[0])
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tensorflow\python\ops\gen_io_ops.py", line 668, in restore_v2
dtypes=dtypes, name=name)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 763, in apply_op
op_def=op_def)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tensorflow\python\framework\ops.py", line 2395, in create_op
original_op=self._default_original_op, op_def=op_def)
File "C:\Users\DIV CHAUDHARY\.conda\envs\chatbot\lib\site-packages\tensorflow\python\framework\ops.py", line 1264, in __init__
self._traceback = _extract_stack()
NotFoundError (see above for traceback): NewRandomAccessFile failed to Create/Open: ./chatbot_weights.ckpt.data-00000-of-00001 : The system cannot find the file specified.
[[Node: save/RestoreV2_52 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/RestoreV2_52/tensor_names, save/RestoreV2_52/shape_and_slices)]]