Logging for elements of compound/weighted loss #18678
Unanswered
maciejzj
asked this question in
Lightning Trainer API: Trainer, LightningModule, LightningDataModule
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I have a pretty standard LightningModule where the loss is passed to the Module via init, like here:
The implementation of train/val/test steps is pretty standard for a supervised training scheme, e.g.:
Now, I'd like to be able to inject a more complex loss with multiple weighted components, something like this:
So finally I can do something like:
One problem is that I want to log/monitor each of the losses in the weighted loss. I have figured out that I can pass a
pl.loggers.Logger
to the weighted loss and callself._logger.log_metrics
with results of the loss function inside the for loop. However, this isn't as great asself.log
inside a LightningModule (I cannot useon_epoch
and logging step is rather problematic). I thought about making WeightedLoss a LightningModule, but then I would have to connect it to the Lightning's experiment somehow. Is there an elegant way to solve this problem?Beta Was this translation helpful? Give feedback.
All reactions