In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "what is the use of dataloader shuffle=True in PyTorch", the content is simple and clear, hoping to help you solve your doubts, let the editor lead you to study and learn "what is the use of dataloader shuffle=True in PyTorch" this article.
Understanding of shuffle=True:
I didn't know the actual effect of shuffle before. Suppose I have some data, such as a batch_size=2, I don't know how to disturb it, which of the following is the specific case?
1. First take the batch in order, and then disrupt the batch, that is, first take a dagger, b, and then disrupt the internal batch.
two。 First disturb, then take the batch.
Proved to be the second shuffle (bool, optional): set to ``True`` to have the data reshuffled at every epoch (default: ``False``). If shuffle: sampler = RandomSampler (dataset) # what you get at this time is the index
Add: simply test how shuffle=True works in pytorch dataloader
Look at the code ~ import sysimport torchimport randomimport argparseimport numpy as npimport pandas as pdimport torch.nn as nnfrom torch.nn import functional as Ffrom torch.optim import lr_schedulerfrom torchvision import datasets, transformsfrom torch.utils.data import TensorDataset, DataLoader, Dataset class DealDataset (Dataset): def _ _ init__ (self): xy = np.loadtxt (open ('. / iris.csv','rb'), delimiter=',', dtype=np.float32) # data = pd.read_csv ("iris.csv" Header=None) # xy = data.values self.x_data = torch.from_numpy (xy [:, 0xy [:]) self.y_data = torch.from_numpy (xy [:, [- 1]]) self.len = xy.shape [0] def _ _ getitem__ (self, index): return self.x_ data [index] Self.y_ data [index] def _ len__ (self): return self.len dealDataset = DealDataset () train_loader2 = DataLoader (dataset=dealDataset, batch_size=2, shuffle=True) # print (dealDataset.x_data) for I, data in enumerate (train_loader2): inputs, labels = data # inputs, labels = Variable (inputs) Variable (labels) print (inputs) # print ("epoch:", epoch, "No.", I, "inputs", inputs.data.size (), "labels", labels.data.size ()) are all the contents of the article "what is the shuffle=True of dataloader in PyTorch?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow 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.