3

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.

ValeKnappich
  • 162
  • 1
  • 8
  • Mind check the latest version of docs, I believe that your question is resolved there :) – Jirka Feb 20 '22 at 20:20
  • @Jirka The `predict` function doesn't seem very useful, since it returns a list, rather than an iterator. So you can't use it if you are predicting on a large dataset. – Thomas Ahle Apr 07 '22 at 19:36

1 Answers1

0

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)
Ivan
  • 34,531
  • 8
  • 55
  • 100