博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MXNet 中的几个数据集
阅读量:6679 次
发布时间:2019-06-25

本文共 6648 字,大约阅读时间需要 22 分钟。

from mxnet import 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= 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)

下载几个数据集到本地磁盘

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)def show_images(images):    n = images.shape[0]    _, figs = plt.subplots(1, n, figsize=(15, 15))    for i in 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]

output_3_3.png-27.7kB

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)def show_images(images):    n = images.shape[0]    _, figs = plt.subplots(1, n, figsize=(15, 15))    for i in 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]

output_4_3.png-31.3kB

mnist_train = gluon.data.vision.MNIST(root= 'E:/Data/MXNet/mnist')mnist_test = gluon.data.vision.MNIST(root= 'E:/Data/MXNet/mnist', train= False)def show_images(images):    n = images.shape[0]    _, figs = plt.subplots(1, n, figsize=(15, 15))    for i in range(n):        figs[i].imshow(images[i].reshape((28, 28)).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 behaves 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]

output_5_3.png-6.1kB

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)def show_images(images):    n = images.shape[0]    _, figs = plt.subplots(1, n, figsize=(15, 15))    for i in range(n):        figs[i].imshow(images[i].reshape((28, 28)).asnumpy())        figs[i].axes.get_xaxis().set_visible(False)        figs[i].axes.get_yaxis().set_visible(False)    plt.show()def get_text_labels(label):    text_labels = [        't-shirt', 'trouser', 'pullover', 'dress,', 'coat',        'sandal', 'shirt', 'sneaker', 'bag', 'ankle boot'    ]    return [text_labels[int(i)] for i in label]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 behaves 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...

output_7_3.png-17.2kB

['pullover', 'ankle boot', 'shirt', 't-shirt', 'dress,', 'coat', 'coat', 'sandal', 'coat']
探寻有趣之事!

转载地址:http://fefao.baihongyu.com/

你可能感兴趣的文章
Java IO类库之Bits
查看>>
ERROR 1217 (23000): Cannot delete or update a pare
查看>>
oracle 11g RAC搭建 ASM存储
查看>>
函数学习-bytearray()
查看>>
SUSE Linux文件系统在线扩容
查看>>
使用Navicat for MySQL工具来连接centos 6.6系统中的MYSQL服务
查看>>
Several ports (8005, 8080, 8009) required by Tomcat Server at localhost are already in use.
查看>>
CentOS7安装配置telnet-server
查看>>
工作软件
查看>>
GitOSC和GitHub上传项目
查看>>
Flink 原理与实现:如何生成 JobGraph
查看>>
承受自律的苦,不要承受自责的悔
查看>>
提示弹框
查看>>
【技术维新 践行精彩】+ IBM的IT服务管理产品与企业运维
查看>>
下拉框选择数据过滤?
查看>>
Gensim官方教程翻译——快速入门
查看>>
常用RAID阵列类型
查看>>
php的命名空间
查看>>
.net查询某一列,某一字段的值
查看>>
SUN 300-1851 300-2015 300-1800 300-2235电源
查看>>