iT邦幫忙

0

tensorflow BP倒傳遞類神經 遇到問題

  • 分享至 

  • xImage

各位大大好,小弟剛入門寫PYTHON,我用tensorflow寫倒傳遞類神經,一直無法解決問題,之前可以跑,現在突然無法跑,不知道是不是漏掉什麼安裝包沒下載,原因暫時不曉得,希望大大們幫忙。
evaluations = []
STEPS = 400
for i in range(1250):
regressor.train(input_fn=wx_input_fn(X_train, y=y_train), steps=STEPS)
evaluations.append(regressor.evaluate(input_fn=wx_input_fn(X_val,
y_val,
num_epochs=1,
shuffle=False)))
以上是我的程式碼,結果跑出以下錯誤:
NotFoundError: Restoring from checkpoint failed. This is most likely due to a Variable name or other graph key that is missing from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

2 root error(s) found.
(0) Not found: Key dnn/hiddenlayer_1/bias not found in checkpoint
[[node save/RestoreV2 (defined at \anaconda3\envs\bp-gpu\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py:1502) ]]
(1) Not found: Key dnn/hiddenlayer_1/bias not found in checkpoint
[[node save/RestoreV2 (defined at \anaconda3\envs\bp-gpu\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py:1502) ]]
[[save/RestoreV2/_7]]
0 successful operations.
0 derived errors ignored.

Original stack trace for 'save/RestoreV2':
File "\anaconda3\envs\bp-gpu\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "\anaconda3\envs\bp-gpu\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "\anaconda3\envs\bp-gpu\lib\site-packages\ipykernel_launcher.py", line 16, in
app.launch_new_instance()
File "\anaconda3\envs\bp-gpu\lib\site-packages\traitlets\config\application.py", line 846, in launch_instance
app.start()
File "\anaconda3\envs\bp-gpu\lib\site-packages\ipykernel\kernelapp.py", line 677, in start
self.io_loop.start()
File "\anaconda3\envs\bp-gpu\lib\site-packages\tornado\platform\asyncio.py", line 199, in start
self.asyncio_loop.run_forever()
File "\anaconda3\envs\bp-gpu\lib\asyncio\base_events.py", line 601, in run_forever
self._run_once()
File "\anaconda3\envs\bp-gpu\lib\asyncio\base_events.py", line 1905, in _run_once
handle._run()
File "\anaconda3\envs\bp-gpu\lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "\anaconda3\envs\bp-gpu\lib\site-packages\ipykernel\kernelbase.py", line 471, in dispatch_queue
await self.process_one()
File "\anaconda3\envs\bp-gpu\lib\site-packages\ipykernel\kernelbase.py", line 460, in process_one
await dispatch(*args)
File "\anaconda3\envs\bp-gpu\lib\site-packages\ipykernel\kernelbase.py", line 367, in dispatch_shell
await result
File "\anaconda3\envs\bp-gpu\lib\site-packages\ipykernel\kernelbase.py", line 662, in execute_request
reply_content = await reply_content
File "\anaconda3\envs\bp-gpu\lib\site-packages\ipykernel\ipkernel.py", line 360, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "\anaconda3\envs\bp-gpu\lib\site-packages\ipykernel\zmqshell.py", line 532, in run_cell
return super().run_cell(*args, **kwargs)
File "\anaconda3\envs\bp-gpu\lib\site-packages\IPython\core\interactiveshell.py", line 2880, in run_cell
result = self._run_cell(
File "\anaconda3\envs\bp-gpu\lib\site-packages\IPython\core\interactiveshell.py", line 2935, in _run_cell
return runner(coro)
File "\anaconda3\envs\bp-gpu\lib\site-packages\IPython\core\async_helpers.py", line 129, in pseudo_sync_runner
coro.send(None)
File "\anaconda3\envs\bp-gpu\lib\site-packages\IPython\core\interactiveshell.py", line 3134, in run_cell_async
has_raised = await self.run_ast_nodes(code_ast.body, cell_name,
File "\anaconda3\envs\bp-gpu\lib\site-packages\IPython\core\interactiveshell.py", line 3337, in run_ast_nodes
if await self.run_code(code, result, async
=asy):
File "\anaconda3\envs\bp-gpu\lib\site-packages\IPython\core\interactiveshell.py", line 3397, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "\AppData\Local\Temp\ipykernel_21300\2606756210.py", line 4, in <cell line: 3>
regressor.train(input_fn=wx_input_fn(X_train, y=y_train), steps=STEPS)
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 350, in train
loss = self._train_model(input_fn, hooks, saving_listeners)
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1176, in _train_model
return self._train_model_default(input_fn, hooks, saving_listeners)
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1207, in _train_model_default
return self._train_with_estimator_spec(estimator_spec, worker_hooks,
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1502, in _train_with_estimator_spec
with training.MonitoredTrainingSession(
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\training\monitored_session.py", line 602, in MonitoredTrainingSession
return MonitoredSession(
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1035, in init
super(MonitoredSession, self).init(
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\training\monitored_session.py", line 750, in init
self._sess = _RecoverableSession(self._coordinated_creator)
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1232, in init
_WrappedSession.init(self, self._create_session())
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1237, in _create_session
return self._sess_creator.create_session()
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\training\monitored_session.py", line 903, in create_session
self.tf_sess = self._session_creator.create_session()
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\training\monitored_session.py", line 661, in create_session
self._scaffold.finalize()
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\training\monitored_session.py", line 244, in finalize
self._saver.build()
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\training\saver.py", line 848, in build
self._build(self._filename, build_save=True, build_restore=True)
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\training\saver.py", line 876, in _build
self.saver_def = self._builder._build_internal( # pylint: disable=protected-access
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\training\saver.py", line 509, in _build_internal
restore_op = self._AddShardedRestoreOps(filename_tensor, per_device,
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\training\saver.py", line 383, in _AddShardedRestoreOps
self._AddRestoreOps(
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\training\saver.py", line 335, in _AddRestoreOps
all_tensors = self.bulk_restore(filename_tensor, saveables, preferred_shard,
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\training\saver.py", line 583, in bulk_restore
return io_ops.restore_v2(filename_tensor, names, slices, dtypes)
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\ops\gen_io_ops.py", line 1489, in restore_v2
_, _, _op, _outputs = _op_def_library._apply_op_helper(
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 748, in _apply_op_helper
op = g._create_op_internal(op_type_name, inputs, dtypes=None,
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\framework\ops.py", line 3561, in _create_op_internal
ret = Operation(
File "\anaconda3\envs\bp-gpu\lib\site-packages\tensorflow\python\framework\ops.py", line 2045, in init
self._traceback = tf_stack.extract_stack_for_node(self._c_op)

andow1198 iT邦新手 4 級 ‧ 2022-06-01 09:56:37 檢舉
似乎是你調用的變數名稱和checkpoint文件裡的不一致,你應該可以嘗試檢查看看
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答