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

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.

主站蜘蛛池模板: 富民县| 灵石县| 永新县| 海阳市| 河东区| 日喀则市| 无为县| 蒲城县| 航空| 汉川市| 安泽县| 达日县| 东海县| 黄龙县| 任丘市| 长岛县| 兴宁市| 贡觉县| 鄂托克前旗| 泾源县| 新干县| 蓬莱市| 庆元县| 长治县| 托克逊县| 天水市| 宝鸡市| 萨嘎县| 五华县| 屏南县| 九龙城区| 赫章县| 青田县| 称多县| 东平县| 南乐县| 洞头县| 苗栗县| 湖北省| 安平县| 龙川县|