tensorflow 重置/清除计算图的实现
作者:hitrjj 时间:2023-07-23 00:41:58
调用tf.reset_default_graph()重置计算图
当在搭建网络查看计算图时,如果重复运行程序会导致重定义报错。为了可以在同一个线程或者交互式环境中(ipython/jupyter)重复调试计算图,就需要使用这个函数来重置计算图,随后修改计算图再次运行。
#重置计算图,清理当前定义节点
import tensorflow as tf
tf.reset_default_graph()
#Your model defined below
#
需要注意的是,下面三种情况使用这个函数会报错:
#1
with graph.as_default():
#不能用
#2
with tf.Session(): block.
#不能用
#3
tf.InteractiveSession()
#Your regions
#不能用
sess.close().
也就是说这个函数需要在with tf.session()外部调用。
来源:https://blog.csdn.net/u014636245/article/details/84073239
标签:tensorflow,重置,清除,计算图
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
页面中 CSS 加载方式的优化
2008-03-26 12:36:00
Oracle数据库密码文件的使用与维护
2010-07-28 13:27:00
MSSQL 监控数据/日志文件增长实现方法
2024-01-22 14:05:34
细化解析:怎样把你的MySQL完全中文化
2008-12-19 17:48:00
Python unittest单元测试openpyxl实现过程解析
2023-06-17 10:54:31
![](https://img.aspxhome.com/file/2023/2/103482_0s.jpg)
使用python实现一个简单ping pong服务器
2022-10-25 03:38:48
![](https://img.aspxhome.com/file/2023/7/94027_0s.jpg)
django表单实现下拉框的示例讲解
2022-03-24 09:18:25
pygame库实现俄罗斯方块小游戏
2022-09-11 10:43:37
![](https://img.aspxhome.com/file/2023/4/69534_0s.jpg)
分享一下Python 开发者节省时间的10个方法
2023-02-14 21:57:33
![](https://img.aspxhome.com/file/2023/6/87746_0s.jpg)
浅谈FastClick 填坑及源码解析
2024-04-10 16:08:57
![](https://img.aspxhome.com/file/2023/0/136790_0s.gif)
Python的一些用法分享
2021-04-19 20:49:22
利用hasOwnProperty给数组去重的面试题分享
2023-08-06 20:48:37
解决Alexnet训练模型在每个epoch中准确率和loss都会一升一降问题
2022-12-06 16:17:37
![](https://img.aspxhome.com/file/2023/5/107785_0s.jpg)
解决python父线程关闭后子线程不关闭问题
2023-11-28 22:01:56
Python实现LRU算法的2种方法
2021-10-19 11:30:32
对numpy下的轴交换transpose和swapaxes的示例解读
2022-09-11 10:30:51
![](https://img.aspxhome.com/file/2023/9/92389_0s.jpg)
一文秒懂python读写csv xml json文件各种骚操作
2023-08-03 23:50:42
基于Python测试程序是否有错误
2021-05-09 22:45:35
![](https://img.aspxhome.com/file/2023/1/131591_0s.png)
oracle 更改数据库名的方法
2009-10-24 18:20:00
5分钟快速掌握JS中var、let和const的异同
2024-05-09 15:05:49