jsat.math.optimization.stochastic
Class Adam
- java.lang.Object
-
- jsat.math.optimization.stochastic.Adam
-
- All Implemented Interfaces:
- java.io.Serializable, GradientUpdater
public class Adam extends java.lang.Object implements GradientUpdater
Adam is inspired byRMSPropandAdaGrad, where the former can be seen as a special case of Adam. Adam has been shown to work well in training neural networks, and still converges well with sparse gradients.
NOTE: that while it will converge, Adam dose not support sparse updates. So runtime when in highly sparse environments will be hampered.
See: Kingma, D. P.,&Ba, J. L. (2015). Adam: A Method for Stochastic Optimization. In ICLR.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static doubleDEFAULT_ALPHAstatic doubleDEFAULT_BETA_1static doubleDEFAULT_BETA_2static doubleDEFAULT_EPSstatic doubleDEFAULT_LAMBDA
-
Constructor Summary
Constructors Constructor and Description Adam()Adam(Adam toCopy)Copy constructorAdam(double alpha, double beta_1, double beta_2, double eps, double lambda)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Adamclone()voidsetup(int d)Sets up this updater to update a weight vector of dimensiondby a gradient of the same dimensionvoidupdate(Vec x, Vec grad, double eta)Updates the weight vectorxsuch that x = x-ηf(grad), where f(grad) is some function on the gradient that effectively returns a new vector.doubleupdate(Vec x, Vec grad, double eta, double bias, double biasGrad)Updates the weight vectorxsuch that x = x-ηf(grad), where f(grad) is some function on the gradient that effectively returns a new vector.
-
-
-
Field Detail
-
DEFAULT_ALPHA
public static final double DEFAULT_ALPHA
- See Also:
- Constant Field Values
-
DEFAULT_BETA_1
public static final double DEFAULT_BETA_1
- See Also:
- Constant Field Values
-
DEFAULT_BETA_2
public static final double DEFAULT_BETA_2
- See Also:
- Constant Field Values
-
DEFAULT_EPS
public static final double DEFAULT_EPS
- See Also:
- Constant Field Values
-
DEFAULT_LAMBDA
public static final double DEFAULT_LAMBDA
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Adam
public Adam()
-
Adam
public Adam(double alpha, double beta_1, double beta_2, double eps, double lambda)
-
Adam
public Adam(Adam toCopy)
Copy constructor- Parameters:
toCopy- the object to copy
-
-
Method Detail
-
update
public void update(Vec x, Vec grad, double eta)
Description copied from interface:GradientUpdaterUpdates the weight vectorxsuch that x = x-ηf(grad), where f(grad) is some function on the gradient that effectively returns a new vector. It is not necessary for the internal implementation to ever explicitly form any of these objects, so long asxis mutated to have the correct result.- Specified by:
updatein interfaceGradientUpdater- Parameters:
x- the vector to mutate such that is has been updated by the gradientgrad- the gradient to update the weight vectorxfrometa- the learning rate to apply
-
update
public double update(Vec x, Vec grad, double eta, double bias, double biasGrad)
Description copied from interface:GradientUpdaterUpdates the weight vectorxsuch that x = x-ηf(grad), where f(grad) is some function on the gradient that effectively returns a new vector. It is not necessary for the internal implementation to ever explicitly form any of these objects, so long asxis mutated to have the correct result.
This version of the update method includes two extra parameters to make it easer to use when a scalar bias term is also used- Specified by:
updatein interfaceGradientUpdater- Parameters:
x- the vector to mutate such that is has been updated by the gradientgrad- the gradient to update the weight vectorxfrometa- the learning rate to applybias- the bias term of the vectorbiasGrad- the gradient for the bias term- Returns:
- the value to change the bias by, the update being
bias = bias - returnValue
-
clone
public Adam clone()
- Specified by:
clonein interfaceGradientUpdater- Overrides:
clonein classjava.lang.Object
-
setup
public void setup(int d)
Description copied from interface:GradientUpdaterSets up this updater to update a weight vector of dimensiondby a gradient of the same dimension- Specified by:
setupin interfaceGradientUpdater- Parameters:
d- the dimension of the weight vector that will be updated
-
-
DataMelt 3.0 © DataMelt by jWork.ORG