python-tensorflow 多线程引起的新graph问题
发布日期:2021-11-05 07:52:20
浏览次数:35
分类:技术文章
本文共 1068 字,大约阅读时间需要 3 分钟。
多个线程使用的是不同的图
def fun(id,graph): # tf.reset_default_graph() # with graph.as_default(): print('id:%d'%id,tf.get_default_graph())t1 = threading.Thread(target=fun,args=[1,tf.get_default_graph()])t2 = threading.Thread(target=fun,args=[2,tf.get_default_graph()])t1.start()t2.start()print(tf.get_default_graph())
id:1 <tensorflow.python.framework.ops.Graph object at 0x000001EEC25A3F98>
id:2 <tensorflow.python.framework.ops.Graph object at 0x000001EEC25A3C50> <tensorflow.python.framework.ops.Graph object at 0x000001EE8FE25080>让多个线程使用同一个图
def fun(id,graph): # tf.reset_default_graph() with graph.as_default(): print('id:%d'%id,tf.get_default_graph())t1 = threading.Thread(target=fun,args=[1,tf.get_default_graph()])t2 = threading.Thread(target=fun,args=[2,tf.get_default_graph()])t1.start()t2.start()print(tf.get_default_graph())
id:1 <tensorflow.python.framework.ops.Graph object at 0x0000027F1C472CC0>
id:2 <tensorflow.python.framework.ops.Graph object at 0x0000027F1C472CC0> <tensorflow.python.framework.ops.Graph object at 0x0000027F1C472CC0>转载地址:https://blog.csdn.net/xingghaoyuxitong/article/details/114765508 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
做的很好,不错不错
[***.243.131.199]2024年04月14日 04时30分42秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
以太坊智能合约开发-《精通以太坊智能合约开发》学习总结实践
2019-04-26
Parabolic SAR(抛物线转向指标)
2019-04-26
java 通用内存分页(List分页)
2019-04-26
什么是WebAuthn、FIDO 是什么?
2019-04-26
Hibernate JPA-原生查询返回BigIntegers而不是long
2019-04-26
Apollo-本地开发模式(不接入配置中心进行本地开发 env=Local)
2019-04-26
拜占庭容错共识(PBFT)
2019-04-26
预言机如何读取和验证数据?
2019-04-26
git- git checkout 创建新的分支、切换分支、切换到指定tag
2019-04-26
什么是非同质化代币(NFT)\ NFT有哪些应用?
2019-04-26
VRF是什么?
2019-04-26
Qt:01---Qt Creator与SDK的下载与安装
2019-04-26
【直播回顾】获取 iOS 用户,您还可以这么做
2019-04-27
如何保证游戏长盛不衰
2019-04-27
Kotlin Vocabulary | 内联函数的原理与应用
2019-04-27
467_Arduino AD采集范围标定
2019-04-27
468_Arduino生成ASCII码表
2019-04-27
469_Arduino超声波距离传感器例程调试
2019-04-27