Shortcuts

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_collate will stack tensor contained in data_batch into a batched tensor with the first dimension batch size, and then move input tensor to the target device.

Different from default_collate in pytorch, default_collate will not process BaseDataElement.

This code is referenced from: Pytorch default_collate. # noqa: E501

Note

default_collate only 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

Read the Docs v: v0.2.0
Versions
latest
stable
v0.5.0
v0.4.0
v0.3.0
v0.2.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.