default_collate_fn¶
- paddle.fluid.dataloader.collate. default_collate_fn ( batch ) [source]
-
Default batch collating function for
paddle.io.DataLoader
, get input data as a list of sample datas, each element in list if the data of a sample, and sample data should composed of list, dictionary, string, number, numpy array and paddle.Tensor, this function will parse input data recursively and stack number, numpy array and paddle.Tensor datas as batch datas. e.g. for following input data:- [{‘image’: np.array(shape=[3, 224, 224]), ‘label’: 1},
-
{‘image’: np.array(shape=[3, 224, 224]), ‘label’: 3}, {‘image’: np.array(shape=[3, 224, 224]), ‘label’: 4}, {‘image’: np.array(shape=[3, 224, 224]), ‘label’: 5},]
This default collate function zipped each number and numpy array field together and stack each field as the batch field as follows:
{‘image’: np.array(shape=[4, 3, 224, 224]), ‘label’: np.array([1, 3, 4, 5])}
- Parameters
-
batch (list of sample data) – batch should be a list of sample data.
- Returns
-
- batched each number, numpy array and paddle.Tensor
-
in input data.
- Return type
-
Batched data