当我得到十个卷积层的变量时,我得到了一个错误

2024-04-20 00:10:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我想得到卷积层的变量并将其可视化。 那我的密码是

d3 = de_conv(d2, weights2['wc2'], biases2['bc2'], out_shape=[batch_size , c2, c2, 128])
    d3 = batch_norm(d3, epsilon=1e-5, decay=0.9)
    d3 = tf.nn.relu(d3)

    tf.add_to_collection('weight_2', weights2['wc3'])

在测试中

with tf.Session() as sess:

            saver.restore(sess , model_path)
            conv_weights = sess.run([tf.get_collection('weight_2')])
            #visualize the weights
            conv_weights = np.array(conv_weights)

            print(conv_weights.shape)
            vis_square(conv_weights)

但我不明白convèu权重有一个混乱的维度

(1, 1, 5, 5, 1, 128)

Tags: 密码可视化tfbatchde卷积collectionsess
1条回答
网友
1楼 · 发布于 2024-04-20 00:10:04

conv层的权重应该是[filter height, filter width, input channels, number of filters (output channels]。除了前两个维度,你的体重是合适的。是不是只有两张单子?例如[[weights]]而不是仅仅weights

相关问题 更多 >