Shortcuts

PredictionLoop

class pytorch_lightning.loops.dataloader.PredictionLoop[source]

Bases: pytorch_lightning.loops.dataloader.dataloader_loop.DataLoaderLoop

Loop to run over dataloaders for prediction.

advance(*args, **kwargs)[source]

Predicts one entire dataloader.

Return type

None

connect(epoch_loop)[source]

Connect the prediction epoch loop with this loop.

Return type

None

on_run_end()[source]

Calls on_predict_epoch_end and on_predict_end hooks and returns results from all dataloaders.

Return type

Union[List[Any], List[List[Any]], None]

on_run_start()[source]

Calls _on_predict_model_eval, _on_predict_start and _on_predict_epoch_start hooks.

Return type

None

reset()[source]

Resets the internal state of the loop for a new run.

Return type

None

property dataloaders: Sequence[torch.utils.data.dataloader.DataLoader]

Returns all prediction dataloaders.

Return type

Sequence[DataLoader]

property max_batches: List[Union[int, float]]

The max number of batches this loop will run for each dataloader.

Return type

List[Union[int, float]]

property num_dataloaders: int

Returns the number of prediction dataloaders.

Return type

int

property return_predictions: bool

Whether to return the predictions or not.

Return type

bool

property skip: bool

Determine whether to return immediately from the call to run().

Example:

@property
def skip(self):
    return len(self.trainer.train_dataloader) == 0
Return type

bool