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.

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: stable
Versions
latest
stable
v0.10.5
v0.10.4
v0.10.3
v0.10.2
v0.10.1
v0.10.0
v0.9.1
v0.9.0
v0.8.5
v0.8.4
v0.8.3
v0.8.2
v0.8.1
v0.8.0
v0.7.4
v0.7.3
v0.7.2
v0.7.1
v0.7.0
v0.6.0
v0.5.0
v0.4.0
v0.3.0
v0.2.0
Downloads
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.