Class LSTM
java.lang.Object
ai.beestream.jitnn.nn.Module
ai.beestream.jitnn.nn.LSTM
- All Implemented Interfaces:
AutoCloseable
A stack of LSTM layers over [T, B, I] sequences (time first), optionally bidirectional, PyTorch's
nn.LSTM equations, gate order, parameter order and initialisation: every weight and
bias uniform in [-1/sqrt(H), 1/sqrt(H)). Parameters per layer and direction (forward, then
reverse): W_ih [4H, in], W_hh [4H, H], b_ih, b_hh [4H]. Padded batches pass their
sequence lengths: outputs past a length are 0 and the final states are each sequence's last.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOutput sequence of the last layer [T, B, directions H] and the final hidden states and cell states, [layers directions, B, H] each. -
Constructor Summary
ConstructorsConstructorDescriptionLSTM(int input, int hidden, int layers, boolean bidirectional, long seed) layersLSTM layers frominputtohiddenfeatures, optionally bidirectional, initialised fromseed.LSTM(int input, int hidden, int layers, long seed) layersunidirectional LSTM layers frominputtohiddenfeatures, initialised fromseed. -
Method Summary
Modifier and TypeMethodDescriptionOutput sequence of the last layer, from zero initial states.From initial states [layers directions, B, H] (null: zeros), for sequences oflengths(null: all T).inthidden()The hidden size per direction.Methods inherited from class Module
buffer, buffers, child, close, isClosed, isTraining, loadStateDict, parameter, parameterCount, parameters, stateDict, train, zeroGrad
-
Constructor Details
-
LSTM
public LSTM(int input, int hidden, int layers, long seed) layersunidirectional LSTM layers frominputtohiddenfeatures, initialised fromseed. -
LSTM
public LSTM(int input, int hidden, int layers, boolean bidirectional, long seed) layersLSTM layers frominputtohiddenfeatures, optionally bidirectional, initialised fromseed.
-
-
Method Details
-
forward
-
forward
From initial states [layers directions, B, H] (null: zeros), for sequences oflengths(null: all T).