collate#
- torch_brain.data.collate(batch)[source]#
Extension of PyTorch’s
default_collatefunction to enable more advanced collation of samples of variable lengths.To specify the collation recipe, wrap the objects using
padorchain. If the wrapped object is an Iterable or Mapping, all its elements will inherit the collation recipe. All objects that are already supported bydefault_collatecan be wrapped.If an object is not wrapped, the default collation recipe will be used, i.e., the outcome will be identical to
default_collate.padorchaindo not track any padding masks or batch index, since that might not always be needed. Usetrack_maskortrack_batchto track masks or batch index for a particular array or tensor.- Parameters:
batch – a single batch to be collated