Access gates of lstm/gru

How can I access the gates of LSTM/GRU ? Are they exposed somehow ? If not, any alternative?

What do you mean by accessing them? Acquiring the weights?

Not weights. I meant value of the gates – forget/reset/update etc. ?
Specifically, the value after sigmoid is what it means.

I see. Not with the provided nn.[GRU|RNN|LSTM](Cell) classes. But certainly doable if you write your own variant. A good reference is probably the Cell classes’ implementation. e.g.

Class: https://github.com/pytorch/pytorch/blob/27d7182d6c7e223e04166f33d5ec46ef8b510944/torch/nn/modules/rnn.py#L599
Fwd: https://github.com/pytorch/pytorch/blob/a3f4fa254c994e83d0da70c6ce2fa5fbde899c62/torch/nn/_functions/rnn.py#L23

1 Like