Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Reading method of Pytorch Fashion Minst dataset

Shulou Source: shulou.com Published: 2022-06-02 07:08:18 10月05日 Update

This article mainly explains the "Pytorch Fashion Minst Data Set Reading Method". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn the "Pytorch Fashion Minst Data Set Reading Method" together!

This chapter mainly illustrates the problem of reading data sets, aiming at the problem of reading and writing Fashion Mnist data sets in trochvision;

The specific read training set and test set are:

mnist_train = torchvision.datasets.FashionMNIST(root='~/Datasets/FashionMNIST', train=True, download=True, transform=transforms.ToTensor())mnist_test = torchvision.datasets.FashionMNIST(root='~/Datasets/FashionMNIST', train=False, download=True, transform=transforms.ToTensor())

There are two parameters to note, train represents whether to participate in training, and the last parameter represents the transformation of the content of the data set into the representation of the tensor;

Batch training can still be done using DataLoader and batch_size;

train_iter = torch.utils.data.DataLoader(mnist_train, batch_size=batch_size, shuffle=True, num_workers=num_workers)test_iter = torch.utils.data.DataLoader(mnist_test, batch_size=batch_size, shuffle=False, num_workers=num_workers)

train_iter, which is a batch data structure, divided into 235 batches according to batch_size;

For each traversal of train_iter, also use the for loop to feed data one by one;

And DataLoader can use multi-thread to read, so the reading time is faster;

start = time.time() for X, y in train_iter: continue print ('%.2f sec' % (time.time() - start)) Thank you for your reading. The above is the content of "Pytorch Fashion Minst Data Set Reading Method". After learning this article, I believe that everyone has a deeper understanding of the Pytorch Fashion Minst Data Set Reading Method. The specific use situation still needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Tags: Data method content problem learning training representative parameter two namely form train of thought situation data structure article time understanding more faster knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei vpn OPPO Reno MySQL MariaDB