簡體   English   中英

當我在張量流中得到卷積層的變量時出現錯誤

[英]I got a error when I got the variables of convolution layers in tensorflow

我想獲取卷積層的變量並將其可視化。 然后我的代碼是

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_weights有一個令人困惑的維度

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

轉換層的權重應為[filter height, filter width, input channels, number of filters (output channels] 。除了前兩個維之外,您的權重是合適的。是否僅包裝在兩個列表中?例如[[weights]]只是weights

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM