LSTM returns tuple

I am building a network and the LSTM layer is returning a tuple. I understand that I will need to split this to enable the next layer to work, however can’t figure out how to do this. My model looks as follows:

m = nn.Sequential(
nn.Embedding(MAX_WORDS, 128),
nn.LSTM(input_size=128, hidden_size=32, num_layers=1,bidirectional = True),
nn.Linear(32, 128),
nn.ReLU(),
nn.Linear(128, 64),
nn.ReLU(),
nn.Linear(64, 3),
nn.Sigmoid())

I need to split it after the LSTM - how do I do this? Appreciate the help :slight_smile: Thank you!

m1 = nn.Sequential(
nn.Embedding(MAX_WORDS, 128),
nn.LSTM(input_size=128, hidden_size=32, num_layers=1,bidirectional = True))

m2 = nn.Sequential(
nn.Linear(64, 128),
nn.ReLU(),
nn.Linear(128, 64),
nn.ReLU(),
nn.Linear(64, 3),
nn.Sigmoid())

output, (h,c) = m1(…)
m2(output)

Note: lstm will return double hidden_size dim if bidirectional is true, or you have to process outputs.

1 Like

What is supposed to be in the …?