In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.