Release/1.2 (#198)
* update template to pytorch 1.10+ and lightning 1.5+ * add experiment mode to all experiment configs and implement special logging paths for experiment mode * add `MaxMetric` to model, for computation of best so far validation accuracy * add RichProgressBar to default callbacks * get rid of trick for preventing auto hparam logging, since lightning now supports it with `self.save_hyperparameters(logger=False)` * add `self.save_hyperparameters()` to datamodule since lightinng now supports it * deprecate Apex support * deprecate bash script for conda setup * change `terminate_on_nan` debug option to `detect_anomaly` for compatibility with lightning v1.5 * specify model and datamodule during `trainer.test()`, for compatibility with lightning v1.5 * remove `configs/trainer/all_params.yaml` * make hyperparameter optimization compatible with lightning v1.5 * general documentation improvements
This commit is contained in:
1 parent
6159c413f2
commit
9468ef91c5
29 files changed
+278
-330
No files matched your search
+7
-6
@@ -76,10 +76,13 @@ def train(config: DictConfig) -> Optional[float]:
|
||||
log.info("Starting training!")
|
||||
trainer.fit(model=model, datamodule=datamodule)
|
||||
|
||||
# Evaluate model on test set, using the best model achieved during training
|
||||
# Get metric score for hyperparameter optimization
|
||||
score = trainer.callback_metrics.get(config.get("optimized_metric"))
|
||||
|
||||
# Test the model
|
||||
if config.get("test_after_training") and not config.trainer.get("fast_dev_run"):
|
||||
log.info("Starting testing!")
|
||||
trainer.test()
|
||||
trainer.test(model=model, datamodule=datamodule, ckpt_path="best")
|
||||
|
||||
# Make sure everything closed properly
|
||||
log.info("Finalizing!")
|
||||
@@ -94,9 +97,7 @@ def train(config: DictConfig) -> Optional[float]:
|
||||
|
||||
# Print path to best checkpoint
|
||||
if not config.trainer.get("fast_dev_run"):
|
||||
log.info(f"Best model ckpt: {trainer.checkpoint_callback.best_model_path}")
|
||||
log.info(f"Best model ckpt at {trainer.checkpoint_callback.best_model_path}")
|
||||
|
||||
# Return metric score for hyperparameter optimization
|
||||
optimized_metric = config.get("optimized_metric")
|
||||
if optimized_metric:
|
||||
return trainer.callback_metrics[optimized_metric]
|
||||
return score
|
||||
Reference in new issue
Block a user