imitation.regularization.updaters#
Implements parameter scaling algorithms to update the parameters of a regularizer.
Classes
|
Scales the lambda of the regularizer by some constant factor. |
|
Protocol type for functions that update the regularizer parameter. |
- class imitation.regularization.updaters.IntervalParamScaler(scaling_factor, tolerable_interval)[source]#
Bases:
LambdaUpdater
Scales the lambda of the regularizer by some constant factor.
Lambda is scaled up if the ratio of the validation loss to the training loss is above the tolerable interval, and scaled down if the ratio is below the tolerable interval. Nothing happens if the ratio is within the tolerable interval.
- __init__(scaling_factor, tolerable_interval)[source]#
Initialize the interval parameter scaler.
- Parameters
scaling_factor (
float
) – The factor by which to scale the lambda, a value in (0, 1).tolerable_interval (
Tuple
[float
,float
]) – The interval within which the ratio of the validation loss to the training loss is considered acceptable. A tuple whose first element is at least 0 and the second element is greater than the first.
- Raises
ValueError – If the tolerable interval is not a tuple of length 2.
ValueError – if the scaling factor is not in (0, 1).
ValueError – if the tolerable interval is negative or not a proper interval.
- class imitation.regularization.updaters.LambdaUpdater(*args, **kwargs)[source]#
Bases:
Protocol
Protocol type for functions that update the regularizer parameter.
A callable object that takes in the current lambda and the train and val loss, and returns the new lambda. This has been implemented as a protocol and not an ABC because a user might wish to provide their own implementation without having to inherit from the base class, e.g. by defining a function instead of a class.
Note: if you implement LambdaUpdater, your implementation MUST be purely functional, i.e. side-effect free. The class structure should only be used to store constant hyperparameters. (Alternatively, closures can be used for that).
- __init__(*args, **kwargs)#