当前位置:网站首页>待完善:tf.name_scope() 和 tf.variable_scope()的区别
待完善:tf.name_scope() 和 tf.variable_scope()的区别
2022-08-08 22:47:00 【Sarah ฅʕ•̫͡•ʔฅ】
with tf.name_scope("a"):
b = tf.get_variable("b",[1])
print(b.name) # b:0
with tf.variable_scope("a"):
b = tf.get_variable("b",[1])
print(b.name) # a/b:0
#此时,如果在tf.name_scope()下进行如下操作,会报错:
with tf.name_scope("a"):
b = tf.get_variable("b",[1])
#因为 b:0 已经存在,所以,再次进行 get_variable()会报错,除非设置 reuse=True;
#而,tf.variable_scope(name)中,只要name改变,则不会报错,如下:
with tf.variable_scope("b"):
b = tf.get_variable("b",[1])
#此时,可以正常执行,因为 b.name 为 b/b:0
边栏推荐
猜你喜欢
随机推荐
巨头杀入的LMFP,是未来正极材料的新归宿?
我曾七次鄙视自己的灵魂——纪伯伦
Liquor Daily Question ---- Find the nth Fibonacci number
用飞书招聘医生,美中宜和“字节化”?
支付宝 To 理财排行名称修改
动态主机配置协议DHCP(DHCPv4)
MPLS Virtual Private Network Everywhere in Life
2.1.5 折叠剪切展开问题
Kubernetes资源编排系列之四: CRD+Operator篇
Upload-labs Pass-02(MIME验证)
中断系统结构及中断控制详解
记录每天学习的新知识: Room
删除排序数组中的重复项(Leetcode26)
Kubernetes与OpenStack
ArcPy图斑编号-根据字段长度自动补齐
全国各省市区行政代码 城市代码.txt
Unity Text三重渐变色
发送封包的函数都有哪些?OD如何下断?
编程需要无畏感
flutter 基本类写法