Class BaseListener
- java.lang.Object
-
- org.nd4j.autodiff.listeners.BaseListener
-
- All Implemented Interfaces:
Listener
- Direct Known Subclasses:
ActivationGradientCheckListener,ArraySavingListener,BaseEvaluationListener,CheckpointListener,ControlflowListener,ExecDebuggingListener,OpBenchmarkListener,ProfilingListener,ScoreListener,UIListener
public abstract class BaseListener extends Object implements Listener
-
-
Constructor Summary
Constructors Constructor Description BaseListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivationAvailable(SameDiff sd, At at, MultiDataSet batch, SameDiffOp op, String varName, INDArray activation)Called when any activation becomes available.ListenerResponseepochEnd(SameDiff sd, At at, LossCurve lossCurve, long epochTimeMillis)Called at the end of every epoch, when fitting from an iteratorvoidepochStart(SameDiff sd, At at)Called at the start of every epoch, when fitting from an iteratorvoiditerationDone(SameDiff sd, At at, MultiDataSet dataSet, Loss loss)Called at the end of every iteration, after all operations (including updating parameters) has been completedvoiditerationStart(SameDiff sd, At at, MultiDataSet data, long etlMs)Called at the start of every iteration (minibatch), before any operations have been executedvoidoperationEnd(SameDiff sd, Operation op)Called at the end of an operation, e.g.voidoperationStart(SameDiff sd, Operation op)Called at the start of an operation, e.g.voidopExecution(SameDiff sd, At at, MultiDataSet batch, SameDiffOp op, OpContext opContext, INDArray[] outputs)Called at the end of each operation executionvoidpreOpExecution(SameDiff sd, At at, SameDiffOp op, OpContext opContext)Called just before each operation is executed (native code called, etc) - after all inputs etc have been setvoidpreUpdate(SameDiff sd, At at, Variable v, INDArray update)Called just before each parameter is to be updated - i.e., just before each parameter is modified.ListenerVariablesrequiredVariables(SameDiff sd)Required variables for this listener.ListenerResponsevalidationDone(SameDiff sd, At at, long validationTimeMillis)Called after the end of every epoch, once validation evaluation is done, when training
-
-
-
Method Detail
-
requiredVariables
public ListenerVariables requiredVariables(SameDiff sd)
Description copied from interface:ListenerRequired variables for this listener.Used to ensure these variables end up in the minimum required subgraph calculated by
InferenceSession. Otherwise, if the variables weren't required by a loss variable, they would not be calculated.Any variables in here are guaranteed to have
Listener.activationAvailable(SameDiff, At, MultiDataSet, SameDiffOp, String, INDArray)called for them, regardless of whether they would normally be calculated or not.- Specified by:
requiredVariablesin interfaceListener
-
epochStart
public void epochStart(SameDiff sd, At at)
Description copied from interface:ListenerCalled at the start of every epoch, when fitting from an iterator- Specified by:
epochStartin interfaceListener- Parameters:
sd- The SameDiff instanceat- Current iteration/epoch etc
-
epochEnd
public ListenerResponse epochEnd(SameDiff sd, At at, LossCurve lossCurve, long epochTimeMillis)
Description copied from interface:ListenerCalled at the end of every epoch, when fitting from an iterator
-
validationDone
public ListenerResponse validationDone(SameDiff sd, At at, long validationTimeMillis)
Description copied from interface:ListenerCalled after the end of every epoch, once validation evaluation is done, when training- Specified by:
validationDonein interfaceListener- Parameters:
sd- The SameDiff instanceat- Current iteration/epoch etcvalidationTimeMillis- How long validation took for this epoch- Returns:
- ListenerResponse.STOP to stop training, CONTINUE or null to continue
-
iterationStart
public void iterationStart(SameDiff sd, At at, MultiDataSet data, long etlMs)
Description copied from interface:ListenerCalled at the start of every iteration (minibatch), before any operations have been executed- Specified by:
iterationStartin interfaceListener- Parameters:
sd- The SameDiff instanceat- Current iteration/epoch etc
-
iterationDone
public void iterationDone(SameDiff sd, At at, MultiDataSet dataSet, Loss loss)
Description copied from interface:ListenerCalled at the end of every iteration, after all operations (including updating parameters) has been completed- Specified by:
iterationDonein interfaceListener- Parameters:
sd- The SameDiff instanceat- Current iteration/epoch etcdataSet- The current dataset (minibatch) used for trainingloss- The loss value for the current minibatch. Will be null except for during training
-
operationStart
public void operationStart(SameDiff sd, Operation op)
Description copied from interface:ListenerCalled at the start of an operation, e.g. training or validation- Specified by:
operationStartin interfaceListener- Parameters:
sd- The SameDiff instanceop- The operation being started
-
operationEnd
public void operationEnd(SameDiff sd, Operation op)
Description copied from interface:ListenerCalled at the end of an operation, e.g. training or validation- Specified by:
operationEndin interfaceListener- Parameters:
sd- The SameDiff instanceop- The operation being started
-
preOpExecution
public void preOpExecution(SameDiff sd, At at, SameDiffOp op, OpContext opContext)
Description copied from interface:ListenerCalled just before each operation is executed (native code called, etc) - after all inputs etc have been set- Specified by:
preOpExecutionin interfaceListener- Parameters:
sd- The SameDiff instanceat- Current iteration/epoch etcop- Operation that has just been executed
-
opExecution
public void opExecution(SameDiff sd, At at, MultiDataSet batch, SameDiffOp op, OpContext opContext, INDArray[] outputs)
Description copied from interface:ListenerCalled at the end of each operation execution
Note: Outputs will most likely be freed later, use detach() if you need to save it.
- Specified by:
opExecutionin interfaceListener- Parameters:
sd- The SameDiff instanceat- Current iteration/epoch etcbatch- The batch's input data. May be null if not called with a batchop- Operation that has just been executedoutputs- The output arrays for the just-executed operation
-
activationAvailable
public void activationAvailable(SameDiff sd, At at, MultiDataSet batch, SameDiffOp op, String varName, INDArray activation)
Description copied from interface:ListenerCalled when any activation becomes available.The activation will most likely be freed later, use dup() if you need to save it.
Note that this method will be called when any activation becomes available, not just ones fromListener.requiredVariables(SameDiff)
It is guaranteed to be called for variables from requiredVariables().
Note that the activations here overlap withListener.opExecution(SameDiff, At, MultiDataSet, SameDiffOp, OpContext, INDArray[])- both contain the same information/arrays- Specified by:
activationAvailablein interfaceListener- Parameters:
sd- The SameDiff instanceat- Current iteration/epoch etcbatch- The batch's input data. May be null if not called with a batchop- Operation that has just been executedvarName- The name of the variableactivation- The variable's activation
-
-