两次输入同名的名称范围:
c = tf.constant(1)
with tf.name_scope("test"):
a = tf.add(c, c)
with tf.name_scope("test"):
b = tf.add(a, a)
Run Code Online (Sandbox Code Playgroud)
导致创建两个名称范围:test
和test_1
.
是否可以在单独的上下文管理器中重新输入范围而不是创建新的范围?
事实证明,这实际上很容易。查看framework/ops.py
TensorFlow 发现,在范围名称中添加“/”不会使范围名称唯一,从而有效地重新进入现有范围。例如:
c = tf.constant(1)
with tf.name_scope("test"):
a = tf.add(c, c)
with tf.name_scope("test/"):
b = tf.add(a, a)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
826 次 |
最近记录: |