fit_readout#
- torchdyno.optim.ridge_regression.fit_readout(train_loader, preprocess_fn=None, l2=None, weights=None, skip_first_n=0, device='cpu')[source]#
Applies the ridge regression on the training data with all the given l2 values and returns a list of matrices, one for each L2 value.
- Parameters:
train_loader (DataLoader) – DataLoader of the training data.
preprocess_fn (Optional[Callable], optional) – a transformation to be applied to X before the linear transformation. Useful whenever this function is called to learn a Readout of a ESN. Defaults to None.
l2_values (List[float]) – List of all the candidate L2 values.
weights (Optional[List[float]], optional) – list of weights to be applied to each sample in the batch. Defaults to None.
skip_first_n (Optional[int], optional) – number of samples to skip in each batch of the train_loader. Defaults to None.
device (Optional[str], optional) – the device on which the function is executed. If None, the function is executed on a CUDA device if available, on CPU otherwise. Defaults to None.
l2 (float | List[float] | None)
- Returns:
- a Tuple containing the best linear matrix, the
corrisponding l2 value and the metric value.
- Return type:
Tuple[Tensor, float, float]