title: LSTM RNN to predict multiple time-steps and multiple features simultaneously
body: <p>I have a dataset from 4 temperature sensors measuring different places in/around a building:
  <a href="https://i.stack.imgur.com/ipXrf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ipXrf.png" alt="enter image description here"></a></p>
  
  <p>I'm training a model that takes inputs of shape (96, 4), 96 time steps for the 4 sensors. From this I want to predict 48 points into the future for each of those sensors, shape (48, 4).</p>
  
  <p>So far I've got an implementation working to predict one sensor only. I mostly followed <a href="https://www.tensorflow.org/tutorials/structured_data/time_series#multi-step_model" rel="noreferrer">this section from the TensorFlow tutorials</a>.</p>
  
  <p>My train X is shape (6681, 96, 4), train Y is shape (6681, 48) as I have restricted this to one sensor only. If I just change train Y to (6681, 48, 4) when training I of course get <code>ValueError: Dimensions must be equal, but are 48 and 4 for 'loss/dense_loss/sub' (op: 'Sub') with input shapes: [?,48], [?,48,4].</code> as my model is not expecting this shape.</p>
  
  <p>Where I'm getting stuck is with my LSTM layer's input/output shapes. I just can't figure out how to finish with a shape of (BATCH_SIZE, 48, 4).</p>
  
  <p>Here's my layer setup at the moment:</p>
  
  <pre><code>tf.keras.backend.clear_session()
  
  
  print("Input shape", x_train_multi.shape[-2:])
  
  multi_step_model = tf.keras.models.Sequential()
  multi_step_model.add(tf.keras.layers.LSTM(32,
                                            return_sequences=True,
                                            input_shape=x_train_multi.shape[-2:]))
  multi_step_model.add(tf.keras.layers.Dropout(rate=0.5)) # Dropout layer after each LSTM to reduce overfitting.
  multi_step_model.add(tf.keras.layers.LSTM(16, activation='relu'))
  multi_step_model.add(tf.keras.layers.Dropout(rate=0.5)) 
  # The argument to Dense shapes the results to give the number of time steps we want.
  # But how do I make it keep 4 features as well?!?
  multi_step_model.add(tf.keras.layers.Dense(future_target / STEP))
  multi_step_model.compile(optimizer=tf.keras.optimizers.RMSprop(clipvalue=1.0), loss='mae')
  
  # Shape of predictions
  for x, y in val_data_multi.take(1):
      print ("Prediction shape", multi_step_model.predict(x).shape)
  </code></pre>
  
  <p>Some thoughts:</p>
  
  <ul>
  <li>Am I just missing something or forgetting to set an argument for the output features/dimensions to use?</li>
  <li>Do I need to train separate RNNs for predicting each sensor?</li>
  </ul>
  
  <p>Thanks! :) </p>