RidgeIncrementalClassification¶
-
class
torch_rc.optim.RidgeIncrementalClassification(params: Iterable, l2_reg: float = 1)[source]¶ Implements an incremental Ridge classification algorithm.
This classifier first converts the target values into
{-1, 1}and then treats the problem as a regression task.The input examples and target values can be provided in batches so that it is not needed to hold the whole dataset in memory all at the same time.
- Parameters
params – iterable of parameters to optimize. Since this algorithm can only be used to train linear layers, the number of parameters should be exactly 2 (one for the weights and one for the biases).
l2_reg – regularization strength. Must be a positive floating point number.
-
fit_step(input, expected)[source]¶ Provides to the optimizer pairs of inputs and expected outputs.
Note
Calling this method does not update the parameters of your model. Instead, it is updated only an internal state of the optimizer. Whenever you want to update the parameters of the model, call the
fit_apply()method. In general, you will callfit_step()multiple times before finally callingfit_apply().- Parameters
input – input tensor of shape (batch, n_features)
expected – target tensor of shape (batch,) and of type
torch.long