(self, ckpt_file, optimizer=None)
return ckpt_dict['global_step']
r"""
        Restores checkpoint from a pth file and restores optimizer state.

        Args:
            ckpt_file (str): A PyTorch pth file containing model weights.
            optimizer (Optimizer): A vanilla optimizer to have its state restored from.

        Returns:
            int: Global step variable where the model was last checkpointed.
r"""
        Restores checkpoint from a pth file and restores optimizer state.
r Restores checkpoint from a pth file and restores optimizer state .
def restore_checkpoint(self, ckpt_file, optimizer=None):
        r"""
        Restores checkpoint from a pth file and restores optimizer state.

        Args:
            ckpt_file (str): A PyTorch pth file containing model weights.
            optimizer (Optimizer): A vanilla optimizer to have its state restored from.

        Returns:
            int: Global step variable where the model was last checkpointed.
        """
        if not ckpt_file:
            raise ValueError("No checkpoint file to be restored.")

        ckpt_dict = megengine.load(ckpt_file)

        # Restore model weights
        self.load_state_dict(ckpt_dict['model_state_dict'])

        # Restore optimizer status if existing. Evaluation doesn't need this
        if optimizer:
            optimizer.load_state_dict(ckpt_dict['optimizer_state_dict'])

        # Return global step
        return ckpt_dict['global_step']
def restore_checkpoint ( self , ckpt_file , optimizer = None ) : if not ckpt_file : raise ValueError ( "No checkpoint file to be restored." ) ckpt_dict = megengine . load ( ckpt_file ) # Restore model weights self . load_state_dict ( ckpt_dict [ 'model_state_dict' ] ) # Restore optimizer status if existing. Evaluation doesn't need this if optimizer : optimizer . load_state_dict ( ckpt_dict [ 'optimizer_state_dict' ] ) # Return global step return ckpt_dict [ 'global_step' ]