PyTorch LSTM dimension
I am trying to teach my first LSTM with numeric sequence data to predict a singular value.

My training set is a numpy matrix shape=207x7 where each input vector has 7 features.
I am not sure how to setup and train my LSTM properly. I have CNN experience, but now first LSTM. 

class LSTM_NN(nn.Module):
"""
Stores the network format
"""
def __init__(self, input_size=7, hidden_layer_size=100, output_size=1):
    super(self.__class__, self).__init__()
    self._hidden_layer_size = hidden_layer_size
    self._lstm = nn.LSTM(input_size, hidden_layer_size)
    self._hidden_cell = (torch.zeros(1, 1, self._hidden_layer_size),
                         torch.zeros(1, 1, self._hidden_layer_size))
    self._linear = nn.Linear(hidden_layer_size, output_size)

def forward(self, input_data):
    """
    Forward propagation
    """

    lstm_out, self._hidden_cell = self._lstm(
        torch.tensor(np.expand_dims(input_data, 0)),
        self._hidden_cell) 

training_data.shape
# (200, 7)
model = LSTM_NN(input_size=training_data.shape[1])
model.forward(training_data)


But I get this error:

Expected hidden[0] size (1, 200, 100), got (1, 1, 100)
  File "train_lstm.py", line 44, in forward


Your input has size [batch_size, seq_len, num_features] = [1, 200, 7]. The LSTM on the other hand, expects the input to have size [seq_len, batch_size, num_features] (as described in nn.LSTM - Inputs).

You can either change the dimensions of your input, or you can set batch_first=True when creating the LSTM, if you prefer having batch size as the first dimension, in which case batch_size and seq_len are swapped and your current input size would be the expected one.

self._lstm = nn.LSTM(input_size, hidden_layer_size, batch_first=True)

