PyTorch всегда возвращает последовательности.
https://pytorch.org/docs/stable/nn.html#lstm

Пример:
import torch as t
batch_size = 2
time_steps = 10
features = 2
data = t.empty(batch_size, time_steps, features).normal_()
lstm = t.nn.LSTM(input_size=2, hidden_size=3, bidirectional=True, batch_first=True)
output, (h_n, c_n) = lstm(data)
[output.shape, h_n.shape, c_n.shape]
[Размер горелки ([2, 10, 6]), Размер горелки ([2, 2, 3]), Размер горелки ([2, 2, 3])]
class Net(t.nn.Module):
def __init__(self):
super(Net, self).__init__()
self.lstm_1 = t.nn.LSTM(input_size=2, hidden_size=3, bidirectional=True, batch_first=True)
self.lstm_2 = t.nn.LSTM(input_size=2*3, hidden_size=4, bidirectional=True, batch_first=True)
def forward(self, input):
output, (h_n, c_n) = self.lstm_1(input)
output, (h_n, c_n) = self.lstm_2(output)
return output
net = Net()
net(data).shape
горелка. Размер ([2, 10, 8])