error_recognize icon indicating copy to clipboard operation
error_recognize copied to clipboard

ValueError: No variables to save

Open wangleiai opened this issue 4 years ago • 2 comments

您好,我运行您代码的时候,发现您把run_classififer.py中的966行和1007行注释了,我去掉注释后,才可以运行。 但是保存模型的时候报了以下错误,想问您如何解决呢?麻烦您了! Traceback (most recent call last): File "run_classifier.py", line 1072, in tf.app.run() File "/home/wanglei/.conda/envs/cc/lib/python3.7/site-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "run_classifier.py", line 1046, in main saver = tf.train.Saver() File "/home/wanglei/.conda/envs/cc/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 832, in init self.build() File "/home/wanglei/.conda/envs/cc/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 844, in build self._build(self._filename, build_save=True, build_restore=True) File "/home/wanglei/.conda/envs/cc/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 869, in _build raise ValueError("No variables to save") ValueError: No variables to save

wangleiai avatar Jan 06 '21 03:01 wangleiai

您好,我运行您代码的时候,发现您把run_classififer.py中的966行和1007行注释了,我去掉注释后,才可以运行。 但是保存模型的时候报了以下错误,想问您如何解决呢?麻烦您了! Traceback (most recent call last): File "run_classifier.py", line 1072, in tf.app.run() File "/home/wanglei/.conda/envs/cc/lib/python3.7/site-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "run_classifier.py", line 1046, in main saver = tf.train.Saver() File "/home/wanglei/.conda/envs/cc/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 832, in init self.build() File "/home/wanglei/.conda/envs/cc/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 844, in build self._build(self._filename, build_save=True, build_restore=True) File "/home/wanglei/.conda/envs/cc/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 869, in _build raise ValueError("No variables to save") ValueError: No variables to save

run.sh脚本是可以运行吧,这个代码只运行训练部分是可以的,也就是调estimator的train接口,模型会自动保存,train_and_eval也是没问题的,报错那部分代码可以直接去掉,是predict相关的 运行到这个地方说明已经成功了,output目录下应该有数据了,该行注释调就行

ganguagua avatar Jan 13 '21 06:01 ganguagua

感谢回复,我试试看

wangleiai avatar Jan 15 '21 02:01 wangleiai