码迷,mamicode.com
首页 > Web开发 > 详细

mxnet-读取示例数据

时间:2018-11-14 19:14:50      阅读:351      评论:0      收藏:0      [点我收藏+]

标签:false   ESS   图片   for   lib   image   asp   51cto   alt   

#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Fri Aug 10 16:13:29 2018 @author: myhaspl """ from mxnet import nd, gluon, init, autograd from mxnet.gluon import nn from mxnet.gluon.data.vision import datasets,transforms import matplotlib.pyplot as plt from time import time mnist_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-读取示例数据

标签:false   ESS   图片   for   lib   image   asp   51cto   alt   

原文地址:http://blog.51cto.com/13959448/2316676

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!