#!/usr/bin/env python2# -*- coding: utf-8 -*-"""Created on Fri Aug 10 16:13:29 2018@author: myhaspl"""from mxnet import nd, gluon, init, autogradfrom mxnet.gluon import nnfrom mxnet.gluon.data.vision import datasets,transforms import matplotlib.pyplot as pltfrom time import timemnist_train = datasets.FashionMNIST(train=True)X, y = mnist_train[0]print (‘X shape: ‘, X.shape, ‘X dtype‘, X.dtype, ‘y:‘, y,‘Y dtype‘, y.dtype)#x:(height, width, channel)#y:numpy.scalar,标签text_labels = [ ???????????‘t-shirt‘, ‘trouser‘, ‘pullover‘, ‘dress‘, ‘coat‘, ???????????‘sandal‘, ‘shirt‘, ‘sneaker‘, ‘bag‘, ‘ankle boot‘]X, y = mnist_train[0:6]#取6个样本_, figs = plt.subplots(1, X.shape[0], figsize=(15, 15))for f,x,yi in zip(figs, X,y): ???# 3D->2D by removing the last channel dim ???f.imshow(x.reshape((28,28)).asnumpy()) ???ax = f.axes ???ax.set_title(text_labels[int(yi)]) ???ax.title.set_fontsize(20) ???ax.get_xaxis().set_visible(False) ???ax.get_yaxis().set_visible(False)plt.show()
(‘X shape: ‘, (28L, 28L, 1L), ‘X dtype‘, <type ‘numpy.uint8‘>, ‘y:‘, 2, ‘Y dtype‘, dtype(‘int32‘))
mxnet-读取示例数据
原文地址:http://blog.51cto.com/13959448/2316676