【问题标题】:tensorflow size of convolution layers卷积层的张量流大小
【发布时间】:2017-09-12 17:30:34
【问题描述】:

我正在尝试从研究论文中重新创建一个 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)

谢谢!

【问题讨论】:

  • 您看到的错误是什么?

标签: tensorflow deep-learning conv-neural-network convolution


【解决方案1】:

在第一个conv3d 之后,你有形状为[None, 16, 16, 4, 32] 的张量,因此你必须在第二个conv3d_s1 中使用形状为[3, 3, 4, 32, 64] 的内核。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-14
    • 2017-09-12
    • 1970-01-01
    相关资源
    最近更新 更多