 <p>You have to use a Graph operation:</p> <pre><code>a = tf.placeholder(tf.float32, shape=(None, 3072)) b = tf.shape(a)[0] </code></pre> <p>returns</p> <pre><code>&lt;tf.Tensor 'strided_slice:0' shape=() dtype=int32&gt; </code></pre> <p>while <code>b = a.get_shape()[0]</code> returns</p> <pre><code>Dimension(None) </code></pre>