Tensorflow saver无法正常工作

2024-04-24 08:45:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我做了一个保存程序来保存我的模型在我的测试模块。因为tensorflow使用了一个新的保存方案,所以它不直接存储.ckpt文件。所以我们用.data-00000-of-00001和.index文件代替.ckpt文件。在

我的保存代码:

saver = tf.train.Saver()
save_path = saver.save(sess, 'D:\Speech_Project\my_model\my_model_01')

以及恢复:

^{pr2}$

我得到的错误是:

TypeError: expected bytes, NoneType found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/admin/PycharmProjects/BanglaCNN01/banglacnn05.py", line 318, in <module>
test_cnn(X1)
File "C:/Users/admin/PycharmProjects/BanglaCNN01/banglacnn05.py", line 243, in test_cnn
saver.restore(sess, tf.train.latest_checkpoint('./'))
File "C:\Users\admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 1428, in restore
{self.saver_def.filename_tensor_name: save_path})
File "C:\Users\admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 767, in run
run_metadata_ptr)
File "C:\Users\admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 965, in _run
feed_dict_string, options, run_metadata)
File "C:\Users\admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1015, in _do_run
target_list, options, run_metadata)
File "C:\Users\admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1022, in _do_call
return fn(*args)
File "C:\Users\admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1004, in _run_fn
status, run_metadata)
SystemError: <built-in function TF_Run> returned a result with an error set

Process finished with exit code 1

请注意,所有代码都在同一个.py文件中。Tensorflow 1.0.1版,适用于Windows CPU版本。即使

graph = tf.get_default_graph()

错误是一样的。需要你的见解。在


Tags: runinpyadminlibpackageslocaltensorflow