Pytorch Lightning Inference

Viewed 1012

I trained a model using pytorch lightning and especially appreciated the ease of using multiple GPU's. Now after training, how can I still make use of lightnings GPU features to run inference on a test set and store/export the predictions?

The documentation on inference does not target that.

Thanks in advance.

1 Answers

You can implement the validation_epoch_end on your LightningModule which is called "at the end of the validation epoch with the outputs of all validation steps". For this to work you also need to define validation_step on that same module.

Once this is done, you can run validation using your trainer and a given dataloader by calling:

trainer.validate(pl_module, dataloaders=validation_dataloader)
Related