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, waitgetStepFunctionprotected 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)
ConvexOptimizersetGradientsAccumulator in interface ConvexOptimizerpublic GradientsAccumulator getGradientsAccumulator()
ConvexOptimizergetGradientsAccumulator in interface ConvexOptimizerpublic double score()
ConvexOptimizerscore in interface ConvexOptimizerpublic Updater getUpdater()
getUpdater in interface ConvexOptimizerpublic Updater getUpdater(boolean initializeIfReq)
getUpdater in interface ConvexOptimizerpublic void setUpdater(Updater updater)
setUpdater in interface ConvexOptimizerpublic ComputationGraphUpdater getComputationGraphUpdater()
getComputationGraphUpdater in interface ConvexOptimizerpublic ComputationGraphUpdater getComputationGraphUpdater(boolean initializIfReq)
getComputationGraphUpdater in interface ConvexOptimizerpublic void setUpdaterComputationGraph(ComputationGraphUpdater updater)
setUpdaterComputationGraph in interface ConvexOptimizerpublic void setListeners(Collection<TrainingListener> listeners)
setListeners in interface ConvexOptimizerpublic NeuralNetConfiguration getConf()
getConf in interface ConvexOptimizerpublic Pair<Gradient,Double> gradientAndScore(LayerWorkspaceMgr workspaceMgr)
ConvexOptimizergradientAndScore in interface ConvexOptimizerpublic boolean optimize(LayerWorkspaceMgr workspaceMgr)
optimize in interface ConvexOptimizerprotected void postFirstStep(INDArray gradient)
public int batchSize()
ConvexOptimizerbatchSize in interface ConvexOptimizerpublic void setBatchSize(int batchSize)
ConvexOptimizersetBatchSize in interface ConvexOptimizerpublic void preProcessLine()
preProcessLine in interface ConvexOptimizerpublic void postStep(INDArray gradient)
postStep in interface ConvexOptimizerpublic void updateGradientAccordingToParams(Gradient gradient, Model model, int batchSize, LayerWorkspaceMgr workspaceMgr)
ConvexOptimizerupdateGradientAccordingToParams in interface ConvexOptimizergradient - the gradient to modifymodel - the model with the parameters to updatebatchSize - batchSize for updatepublic void setupSearchState(Pair<Gradient,Double> pair)
setupSearchState in interface ConvexOptimizerpair - 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 © 2020. All rights reserved.