Hi,
I’m trying to test a slight modification of multi-layer lstm: I want to sum all the intermediate hidden outputs before applying it to a fc layer. my forward pass looks like this:
def forward(self, input_seq):
out = []
for i in range(input_seq.shape[0]):
_, self.hidden = self.rec_net(input_seq[i].unsqueeze(0), self.hidden)
hidden_sum = self.hidden[0].sum(dim=0).unsqueeze(0)
out.append(hidden_sum)
    return self.fc(torch.cat(out)) # fully connected

it seems to work and converge, but it works very slowly.
Is there a more efficient way to implement it in pytroch?
Thanks,
Guy