Fashion MNIST

https://www.kaggle.com/zalando-research/fashionmnist

Fashion-MNIST is a dataset of Zalando's article images—consisting of a training set of 60,000 examples and a test set of 10,000 examples. Each example is a 28x28 grayscale image, associated with a label from 10 classes. Zalando intends Fashion-MNIST to serve as a direct drop-in replacement for the original MNIST dataset for benchmarking machine learning algorithms. It shares the same image size and structure of training and testing splits.

The original MNIST dataset contains a lot of handwritten digits. Members of the AI/ML/Data Science community love this dataset and use it as a benchmark to validate their algorithms. In fact, MNIST is often the first dataset researchers try. "If it doesn't work on MNIST, it won't work at all", they said. "Well, if it does work on MNIST, it may still fail on others."

Zalando seeks to replace the original MNIST dataset

Code

https://github.com/fanqingsong/code-snippet/blob/master/machine_learning/FMNIST/code.py

  1. # TensorFlow and tf.keras
  2. import tensorflow as tf
  3. from tensorflow import keras
  4.  
  5. # Helper libraries
  6. import numpy as np
  7.  
  8. print(tf.__version__)
  9.  
  10. fashion_mnist = keras.datasets.fashion_mnist
  11.  
  12. (train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
  13.  
  14. class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',
  15. 'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']
  16.  
  17. train_images = train_images / 255.0
  18.  
  19. test_images = test_images / 255.0
  20.  
  21. model = keras.Sequential([
  22. keras.layers.Flatten(input_shape=(28, 28)),
  23. keras.layers.Dense(128, activation=tf.nn.relu),
  24. keras.layers.Dense(10, activation=tf.nn.softmax)
  25. ])
  26.  
  27. model.compile(optimizer=tf.train.AdamOptimizer(),
  28. loss='sparse_categorical_crossentropy',
  29. metrics=['accuracy'])
  30.  
  31. model.fit(train_images, train_labels, epochs=5)
  32.  
  33. test_loss, test_acc = model.evaluate(test_images, test_labels)
  34.  
  35. print('Test accuracy:', test_acc)
  36.  
  37. predictions = model.predict(test_images)
  38.  
  39. print(test_labels[0])
  40.  
  41. print(np.argmax(predictions[0]))

run

root@DESKTOP-OGSLB14:~/mine/code-snippet/machine_learning/FMNIST#
root@DESKTOP-OGSLB14:~/mine/code-snippet/machine_learning/FMNIST# python code.py
1.14.0
WARNING: Logging before flag parsing goes to stderr.
W0816 23:26:49.741352 140630311962432 deprecation.py:506] From /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/init_ops.py:1251: calling __init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
Instructions for updating:
Call initializer instance with the dtype argument instead of passing it to the constructor
W0816 23:26:49.977197 140630311962432 deprecation_wrapper.py:119] From code.py:33: The name tf.train.AdamOptimizer is deprecated. Please use tf.compat.v1.train.AdamOptimizer instead.

2019-08-16 23:26:50.289949: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-08-16 23:26:50.684455: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 1992000000 Hz
2019-08-16 23:26:50.686887: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7fffe64d99e0 executing computations on platform Host. Devices:
2019-08-16 23:26:50.686967: I tensorflow/compiler/xla/service/service.cc:175]   StreamExecutor device (0): <undefined>, <undefined>
2019-08-16 23:26:50.958569: W tensorflow/compiler/jit/mark_for_compilation_pass.cc:1412] (One-time warning): Not using XLA:CPU for cluster because envvar TF_XLA_FLAGS=--tf_xla_cpu_global_jit was not set.  If you want XLA:CPU, either set that envvar, or use experimental_jit_scope to enable XLA:CPU.  To confirm that XLA is active, pass --vmodule=xla_compilation_cache=1 (as a proper command-line flag, not via TF_XLA_FLAGS) or set the envvar XLA_FLAGS=--xla_hlo_profile.
Epoch 1/5
60000/60000 [==============================] - 3s 50us/sample - loss: 0.4992 - acc: 0.8240
Epoch 2/5
60000/60000 [==============================] - 2s 40us/sample - loss: 0.3758 - acc: 0.8650
Epoch 3/5
60000/60000 [==============================] - 3s 42us/sample - loss: 0.3382 - acc: 0.8770
Epoch 4/5
60000/60000 [==============================] - 2s 41us/sample - loss: 0.3135 - acc: 0.8854
Epoch 5/5
60000/60000 [==============================] - 3s 42us/sample - loss: 0.2953 - acc: 0.8922
10000/10000 [==============================] - 0s 25us/sample - loss: 0.3533 - acc: 0.8715
('Test accuracy:', 0.8715)
9
9
root@DESKTOP-OGSLB14:~/mine/code-snippet/machine_learning/FMNIST#

Reference

https://github.com/MachineIntellect/DeepLearner/blob/master/basic_classification.ipynb

https://tensorflow.google.cn/beta/guide/data

