Class CheckpointListener

    • Method Detail

      • epochEnd

        public ListenerResponse epochEnd​(SameDiff sameDiff,
                                         At at,
                                         LossCurve lossCurve,
                                         long epochTimeMillis)
        Description copied from interface: Listener
        Called at the end of every epoch, when fitting from an iterator
        Specified by:
        epochEnd in interface Listener
        Overrides:
        epochEnd in class BaseListener
        Parameters:
        sameDiff - 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
      • isActive

        public boolean isActive​(Operation operation)
        Description copied from interface: Listener
        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.
        Specified by:
        isActive in interface Listener
      • iterationDone

        public void iterationDone​(SameDiff sd,
                                  At at,
                                  MultiDataSet dataSet,
                                  Loss loss)
        Description copied from interface: Listener
        Called at the end of every iteration, after all operations (including updating parameters) has been completed
        Specified by:
        iterationDone in interface Listener
        Overrides:
        iterationDone in class BaseListener
        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
      • availableCheckpoints

        public List<Checkpoint> availableCheckpoints()
        List all available checkpoints. A checkpoint is 'available' if the file can be loaded. Any checkpoint files that have been automatically deleted (given the configuration) will not be returned here.
        Returns:
        List of checkpoint files that can be loaded
      • availableCheckpoints

        public static List<Checkpoint> availableCheckpoints​(File directory)
        List all available checkpoints. A checkpoint is 'available' if the file can be loaded. Any checkpoint files that have been automatically deleted (given the configuration) will not be returned here. Note that the checkpointInfo.txt file must exist, as this stores checkpoint information
        Returns:
        List of checkpoint files that can be loaded from the specified directory
      • lastCheckpoint

        public Checkpoint lastCheckpoint()
        Return the most recent checkpoint, if one exists - otherwise returns null
        Returns:
        Checkpoint
      • lastCheckpoint

        public static Checkpoint lastCheckpoint​(File rootDir)
        Return the most recent checkpoint, if one exists - otherwise returns null
        Parameters:
        rootDir - Root direcotry for the checkpoint files
        Returns:
        Checkpoint
      • getFileForCheckpoint

        public File getFileForCheckpoint​(Checkpoint checkpoint)
        Get the model file for the given checkpoint. Checkpoint model file must exist
        Parameters:
        checkpoint - Checkpoint to get the model file for
        Returns:
        Model file for the checkpoint
      • getFileForCheckpoint

        public File getFileForCheckpoint​(int checkpointNum)
        Get the model file for the given checkpoint number. Checkpoint model file must exist
        Parameters:
        checkpointNum - Checkpoint number to get the model file for
        Returns:
        Model file for the checkpoint
      • getFileForCheckpoint

        public static File getFileForCheckpoint​(File rootDir,
                                                int checkpointNum)
      • loadCheckpoint

        public SameDiff loadCheckpoint​(int checkpointNum,
                                       boolean loadUpdaterState)
        Load a given checkpoint number
        Parameters:
        loadUpdaterState - If true: load the updater state. See SameDiff.load(File, boolean) for more details
      • loadCheckpoint

        public static SameDiff loadCheckpoint​(File rootDir,
                                              int checkpointNum,
                                              boolean loadUpdaterState)
        Load a SameDiff instance for the given checkpoint that resides in the specified root directory
        Parameters:
        rootDir - Directory that the checkpoint resides in
        checkpointNum - Checkpoint model number to load
        loadUpdaterState - If true: load the updater state. See SameDiff.load(File, boolean) for more details
        Returns:
        The loaded model
      • loadLastCheckpoint

        public static SameDiff loadLastCheckpoint​(File rootDir,
                                                  boolean loadUpdaterState)
        Load the last (most recent) checkpoint from the specified root directory
        Parameters:
        rootDir - Root directory to load checpoint from
        Returns:
        ComputationGraph for last checkpoint