How to use predict function to return predictions
How to get predictions
  class OurModel(LightningModule):
      def __init__(self):
        super(OurModel,self).__init__()
        self.layer = MyModelV3()
      def forward(self,x):
        return self.layer(x)

  def train_dataloader(self):
    return DataLoader(DataReader(train_df))

  def training_step(self,batch,batch_idx):
    return loss

  def test_dataloader(self):
    return DataLoader(DataReader(test_df))
    
  def test_step(self,batch,batch_idx):
    image,label=batch
    out=self(image)
    loss=self.criterion(out,label)
    return loss

  def predict(self, batch):
        return self(batch) 
I am not sure, how to use predict function. How to define data loader for predict function. I want to get predictions for test_df. But now idea how to do this.
Hi @talhaanwarch, in order to get predictions from a data loader you need to implement predict_step in your LightningModule (docs here: https://pytorch-lightning.readthedocs.io/en/stable/common/lightning_module.html#predict-step). You would then be able to call Trainer.predict with the dataloader you want use following the API here: https://pytorch-lightning.readthedocs.io/en/stable/api/pytorch_lightning.trainer.trainer.html#pytorch_lightning.trainer.trainer.Trainer.predict
Hope that helps 😃