Evolvable Long Short-Term Memory (LSTM)¶
Parameters¶
- class agilerl.modules.lstm.EvolvableLSTM(*args, **kwargs)¶
The Evolvable Long Short-Term Memory (LSTM) class.
- Parameters:
input_size (int) – Size of input features
hidden_size (int) – Size of hidden state
num_outputs (int) – Output dimension
num_layers (int) – Number of LSTM layers stacked together
output_activation (str, optional) – Output activation layer, defaults to None
min_hidden_size (int, optional) – Minimum hidden state size, defaults to 32
max_hidden_size (int, optional) – Maximum hidden state size, defaults to 512
min_layers (int, optional) – Minimum number of LSTM layers, defaults to 1
max_layers (int, optional) – Maximum number of LSTM layers, defaults to 3
dropout (float, optional) – Dropout probability between LSTM layers, defaults to 0.0
device (str, optional) – Device for accelerated computing, ‘cpu’ or ‘cuda’, defaults to ‘cpu’
name (str, optional) – Name of the network, defaults to ‘lstm’
- add_layer() None ¶
Adds an LSTM layer to the network. Falls back on add_node() if max layers reached.
- change_activation(activation: str, output: bool = False) None ¶
Set the output activation function for the network.
- create_lstm() ModuleDict ¶
Creates and returns an LSTM network with the current configuration.
- Returns:
LSTM network
- Return type:
nn.ModuleDict
- forward(x: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | Tensor, states: Tuple[Tensor, Tensor] | None = None) Tensor ¶
Forward pass of the network.
- Parameters:
x (ArrayOrTensor) – Input tensor
states (Tuple[torch.Tensor, torch.Tensor], optional) – Tuple of hidden and cell states, defaults to None
- Returns:
Output tensor
- Return type:
torch.Tensor
- get_output_dense() Module ¶
Returns output layer of neural network.