name_scope和 variable_scope区别

变量的全局名和variable_scope有关,和name_scope无关

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import tensorflow as tf
v = tf.Variable( [2,2,3,32],name='weights')
with tf.variable_scope('variable_scope'):
v1 = tf.get_variable('weights', [2,2,3,32])

with tf.name_scope('name_scope'):
v2 = tf.get_variable('weights',[2,2,3,32])

print v.name
print v1.name
print v2.name
---
weights:0
variable_scope/weights:0
weights_1:0

请作者喝一杯咖啡☕️