Save predictions in test_step
#12066
-
Hey, I set up an AutoEncoder for image reconstruction using the def test_step(self, batch, batch_idx):
batch_hat = self(batch)
loss_test = nn.functional.mse_loss(batch_hat, batch)
self.log("loss_test", loss_test, on_step=True, on_epoch=True, sync_dist=True)
# I want to add something like this (NOT FUNCTIONAL)
filepath = trainer.datamodule.dataset_test.my_file_names[batch_idx]
my_save_function(batch_hat, filepath)
return loss_test and I call trainer.test(my_model, my_datamodule) , where Question: How can I access the name of my samples in Best, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
hey @dsethz ! you can return the filenames from your |
Beta Was this translation helpful? Give feedback.
hey @dsethz !
you can return the filenames from your
Dataset.__getitem__
which will be available inside the batch and you can access them insidetest_step
easily.