본문 바로가기
AI/Pytorch

DataLoader 정리

by 별빛밤 2023. 3. 3.

DataLoader란 ?

 

Dataset을 가져오는 역할

 

DataLoader Process
GPU, CPU Coumunication Image

 

 

How to use DataLoader with pytorch

 

Dataset : Dataset, Custom Dataset을 이용할 수 있다.

batch_size : Dataset의 데이터를 몇 개씩 가져올 것인지 나타냄

shuffle : 데이터를 가져올 때 Dataset 순서대로 가져올 것인지  무작위로 가져올 것인지 나타냄

collate_fn : DataLoader에서 batch_size 만큼 mini-batch로 가져옴. mini-batch에서 collate_fn에 사용된 함수가 적용된 상태로 DataLoader에서 내보냄.  

num_workers : mulit process data loading, 연산 처리 속도에 영향을 받음, data load 할 때 subprocess를 얼마나 사용할 것인지 나타냄.

 

 

[※ 참고 사이트]

[1] https://pytorch.org/docs/stable/data.html#torch.utils.data.Dataset

 

torch.utils.data — PyTorch 1.13 documentation

torch.utils.data At the heart of PyTorch data loading utility is the torch.utils.data.DataLoader class. It represents a Python iterable over a dataset, with support for These options are configured by the constructor arguments of a DataLoader, which has si

pytorch.org

[2] https://jybaek.tistory.com/799

 

DataLoader num_workers에 대한 고찰

Pytorch에서 학습 데이터를 읽어오는 용도로 사용되는 DataLoader는 torch 라이브러리를 import만 하면 쉽게 사용할 수 있어서 흔히 공식처럼 잘 쓰고 있습니다. 다음과 같이 같이 사용할 수 있겠네요. fr

jybaek.tistory.com

[3] https://mole-starseeker.tistory.com/59

 

에폭(epoch), 배치 사이즈(batch size), 미니 배치(mini batch), 이터레이션(iteration)

# 에폭(epoch)이란? 배치 사이즈(batch size)란? 에폭(epoch): 하나의 단위. 1에폭은 학습에서 훈련 데이터를 모두 소진했을 때의 횟수에 해당함. 미니 배치(mini batch): 전체 데이터 셋을 몇 개의 데이터 셋

mole-starseeker.tistory.com

[4] https://wikidocs.net/55580

 

03-06 미니 배치와 데이터 로드(Mini Batch and Data Load)

이번 챕터에서 배우는 내용은 선형 회귀에 한정되는 내용은 아닙니다. 이번 챕터에서는 데이터를 로드하는 방법과 미니 배치 경사 하강법(Minibatch Gradient Descen…

wikidocs.net

[5] https://notou10.tistory.com/36

 

'AI > Pytorch' 카테고리의 다른 글

텐서 크기 확인 방법  (0) 2023.05.12
torch.nn.CrossEntropyLoss  (0) 2023.03.11
Learning rate scheduler  (0) 2023.03.07
Optimizer  (0) 2023.03.06