LSTM is expecting (seq_len, batch, input_size) but when I do that PyTorch throws an error:
ValueError: Expected input batch_size (20) to match target batch_size (27).

20 is seq_len and 27 is batch_size.
Input shape:
torch.Size([20, 27, 87])

(seq_len, batch, input_size)  accordingly.
My model:
class RNN(nn.Module):
    def __init__(self):
        super(RNN, self).__init__()
        self.lstm1 = nn.LSTM(input_size=87, hidden_size=256)
        self.lstm2 = nn.LSTM(input_size=256, hidden_size=128)
        self.lstm3 = nn.LSTM(input_size=128, hidden_size=64)
        self.lstm4 = nn.LSTM(input_size=64, hidden_size=32)
        self.fc1 = nn.Linear(in_features=32, out_features=128)
        self.fc2 = nn.Linear(in_features=128, out_features=64)
        self.fc3 = nn.Linear(in_features=64, out_features=32)
        self.fc4 = nn.Linear(in_features=32, out_features=3)

    def forward(self, x):
        x = torch.tanh(self.lstm1(x)[0])
        x = torch.tanh(self.lstm2(x)[0])
        x = torch.tanh(self.lstm3(x)[0])
        x = torch.tanh(self.lstm4(x)[0])
        x = F.relu(self.fc1(x))
        x = F.relu(self.fc2(x))
        x = F.relu(self.fc3(x))
        x = self.fc4(x)
        return x

There are two questions:

What’s wrong with seq_len in my case?
Is it ok to swapaxes to meet requirments or it mixes important things:

X_train = X_train.swapaxes(1,0)