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
