public abstract class BaseListener extends Object implements Listener
Listener
with all methods implemented as no-op.
Extend this for custom listeners to selectively override only the required methods
If you want to use evaluations in your listener, use BaseEvaluationListener
Constructor and Description |
---|
BaseListener() |
Modifier and Type | Method and Description |
---|---|
void |
activationAvailable(SameDiff sd,
At at,
MultiDataSet batch,
SameDiffOp op,
String varName,
INDArray activation)
Called when any activation becomes available.
|
ListenerResponse |
epochEnd(SameDiff sd,
At at,
LossCurve lossCurve,
long epochTimeMillis)
Called at the end of every epoch, when fitting from an iterator
|
void |
epochStart(SameDiff sd,
At at)
Called at the start of every epoch, when fitting from an iterator
|
void |
iterationDone(SameDiff sd,
At at,
MultiDataSet dataSet,
Loss loss)
Called at the end of every iteration, after all operations (including updating parameters) has been completed
|
void |
iterationStart(SameDiff sd,
At at,
MultiDataSet data,
long etlMs)
Called at the start of every iteration (minibatch), before any operations have been executed
|
void |
operationEnd(SameDiff sd,
Operation op)
Called at the end of an operation, e.g.
|
void |
operationStart(SameDiff sd,
Operation op)
Called at the start of an operation, e.g.
|
void |
opExecution(SameDiff sd,
At at,
MultiDataSet batch,
SameDiffOp op,
INDArray[] outputs)
Called at the end of each operation execution
|
void |
preOpExecution(SameDiff sd,
At at,
SameDiffOp op)
Called just before each operation is executed (native code called, etc) - after all inputs etc have been set
|
void |
preUpdate(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.
|
ListenerVariables |
requiredVariables(SameDiff sd)
Required variables for this listener.
|
ListenerResponse |
validationDone(SameDiff sd,
At at,
long validationTimeMillis)
Called after the end of every epoch, once validation evaluation is done, when training
|
public ListenerVariables requiredVariables(SameDiff sd)
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.
requiredVariables
in interface Listener
public void epochStart(SameDiff sd, At at)
Listener
epochStart
in interface Listener
sd
- The SameDiff instanceat
- Current iteration/epoch etcpublic ListenerResponse epochEnd(SameDiff sd, At at, LossCurve lossCurve, long epochTimeMillis)
Listener
public ListenerResponse validationDone(SameDiff sd, At at, long validationTimeMillis)
Listener
validationDone
in interface Listener
sd
- The SameDiff instanceat
- Current iteration/epoch etcvalidationTimeMillis
- How long validation took for this epochpublic void iterationStart(SameDiff sd, At at, MultiDataSet data, long etlMs)
Listener
iterationStart
in interface Listener
sd
- The SameDiff instanceat
- Current iteration/epoch etcpublic void iterationDone(SameDiff sd, At at, MultiDataSet dataSet, Loss loss)
Listener
iterationDone
in interface Listener
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 trainingpublic void operationStart(SameDiff sd, Operation op)
Listener
operationStart
in interface Listener
sd
- The SameDiff instanceop
- The operation being startedpublic void operationEnd(SameDiff sd, Operation op)
Listener
operationEnd
in interface Listener
sd
- The SameDiff instanceop
- The operation being startedpublic void preOpExecution(SameDiff sd, At at, SameDiffOp op)
Listener
preOpExecution
in interface Listener
sd
- The SameDiff instanceat
- Current iteration/epoch etcop
- Operation that has just been executedpublic void opExecution(SameDiff sd, At at, MultiDataSet batch, SameDiffOp op, INDArray[] outputs)
Listener
Note: Outputs will most likely be freed later, use detach() if you need to save it.
opExecution
in interface Listener
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 operationpublic void activationAvailable(SameDiff sd, At at, MultiDataSet batch, SameDiffOp op, String varName, INDArray activation)
Listener
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 from Listener.requiredVariables(SameDiff)
It is guaranteed to be called for variables from requiredVariables().
Note that the activations here overlap with Listener.opExecution(SameDiff, At, MultiDataSet, SameDiffOp, INDArray[])
-
both contain the same information/arrays
activationAvailable
in interface Listener
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 activationCopyright © 2019. All rights reserved.