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

# TensorFlow and tf.keras
import tensorflow as tf
from tensorflow import keras # Helper libraries
import numpy as np print(tf.__version__) fashion_mnist = keras.datasets.fashion_mnist (train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data() class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',
'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot'] train_images = train_images / 255.0 test_images = test_images / 255.0 model = keras.Sequential([
keras.layers.Flatten(input_shape=(28, 28)),
keras.layers.Dense(128, activation=tf.nn.relu),
keras.layers.Dense(10, activation=tf.nn.softmax)
]) model.compile(optimizer=tf.train.AdamOptimizer(),
loss='sparse_categorical_crossentropy',
metrics=['accuracy']) model.fit(train_images, train_labels, epochs=5) test_loss, test_acc = model.evaluate(test_images, test_labels) print('Test accuracy:', test_acc) predictions = model.predict(test_images) print(test_labels[0]) 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. Docker容器的简单使用

    1. docker的使用 1> 创建容器 创建并启动容器: docker run -it -name 容器名 镜像: 版本  /bin/sh(bash) 创建并不启动容器:docker crea ...

  2. FTPClient中使用completePendingCommand方法注意事项

    方法介绍: * There are a few FTPClient methods that do not complete the * entire sequence of FTP commands ...

  3. Java Spring Boot 一些调试技巧

    配置文件的管理 有的时候我们希望开发环境和测试环境的配置文件放在一起可以快速切换 spring boot 为我们提供了很方便的的选项 在 application.properties 中只需要添加属性 ...

  4. 浏览器性能监控performance使用

    浏览器中有一个performance的性能监控,平时我也没有用到,接手了一个大数据的项目,发现页面打开的比较慢,使用浏览器的performance分析可以看到各个步骤花费的时间. 关于项目的性能分析如 ...

  5. ZOJ3261-Connections in Galaxy War-(逆向并查集+离线处理)

    题意: 1.有n个星球,每个星球有一个编号(1-n)和一个能量值. 2.一开始将某些星球连通. 3.开战后有很多个操作,查询某个星球能找谁求救或者摧毁两颗星球之间的连通路径,使其不能连通.如果连通则可 ...

  6. PHP 判断时间段 至今过了多长时间

    /** * * @param timestamp $time 输入时间 * @return str $str 输入时间与现在时间差的中文 */ function wordTime($time) { / ...

  7. Numpy | 14 字符串函数

    本章函数用于对 dtype 为 numpy.string_ 或 numpy.unicode_ 的数组执行向量化字符串操作. 它们基于 Python 内置库中的标准字符串函数. 这些函数在字符数组类(n ...

  8. Cortex Architecture

    内容来自github 官方文档,参考连接:https://github.com/cortexproject/cortex/blob/master/docs/architecture.md Cortex ...

  9. 网络编程——select介绍

    一.select函数简介 select一般用在socket网络编程中,在网络编程的过程中,经常会遇到许多阻塞的函数,网络编程时使用的recv, recvfrom.connect函数都是阻塞的函数,当函 ...

  10. 洛谷p1967货车运输(kruskal重构树)

    题面 题解中有很多说最优解是kruskal重构树 所以 抽了个早自习看了看这方面的内容 我看的博客 感觉真的挺好使的 首先对于kruskal算法来说 是基于贪心的思想把边权排序用并查集维护是否是在同一 ...