clinicadl.data.dataloader.collate.CollateFn

class clinicadl.data.dataloader.collate.CollateFn[source]

Abstract class to define how sequences of Sample are collated into batches.

See PyTorch’s documentation.

The only function to override is __call__(), which defines how the samples are collated, and thus what will be the output of the DataLoader.

abstract __call__(samples: Sequence[T | Sequence[T] | dict[Any, T]]) Batch[T] | Sequence[Batch[T]] | dict[Any, Batch[T]][source]

Defines how the samples are collated.

Parameters:

samples (Sequence[SampleLike]) – A sequence of Samples, sequences of Samples, or dictionaries of Samples.

Returns:

BatchType – A Batch, a sequence of Batches, or a dictionary of Batches.