TensorFlow报错:ValueError The passed save_path is not a valid checkpoint
报错
错误是由于在测试的过程中导入checkpoint时,传入的save_path是无效的,或者是说,传入的save_path在给定的路径中没有找到对应的文件。
self.saver.restore(sess, checkpoint.model_checkpoint_path)
原因
Tensorflow会将模型保存生成四个文件,如下图所示。
- 图a的情况是模型保存时,仅传入了地址,而地址中不包含文件的名称。在这种情况下,checkpoint_dir可以直接作为路径传入模型恢复save.restore()的函数中。
- 图b的情况是模型保存时,地址中添加了需要保存文件的名称filename,并且在save声明时,使用了max_to_keep=1的设置,即保存的文件名称中,在XXX.ckpt后包含 “-1” 的名称,其表示当前保存模型的训练代数。在这种情况下,使用当前的checkpoint_dir作为模型恢复saver.restore()函数中的路径,将会报错。
在编写时,如果使用的是save = tf.train.Saver() 使用了max_to_keep=1的设置,并且在模型训练保存的过程中,是每训练一代保存一次。 此时,checkpoint_dir将不再适用于save.restore(sess, checkpoint_dir)中的checkpoint_dir。因为从图b中可以看到,其包含-1(训练代数的后缀)。如果仍将checkpoint_dir作为模型参数读入的地址传入save.restore()中,将会报错。
ValueError: The passed save_path is not a valid checkpoint
解决方法
使用tf.train.latest_checkpoint()函数,将不包含文件名称的路径传入函数中,获取到文件的路径module_file,并将其传入saver.restore()中,便可以解决上述问题。
module_file = tf.train.latest_checkpoint(diag_obj.save_path)
saver.restore(sess, module_file)
TensorFlow报错:ValueError The passed save_path is not a valid checkpoint相关推荐
- 解决tensorflow报错ValueError: Variable conv1/weights already exists, disallowed.
早上在跑别人的tensorflow代码时报错: Traceback (most recent call last):File "<ipython-input-23-712e8e1f02 ...
- Tensorflow报错:ValueError: Trying to share variable ..., but specified shape ... and found shape ...
Tensorflow报错:ValueError: Trying to share variable CON/conv2/W, but specified shape (3, 3, 128, 256) ...
- tensorflow的Dataset对象报错ValueError: GraphDef cannot be larger than 2GB
Dataset对象报错ValueError: GraphDef cannot be larger than 2GB或Cannot create a tensor proto whose content ...
- Keras前后尺寸一致却依然报错'ValueError: total size of new array must be unchanged'的原因
某些情况下我们需要对张量进行维度变换,一般可以通过调用以下两种方法实现: # 1. TensorFlow自带 tf.reshape(tensor, target_shape) # 2. (推荐)Ker ...
- 针对报错 ValueError: When using data tensors as input to a model, you should specify the `steps_per_epoc
针对报错 ValueError: When using data tensors as input to a model, you should specify the steps_per_epoch ...
- anconda安装后命令行中安装tensorflow报错
现象 anconda安装后命令行中安装tensorflow报错 pip install --upgrade --ignore-installed tensorflow-gpu Building wh ...
- NVIDIA Jetson Xavier NX上导入tensorflow报错:AttributeError: module ‘wrapt‘ has no attribute ‘ObjectProxy‘
欢迎大家关注笔者,你的关注是我持续更博的最大动力 原创文章,转载告知,盗版必究 在Jetson Xavier NX上导入tensorflow报错:AttributeError: module 'wra ...
- 解决tensorflow报错:AttributeError: module ‘tensorflow.keras.backend‘ has no attribute ‘get_session‘ 问题
欢迎大家关注笔者,你的关注是我持续更博的最大动力 原创文章,转载告知,盗版必究 解决tensorflow报错:AttributeError: module 'tensorflow.keras.back ...
- 用pip安装tensorflow报错SyntaxError: invalid syntax
用pip安装tensorflow报错SyntaxError: invalid syntax 解决办法:直接在cmd中输入安装语句
- 服务器安装opencv报错--libSM.so.6: cannot open shared ...+tensorflow 报错libcusolver.so.8.0: can not...
1.安装opencv出现以下错误: pip install opencv-contrib-python apt-get install -y python-qt4 apt-get install tk ...
最新文章
- 计算机应用基础学期教学小结,《计算机应用基础》的教学总结及小结.docx
- 计算机应用基础中专教材pdf,中等职业教育通用教材-计算机应用基础.pdf
- Makefile和automake中判断CPU位数
- Spring Boot 中使用 MyBatis 整合 Druid 多数据源
- Spring Cloud Hoxton正式发布,Spring Boot 2.2 不再孤单
- 车辆行人检测数据集_澎思科技行人再识别技术取得突破,刷新三大数据集世界记录...
- 如何成为一名Web前端开发人员?入行学习完整指南
- MariaDB 在 RedHat Linux 上的安装过程以及 MySQL 相关命令的使用
- Python import其他文件夹的文件
- 给物体赋值 只改变transform.position的某一维,访问另一个脚本的变量以及给物体用脚本动态添加属性
- 【算法设计与分析】专栏目录
- 【oracle】查看当前用户各个表的记录数
- 古典钢琴音源插件-COLOVE Products Pianos X1 v2.0 WiN-MAC
- 什么叫faq_FAQ是什么意思啊
- 【笔记整理】网络攻防技术
- 计算机可以实现u盘和硬盘格式化,“资源管理器”和“计算机”窗口都可以实现U盘和硬盘格式化...
- shell脚本明文密码隐藏且加密
- 二阶振荡环节的谐振频率_典型环节的频率特性二阶振荡环节.ppt
- 生活不只有BAT,还有这些市值超1000亿的快消公司
- 湎计算机网络通讯设备有哪些,计算机网络习题集及答案.pdf