Package ai.djl.training.optimizer
Class Optimizer.OptimizerBuilder<T extends Optimizer.OptimizerBuilder>
java.lang.Object
ai.djl.training.optimizer.Optimizer.OptimizerBuilder<T>
- Direct Known Subclasses:
Adadelta.Builder
,Adagrad.Builder
,Adam.Builder
,AdamW.Builder
,Nag.Builder
,RmsProp.Builder
,Sgd.Builder
- Enclosing class:
- Optimizer
public abstract static class Optimizer.OptimizerBuilder<T extends Optimizer.OptimizerBuilder>
extends Object
The Builder to construct an
Optimizer
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionoptBeginNumUpdate
(int beginNumUpdate) Sets the initial value of the number of updates.optClipGrad
(float clipGrad) Sets the value of the \(clipGrad\).optWeightDecays
(float weightDecays) Sets the value of weight decay.protected abstract T
self()
setRescaleGrad
(float rescaleGrad) Sets the value used to rescale the gradient.
-
Constructor Details
-
OptimizerBuilder
protected OptimizerBuilder()
-
-
Method Details
-
setRescaleGrad
Sets the value used to rescale the gradient. This is used to alleviate the effect of batching on the loss. Usually, the value is set to \( 1/batch_size \). Defaults to 1.- Parameters:
rescaleGrad
- the value used to rescale the gradient- Returns:
- this
Builder
-
optWeightDecays
Sets the value of weight decay. Weight decay augments the objective function with a regularization term that penalizes large weights.- Parameters:
weightDecays
- the value of weight decay to be set- Returns:
- this
Builder
-
optClipGrad
Sets the value of the \(clipGrad\). Clips the gradient to the range of \([-clipGrad, clipGrad]\). If \(clipGrad \lt 0\), gradient clipping is turned off.\(grad = max(min(grad, clipGrad), -clipGrad)\)
- Parameters:
clipGrad
- the value of \(clipGrad\)- Returns:
- this
Builder
-
optBeginNumUpdate
Sets the initial value of the number of updates.- Parameters:
beginNumUpdate
- the initial value of the number of updates- Returns:
- this
Builder
-
self
-