In callbacks, we can use either pl_module or trainer. model to access the actual lightning model that does the job. What is the difference?
pl_module
is your LightningModule
instance, while trainer.model
can be an instance that wraps your LightningModule
in certain strategies. For example, if you use DDP,
-
pl_module
is an instance ofLightningModule
, and -
trainer.model
isDistributedDataParallel
.
1 Like