fromimport gluon
def transform (data, label ): return data.astype ( ' float32 ' ) / 255 ., Label.astype ( ' float32 ' ) mnist_train = Gluon.data.vision.MNIST (Train= true , Transform= transform) mnist_test = Gluon.data.vision.MNIST (Train= span class= "va" >false , Transform= transform)
C:\Anaconda3\lib\site-packages\mxnet\gluon\data\vision.py:118: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead label = np.fromstring(fin.read(), dtype=np.uint8).astype(np.int32)C:\Anaconda3\lib\site-packages\mxnet\gluon\data\vision.py:122: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead data = np.fromstring(fin.read(), dtype=np.uint8)
Download several datasets to the local disk cifar_100
Cifar_100_train=gluon.data.vision.CIFAR100 (Root= ' e:/data/mxnet/cifar100 ') cifar_100_test=gluon.data.vision.CIFAR100 (Root= ' e:/data/mxnet/cifar100 ', train= False)defShow_images (IMAGES): n=images.shape[0] _, figs=Plt.subplots (1, N, Figsize=( the, the)) forIinch Range(n): Figs[i].imshow (Images[i].asnumpy ()) Figs[i].axes.get_xaxis (). Set_visible (False) Figs[i].axes.get_yaxis (). Set_visible (False) plt.show () data, label=cifar_100_train[1:9]Print(data.shape, label) show_images (data)
Downloading E:/Data/MXNet/cifar100\cifar-100-binary.tar.gz from https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/cifar100/cifar-100-binary.tar.gz...C:\Anaconda3\lib\site-packages\mxnet\gluon\data\vision.py:252: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead data = np.fromstring(fin.read(), dtype=np.uint8).reshape(-1, 3072+2)(8, 32, 32, 3) [15 4 14 1 5 18 3 10]
Cifar-10
Cifar_10_train=GLUON.DATA.VISION.CIFAR10 (Root= ' E:/data/mxnet/cifar10 ') cifar_10_test=GLUON.DATA.VISION.CIFAR10 (Root= ' E:/data/mxnet/cifar10 ', train= False)defShow_images (IMAGES): n=images.shape[0] _, figs=Plt.subplots (1, N, Figsize=( the, the)) forIinch Range(n): Figs[i].imshow (Images[i].asnumpy ()) Figs[i].axes.get_xaxis (). Set_visible (False) Figs[i].axes.get_yaxis (). Set_visible (False) plt.show () data, label=cifar_10_train[1:9]Print(data.shape, label) show_images (data)
Downloading E:/Data/MXNet/cifar10\cifar-10-binary.tar.gz from https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/cifar10/cifar-10-binary.tar.gz...C:\Anaconda3\lib\site-packages\mxnet\gluon\data\vision.py:193: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead data = np.fromstring(fin.read(), dtype=np.uint8).reshape(-1, 3072+1)(8, 32, 32, 3) [9 9 4 1 1 2 7 8]
Mnist_train
Mnist_train=Gluon.data.vision.MNIST (Root= ' E:/data/mxnet/mnist ') mnist_test=Gluon.data.vision.MNIST (Root= ' E:/data/mxnet/mnist ', train= False)defShow_images (IMAGES): n=images.shape[0] _, figs=Plt.subplots (1, N, Figsize=( the, the)) forIinch Range(n): Figs[i].imshow (Images[i].reshape ( -, -). Asnumpy ()) Figs[i].axes.get_xaxis (). Set_visible (False) Figs[i].axes.get_yaxis (). Set_visible (False) plt.show () data, label=mnist_train[1:9]Print(data.shape, label) show_images (data)
Downloading e:/data/mxnet/mnist\train-images-idx3-ubyte.gz from https:// Apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/mnist/train-images-idx3-ubyte.gz ... Downloading e:/data/mxnet/mnist\train-labels-idx1-ubyte.gz from https:// Apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/mnist/train-labels-idx1-ubyte.gz ... C:\anaconda3\lib\site-packages\mxnet\gluon\data\vision.py:118:deprecationwarning:the binary mode of fromstring is Deprecated, as it behaves surprisingly on Unicode inputs. Use Frombuffer instead label = np.fromstring (Fin.read (), dtype=np.uint8). Astype (Np.int32) C:\Anaconda3\lib\ Site-packages\mxnet\gluon\data\vision.py:122:deprecationwarning:the binary mode of fromstring is deprecated, as it Beha Ves surprisingly on Unicode inputs. Use Frombuffer instead data = np.fromstring (Fin.read (), dtype=np.uint8) downloading e:/data/mxnet/mnist\ T10k-images-idx3-ubyte.gz from https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/mnist/ t10k-images-idx3-ubyte.gz ... Downloading e:/data/mxnet/mnist\t10k-labels-idx1-ubyte.gz from https:// Apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/mnist/t10k-labels-idx1-ubyte.gz ... (8, 28, 28, 1) [0 4 1 9 2 1 3 1]
Fashion-mnist
Fashion_mnist_train=Gluon.data.vision.FashionMNIST (Root= ' E:/data/mxnet/fashion_mnist ') fashion_mnist_test=Gluon.data.vision.FashionMNIST (Root= ' E:/data/mxnet/fashion_mnist ', train= False)defShow_images (IMAGES): n=images.shape[0] _, figs=Plt.subplots (1, N, Figsize=( the, the)) forIinch Range(n): Figs[i].imshow (Images[i].reshape ( -, -). Asnumpy ()) Figs[i].axes.get_xaxis (). Set_visible (False) Figs[i].axes.get_yaxis (). Set_visible (False) Plt.show ()defGet_text_labels (label): Text_labels=[' T-shirt ',' Trouser ',' pullover ',' dress, ',' coat ',' Sandal ',' Shirt ',' sneaker ',' bag ',' Ankle boot ']return[text_labels[int(i)] forIinchLabel]data, label=fashion_mnist_train[0:9]show_images (data)Print(Get_text_labels (label))
Downloading e:/data/mxnet/fashion_mnist\train-images-idx3-ubyte.gz from https:// Apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-images-idx3-ubyte.gz ... Downloading e:/data/mxnet/fashion_mnist\train-labels-idx1-ubyte.gz from https:// Apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz ... C:\anaconda3\lib\site-packages\mxnet\gluon\data\vision.py:118:deprecationwarning:the binary mode of fromstring is Deprecated, as it behaves surprisingly on Unicode inputs. Use Frombuffer instead label = np.fromstring (Fin.read (), dtype=np.uint8). Astype (Np.int32) C:\Anaconda3\lib\ Site-packages\mxnet\gluon\data\vision.py:122:deprecationwarning:the binary mode of fromstring is deprecated, as it Beha Ves surprisingly on Unicode inputs. Use Frombuffer instead data = np.fromstring (Fin.read (), dtype=np.uint8) downloading e:/data/mxnet/fashion_mnist\ T10k-images-idx3-ubyte.gz from Https://apache-mxnet.s3-accelerate.dualstacK.amazonaws.com/gluon/dataset/fashion-mnist/t10k-images-idx3-ubyte.gz ... Downloading e:/data/mxnet/fashion_mnist\t10k-labels-idx1-ubyte.gz from https:// Apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/t10k-labels-idx1-ubyte.gz ...
[‘pullover‘, ‘ankle boot‘, ‘shirt‘, ‘t-shirt‘, ‘dress,‘, ‘coat‘, ‘coat‘, ‘sandal‘, ‘coat‘]
Several datasets in the MXNet