title: Tensorflow tf.reshape() seems to behave differently to numpy.reshape()
body: <p>I'm trying to train a LSTM network and it trains successfully in one way, but throws an error in the other way. In the first example I reshape the input array X using numpy reshape and in the other way I reshape it using tensorflow reshape.</p>
  
  <p>Works fine:</p>
  
  <pre><code>import numpy as np
  import tensorflow as tf
  import tensorflow.contrib.learn as learn
  
  
  # Parameters
  learning_rate = 0.1
  training_steps = 3000
  batch_size = 128
  
  # Network Parameters
  n_input = 4
  n_steps = 10
  n_hidden = 128
  n_classes = 6
  
  X = np.ones([1770,4])
  y = np.ones([177])
  
  # NUMPY RESHAPE OUTSIDE RNN_MODEL
  X = np.reshape(X, (-1, n_steps, n_input))
  
  def rnn_model(X, y):
  
    # TENSORFLOW RESHAPE INSIDE RNN_MODEL
    #X = tf.reshape(X, [-1, n_steps, n_input])  # (batch_size, n_steps, n_input)
  
    # # permute n_steps and batch_size
    X = tf.transpose(X, [1, 0, 2])
  
    # # Reshape to prepare input to hidden activation
    X = tf.reshape(X, [-1, n_input])  # (n_steps*batch_size, n_input)
    # # Split data because rnn cell needs a list of inputs for the RNN inner loop
    X = tf.split(0, n_steps, X)  # n_steps * (batch_size, n_input)
  
    # Define a GRU cell with tensorflow
    lstm_cell = tf.nn.rnn_cell.BasicLSTMCell(n_hidden)
    # Get lstm cell output
    _, encoding = tf.nn.rnn(lstm_cell, X, dtype=tf.float32)
  
    return learn.models.logistic_regression(encoding, y)
  
  
  classifier = learn.TensorFlowEstimator(model_fn=rnn_model, n_classes=n_classes,
                                         batch_size=batch_size,
                                         steps=training_steps,
                                         learning_rate=learning_rate)
  
  classifier.fit(X,y)
  </code></pre>
  
  <p>Does not work:</p>
  
  <pre><code>import numpy as np
  import tensorflow as tf
  import tensorflow.contrib.learn as learn
  
  
  # Parameters
  learning_rate = 0.1
  training_steps = 3000
  batch_size = 128
  
  # Network Parameters
  n_input = 4
  n_steps = 10
  n_hidden = 128
  n_classes = 6
  
  X = np.ones([1770,4])
  y = np.ones([177])
  
  # NUMPY RESHAPE OUTSIDE RNN_MODEL
  #X = np.reshape(X, (-1, n_steps, n_input))
  
  def rnn_model(X, y):
  
    # TENSORFLOW RESHAPE INSIDE RNN_MODEL
    X = tf.reshape(X, [-1, n_steps, n_input])  # (batch_size, n_steps, n_input)
  
    # # permute n_steps and batch_size
    X = tf.transpose(X, [1, 0, 2])
  
    # # Reshape to prepare input to hidden activation
    X = tf.reshape(X, [-1, n_input])  # (n_steps*batch_size, n_input)
    # # Split data because rnn cell needs a list of inputs for the RNN inner loop
    X = tf.split(0, n_steps, X)  # n_steps * (batch_size, n_input)
  
    # Define a GRU cell with tensorflow
    lstm_cell = tf.nn.rnn_cell.BasicLSTMCell(n_hidden)
    # Get lstm cell output
    _, encoding = tf.nn.rnn(lstm_cell, X, dtype=tf.float32)
  
    return learn.models.logistic_regression(encoding, y)
  
  
  classifier = learn.TensorFlowEstimator(model_fn=rnn_model, n_classes=n_classes,
                                         batch_size=batch_size,
                                         steps=training_steps,
                                         learning_rate=learning_rate)
  
  classifier.fit(X,y)
  </code></pre>
  
  <p>The latter throws the following error:</p>
  
  <pre><code>WARNING:tensorflow:&lt;tensorflow.python.ops.rnn_cell.BasicLSTMCell object at 0x7f1c67c6f750&gt;: Using a concatenated state is slower and will soon be deprecated.  Use state_is_tuple=True.
  Traceback (most recent call last):
    File "/home/blabla/test.py", line 47, in &lt;module&gt;
      classifier.fit(X,y)
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/base.py", line 160, in fit
      monitors=monitors)
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 484, in _train_model
      monitors=monitors)
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/graph_actions.py", line 328, in train
      reraise(*excinfo)
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/graph_actions.py", line 254, in train
      feed_dict = feed_fn() if feed_fn is not None else None
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/io/data_feeder.py", line 366, in _feed_dict_fn
      out.itemset((i, self.y[sample]), 1.0)
  IndexError: index 974 is out of bounds for axis 0 with size 177
  </code></pre>