title: Input to reshape is a tensor with 4104 values, but the requested shape requires a multiple of 96
body: <p>I'm new to tensorflow and I want to do some time series forecasting and followed <a href="https://mapr.com/blog/deep-learning-tensorflow/" rel="nofollow noreferrer">this</a> link. I want to have 36 hours data as input and next consecutive 48 hour as output data so I made x and y batches as follows:</p>
  
  <pre><code>""" Making our training dataset with batch size of num_period """
  x_batches = {'NSW': X_NSW.transpose().reshape(-1,72,1),
               'QLD': X_QLD.transpose().reshape(-1,72,1),
               'SA': X_SA.transpose().reshape(-1,72,1),
               'TAS': X_TAS.transpose().reshape(-1,72,1),
               'VIC': X_VIC.transpose().reshape(-1,72,1)}
  
  y_batches = {'NSW': Y_NSW.transpose().reshape(-1,96,1),
                   'QLD': Y_QLD.transpose().reshape(-1,96,1),
                   'SA': Y_SA.transpose().reshape(-1,96,1),
                   'TAS': Y_TAS.transpose().reshape(-1,96,1),
                   'VIC': Y_VIC.transpose().reshape(-1,96,1)}
  </code></pre>
  
  <p>Then I used the same code as given in the link above (but modified it according to need) and got the following code:</p>
  
  <pre><code>inputs = 1  #input vector size
  hidden = 100    
  output = 1  #output vector size
  
  X = tf.placeholder(tf.float32, [None, 72, inputs])
  y = tf.placeholder(tf.float32, [None, 96, output])
  
  basic_cell = tf.contrib.rnn.BasicRNNCell(num_units=hidden, activation=tf.nn.relu)
  rnn_output, states = tf.nn.dynamic_rnn(basic_cell, X, dtype=tf.float32)
  
  learning_rate = 0.001   #small learning rate so we don't overshoot the minimum
  
  stacked_rnn_output = tf.reshape(rnn_output, [-1, hidden])           #change the form into a tensor
  stacked_outputs = tf.layers.dense(stacked_rnn_output, output)        #specify the type of layer (dense)
  outputs = tf.reshape(stacked_outputs, [-1, 96, output])          #shape of results
  </code></pre>
  
  <p>But the system is throwing me following error </p>
  
  <pre><code>outputs = tf.reshape(stacked_outputs, [-1, 96, output])          #shape of results
  
  ...
  
  InvalidArgumentError (see above for traceback): Input to reshape is a tensor with 4104 values, but the requested shape requires a multiple of 96
       [[Node: Reshape_1 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/cpu:0"](dense/BiasAdd, Reshape_1/shape)]]
  </code></pre>
  
  <p>I know I'm making some mistake in the following line but I'm unable to figure it out.</p>
  
  <pre><code>stacked_rnn_output = tf.reshape(rnn_output, [-1, hidden])           #change the form into a tensor
  stacked_outputs = tf.layers.dense(stacked_rnn_output, output)        #specify the type of layer (dense)
  outputs = tf.reshape(stacked_outputs, [-1, 96, output])          #shape of results
  </code></pre>