卷积层的张量流大小

tensorflow size of convolution layers

我正在尝试从一篇研究论文中重新创建一个 cnn,但我对深度学习还是个新手。

我得到了一个尺寸为 32x32x7 的 3d 补丁。我首先想执行一个大小为 3x3 的卷积,具有 32 个特征和步幅为 2。然后根据该结果,我需要执行具有 64 个特征和步幅为 1 的 3x3x4 卷积。我不想合并或激活两个卷积之间的函数。 为什么我不能将第一个卷积的结果输入第二个?

   import tensorflow as tf
   sess = tf.InteractiveSession()

   def conv3d(tempX, tempW):
     return tf.nn.conv3d(tempX, tempW, strides=[2, 2, 2, 2, 2], 
     padding='SAME')

   def conv3d_s1(tempX, tempW):
      return tf.nn.conv3d(tempX, tempW, strides=[1, 1, 1, 1, 1], 
      padding='SAME')

   def weight_variable(shape):
      initial = tf.truncated_normal(shape, stddev=0.1)
      return tf.Variable(initial)

   x = tf.placeholder(tf.float32, shape=[None, 7168])
   y_ = tf.placeholder(tf.float32, shape=[None, 3])
   W = tf.Variable(tf.zeros([7168,3]))

   #first convolution
   W_conv1 = weight_variable([3, 3, 1, 1, 32])
   x_image = tf.reshape(x, [-1, 32, 32, 7, 1])
   h_conv1 = conv3d(x_image, W_conv1)

   #second convolution
   W_conv2 = weight_variable([3, 3, 4, 1, 64])
   h_conv2 = conv3d_s1(h_conv1, W_conv2)

谢谢!

在第一个 conv3d 之后你有形状为 [None, 16, 16, 4, 32] 的张量,因此你必须在第二个 conv3d_s1.

中使用形状为 [3, 3, 4, 32, 64] 的内核