In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this "pytorch dataset and dataloader case Analysis" article, so the editor summarizes the following, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "pytorch dataset and dataloader case Analysis" article.
Dataset,dataloder analysis
Only the datasets downloaded from the Internet are stored in the cifar_data_test folder created by ourselves.
Cifar-10-python.tar.gz
Due to the existence of download=True: an extra cifar-10-batches-py
Dataset = torchvision.datasets.CIFAR10 (root='./cifar_data_test',download=True)
Print (dataset) can see that the dataset defaults to train=True
Train=False is used to select a training set or a test set.
Dataset = torchvision.datasets.CIFAR10 (root='./cifar_data_test',train=False,download=True) print (dataset) print (dataset.classes) print (dataset.data.shape, "\ n", dataset.data)
Transform
One: because CIFAR10 is tensor, it is useless to it.
Second: the transform added to dataset does not normalize the dataset, but only when dataloader
Import torchvision.datasetsimport torchvision.transforms as transformsfrom torch.utils.data import DataLoader#transform has two operations, one is to change it into tensor form that pythonj is easy to handle. The second is to normalize tensor transform= transforms.Compose ([transforms.ToTensor (), transforms.Normalize ((0.1307,), (0.3081,))]) dataset = torchvision.datasets.CIFAR10 (root='./cifar_data_test',train=True,download=True,transform=transform) print (dataset.data) # unnormalized train_loader = DataLoader (dataset,shuffle=False,batch_size=32) # dataloader has no transform parameter for img Target in train_loader:print (img) # data normalization above is the content of the article "dataset and dataloader instance Analysis of pytorch" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.