fashion MNIST识别(Tensorflow + Keras + NN)的更多相关文章

  1. mnist识别优化——使用新的fashion mnist进行模型训练

    今天通过论坛偶然知道,在mnist之后,还出现了一个旨在代替经典mnist数据集的Fashion MNIST,同mnist一样,它也是被用作深度学习程序的“hello world”,而且也是由70k张 ...

  2. mnist手写数字识别——深度学习入门项目(tensorflow+keras+Sequential模型)

    前言 今天记录一下深度学习的另外一个入门项目——<mnist数据集手写数字识别>,这是一个入门必备的学习案例,主要使用了tensorflow下的keras网络结构的Sequential模型 ...

  3. 100天搞定机器学习|day39 Tensorflow Keras手写数字识别

    提示:建议先看day36-38的内容 TensorFlow™ 是一个采用数据流图(data flow graphs),用于数值计算的开源软件库.节点(Nodes)在图中表示数学操作,图中的线(edge ...

  4. 100天搞定机器学习|day40-42 Tensorflow Keras识别猫狗

    100天搞定机器学习|1-38天 100天搞定机器学习|day39 Tensorflow Keras手写数字识别 前文我们用keras的Sequential 模型实现mnist手写数字识别,准确率0. ...

  5. Mnist手写数字识别 Tensorflow

    Mnist手写数字识别 Tensorflow 任务目标 了解mnist数据集 搭建和测试模型 编辑环境 操作系统:Win10 python版本:3.6 集成开发环境:pycharm tensorflo ...

  6. 深度学习常用数据集 API(包括 Fashion MNIST)

    基准数据集 深度学习中经常会使用一些基准数据集进行一些测试.其中 MNIST, Cifar 10, cifar100, Fashion-MNIST 数据集常常被人们拿来当作练手的数据集.为了方便,诸如 ...

  7. 手写数字识别——利用keras高层API快速搭建并优化网络模型

    在<手写数字识别——手动搭建全连接层>一文中,我们通过机器学习的基本公式构建出了一个网络模型,其实现过程毫无疑问是过于复杂了——不得不考虑诸如数据类型匹配.梯度计算.准确度的统计等问题,但 ...

  8. [转] 理解CheckPoint及其在Tensorflow & Keras & Pytorch中的使用

    作者用游戏的暂停与继续聊明白了checkpoint的作用,在三种主流框架中演示实际使用场景,手动点赞. 转自:https://blog.floydhub.com/checkpointing-tutor ...

  9. 【学习总结】win7使用anaconda安装tensorflow+keras

    tips: Keras是一个高层神经网络API(高层意味着会引用封装好的的底层) Keras由纯Python编写而成并基Tensorflow.Theano以及CNTK后端. 故先安装TensorFlo ...

随机推荐

  1. ELK快速入门(三)logstash收集日志写入redis

    ELK快速入门三-logstash收集日志写入redis 用一台服务器部署redis服务,专门用于日志缓存使用,一般用于web服务器产生大量日志的场景. 这里是使用一台专门用于部署redis ,一台专 ...

  2. Tomcat配置域名、ip访问及解决80端口冲突

    1.先在tomcat下的conf下找到server.xml文件,用记事本打开后,首先对端口号进行修改,以前一直以为8080是默认的端口号,其实默认的端口号是80 <Connector port= ...

  3. css3 -webkit-image-set 设置不同分辨率 背景图片

  4. 直接将字典转为DataFrame格式时,会出现:ValueError: If using all scalar values, you must pass an index(四种解决方案)

    问题:想要将字典直接转为DataFrame格式时,除了字典外没有传入其他参数时,会报错 ValueError: If using all scalar values, you must pass an ...

  5. springboot集成ftp

    目录 springboot集成ftp pom依赖包 ftp登录初始化 ftp上传文件 ftp读取文件,并转成base64 ftp下载文件 ftp客户端与服务端之间数据传输,主动模式和被动模式 spri ...

  6. 201671010426 孙锦喆 实验十四 团队项目评审&课程学习总结

    徐明锦 徐明锦 2 95 2019-06-30T14:54:00Z 2019-06-30T14:54:00Z 9 608 3472 28 8 4072 14.00 Clean Clean false ...

  7. Discuz!基础的代码安全和代码规范

    变量所有漏洞都来源于变量,因此变量首先要做的就是定义初始化.用任何一个变量前一定要先定义,初始化它虽然现在Discuz!X来说,GPC不会被全局覆盖了,但是大家写插件的过程中也不要忽视了因为在服务器p ...

  8. 2019牛客暑期多校训练营(第八场)E:Explorer(LCT裸题 也可用线段树模拟并查集维护连通性)

    题意:给定N,M,然后给出M组信息(u,v,l,r),表示u到v有[l,r]范围的通行证有效.问有多少种通行证可以使得1和N连通. 思路:和bzoj魔法森林有点像,LCT维护最小生成树.  开始和队友 ...

  9. 判断json对象是否在数组中

    // 判断对象是否在数组中function objinArrar(check,param){ var isExisted = false; var index = -1; for(var i=0;i& ...

  10. Nginx 优化配置

    基本配置优化(优化后配置样例,可以改后直接上生产) 1 #头部配置 2 user nginx nginx; #定义nginx的启动用户,不建议使用root 3 worker_processes 4; ...