0
我使用name_scope来管理变量的namepsace,所以它可以很好地显示在张量板上。但是我发现一些奇怪的东西,name_scope不会为由tf.get_variable创建的变量添加前缀。 因此,代码提出一个错误:关于tensorboard name_scope
with tf.name_scope(self.networkName + '/conv1'):
self.conv1_w = tf.get_variable(shape = [8, 8, 4, 16], name = 'w', initializer=tf.contrib.layers.xavier_initializer())
self.conv1_b = tf.get_variable(shape = [16], name = 'b', initializer=tf.contrib.layers.xavier_initializer())
self.conv1_o = tf.nn.relu(tf.nn.conv2d(self.states, self.conv1_w, [1, 4, 4, 1], 'SAME') + self.conv1_b)
with tf.name_scope(self.networkName + '/conv2'):
self.conv2_w = tf.get_variable(shape = [4, 4, 16, 32], name = 'w', initializer=tf.contrib.layers.xavier_initializer())
self.conv2_b = tf.get_variable(shape = [32], name = 'b', initializer=tf.contrib.layers.xavier_initializer())
self.conv2_o = tf.nn.relu(tf.nn.conv2d(self.conv1_o, self.conv2_w, [1, 2, 2, 1], 'SAME') + self.conv2_b)
ValueError: Variable w already exists, disallowed.
我可以用它代替name_scope variable_scope? tensorboard可以在variable_scope上工作吗?