default_collate¶
- torchaug.data.dataloader.default_collate(batch)[source]¶
Take in a batch of data and put the elements within the batch into a tensor or ta_tensor with an additional outer dimension - batch size if relevant.
The exact output type can be a
torch.Tensor, a Sequence oftorch.Tensor, a Collection oftorch.Tensor,TATensor, a Sequence ofTATensor, a Collection ofTATensor, or left unchanged, depending on the input type. This is used as the default function for collation when batch_size or batch_sampler is defined inDataLoader.Here is the general input type (based on the type of the element within the batch) to output type mapping:
torch.Tensor->torch.Tensor(with an added outer dimension batch size)Image->BatchImagesVideo->BatchVideosMask->BatchMasksNumPy Arrays ->
torch.Tensorfloat ->
torch.Tensorint ->
torch.Tensorstr -> str (unchanged)
bytes -> bytes (unchanged)
Mapping[K, V_i] -> Mapping[K, default_collate([V_1, V_2, …])]
NamedTuple[V1_i, V2_i, …] -> NamedTuple[default_collate([V1_1, V1_2, …]), default_collate([V2_1, V2_2, …]), …]
Sequence[V1_i, V2_i, …] -> Sequence[default_collate([V1_1, V1_2, …]), default_collate([V2_1, V2_2, …]), …]
- Parameters:
batch – a single batch to be collated