peal.training.loggers.log_images_to_writer

peal.training.loggers.log_images_to_writer(dataloader, writer, tag='train')[source]

Write up to three sample batches of a dataloader to TensorBoard.

For a DataloaderMixer that does not concatenate batches, batches are drawn from its first (and, for the third grid, second) underlying loader. Images are mapped to [0, 1] with the dataset’s project_to_pytorch_default when available; if the dataset offers diffusion_augmentation the augmented batch is written as a second grid. The tag encodes the batch index and, for 1-D labels, the label list. The mixer is reset before and after so training starts from fresh iterators.

Parameters:
  • dataloader (torch.utils.data.DataLoader or DataloaderMixer) – Source of the batches; dataloader.dataset must be reachable.

  • writer (torch.utils.tensorboard.SummaryWriter) – Destination of the image grids.

  • tag (str) – Prefix of the image tags, e.g. "train" or "val".