EasyTPP Model Wrapper Module#
Initialize a Pytorch model wrapper that feed into Model Runner
- class easy_tpp.model_wrapper.ModelWrapper(model, base_config, model_config, trainer_config)#
Bases:
object- restore(ckpt_dir)#
Load the checkpoint to restore the model.
- Parameters:
ckpt_dir (str) – path for the checkpoint.
- save(ckpt_dir)#
Save the checkpoint for the model.
- Parameters:
ckpt_dir (str) – path for the checkpoint.
- write_summary(epoch, kv_pairs, phase)#
Write the kv_paris into the tensorboard
- Parameters:
epoch (int) – epoch index in the training.
kv_pairs (dict) – metrics dict.
phase (RunnerPhase) – a const that defines the stage of model runner.
- close_summary()#
Close the tensorboard summary writer.
- run_batch(batch, phase, epoch=None, batch_index=None)#
Run one batch.
- Parameters:
batch (EasyTPP.BatchEncoding) – preprocessed batch data that go into the model.
phase (RunnerPhase) – a const that defines the stage of model runner.
epoch (int, optional) – zero-based training epoch for error context.
batch_index (int, optional) – zero-based batch index for error context.
- Returns:
for training and validation we return loss, prediction and labels; for prediction we return prediction.
- Return type:
tuple
- easy_tpp.model_wrapper.TorchModelWrapper#
alias of
ModelWrapper