Reservoir#
- class torchdyno.models.esn.reservoir.Reservoir[source]#
Bases:
ModuleA Reservoir of for Echo State Networks.
- Parameters:
input_size – the number of expected features in the input x
hidden_size – the number of features in the hidden state h
activation – name of the activation function from torch (e.g. torch.tanh)
leakage – the value of the leaking parameter alpha
input_scaling – the value for the desired scaling of the input (must be <= 1)
rho – the desired spectral radius of the recurrent matrix (must be < 1)
bias – if
False, the layer does not use bias weights bmode – execution mode of the reservoir (vanilla or intrinsic plasticity)
kernel_initializer – the kind of initialization of the input transformation. Default: ‘uniform’
recurrent_initializer – the kind of initialization of the recurrent matrix. Default: ‘normal’
net_gain_and_bias – if
True, the network uses additionalg(gain) andb(bias) parameters. Default:False
Methods
__init__(input_size, hidden_size[, ...])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(input[, initial_state, mask])Define the computation performed at every call.
merge_reservoirs(others[, joint_scaling, ...])Merges two reservoirs into a single reservoir.
Attributes
Reservoir state dimension.
Input dimension.
- __init__(input_size, hidden_size, activation='tanh', leakage=1.0, input_scaling=0.9, rho=0.99, bias=False, kernel_initializer='uniform', recurrent_initializer='uniform', net_gain_and_bias=False)[source]#
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- Parameters:
input_size (int)
hidden_size (int)
activation (str)
leakage (float)
input_scaling (float)
rho (float)
bias (bool)
kernel_initializer (str | Callable[[Size], Tensor])
recurrent_initializer (str | Callable[[Size], Tensor])
net_gain_and_bias (bool)
- forward(input, initial_state=None, mask=None)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Parameters:
input (Tensor)
initial_state (Tensor | None)
mask (Tensor | None)
- Return type:
Tensor
- merge_reservoirs(others, joint_scaling=None, coupled=False, independent_inputs=False)[source]#
Merges two reservoirs into a single reservoir.
- property input_size: int#
Input dimension.
Reservoir state dimension.