Train
ReservoirComputing.train! — Function
train!(rc, train_data, target_data, ps, st,
train_method=StandardRidge(0.0);
washout=0, return_states=false)Trains a given reservoir computing by creating the reservoir states from train_data, and then fiting the readout layer using target_data as target. The learned weights/layer are written into ps.
Arguments
rc: A reservoir computing model, either provided by ReservoirComputing.jl or built withReservoirChain. Must contain a trainable layer (for exampleLinearReadout), and a collection pointCollect.train_data: input sequence where columns are time steps.target_data: targets aligned withtrain_data.ps: model parameters.st: model states.train_method: training algorithm. Default isStandardRidge.
Keyword arguments
washout: number of initial time steps to discard (applied equally to features and targets). Default0.return_states: iftrue, also returns the feature matrix used for the fit.kwargs...: additional keyword arguments for the training algorithm, if needed. Defaults vary according to the different training method.
Returns
(ps, st): updated model parameters and states.(ps, st), states: Ifreturn_states=true.
Notes
- Features are produced by
collectstates(rc, train_data, ps, st). If you rely on the implicit collection of aLinearReadout, make sure that readout was created withinclude_collect=true, or insert an explicitCollect()earlier in theReservoirChain.
ReservoirComputing.train — Function
train(train_method, states, target_data; kwargs...)Lower level training hook to fit a readout from precomputed reservoir features and given targets.
Dispatching on this method with different training methods allows one to hook directly into train! without additional changes.
Arguments
train_method: An object describing the training algorithm and its hyperparameters (e.g. regularization strength, solver choice, constraints).states: Feature matrix with reservoir states (ie. obtained withcollectstates). Shape(n_features, T), whereTis the number of samples (e.g. time steps).target_data: Target matrix aligned withstates. Shape(n_outputs, T).
Returns
output_weights: Trained readout. Should be a forward method to be hooked into a layer. For instance, in case of linear regressionoutput_weightsis a mtrix consumable byLinearReadout.
Notes
- Any sequence pre-processing (e.g. washout) should be handled by the caller before invoking
train. Seetrain!for an end-to-end workflow. - For very long
T, consider chunked or iterative solvers to reduce memory usage. - If your approach returns additional artifacts (e.g. diagnostics), prefer storing them inside
train_methodor exposing a separate API; keeptrain’s return value as the forward method only.
Training methods
ReservoirComputing.StandardRidge — Type
StandardRidge([Type], [reg])Ridge regression method.
Equations
\[\mathbf{w} = (\mathbf{X}^\top \mathbf{X} + \lambda \mathbf{I})^{-1} \mathbf{X}^\top \mathbf{y}\]
Arguments
Type: type of the regularization argument. Default is inferred internally, there's usually no need to tweak thisreg: regularization coefficient. Default is set to 0.0 (linear regression).