Gluon Data loading image data (with tags) load function: Gluon.data.vision.ImageFolderDataset
Give a description of the Imagefolderdataset class,
Init Signature:mxnet.gluon.data.vision.datasets.ImageFolderDataset (Root, Flag=1, transform=none) Source:class Imag Efolderdataset (DataSet. DataSet): "" "A DataSet for loading image files stored in A folder structure like:: Root/car/0001.jpg root /car/xxxa.jpg root/car/yyyb.jpg root/bus/123.jpg root/bus/023.jpg root/bus/wwww.jpg Paramet ERs----------root:str Path to root directory. Flag: {0, 1}, default 1 # controls color or grayscale If 0, always convert loaded images to greyscale (1 channel). If 1, always convert loaded images to colored (3 channels). transform:callable, default None A function that takes data and label and transforms them::: Transform = Lambda data, Label: (Data.astype (Np.float32)/255, label) Attributes----------synsets:list # View the category, which is actually the file name List of class names. ' Synsets[i] ' is the name for the integer label ' i ' Items:list of tuples # generated data listOf all images in (filename, label) pairs. """
Instance:
Train_imgs = Gluon.data.vision.ImageFolderDataset ( data_dir+ '/hotdog/train ', transform=lambda X, y: Transform (X, Y, train_augs)) Test_imgs = Gluon.data.vision.ImageFolderDataset ( data_dir+ '/hotdog/test ', Transform=lambda x, Y:transform (x, Y, test_augs)) print (TRAIN_IMGS) print (train_imgs.synsets) data = Gluon.data.DataLoader (Train_imgs, Shuffle=true)
<mxnet.gluon.data.vision.datasets.imagefolderdataset object at 0x7fbed5641c18>[' hotdog ', ' Not-hotdog ']
Batch iterator: Gluon.data.DataLoader
With a special method, the Def __iter__(self), whose instance can be iterated, that is, each time the data of a batch is returned, cut on the first dimension.
The first positional parameters document is as follows:
Dataset:dataset Source Dataset. Note that NumPy and mxnet arrays can be directly used as a Dataset.
The last generated X_batch feed net (x_batch) propagates forward, y_batch into loss (Output,y_batch) to calculate loss after the reverse propagation.
Second, mxnet data loading
78394322
50208733#%e4%ba%8c%e4%bb%8e%e5%8e%9f%e7%94%9f%e6%95%b0%e6%8d%ae%e7%94%9f%e6%88%90lst%e6%96%87%e4%bb%b6
"MXNet" Sixth play _ Data Processing API (to be continued)