import tensorflow as tf
with tf.variable_scope("foo"):
# 创建一个常量为1的v
c = tf.get_variable('constant', [1], initializer=tf.constant_initializer(1.0))
with tf.variable_scope("foo",reuse=True):
v = tf.get_variable('constant')
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
print(c.eval())
print(v.eval())
# [1.]
# [1.]