利用Pytorch DataLoader中的collate_fn自定义批加载方式
Pytorch DataLoader中的collate_fn允许用户灵活的定义批样本的加载方式,例如加载变尺寸的张量。
collate_fn (callable, optional) – 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
快去成为你想要的样子!