def load_existing_epoch_number(dir=None):
        """
        Try to load the latest epoch number from an existing json stats file (if any).
        Returns None if not found.
        """
        stats = JSONWriter.load_existing_json(dir)
        try:
            return int(stats[-1]['epoch_num'])
        except Exception:
            return None

        Try to load the latest epoch number from an existing json stats file (if any).
        Returns None if not found.
        
tensorpack/callbacks/monitor.py