The GRU class implements a multi-layer gated recurrent unit (GRU) network. It supports stacked GRU layers, where each layer processes the input sequence and passes its output to the next layer. The class also provides methods for parameter retrieval and forward computation.
Value parameters
- hiddenSize
-
number of features in the hidden state
- inputSize
-
number of features in the input at each time step
- numLayers
-
number of stacked GRU layers (default: 1)
Attributes
- See also
- Companion
- object
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Perform the forward pass through all layers of the GRU. Processes the input sequence through each layer, updating the hidden states at each time step. Optionally supports truncated backpropagation through time (TBPTT).
Perform the forward pass through all layers of the GRU. Processes the input sequence through each layer, updating the hidden states at each time step. Optionally supports truncated backpropagation through time (TBPTT).
Value parameters
- h0
-
optional initial hidden states for each layer (default: zero-initialized)
- inputSeq
-
the input sequence, where each element is a tensor of shape (batchSize, inputDim, 1)
- tbptt
-
the truncation interval for TBPTT (default: 0, meaning no truncation)
Attributes
- Returns
-
a tuple containing: - the output sequence from the top layer (one tensor per time step) - the final hidden states for all layers
- Throws
-
IllegalArgumentException
if the input sequence is empty
Retrieve a specific layer of the GRU.
Retrieve a specific layer of the GRU.
Value parameters
- i
-
index of the layer to retrieve
Attributes
- Returns
-
the
RNNBaseinstance representing the layer
Retrieve the parameters of all layers in the GRU.
Retrieve the parameters of all layers in the GRU.
Attributes
- Returns
-
an indexed sequence of
Variablobjects representing the parameters - Definition Classes
Inherited methods
Set the module to evaluation mode (and all submodules recursively).
Set the module to evaluation mode (and all submodules recursively).
Attributes
- Inherited from:
- BaseModule
Return the gradients of all parameters.
Replace the current parameters with new ones. Useful for weight updates, loading saved models, etc.
Replace the current parameters with new ones. Useful for weight updates, loading saved models, etc.
Value parameters
- newParams
-
The new parameter list to assign
Attributes
- Inherited from:
- BaseModule
Set the module to training mode (and all submodules recursively).
Set the module to training mode (and all submodules recursively).
Attributes
- Inherited from:
- BaseModule
Zero out all gradients (in-place).
Concrete fields
Inherited fields
Flag to control training or evaluation behavior.
Automatically detect submodules (other BaseModules) within this module.
Automatically detect submodules (other BaseModules) within this module.
Attributes
- Inherited from:
- BaseModule