Linux上多次restore Tensorflow模型报错
环境:python3,tensotflow
在恢复了预先训练好的模型进行预测时,第一次是能够成功执行的,但我多次restore模型时,出现了以下问题:
1.ValueError: Variable char_embed/char_embedding already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at:
解决方法参考https://www.jianshu.com/p/fc11f32800f9
2. NotFoundError (see above for traceback): Key Variable_3 not found in checkpoint
错误提示在checkpoint中没有找到Variable_3。使用以下语句查看checkpoint中的变量,发现的确没有Variable_3。而使用tf.global_variables()查看到新生成了包括Variable_3的新tensor。可参考这里了解具体过程。
解决办法:加入tf.reset_default_graph() 或参考这里进行多项查看。
import os#checkpoint文件的路径checkpoint_path=os.path.join(os.getcwd(),'ckpt1/ner.ckpt')reader=tf.train.NewCheckpointReader(checkpoint_path)var=reader.get_variable_to_shape_map()for key in var: print("tensor_name",key) #显示tensor的内容,若只想查看tensor的名称,可以下面这句注释掉,使结果更清晰 print(reader.get_tensor(key))
其中,我的/ckpt1下的文件如下:
3. 加入tf.reset_default_graph之后,出现以下报错:
Error: Do not use tf.reset_default_graph() to clear nested graphs. If you need a cleared graph, exit the nesting and create a new graph.
原因参考这里,就是说,不能在以下情况使用tf.reset_default_graph():
Inside a with graph.as_default(): block. 【在with graph.as_default(): 块下面】
Inside a with tf.Session(): block.【在with tf.Session():块下面】
Between creating a tf.InteractiveSession and calling sess.close() 【在使用了tf.InteractiveSession和调用sess.close()之间】
---------------------
作者:xxzhix
来源:CSDN
原文:https://blog.csdn.net/xxzhix/article/details/81983982
版权声明:本文为博主原创文章,转载请附上博文链接!
Linux上多次restore Tensorflow模型报错的更多相关文章
- 在Linux上配置xampp后远程访问域名报错
在Linux上配置xampp后远程访问域名报错: New XAMPP security concept: Access to the requested object is only availabl ...
- linux上安装完torch后仍报错:ImportError: No module named torch
linux上安装完torch后仍报错: Traceback (most recent call last): File , in <module> import torch ImportE ...
- Linux上tomcat部署web项目,访问报错"ip访问时间过长"
项目原来是可以访问的,后来突然不能不访问了,系统ip也是能ping通的,后来就想是不是防火墙的问题,查看一下还真是 原因:Linux服务器上的防火墙开着,关闭即可 1.查看firewall服务状态 s ...
- 【pycharm】pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法
pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法 解决方法: 在pycharm的安装目 ...
- 在PHP5.4上使用Google翻译的API报错
/********************************************************************** * 在PHP5.4上使用Google翻译的API报错 * ...
- PyCharm导入tensorflow包报错的问题
[注]PyCharm导入tensorflow包报错的问题 若是你也遇到这个问题,说明你也没有理解tensorflow到底在哪里. 当安装了anaconda3.6后,在PyCharm中设置interpr ...
- 在CentOS上安装node.js的时候报错:No acceptable C compiler found!解决办法
在CentOS上安装node.js的时候报错:No acceptable C compiler found! 原因:没有c编译器. 解决办法:安装GCC 命令如下: #yum install gcc ...
- Windows 10 上安装 3D Studio Max 2016 报错的解决办法
在 Windows 10 上安装 3D Stuido Max 2016 报错,无法正常安装,查看日志是 VC 运行时安装错误,经过分析发现在 Windows 10 上已经有这些运行时并且版本比安装包中 ...
- Linux 下使用C语言 gets()函数报错
在Linux下,使用 gets(cmd) 函数报错:warning: the 'gets' function is dangerous and should not be used. 解决办法:采用 ...
随机推荐
- 20155327 2017-2018-2 《Java程序设计》第一周学习总结
20155327 2017-2018-2 <Java程序设计>第一周学习总结 教材学习内容总结 三大平台: 1.Java SE:JVM,JRE,JDK,java语言 JVM:Java虚拟机 ...
- 11 [异常]-try...except
1.什么是异常 异常就是程序运行时发生错误的信号(在程序出现错误时,则会产生一个异常,若程序没有处理它,则会抛出该异常,程序的运行也随之终止),在python中,错误触发的异常如下 2.错误 错误分成 ...
- 07- django组件:中间件
1.中间件的概念 中间件顾名思义,是介于request与response处理之间的一道处理过程,相对比较轻量级,并且在全局上改变django的输入与输出.因为改变的是全局,所以需要谨慎实用,用不好会影 ...
- 解决 spring-test 出现 Failed to load ApplicationContext 的异常
在使用spring-test的时候,在启动@Test的方法时,spring-test会去加载spring的配置文件,这个时候如果配置文件没有在 @ContextConfiguration 中写全,就会 ...
- 图片缩放插件GestureImageView——Android 常用插件推荐(一)
Android 开发过程中,交互效果是一个非常繁琐的过程,甚至比Web开发过程中JS特效更加复杂.通过多年的发展,常用的交互方式已经发展相当成熟,而且有很多非常好的插件.为了避免重复造轮子,一些常用的 ...
- fortran shapefile学习
试图编写一个fortran程序,用以判断给定的点是否落在给定shapefile的范围内. 需要利用到FortranGIS库 ,而该库又依赖于Shapefile C Library 安装shapelib ...
- SQL常见面试题
1.用一条SQL 语句 查询出每门课都大于80 分的学生姓名 name kecheng fenshu张三 语文 81张三 数学 75李四 语文 ...
- 自动化工具 fastmonkey
Android Monkey 二次开发,实现高速点击的 Android Monkey 一.工具介绍: 1.本工具是testhome上 zhangzhao_lenovo开源出来的工具,源码暂时还未开源: ...
- Unity特殊文件夹详解
##1.Editor Editor文件夹可以在根目录下,也可以在子目录里,只要名子叫Editor就可以.比如目录:/xxx/xxx/Editor 和 /Editor 是一样的,无论多少个叫Editor ...
- 在vsphere6.5启用Tesla K80
基础环境: vsphere6.5 VMware vCenter6.5 宝德服务器2750S Tesla K80 0x01 选择主机,配置→硬件→PCI设备→添加K80显卡 注意:1.添加完显卡后,主机 ...