tags: Machine learning Neural Networks
Deep eye learning experience
Experiment: RMB two classification, training a two classifier, can distinguish the fourth set of RMB 1 yuan and 100 yuan.
5 steps of model training, data, model, loss function, optimizer, iterative training
This article only discusses the data.
Data: data collection --- img, label
Data segmentation---train, valid, test
Data reading---DataLoader(Sampler (generate index),Dataset(According to the index to get img and label))
Data pre-processing---transforms
DataLoader: Building an iterable data loader
torch.utils.data.DataLoader(dataset,batch_size=1,shuffle=False,sampler=None,batch_sampler=None,num_workers=0,
collate_fn=None,pin_memory=None,drop_last=False,timeout=0,worker_init_fn=None,multiprocessing_context=None)
dataset:Dataset class,Decide where and how to read data
batch_size: Batch size
shuffle: Whether each epoch of training samples is out of order
num_workers: Number of processes reading data
drop_last: When the number of samples cannot be divided by batch_size, whether to discard the last batch of data.
The relationship between three common names:
epoch: All training samples are input into the model once, which is called an epoch
iteration: A batch of samples is input into the model, which is called an iteration
batch_size: The number of samples in a batch of samples, called batch_size, which determines how many iterations an epoch has.
For example: an epoch is 120 samples, if batch_size=10, then there are 12 iterations
An epoch is 125 samples, if batch_size=10, drop_last=True, then there are 12 iterations
�� ��
Dataset: Dataset abstract class, all custom Datasets need to inherit it, and duplicate __getitem__(), getitem receives the index and returns the sample (img, label)
Data reading: which data to read: which batch_size samples should be read for each iteration, the Index output by the Sampler
Where to read data from: set hard disk data path, data_dir in Dataset
How to read data: getitem in Dataset
The data reading is shown in the figure:

Blog writing is not standardized, mainly for easy search and knowledge memory.
Next articleData preprocessing--transforms
Make sure the installation scikit-image numpy Dataset and DataLoader are tools that read data in Pytorch. Now make a summary and summary of these two tools. 1.Dataset one example: Output result We hav...
DataLoader and DataSet The first step in neural network training is often the loading and processing of the data set. Of course, we can do it yourself, but this often brings us any inconvenience, espe...
Preface Whether it is model training or actual testing, data reading is the first step, because deep learning is ultimately driven by data. If there is a program that can accurately read ...
1 All pictures are in one folder 1 2 Put pictures of each category in a folder The officially written torchvision.datasets.ImageFolder interface implements data import. This in...
When I was young, nostalgia was a small postage stamp, you were on one side and I was on the other; After growing up, nostalgia is a nucleic acid certificate, you are at home, I am in isolation! 1. py...
Pytorch Dataset, DataLoader generates custom training data table of Contents Pytorch Dataset, DataLoader generates custom training data 1. torch.utils.data.Dataset 2. torch.utils.data.DataLoader 3. Us...
Pytorch's data reading mainly consists of three classes: Dataset DataLoader DataLoaderIter These three are roughly a relationship of sequential packaging: 1. is loaded into 2., 2. is loaded int...
** If you learn a lot of things in the past, may really learn later, when you need to use, you may not remember what you learned; but you do not know the face of knowledge, suddenly find that you have...
1. Introduction to iterable objects and iterators Iterable object (iterable): implements the __iter__ method, which returns an iterator object; Iterator: Iterator contains __iter__ and next methods. W...