官术网_书友最值得收藏!

  • 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.

主站蜘蛛池模板: 大姚县| 连江县| 疏勒县| 秭归县| 惠东县| 湖口县| 清水河县| 平度市| 义马市| 安庆市| 湘西| 鹤山市| 永康市| 伊宁县| 上饶市| 靖州| 七台河市| 许昌县| 普兰县| 松桃| 苍南县| 丰都县| 西乌珠穆沁旗| 丰都县| 敦煌市| 呼伦贝尔市| 天峨县| 华亭县| 辛集市| 万载县| 罗田县| 汶川县| 奉节县| 宣城市| 海宁市| 承德县| 淳化县| 资兴市| 漳州市| 浦东新区| 邮箱|