利用Pytorch DataLoader中的collate_fn自定义批加载方式

Pytorch DataLoader中的collate_fn允许用户灵活的定义批样本的加载方式,例如加载变尺寸的张量。

 

 collate_fn (callableoptional) – merges a list of samples to form a mini-batch of Tensor(s). Used when using batched loading from a map-style dataset.

 

https://discuss.pytorch.org/t/how-to-use-collate-fn/27181

https://discuss.pytorch.org/t/how-to-create-batches-of-a-list-of-varying-dimension-tensors/50773

https://stackoverflow.com/questions/55041080/how-does-pytorch-dataloader-handle-variable-size-data

 

posted on 2020-06-15 22:31  那抹阳光1994  阅读(1189)  评论(0编辑  收藏  举报

导航