2016-12-10 74 views
0

我想獲得卷積層的變量並將其可視化。 然後我的代碼是當我得到張量流中卷積層的變量時出現錯誤

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) 

回答

0

重量爲CONV層應該是[filter height, filter width, input channels, number of filters (output channels]。除前兩個維度外,你的體重適合。它只是包裹在兩個列表中?例如。 [[weights]]而不僅僅是weights