def __init__(self, cfg):
    super().__init__()
    self.check_cfg(cfg)
    if (torch.cuda.is_available() and cfg.USE_CUDA):
        self.device = torch.device('cuda')
    else:
        self.device = torch.device('cpu')
    self.use_amp = cfg.TRAIN.USE_AMP
    if self.use_amp:
        self.scaler = torch.cuda.amp.GradScaler()
    self.start_epoch = self.epoch = 0
    self.max_epoch = cfg.OPTIM.MAX_EPOCH
    self.output_dir = cfg.OUTPUT_DIR
    self.cfg = cfg
    self.build_data_loader()
    self.build_model()
    self.evaluator = build_evaluator(cfg, lab2cname=self.dm.lab2cname)
    self.best_val_acc = (- np.inf)
    self.best_test_acc = (- np.inf)
    self.best_val_test_acc = 0
    self.best_val_epoch = 0
    self.best_test_epoch = 0
def __init__(self, cfg):
    super().__init__()
    self.check_cfg(cfg)
    if (torch.cuda.is_available() and cfg.USE_CUDA):
        self.device = torch.device('cuda')
    else:
        self.device = torch.device('cpu')
    self.use_amp = cfg.TRAIN.USE_AMP
    if self.use_amp:
        self.scaler = torch.cuda.amp.GradScaler()
    self.start_epoch = self.epoch = 0
    self.max_epoch = cfg.OPTIM.MAX_EPOCH
    self.output_dir = cfg.OUTPUT_DIR
    self.cfg = cfg
    self.build_data_loader()
    self.build_model()
    self.evaluator = build_evaluator(cfg, lab2cname=self.dm.lab2cname)
    self.best_val_acc = (- np.inf)
    self.best_test_acc = (- np.inf)
    self.best_val_test_acc = 0
    self.best_val_epoch = 0
    self.best_test_epoch = 0