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 with ReservoirChain. Must contain a trainable layer (for example LinearReadout), and a collection point Collect.
  • train_data: input sequence where columns are time steps.
  • target_data: targets aligned with train_data.
  • ps: model parameters.
  • st: model states.
  • train_method: training algorithm. Default is StandardRidge.

Keyword arguments

  • washout: number of initial time steps to discard (applied equally to features and targets). Default 0.
  • return_states: if true, 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: If return_states=true.

Notes

  • Features are produced by collectstates(rc, train_data, ps, st). If you rely on the implicit collection of a LinearReadout, make sure that readout was created with include_collect=true, or insert an explicit Collect() earlier in the ReservoirChain.
source
ReservoirComputing.trainFunction
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 with collectstates). Shape (n_features, T), where T is the number of samples (e.g. time steps).
  • target_data: Target matrix aligned with states. 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 regression output_weights is a mtrix consumable by LinearReadout.

Notes

  • Any sequence pre-processing (e.g. washout) should be handled by the caller before invoking train. See train! 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_method or exposing a separate API; keep train’s return value as the forward method only.
source

Training methods

ReservoirComputing.StandardRidgeType
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 this
  • reg: regularization coefficient. Default is set to 0.0 (linear regression).
source