public abstract class BaseOptimizer extends Object implements ConvexOptimizer
Modifier and Type | Field and Description |
---|---|
protected GradientsAccumulator |
accumulator |
protected ComputationGraphUpdater |
computationGraphUpdater |
protected NeuralNetConfiguration |
conf |
static String |
GRADIENT_KEY |
protected BackTrackLineSearch |
lineMaximizer |
protected static org.slf4j.Logger |
log |
protected Model |
model |
protected double |
oldScore |
static String |
PARAMS_KEY |
protected double |
score |
static String |
SCORE_KEY |
static String |
SEARCH_DIR |
protected Map<String,Object> |
searchState |
protected double |
step |
protected StepFunction |
stepFunction |
protected double |
stepMax |
protected Collection<TrainingListener> |
trainingListeners |
protected Updater |
updater |
Constructor and Description |
---|
BaseOptimizer(NeuralNetConfiguration conf,
StepFunction stepFunction,
Collection<TrainingListener> trainingListeners,
Model model) |
Modifier and Type | Method and Description |
---|---|
static void |
applyConstraints(Model model) |
int |
batchSize()
The batch size for the optimizer
|
ComputationGraphUpdater |
getComputationGraphUpdater() |
ComputationGraphUpdater |
getComputationGraphUpdater(boolean initializIfReq) |
NeuralNetConfiguration |
getConf() |
static StepFunction |
getDefaultStepFunctionForOptimizer(Class<? extends ConvexOptimizer> optimizerClass) |
static int |
getEpochCount(Model model) |
GradientsAccumulator |
getGradientsAccumulator()
This method returns GradientsAccumulator instance used in this optimizer.
|
static int |
getIterationCount(Model model) |
Updater |
getUpdater() |
Updater |
getUpdater(boolean initializeIfReq) |
Pair<Gradient,Double> |
gradientAndScore(LayerWorkspaceMgr workspaceMgr)
The gradient and score for this optimizer
|
static void |
incrementIterationCount(Model model,
int incrementBy) |
boolean |
optimize(LayerWorkspaceMgr workspaceMgr)
Optimize call.
|
protected void |
postFirstStep(INDArray gradient) |
void |
postStep(INDArray gradient)
Post step to update searchDirection with new gradient and parameter information
|
void |
preProcessLine()
Pre preProcess to setup initial searchDirection approximation
|
double |
score()
The score for the optimizer so far
|
void |
setBatchSize(int batchSize)
Set the batch size for the optimizer
|
void |
setGradientsAccumulator(GradientsAccumulator accumulator)
This method specifies GradientsAccumulator instance to be used for updates sharing across multiple models
|
void |
setListeners(Collection<TrainingListener> listeners) |
void |
setUpdater(Updater updater) |
void |
setUpdaterComputationGraph(ComputationGraphUpdater updater) |
void |
setupSearchState(Pair<Gradient,Double> pair)
Setup the initial search state
|
void |
updateGradientAccordingToParams(Gradient gradient,
Model model,
int batchSize,
LayerWorkspaceMgr workspaceMgr)
Update the gradient according to the configuration such as adagrad, momentum, and sparsity
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getStepFunction
protected NeuralNetConfiguration conf
protected static final org.slf4j.Logger log
protected StepFunction stepFunction
protected Collection<TrainingListener> trainingListeners
protected Model model
protected BackTrackLineSearch lineMaximizer
protected Updater updater
protected ComputationGraphUpdater computationGraphUpdater
protected double step
protected double score
protected double oldScore
protected double stepMax
public static final String GRADIENT_KEY
public static final String SCORE_KEY
public static final String PARAMS_KEY
public static final String SEARCH_DIR
protected GradientsAccumulator accumulator
public BaseOptimizer(NeuralNetConfiguration conf, StepFunction stepFunction, Collection<TrainingListener> trainingListeners, Model model)
conf
- stepFunction
- trainingListeners
- model
- public void setGradientsAccumulator(GradientsAccumulator accumulator)
ConvexOptimizer
setGradientsAccumulator
in interface ConvexOptimizer
public GradientsAccumulator getGradientsAccumulator()
ConvexOptimizer
getGradientsAccumulator
in interface ConvexOptimizer
public double score()
ConvexOptimizer
score
in interface ConvexOptimizer
public Updater getUpdater()
getUpdater
in interface ConvexOptimizer
public Updater getUpdater(boolean initializeIfReq)
getUpdater
in interface ConvexOptimizer
public void setUpdater(Updater updater)
setUpdater
in interface ConvexOptimizer
public ComputationGraphUpdater getComputationGraphUpdater()
getComputationGraphUpdater
in interface ConvexOptimizer
public ComputationGraphUpdater getComputationGraphUpdater(boolean initializIfReq)
getComputationGraphUpdater
in interface ConvexOptimizer
public void setUpdaterComputationGraph(ComputationGraphUpdater updater)
setUpdaterComputationGraph
in interface ConvexOptimizer
public void setListeners(Collection<TrainingListener> listeners)
setListeners
in interface ConvexOptimizer
public NeuralNetConfiguration getConf()
getConf
in interface ConvexOptimizer
public Pair<Gradient,Double> gradientAndScore(LayerWorkspaceMgr workspaceMgr)
ConvexOptimizer
gradientAndScore
in interface ConvexOptimizer
public boolean optimize(LayerWorkspaceMgr workspaceMgr)
optimize
in interface ConvexOptimizer
protected void postFirstStep(INDArray gradient)
public int batchSize()
ConvexOptimizer
batchSize
in interface ConvexOptimizer
public void setBatchSize(int batchSize)
ConvexOptimizer
setBatchSize
in interface ConvexOptimizer
public void preProcessLine()
preProcessLine
in interface ConvexOptimizer
public void postStep(INDArray gradient)
postStep
in interface ConvexOptimizer
public void updateGradientAccordingToParams(Gradient gradient, Model model, int batchSize, LayerWorkspaceMgr workspaceMgr)
ConvexOptimizer
updateGradientAccordingToParams
in interface ConvexOptimizer
gradient
- the gradient to modifymodel
- the model with the parameters to updatebatchSize
- batchSize for updatepublic void setupSearchState(Pair<Gradient,Double> pair)
setupSearchState
in interface ConvexOptimizer
pair
- public static StepFunction getDefaultStepFunctionForOptimizer(Class<? extends ConvexOptimizer> optimizerClass)
public static int getIterationCount(Model model)
public static void incrementIterationCount(Model model, int incrementBy)
public static int getEpochCount(Model model)
public static void applyConstraints(Model model)
Copyright © 2021. All rights reserved.