(self, config_path: Path, data_path: Path)
| 142 | print("-" * 45) |
| 143 | |
| 144 | def load_config(self, config_path: Path, data_path: Path) -> None: |
| 145 | with config_path.open() as f: |
| 146 | self.config = config = parse_config( |
| 147 | yaml.load(f, Loader=yaml.Loader)) |
| 148 | if self.device == 'cpu': |
| 149 | warnings.warn("Using CPU will be slow") |
| 150 | self.train_loader, self.test_loader, self.num_classes = get_data( |
| 151 | name=config['dataset'], root=data_path, mini_batch_size=config['mini_batch_size'], |
| 152 | num_workers=config['num_workers'], aug=config['aug'], cutout=config['cutout'], n_holes=config['n_holes'], |
| 153 | length=config['cutout_length'], dist=self.dist) |
| 154 | self.criterion = torch.nn.CrossEntropyLoss() |
| 155 | if np.less(float(config['early_stop_threshold']), 0): |
| 156 | print("Notice: early stop will not be used as it was " + |
| 157 | f"set to {config['early_stop_threshold']}, " + |
| 158 | "training till completion") |
| 159 | self.early_stop = EarlyStop( |
| 160 | patience=int(config['early_stop_patience']), |
| 161 | threshold=float(config['early_stop_threshold'])) |
| 162 | cudnn.benchmark = True # This command is time consuming for the first epochs |
| 163 | self.checkpoint_path = self.create_output_dir(checkpoint=True) |
| 164 | if self.resume is not None: |
| 165 | if self.gpu is None: |
| 166 | self.checkpoint = torch.load(str(self.resume)) |
| 167 | else: |
| 168 | self.checkpoint = torch.load( |
| 169 | str(self.resume), |
| 170 | map_location=self.gpu) |
| 171 | self.start_epoch = self.checkpoint['epoch'] |
| 172 | self.start_trial = self.checkpoint['trial'] |
| 173 | self.best_acc1 = self.checkpoint['best_acc1'] |
| 174 | print(f'Resuming config for trial {self.start_trial} at ' + |
| 175 | f'epoch {self.start_epoch}') |
| 176 | |
| 177 | def get_pretrained_model(self): |
| 178 | if self.config['network'] == "resnet50Cifar": |
no test coverage detected