aibedo.test.reload_and_test_model
- aibedo.test.reload_and_test_model(run_id: str, checkpoint_path: Optional[str] = None, config: Optional[omegaconf.dictconfig.DictConfig] = None, entity: str = 'salv47', project: str = 'AIBEDO', train_model: bool = False, test_model: bool = True, predict_model: bool = False, override_kwargs: Optional[Sequence[str]] = None)[source]
- This function reloads a model from a checkpoint and trains and/or tests it.
If train_model is True, it trains the model (i.e. can be used to resume training).
If test_model is True, it tests the model (i.e. can be used to test a trained model).
- If the model was trained using Wandb logging, reloading it and resuming training or testing will be as easy as:
>>> example_run_id = "22ejv03e" >>> reload_and_test_model(run_id=example_run_id, train_model=True, test_model=True)
- To resume training and train for more epochs (e.g. 100), use the following:
>>> reload_and_test_model(run_id=example_run_id, train_model=True, override_kwargs=['trainer.max_epochs=100'])
- Parameters
run_id (str) – Wandb run id
checkpoint_path (str) – An optional local ckpt path to load the weights from. If None, the best one on wandb will be used.
config (DictConfig) – An optional config to load the model and data from. If None, the config is loaded from Wandb.
entity (str) – Wandb entity
project (str) – Wandb project
train_model (bool) – Whether to train the model before (optional) testing. If you want to train the model for more epochs, make sure to override the original number of epochs with e.g.
override_kwargs=['trainer.max_epochs=100', ...]. Default:Falsetest_model (bool) – Whether to test the model. Default:
Truepredict_model (bool) – Whether to predict with the model (the
predict_dataloader()of the datamodule). Default:Falseoverride_kwargs – A list of strings (of the form “key=value”) that will override the given/reloaded config.