cfg.PRINT_EVERY = conf['print_every'] """ Training settings """ cfg.NUM_EPOCHS = conf['num_epochs'] cfg.BATCH_SIZE = conf['batch_size'] cfg.DEVICE = torch.device('cuda:1' if torch.cuda.is_available() else 'cpu') cfg.PATIENCE = conf['patience'] cfg.RESUME = conf['resume'] cfg.NUM_WORKERS = conf['num_workers'] cfg.LEARNING_RATE = conf['learning_rate'] cfg.WEIGHT_DECAY = conf['weight_decay'] """ Model saving """ cfg.CHECKPOINT_DIR = os.path.join(cfg.ROOT_DIR, 'checkpoint') cfg.BEST_MODEL_PATH = os.path.join(cfg.CHECKPOINT_DIR, 'best_model.pth') cfg.BEST_ACC_PATH = os.path.join(cfg.CHECKPOINT_DIR, 'best_acc.txt') cfg.CHECKPOINT_PATH = os.path.join(cfg.CHECKPOINT_DIR, cfg.RUN_NAME + '.tar') """ Clear history """ if cfg.CLEAR_HISTORY: if os.path.exists(cfg.LOG_DIR): for f in os.listdir(cfg.LOG_DIR): os.remove(os.path.join(cfg.LOG_DIR, f)) if os.path.exists(cfg.CHECKPOINT_PATH): os.remove(cfg.CHECKPOINT_PATH)