Interface Listener

    • Method Detail

      • isActive

        boolean isActive​(Operation operation)
        Returns whether this listener is active during the given operation. If this returns false for the given operation, those listener methods will not be called.
      • epochStart

        void epochStart​(SameDiff sd,
                        At at)
        Called at the start of every epoch, when fitting from an iterator
        Parameters:
        sd - The SameDiff instance
        at - Current iteration/epoch etc
      • epochEnd

        ListenerResponse epochEnd​(SameDiff sd,
                                  At at,
                                  LossCurve lossCurve,
                                  long epochTimeMillis)
        Called at the end of every epoch, when fitting from an iterator
        Parameters:
        sd - The SameDiff instance
        at - Current iteration/epoch etc
        lossCurve - The losses so far
        epochTimeMillis - How long this epoch took
        Returns:
        ListenerResponse.STOP to stop training, CONTINUE or null to continue
      • validationDone

        ListenerResponse validationDone​(SameDiff sd,
                                        At at,
                                        long validationTimeMillis)
        Called after the end of every epoch, once validation evaluation is done, when training
        Parameters:
        sd - The SameDiff instance
        at - Current iteration/epoch etc
        validationTimeMillis - How long validation took for this epoch
        Returns:
        ListenerResponse.STOP to stop training, CONTINUE or null to continue
      • iterationStart

        void iterationStart​(SameDiff sd,
                            At at,
                            MultiDataSet data,
                            long etlTimeMs)
        Called at the start of every iteration (minibatch), before any operations have been executed
        Parameters:
        sd - The SameDiff instance
        at - Current iteration/epoch etc
      • iterationDone

        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
        Parameters:
        sd - The SameDiff instance
        at - Current iteration/epoch etc
        dataSet - The current dataset (minibatch) used for training
        loss - The loss value for the current minibatch. Will be null except for during training
      • operationStart

        void operationStart​(SameDiff sd,
                            Operation op)
        Called at the start of an operation, e.g. training or validation
        Parameters:
        sd - The SameDiff instance
        op - The operation being started
      • operationEnd

        void operationEnd​(SameDiff sd,
                          Operation op)
        Called at the end of an operation, e.g. training or validation
        Parameters:
        sd - The SameDiff instance
        op - The operation being started
      • preOpExecution

        void preOpExecution​(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 set
        Parameters:
        sd - The SameDiff instance
        at - Current iteration/epoch etc
        op - Operation that has just been executed
      • opExecution

        void opExecution​(SameDiff sd,
                         At at,
                         MultiDataSet batch,
                         SameDiffOp op,
                         OpContext opContext,
                         INDArray[] outputs)
        Called at the end of each operation execution

        Note: Outputs will most likely be freed later, use detach() if you need to save it.

        Parameters:
        sd - The SameDiff instance
        at - Current iteration/epoch etc
        batch - The batch's input data. May be null if not called with a batch
        op - Operation that has just been executed
        outputs - The output arrays for the just-executed operation
      • activationAvailable

        void activationAvailable​(SameDiff sd,
                                 At at,
                                 MultiDataSet batch,
                                 SameDiffOp op,
                                 String varName,
                                 INDArray activation)
        Called 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 from requiredVariables(SameDiff)
        It is guaranteed to be called for variables from requiredVariables().

        Note that the activations here overlap with opExecution(SameDiff, At, MultiDataSet, SameDiffOp, OpContext, INDArray[]) - both contain the same information/arrays

        Parameters:
        sd - The SameDiff instance
        at - Current iteration/epoch etc
        batch - The batch's input data. May be null if not called with a batch
        op - Operation that has just been executed
        varName - The name of the variable
        activation - The variable's activation
      • preUpdate

        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.
        Parameters:
        sd - SameDiff instance
        at - The current iteration/epoch etc
        v - Variable about to be updated during backprop
        update - The array representing the update (i.e., the gradient after applying learning rate, momentum, etc)