- Deep Learning with PyTorch Quick Start Guide
- David Julian
- 192字
- 2021-07-02 15:00:12
PyTorch dataset loaders
Pytorch includes data loaders for several datasets to help you get started. The torch.dataloader is the class used for loading datasets. The following is a list of the included torch datasets and a brief description:

Here is a typical example of how we load one of these datasets into PyTorch:

CIFAR10 is a torch.utils.dataset object. Here, we are passing it four arguments. We specify a root directory relative to where the code is running, a Boolean, train, indicating if we want the test or training set loaded, a Boolean that, if set to True, will check to see if the dataset has previously been downloaded and if not download it, and a callable transform. In this case, the transform we select is ToTensor(). This is an inbuilt class of torchvision.transforms that makes the class return a tensor. We will discuss transforms in more detail later in the chapter.
The contents of the dataset can be retrieved by a simple index lookup. We can also check the length of the entire dataset with the len function. We can also loop through the dataset in order. The following code demonstrates this:

- 32位嵌入式系統(tǒng)與SoC設(shè)計導(dǎo)論
- 大數(shù)據(jù)戰(zhàn)爭:人工智能時代不能不說的事
- 構(gòu)建高質(zhì)量的C#代碼
- Hands-On Artificial Intelligence on Amazon Web Services
- 一本書玩轉(zhuǎn)數(shù)據(jù)分析(雙色圖解版)
- OpenStack Cloud Computing Cookbook(Second Edition)
- DevOps:Continuous Delivery,Integration,and Deployment with DevOps
- 網(wǎng)絡(luò)安全與防護(hù)
- 氣動系統(tǒng)裝調(diào)與PLC控制
- Mastering Text Mining with R
- Python文本分析
- FANUC工業(yè)機(jī)器人配置與編程技術(shù)
- Apache Spark Quick Start Guide
- 網(wǎng)絡(luò)安全概論
- Hands-On Generative Adversarial Networks with Keras