检查点错误

时间:2018-03-10 08:14:02

标签: python python-2.7 tensorflow deep-learning

我正在尝试使用估算器实现DNN分类器,如本教程所示:http://nbviewer.jupyter.org/gist/yufengg/7dd4170cc730ce418a1dcd141532ec6e

但是,每当我运行代码时,我都会收到这条冗长的错误消息:

追踪(最近一次通话):   File&#34; / Users / vivekreddy / Desktop / NN / IRis Practice Estimators.py&#34;,第48行,in     步骤= 1000)   火车文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/estimator/estimator.py" ;,第352行,在火车上     loss = self._train_model(input_fn,hooks,saving_listeners)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/estimator/estimator.py" ;,第888行,在_train_model中     log_step_count_steps = self._config.log_step_count_steps)为mon_sess:   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py",第384行,在MonitoredTrainingSession中     stop_grace_period_secs = stop_grace_period_secs)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py" ;,第795行,在 init < /强>     stop_grace_period_secs = stop_grace_period_secs)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py" ;,第518行,在 init < /强>     self._sess = _RecoverableSession(self._coordinated_creator)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py" ;,第981行,在 init < /强>     _WrappedSession。 init (self,self._create_session())   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py",第986行,在_create_session中     return self._sess_creator.create_session()   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py" ;,第675行,在create_session中     self.tf_sess = self._session_creator.create_session()   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py",第446行,在create_session中     init_fn = self._scaffold.init_fn)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/session_manager.py" ;,第275行,在prepare_session中     配置= CONFIG)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/session_manager.py" ;,第207行,在_restore_checkpoint中     saver.restore(sess,ckpt.model_checkpoint_path)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/saver.py" ;,第1755行,恢复     {self.saver_def.filename_tensor_name:save_path})   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/client/session.py" ;,第905行,在运行中     run_metadata_ptr)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/client/session.py" ;,第1137行,在_run中     feed_dict_tensor,options,run_metadata)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/client/session.py" ;,第1355行,在_do_run中     选项,run_metadata)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/client/session.py" ;,第1374行,在_do_call     提升类型(e)(node_def,op,message) NotFoundError:检查点中找不到密钥dnn / hiddenlayer_0 / bias      [[节点:save / RestoreV2 = RestoreV2 [dtypes = [DT_FLOAT,DT_FLOAT,DT_FLOAT,DT_FLOAT,DT_FLOAT,...,DT_FLOAT,DT_FLOAT,DT_FLOAT,DT_FLOAT,DT_INT64],_ device =&#34; / job:localhost / replica :0 / task:0 / device:CPU:0&#34;](_ arg_save / Const_0_0,save / RestoreV2 / tensor_names,save / RestoreV2 / shape_and_slices)]]

由op u&#39; save / RestoreV2&#39;引起,定义于:   文件&#34;&#34;,第1行,in   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/idlelib/run.py" ;,第115行,主要     ret =方法(* args,** kwargs)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/idlelib/run.py" ;,第325行,在runco​​de中     self.locals中的exec代码   File&#34; / Users / vivekreddy / Desktop / NN / IRis Practice Estimators.py&#34;,第48行,in     步骤= 1000)   火车文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/estimator/estimator.py" ;,第352行,在火车上     loss = self._train_model(input_fn,hooks,saving_listeners)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/estimator/estimator.py" ;,第888行,在_train_model中     log_step_count_steps = self._config.log_step_count_steps)为mon_sess:   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py",第384行,在MonitoredTrainingSession中     stop_grace_period_secs = stop_grace_period_secs)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py" ;,第795行,在 init < /强>     stop_grace_period_secs = stop_grace_period_secs)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py" ;,第518行,在 init < /强>     self._sess = _RecoverableSession(self._coordinated_creator)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py" ;,第981行,在 init < /强>     _WrappedSession。 init (self,self._create_session())   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py",第986行,在_create_session中     return self._sess_creator.create_session()   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py" ;,第675行,在create_session中     self.tf_sess = self._session_creator.create_session()   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py" ;,第437行,在create_session中     self._scaffold.finalize()   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py" ;,第214行,最终确定     self._saver.build()   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/saver.py" ;,第1302行,在构建中     self._build(self._filename,build_save = True,build_restore = True)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/saver.py" ;,第1339行,在_build中     build_save = build_save,build_restore = build_restore)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/saver.py",第790行,在_build_internal中     restore_sequentially,重塑)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/saver.py" ;,第502行,在_AddShardedRestoreOps中     名称=&#34; restore_shard&#34))   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/saver.py" ;,第449行,在_AddRestoreOps中     restore_sequentially)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/training/saver.py" ;,第847行,在bulk_restore中     返回io_ops.restore_v2(filename_tensor,名称,切片,dtypes)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/ops/gen_io_ops.py",第1030行,在restore_v2中     shape_and_slices = shape_and_slices,dtypes = dtypes,name = name)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py" ;,第787行,在_apply_op_helper中     op_def = op_def)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/framework/ops.py",第3271行,在create_op中     op_def = op_def)   文件&#34; /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/framework/ops.py" ;,第1650行,在 init < /强>     self._traceback = self._graph._extract_stack()#pylint:disable = protected-access

NotFoundError(参见上面的回溯):检查点中找不到密钥dnn / hiddenlayer_0 / bias      [[节点:save / RestoreV2 = RestoreV2 [dtypes = [DT_FLOAT,DT_FLOAT,DT_FLOAT,DT_FLOAT,DT_FLOAT,...,DT_FLOAT,DT_FLOAT,DT_FLOAT,DT_FLOAT,DT_INT64],_ device =&#34; / job:localhost / replica :0 / task:0 / device:CPU:0&#34;](_ arg_save / Const_0_0,save / RestoreV2 / tensor_names,save / RestoreV2 / shape_and_slices)]]

在做了一些打印语句之后,我确信在这行代码中发生了错误: classifier.train(input_fn = input_fn(training_set),步数= 1000)

我想知道它是否与我的Tensorflow版本有关,即1.6 任何帮助赞赏。感谢。

2 个答案:

答案 0 :(得分:4)

我想我知道答案。只需删除模型目录下的所有文件(包括检查点)即可。如果您执行了以前的模型并且在执行后没有删除文件,那么会有文件。

答案 1 :(得分:0)

发生这种情况是因为同一目录包含另一个模型的组件。就我而言,我具有以前的线性模型的组件,并试图在同一文件夹中创建DNN分类器。我删除了所有(/temp/iris_model/),然后重试。有效。

操作系统:Ubuntu 16.04 LTS
tensorflow:1.11.0
IDE:jupytor笔记本