title: Tensorflow: Using tf.slice to split the input
body: <p>I'm trying to split my input layer into different sized parts. I'm trying to use tf.slice to do that but it's not working.</p>
  
  <p>Some sample code:</p>
  
  <pre><code>import tensorflow as tf
  import numpy as np
  
  ph = tf.placeholder(shape=[None,3], dtype=tf.int32)
  
  x = tf.slice(ph, [0, 0], [3, 2])
  
  input_ = np.array([[1,2,3],
                     [3,4,5],
                     [5,6,7]])
  
  with tf.Session() as sess:
          sess.run(tf.initialize_all_variables())
          print sess.run(x, feed_dict={ph: input_})
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>[[1 2]
   [3 4]
   [5 6]]
  </code></pre>
  
  <p>This works and is roughly what I want to happen, but I have to specify the first dimension (<code>3</code> in this case). I can't know though how many vectors I'll be inputting, that's why I'm using a <code>placeholder</code> with <code>None</code> in the first place!</p>
  
  <p>Is it possible to use <code>slice</code> in such a way that it will work when a dimension is unknown until runtime?</p>
  
  <p>I've tried using a <code>placeholder</code> that takes its value from <code>ph.get_shape()[0]</code> like so: <code>x = tf.slice(ph, [0, 0], [num_input, 2])</code>. but that didn't work either.</p>