How to visualize transforms in preprocessing before training starts


I would like to visualize certain transforms in the preprocessing either during sanity_check or before training starts (via Trainer.logger; specifically: log through wandb). The preocessing naturally happens in Dataset, used together with LightningDataModule. All the training logic is implemented separately as LightningModule.

My questions is: since the Trainer.logger is not accessible in LightningDataModule and Dataset, how to efficiently implement this logging or visualization? Or are there existing hooks for this purpose?

Many thanks in advance!

Hi, there are multiple ways to achieve this:

  • You could either just pass your logger to your DataModule and log in there

    • either where you create the data (e.g. the setup, prepare_data or __init__ methods)

    • in the on_before_batch_transfer hook of the data module if you want a single batch only or apply the transforms on the fly.

  • You could use the on_sanity_check_start or on_train_start

Hope this helps.

Many thanks for the detailed info!