待完善:tf.name_scope() 和 tf.variable_scope()的区别

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

	
	

猜你喜欢

转载自blog.csdn.net/u014765410/article/details/100541627