LearningRateControl

class LearningRateControl.ConstantLearningRate(defaultLearningRate, minLearningRate=0.0, defaultLearningRates=None, errorMeasureKey=None, relativeErrorAlsoRelativeToLearningRate=False, minNumEpochsPerNewLearningRate=0, filename=None)[source]
Parameters:
  • defaultLearningRate (float) – default learning rate. usually for epoch 1
  • | dict[int,float] defaultLearningRates (list[float]) – learning rates
  • errorMeasureKey (str) – for getEpochErrorValue() the selector for EpochData.error which is a dict
  • minNumEpochsPerNewLearningRate (int) – if the lr was recently updated, use it for at least N epochs
  • filename (str) – load from and save to file
calcLearningRateForEpoch(epoch)[source]

Dummy constant learning rate. Returns initial learning rate. :type epoch: int :returns learning rate :rtype: float

need_error_info = False[source]
class LearningRateControl.LearningRateControl(defaultLearningRate, minLearningRate=0.0, defaultLearningRates=None, errorMeasureKey=None, relativeErrorAlsoRelativeToLearningRate=False, minNumEpochsPerNewLearningRate=0, filename=None)[source]
Parameters:
  • defaultLearningRate (float) – default learning rate. usually for epoch 1
  • | dict[int,float] defaultLearningRates (list[float]) – learning rates
  • errorMeasureKey (str) – for getEpochErrorValue() the selector for EpochData.error which is a dict
  • minNumEpochsPerNewLearningRate (int) – if the lr was recently updated, use it for at least N epochs
  • filename (str) – load from and save to file
class EpochData(learningRate, error=None)[source]
calcLearningRateForEpoch(epoch)[source]

:returns learning rate :rtype: float

calcNewLearnignRateForEpoch(epoch)[source]
calcRelativeError(oldEpoch, newEpoch)[source]
getEpochErrorDict(epoch)[source]
getEpochErrorValue(epoch)[source]
getErrorKey(epoch)[source]
getLastBestEpoch(last_epoch, first_epoch=1, filter_score=inf, only_last_n=-1, min_score_dist=0.0)[source]
Parameters:
  • first_epoch (int) – will check all epochs >= first_epoch
  • last_epoch (int) – will check all epochs <= last_epoch
  • filter_score (float) – all epochs which values over this score are not considered
  • only_last_n (int) – if set, from the resulting list, we consider only the last only_last_n
  • min_score_dist (float) – filter out epochs where the diff to the most recent is not big enough
Returns:

the last best epoch. to get the details then, you might want to use getEpochErrorDict.

Return type:

int|None

getLastEpoch(epoch)[source]
getLearningRateForEpoch(epoch)[source]
Return type:float
getMostRecentLearningRate(epoch, excludeCurrent=True)[source]
load()[source]
classmethod load_initial_from_config(config)[source]
Return type:LearningRateControl
classmethod load_initial_kwargs_from_config(config)[source]
Return type:dict[str]
need_error_info = True[source]
save()[source]
setDefaultLearningRateForEpoch(epoch, learningRate)[source]
setEpochError(epoch, error)[source]
class LearningRateControl.NewbobAbs(errorThreshold, learningRateDecayFactor, **kwargs)[source]
calcLearningRateForEpoch(epoch)[source]

Newbob+ on train data. :type epoch: int :returns learning rate :rtype: float

classmethod load_initial_kwargs_from_config(config)[source]
Return type:dict[str]
class LearningRateControl.NewbobMultiEpoch(numEpochs, updateInterval, relativeErrorThreshold, learningRateDecayFactor, **kwargs)[source]
Parameters:defaultLearningRate (float) – learning rate for epoch 1+2
calcLearningRateForEpoch(epoch)[source]

Newbob+ on train data. :type epoch: int :returns learning rate :rtype: float

classmethod load_initial_kwargs_from_config(config)[source]
Return type:dict[str]
class LearningRateControl.NewbobRelative(relativeErrorThreshold, learningRateDecayFactor, **kwargs)[source]
Parameters:defaultLearningRate (float) – learning rate for epoch 1+2
calcLearningRateForEpoch(epoch)[source]

Newbob+ on train data. :type epoch: int :returns learning rate :rtype: float

classmethod load_initial_kwargs_from_config(config)[source]
Return type:dict[str]
LearningRateControl.demo()[source]
LearningRateControl.learningRateControlType(typeName)[source]
LearningRateControl.loadLearningRateControlFromConfig(config)[source]
Return type:LearningRateControl