Access datamodule in custom callbacks #6412
Answered
by
SkafteNicki
vishal-wiai
asked this question in
Lightning Trainer API: Trainer, LightningModule, LightningDataModule
-
I want to create a custom I am little confused on how to do this. Can anyone help me out with a quick snippet? Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
SkafteNicki
Mar 8, 2021
Replies: 1 comment
-
Something like this should work :] from pytorch_lightning.callbacks import Callback
class MyCallback(Callback):
def __init__(self, ...):
...
# hook for doing something with your datamodule before training step
def on_train_batch_start(self, trainer, *args, **kwargs):
dm = trainer.datamodule # this is a reference to your datamodule during training
# do something here with your datamodule |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
akihironitta
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Something like this should work :]