title: Using the shape of a tensor with dynamic shape in tensorflow operations
body: <p>Is there a way to use the shape of a tensor with dynamic shape in <code>tensorflow</code> operations without evaluating it in a session?
  For instance, consider the following:</p>
  
  <pre class="lang-py prettyprint-override"><code>activation = tf.nn.relu(conv_plus_b, name=scope.name) #has shape [None, None, 700,1]
  conv_len =activation.shape[1]
  pool = tf.nn.max_pool(activation, ksize=[1,conv_len,1,1], strides=[1,1,1,1], padding='VALID')
  </code></pre>
  
  <p>Running this code throws the error: <code>TypeError: Expected int for argument 'ksize' not Dimension(None)</code>.</p>
  
  <p>So my question is: Is there any way of using such dynamic shapes to define the shape parameter of <code>tensorflow</code> operations without evaluating it in a session? </p>
  
  <p>I found a similar issue on: 
  <a href="https://groups.google.com/a/tensorflow.org/forum/#!topic/discuss/BlguDbTxCAk" rel="nofollow noreferrer">https://groups.google.com/a/tensorflow.org/forum/#!topic/discuss/BlguDbTxCAk</a>
  The following solution was proposed for performing resize operations in <code>tensorflow</code> using dynamic shape:</p>
  
  <pre class="lang-py prettyprint-override"><code>n = tf.shape(foo)[0]
  tf.reshape(foo, tf.pack([n, 1]))
  </code></pre>
  
  <p>tf.pack has been deprecated. I'm not sure if tf.stack would work in tf.reshape operation but using it in tf.nn.max_pool throws the error <code>TypeError: Expected list for attr ksize</code></p>
  
  <p>I understand that there are different variations of the shape function. I've tried activation.get_shape()[1] (which I heard works with static shapes), activation.shape[1] and tf.shape(activation)[1]. They all throw errors.</p>
  
  <p>Thanks a lot for looking into this.</p>