我有一个程序,我在Tensorflow中 Build 了一个具有卷积层的神经网络,我试图定期输出滤波器权重作为图像 . 我知道我的网络正在根据我在Tensorboard中跟踪的性能正确更新(我已经通过直接打印来验证权重正在改变),但权重图像始终是相同的(看似随机的)值 . 我使用初始化我的图层

self.inputs = tf.placeholder(shape=[None, s_size], dtype=tf.float32)
self.image_in = tf.reshape(self.inputs, shape=[-1, int(input_pixels / view_width), view_width, 1])
self.conv1 = slim.conv2d(activation_fn=tf.nn.elu, inputs=self.image_in, num_outputs=16, kernel_size=[8, 8], stride=[4, 4], padding='VALID', scope="conv1")
self.conv2 = slim.conv2d(activation_fn=tf.nn.elu,  inputs=self.conv1, num_outputs=32, kernel_size=[4, 4], stride=[2, 2], padding='VALID', scope="conv2")
hidden = slim.fully_connected(slim.flatten(self.conv2), 256, activation_fn=tf.nn.elu)

一旦训练开始,每100次迭代我使用提供的函数保存权重here

filters = ["conv1", "conv2"]
for filter in filters:
    with tf.variable_scope(self.name + "/" + filter, reuse=True):
        weights = tf.get_variable("weights")
        grid = put_kernels_on_grid(weights)
        scipy.misc.imsave('filters/' + filter + "_" + str(episode_count) + ".jpg", grid.eval()[0, :, :, 0])

鉴于过滤器中的权重正确更新,为什么tf.get_variable()返回的权重也不会更新?