Datamodule and multiple transforms #13341
Unanswered
abcamiletto
asked this question in
Lightning Trainer API: Trainer, LightningModule, LightningDataModule
Replies: 1 comment 2 replies
-
You can simply replace the original transform with a preferred transform for each dataset instance after splitting, no? Or, you can do something similar to an example in Bolts which instantiates dataset multiple times to create datasets with different transforms for each with the seed fixed: https://github.com/Lightning-AI/lightning-bolts/blob/ad771c615284816ecadad11f3172459afdef28e3/pl_bolts/datamodules/stl10_datamodule.py |
Beta Was this translation helpful? Give feedback.
2 replies
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 all,
I have a Dataset which needs a different augmentation for the training and the validation set. I cannot find a straightforward way to do that. My implementation is pretty much the following
I need to call self.dataset.use_validation_transform() at the beginning of each validation (at the end of each epoch).
I expected to be able to do so in the stage method but found out that the stage method it's only called at the beginning of the .fit() call.
I'm aware that i could call that from the model accessing it by the self.datamodule attribute in the on_validation_start method, but it seems an antipattern to me. I'd love to keep model and data independent.
Is there an easy way to do so that i'm missing? Or am i doing something weird enough that I should avoid?
Thx in advance for any response!
Beta Was this translation helpful? Give feedback.
All reactions