title: How to extract the shape value of a placeholder Tensor in Tensorflow?
body: <p>I defined a <code>x = tf.placeholder("float", shape=[None, 784])</code> for input data. Later on, I need to know the first value of the shape of <code>x</code> as batch size. And I extract the value by <code>x.get_shape().as_list()[0]</code> but I got <code>None</code>. Could you please tell me how should I extract it properly? Thanks a lot!</p>
  
  <p>Edit:</p>
  
  <p>I have used <code>tf.get_shape()</code> now but it cause another bug. In my code, I have defined a <code>deconv</code> funciton:</p>
  
  <pre><code>def deconv(X, W, b, output_shape):
      X += b 
      return tf.nn.conv2d_transpose(X, W, output_shape, strides=[1, 1, 1, 1])
  </code></pre>
  
  <p>If I set the <code>batch_size</code> to a <code>int</code> in such way: <code>batch_size = 50</code>, the calling of the <code>deconv</code> functions works well as following:</p>
  
  <pre><code>W_conv2_T = tf.ones([5, 5, 32, 64])
  pool1_tr = deconv(conv2_tr, W_conv2_T, tf.zeros([64]), [batch_size, 14, 14, 32])
  </code></pre>
  
  <p>The shape of <code>conv2_tr</code> is <code>[50, 14, 14, 64]</code>. And the resulting shape of <code>pool1_tr</code> is <code>[50, 14, 14, 32]</code>. But if I set <code>batch_size = tf.get_shape(x)[0]</code>, shape of <code>conv2_tr</code> is <code>[None, 14, 14, 64]</code> and the resulting shape of <code>pool1_tr</code> becomes <code>[None, None, None, None]</code>. This bug is so strange. Could you please help me with this issue? Thanks in advance!</p>