MCPcopy Create free account
hub / github.com/AtlasAnalyticsLab/AdaFisher / load_config

Method load_config

Image_Classification/src/train.py:144–175  ·  view source on GitHub ↗
(self, config_path: Path, data_path: Path)

Source from the content-addressed store, hash-verified

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":

Callers 1

__init__Method · 0.95

Calls 4

create_output_dirMethod · 0.95
parse_configFunction · 0.90
get_dataFunction · 0.90
EarlyStopClass · 0.90

Tested by

no test coverage detected