(self)
| 261 | return output_path_net |
| 262 | |
| 263 | def train(self) -> None: |
| 264 | learning_rate = self.config['init_lr'] |
| 265 | for trial in range(self.start_trial, |
| 266 | self.config['n_trials']): |
| 267 | self.reset(learning_rate) |
| 268 | if trial == self.start_trial and self.resume is not None: |
| 269 | print("Resuming Network/Optimizer") |
| 270 | self.network.load_state_dict( |
| 271 | self.checkpoint['state_dict_network']) |
| 272 | self.optimizer.load_state_dict( |
| 273 | self.checkpoint['state_dict_optimizer']) |
| 274 | self.scheduler.load_state_dict( |
| 275 | self.checkpoint['state_dict_scheduler']) |
| 276 | epochs = range(self.start_epoch, self.config['max_epochs']) |
| 277 | output_path_net = self.create_output_dir() |
| 278 | self.output_filename = self.checkpoint['output_filename'] |
| 279 | |
| 280 | else: |
| 281 | epochs = range(0, self.config['max_epochs']) |
| 282 | output_path_net = self.create_output_dir() |
| 283 | self.output_filename = Path( |
| 284 | (f"date={datetime.now().strftime('%Y-%m-%d-%H-%M-%S')}_results_trial={trial}_" |
| 285 | f"{self.config['network']}_{self.config['dataset']}_{self.config['optimizer']}_") |
| 286 | + '_'.join([f"{k}={v}" for k, v in self.config['optimizer_kwargs'].items()]) + |
| 287 | f"_{self.config['scheduler']}" + |
| 288 | '_'.join([f"{k}={v}" for k, v in self.config['scheduler_kwargs'].items()]) + |
| 289 | f"_LR={learning_rate}") |
| 290 | |
| 291 | lr_output_path = output_path_net / self.output_filename |
| 292 | lr_output_path.mkdir(exist_ok=True, parents=True) |
| 293 | self.output_filename = lr_output_path |
| 294 | self.run_epochs(trial, epochs) |
| 295 | |
| 296 | def on_time_results(self, results: dict, epoch: int) -> None: |
| 297 | if epoch == 0: |
no test coverage detected