Class SleepyTrainingListener
- java.lang.Object
-
- org.deeplearning4j.optimize.api.BaseTrainingListener
-
- org.deeplearning4j.optimize.listeners.SleepyTrainingListener
-
- All Implemented Interfaces:
Serializable
,TrainingListener
public class SleepyTrainingListener extends BaseTrainingListener implements Serializable
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SleepyTrainingListener.SleepMode
static class
SleepyTrainingListener.TimeMode
-
Field Summary
Fields Modifier and Type Field Description protected ThreadLocal<AtomicLong>
lastBP
protected ThreadLocal<AtomicLong>
lastEE
protected ThreadLocal<AtomicLong>
lastES
protected ThreadLocal<AtomicLong>
lastFF
protected ThreadLocal<AtomicLong>
lastIteration
protected SleepyTrainingListener.SleepMode
sleepMode
protected SleepyTrainingListener.TimeMode
timeMode
protected long
timerBP
protected long
timerEE
protected long
timerES
protected long
timerFF
protected long
timerIteration
-
Constructor Summary
Constructors Constructor Description SleepyTrainingListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
iterationDone(Model model, int iteration, int epoch)
Event listener for each iteration.void
onBackwardPass(Model model)
Called once per iteration (backward pass) after gradients have been calculated, and updated Gradients are available viaModel.gradient()
.void
onEpochEnd(Model model)
Called once at the end of each epoch, when using methods such asMultiLayerNetwork.fit(DataSetIterator)
,ComputationGraph.fit(DataSetIterator)
orComputationGraph.fit(MultiDataSetIterator)
void
onEpochStart(Model model)
Called once at the start of each epoch, when using methods such asMultiLayerNetwork.fit(DataSetIterator)
,ComputationGraph.fit(DataSetIterator)
orComputationGraph.fit(MultiDataSetIterator)
void
onForwardPass(Model model, List<INDArray> activations)
Called once per iteration (forward pass) for activations (usually for aMultiLayerNetwork
), only at training timevoid
onForwardPass(Model model, Map<String,INDArray> activations)
Called once per iteration (forward pass) for activations (usually for aComputationGraph
), only at training timevoid
onGradientCalculation(Model model)
Called once per iteration (backward pass) before the gradients are updated Gradients are available viaModel.gradient()
.protected void
sleep(long sleepTimeMs)
protected void
sleep(AtomicLong lastTime, long sleepTime)
-
-
-
Field Detail
-
lastEE
protected final transient ThreadLocal<AtomicLong> lastEE
-
lastES
protected final transient ThreadLocal<AtomicLong> lastES
-
lastFF
protected final transient ThreadLocal<AtomicLong> lastFF
-
lastBP
protected final transient ThreadLocal<AtomicLong> lastBP
-
lastIteration
protected final transient ThreadLocal<AtomicLong> lastIteration
-
timerEE
protected long timerEE
-
timerES
protected long timerES
-
timerFF
protected long timerFF
-
timerBP
protected long timerBP
-
timerIteration
protected long timerIteration
-
sleepMode
protected SleepyTrainingListener.SleepMode sleepMode
-
timeMode
protected SleepyTrainingListener.TimeMode timeMode
-
-
Method Detail
-
sleep
protected void sleep(long sleepTimeMs)
-
sleep
protected void sleep(AtomicLong lastTime, long sleepTime)
-
onEpochStart
public void onEpochStart(Model model)
Description copied from interface:TrainingListener
Called once at the start of each epoch, when using methods such asMultiLayerNetwork.fit(DataSetIterator)
,ComputationGraph.fit(DataSetIterator)
orComputationGraph.fit(MultiDataSetIterator)
- Specified by:
onEpochStart
in interfaceTrainingListener
- Overrides:
onEpochStart
in classBaseTrainingListener
-
onEpochEnd
public void onEpochEnd(Model model)
Description copied from interface:TrainingListener
Called once at the end of each epoch, when using methods such asMultiLayerNetwork.fit(DataSetIterator)
,ComputationGraph.fit(DataSetIterator)
orComputationGraph.fit(MultiDataSetIterator)
- Specified by:
onEpochEnd
in interfaceTrainingListener
- Overrides:
onEpochEnd
in classBaseTrainingListener
-
onForwardPass
public void onForwardPass(Model model, List<INDArray> activations)
Description copied from interface:TrainingListener
Called once per iteration (forward pass) for activations (usually for aMultiLayerNetwork
), only at training time- Specified by:
onForwardPass
in interfaceTrainingListener
- Overrides:
onForwardPass
in classBaseTrainingListener
- Parameters:
model
- Modelactivations
- Layer activations (including input)
-
onForwardPass
public void onForwardPass(Model model, Map<String,INDArray> activations)
Description copied from interface:TrainingListener
Called once per iteration (forward pass) for activations (usually for aComputationGraph
), only at training time- Specified by:
onForwardPass
in interfaceTrainingListener
- Overrides:
onForwardPass
in classBaseTrainingListener
- Parameters:
model
- Modelactivations
- Layer activations (including input)
-
iterationDone
public void iterationDone(Model model, int iteration, int epoch)
Description copied from interface:TrainingListener
Event listener for each iteration. Called once, after each parameter update has ocurred while training the network- Specified by:
iterationDone
in interfaceTrainingListener
- Overrides:
iterationDone
in classBaseTrainingListener
- Parameters:
model
- the model iteratingiteration
- the iteration
-
onBackwardPass
public void onBackwardPass(Model model)
Description copied from interface:TrainingListener
Called once per iteration (backward pass) after gradients have been calculated, and updated Gradients are available viaModel.gradient()
.Unlike
TrainingListener.onGradientCalculation(Model)
the gradients at this point will be post-update, rather than raw (pre-update) gradients at that method call.- Specified by:
onBackwardPass
in interfaceTrainingListener
- Overrides:
onBackwardPass
in classBaseTrainingListener
- Parameters:
model
- Model
-
onGradientCalculation
public void onGradientCalculation(Model model)
Description copied from interface:TrainingListener
Called once per iteration (backward pass) before the gradients are updated Gradients are available viaModel.gradient()
. Note that gradients will likely be updated in-place - thus they should be copied or processed synchronously in this method.For updates (gradients post learning rate/momentum/rmsprop etc) see
TrainingListener.onBackwardPass(Model)
- Specified by:
onGradientCalculation
in interfaceTrainingListener
- Overrides:
onGradientCalculation
in classBaseTrainingListener
- Parameters:
model
- Model
-
-