- Deep Learning with PyTorch
- Vishnu Subramanian
- 128字
- 2021-06-24 19:16:26
DataLoader class
The DataLoader class present in PyTorch's utils class combines a dataset object along with different samplers, such as SequentialSampler and RandomSampler, and provides us with a batch of images, either using a single or multi-process iterators. Samplers are different strategies for providing data to algorithms. The following is an example of a DataLoader for our Dogs vs. Cats dataset:
dataloader = DataLoader(dogsdset,batch_size=32,num_workers=2)
for imgs , labels in dataloader:
#Apply your DL on the dataset.
pass
imgs will contain a tensor of shape (32, 224, 224, 3), where 32 represents the batch size.
The PyTorch team also maintains two useful libraries, called torchvision and torchtext, which are built on top of the Dataset and DataLoader classes. We will use them in the relevant chapters.
推薦閱讀
- 新媒體跨界交互設(shè)計(jì)
- Istio入門與實(shí)戰(zhàn)
- 網(wǎng)絡(luò)服務(wù)器配置與管理(第3版)
- Applied Unsupervised Learning with R
- Effective STL中文版:50條有效使用STL的經(jīng)驗(yàn)(雙色)
- 基于Apache Kylin構(gòu)建大數(shù)據(jù)分析平臺
- SiFive 經(jīng)典RISC-V FE310微控制器原理與實(shí)踐
- Hands-On Artificial Intelligence for Banking
- 龍芯自主可信計(jì)算及應(yīng)用
- Wireframing Essentials
- 圖解計(jì)算機(jī)組裝與維護(hù)
- Mastering Machine Learning on AWS
- Blender 3D By Example
- INSTANT Cinema 4D Starter
- Hands-On Unsupervised Learning with Python