简体   繁体   English

第二个卷积层的输入维数?

[英]Dimension of the input of second convolutional layer?

In the following code I have introduced one convolution and one maximum pooling layer. 在下面的代码中,我介绍了一个卷积和一个最大池化层。 Output of pooling layer has a shape of (4,6,6,1). 汇聚层的输出的形状为(4,6,6,1)。 Now I want to define second convolutional layer. 现在我要定义第二个卷积层。 What will be the input for the second convolutional layer? 第二个卷积层的输入是什么? Can I call same conv2d function? 我可以调用相同的conv2d函数吗? But here the input channel is different. 但是这里的输入通道是不同的。

 batch_size = 4
 image_height = 12
 image_width =12
 input_channel = 2
 output_channel =1
 input =  tf.Variable(tf.random_normal([batch_size,image_height,image_width,input_channel]))
 filter = tf.Variable(tf.random_normal([2,2,input_channel,output_channel]))
 def conv2d(inputs,filters):
     return tf.nn.conv2d(inputs,filters,strides=[1,1,1,1],padding='SAME')
 def max_pool(conv_out):
     return tf.nn.max_pool(conv_out,ksize=[1,2,2,1],strides=[1,2,2,1],padding='SAME')
 conv_out1 = conv2d(input,filter)
 pooling_out1= max_pool(conv_out1)
 sess =tf.InteractiveSession()
 sess.run(tf.initialize_all_variables())
 print conv_out1.get_shape()
 print pooling_out1.get_shape()

您可以调用相同的conv2d函数,但希望使用不同的过滤器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM