myria3d.callbacks¶
Submodules¶
myria3d.callbacks.comet_callbacks¶
- class myria3d.callbacks.comet_callbacks.LogCode(code_dir: str)[source]¶
Bases:
CallbackUpload all code files to comet, at the beginning of the run.
- class myria3d.callbacks.comet_callbacks.LogLogsPath[source]¶
Bases:
CallbackLogs run working directory to comet.ml
myria3d.callbacks.finetuning_callbacks¶
- class myria3d.callbacks.finetuning_callbacks.FinetuningFreezeUnfreeze(d_in: int = 9, num_classes: int = 6, unfreeze_fc_end_epoch: int = 3, unfreeze_decoder_train_epoch: int = 6)[source]¶
Bases:
BaseFinetuning
myria3d.callbacks.metric_callbacks¶
- class myria3d.callbacks.metric_callbacks.ModelMetrics(num_classes=7)[source]¶
Bases:
CallbackCompute metrics for multiclass classification.
Accuracy, Precision, Recall, F1Score are micro-averaged. IoU (Jaccard Index) is macro-average to get the mIoU. All metrics are also computed per class.
Be careful when manually computing/reseting metrics. See: https://lightning.ai/docs/torchmetrics/stable/pages/lightning.html
- on_test_batch_end(trainer, pl_module, outputs, batch, batch_idx)[source]¶
Called when the test batch ends.
- on_train_batch_end(trainer, pl_module, outputs, batch, batch_idx)[source]¶
Called when the train batch ends.
Note
The value
outputs["loss"]here will be the normalized value w.r.taccumulate_grad_batchesof the loss returned fromtraining_step.
- on_train_epoch_end(trainer, pl_module)[source]¶
Called when the train epoch ends.
To access all batch outputs at the end of the epoch, you can cache step outputs as an attribute of the
pytorch_lightning.core.LightningModuleand access them in this hook:class MyLightningModule(L.LightningModule): def __init__(self): super().__init__() self.training_step_outputs = [] def training_step(self): loss = ... self.training_step_outputs.append(loss) return loss class MyCallback(L.Callback): def on_train_epoch_end(self, trainer, pl_module): # do something with all training_step outputs, for example: epoch_mean = torch.stack(pl_module.training_step_outputs).mean() pl_module.log("training_epoch_mean", epoch_mean) # free up the memory pl_module.training_step_outputs.clear()