微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何解决 tensorflow 1.0.0 中未加载权重的错误?

如何解决如何解决 tensorflow 1.0.0 中未加载权重的错误?

这是代码,我使用的是 TensorFlow 1.0.0 和 python 3.5。我正在使用康奈尔电影对话语料库训练 seq2seq 聊天机器人。我成功地将 weights.ckpt 文件保存在目录中。 enter image description here

# 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,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",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",**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,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],save/RestoreV2_52/shape_and_slices)]]

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。