Parameter bag for LSTM operations.
Used by lstm_forward, lstm_forward_train, and
lstm_backward. weights is supplied separately as
std::vector<Storage> in the order
[W_ih, W_hh, b_ih, b_hh] per layer; bidirectional layers
double the count (forward block followed by reverse block).
When proj_size > 0 (the projected-LSTM / LSTMP variant) an
additional weight tensor W_hr of shape (proj_size, hidden_size) is appended per layer so the order becomes
[W_ih, W_hh, b_ih, b_hh, W_hr]. The recurrent weight
W_hh then has its second axis sized proj_size instead of
hidden_size because the projected hidden state feeds the
next time step. The cell state c_n keeps shape
hidden_size regardless.
Attributes
input_size, hidden_sizeintInput feature size and recurrent hidden size.
num_layersintNumber of stacked LSTM layers.
seq_len, batch_sizeintTime and batch dimensions of the input sequence.
batch_firstboolIf
true the input is laid out as (batch, seq, input); otherwise (seq, batch, input).bidirectionalboolWhether to run a reverse-direction stack alongside the forward.
has_biasboolWhether the per-gate bias terms are present.
proj_sizeint0 ⇒ standard LSTM; > 0 ⇒ projected (LSTMP) variant.