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

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.

主站蜘蛛池模板: 井冈山市| 宁德市| 清原| 托克逊县| 墨江| 玛多县| 开阳县| 资源县| 潮州市| 梅河口市| 江山市| 苗栗县| 柳江县| 巴青县| 肥城市| 错那县| 宁陵县| 金昌市| 屯留县| 光泽县| 普洱| 长兴县| 汕头市| 温泉县| 靖宇县| 辽阳市| 武义县| 苏尼特右旗| 黑山县| 卢湾区| 武清区| 永嘉县| 介休市| 西畴县| 城口县| 温州市| 托里县| 南陵县| 大石桥市| 云林县| 若羌县|