mmengine.dataset.default_collate¶
- mmengine.dataset.default_collate(data_batch)[source]¶
Convert list of data sampled from dataset into a batch of data, of which type consistent with the type of each data_itement in
data_batch.Different from
pseudo_collate(),default_collatewill stack tensor contained indata_batchinto a batched tensor with the first dimension batch size, and then move input tensor to the target device.Different from
default_collatein pytorch,default_collatewill not processBaseDataElement.This code is referenced from: Pytorch default_collate.
Note
default_collateonly accept input tensor with the same shape.- Parameters:
data_batch (Sequence) – Data sampled from dataset.
- Returns:
Data in the same format as the data_itement of
data_batch, of which tensors have been stacked, and ndarray, int, float have been converted to tensors.- Return type:
Any