The method of reading image data by pytorch
This article mainly explains "the method of reading image data by pytorch". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "the method of reading image data by pytorch".
The methods and steps for pytoech to read image data are fixed. Generally, the first step is to set the preprocessing method, the second step is to set the data class, that is, to determine what the data is to read, and the third step is to read the data, that is, to read the data in accordance with the requirements of the setting.
Take a common example:
# step 1: preprocess transform= transforms.Compose ([transforms.ToTensor (), transforms.Normalize (mean= [0.5], std= [0.5])] # step 2: set the data class train_dataset = datasets.MNIST (root='D:\ code\ mnist', train=True, download=False, transform=transform) test_dataset = datasets.MNIST (root='D:\ code\ mnist', train=False, download=False, transform=transform) # step 3: read data train_loader = DataLoader (train_dataset, shuffle=True) Batch_size=batch_size) test_loader = DataLoader (test_dataset, shuffle=False, batch_size=batch_size) so far I believe that everyone has a deeper understanding of the "pytorch method of reading image data", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!