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上工作嗎?