- 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.
推薦閱讀
- Arduino入門基礎(chǔ)教程
- Intel FPGA/CPLD設(shè)計(基礎(chǔ)篇)
- 龍芯應(yīng)用開發(fā)標(biāo)準(zhǔn)教程
- 計算機(jī)組裝·維護(hù)與故障排除
- 筆記本電腦使用、維護(hù)與故障排除從入門到精通(第5版)
- Hands-On Artificial Intelligence for Banking
- 基于PROTEUS的電路設(shè)計、仿真與制板
- Blender Game Engine:Beginner's Guide
- FreeSWITCH Cookbook
- Building Machine Learning Systems with Python
- Blender for Video Production Quick Start Guide
- 計算機(jī)應(yīng)用基礎(chǔ)案例教程(Windows 7+Office 2010)
- The Reinforcement Learning Workshop
- Arduino案例實戰(zhàn)(卷Ⅳ)
- Practical Artificial Intelligence and Blockchain