分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

mxnet-读取示例数据

发布时间:2023-09-06 02:22责任编辑:蔡小小关键词:暂无标签
#!/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

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved