Torch.nn.functional.lstm

Hi, all

I want to use a functional lstm, just as torch.nn.functional.linear, how to reach that?

Thanks.

Just implement the function yourself. It will take you a few mins. You can find the equations of the LSTM
in the docs under nn.LSTM .

It is possible, using the _VF.lstm() function found here: https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/rnn.py

It will run faster than a manual implementation and be compatible with additional PyTorch features such as dropout.

Model parameters can be passed in using [tensor for tensor in ordereddict.values()] provided the OrderedDict’s keys are ordered as those of the standard pytorch lstm.state_dict().

1 Like