转:TensorFlow基础:共享变量
此博客对 Variable Scope
和tf.get_variable()
写得相当清晰,十分推荐:
os.environ["TF_FORCE_GPU_ALLOW_GROWTH"] = "true"
with tf.variable_scope("foo"):
with tf.name_scope("bar"):
v = tf.get_variable("v", [1])
x = 1.0 + v
assert v.name == "foo/v:0"
assert x.op.name == "foo/bar/add"
assert x.name == "foo/bar/add:0"