标签: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‘))
标签:false ESS 图片 for lib image asp 51cto alt
原文地址:http://blog.51cto.com/13959448/2316676