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. Linux运维技术之端口转发

  2. 矩阵LU分解程序实现(Matlab)

    n=4;%确定需要LU分解的矩阵维数 %A=zeros(n,n); L=eye(n,n);P=eye(n,n);U=zeros(n,n);%初始化矩阵 tempU=zeros(1,n);tempP=z ...

  3. XXX接口自动化测试方案

    XXX接口自动化测试方案 1.引言 1.1 文档版本 版本 作者 审批 备注 V1.0 XXXX 创建测试方案文档 1.2 项目情况 项目名称 XXX 项目版本 V1.0 项目经理 XX 测试人员 X ...

  4. Educational Codeforces Round 67 D. Subarray Sorting

    Educational Codeforces Round 67 D. Subarray Sorting 传送门 题意: 给出两个数组\(a,b\),现在可以对\(a\)数组进行任意次排序,问最后能否得 ...

  5. 点击一个超链接,弹出固定大小的新窗口(js实现)

    1.最基本的弹出窗口代码 <SCRIPT LANGUAGE="javascript"> <!-- window.open ('page.html') --> ...

  6. js--同步运动json下

    这一节针对上一节讲述的bug,我们来处理一下. 这个bug存在的原因就是,一旦只要有一个属性值达到目标值就会清除定时器,所以我们要改变 的就是清除定时器的那么部分.看下面的修改 var timer; ...

  7. jenkins邮件配置以及邮件添加附件详解

    1.在系统管理-系统设置  中找到邮件配置模块 填写情况如下图 第一步,填写系统管理员邮箱 第二步,填写邮箱配置 第三步,然后在项目中添加邮箱配置 项目中邮件设置中关于附件添加 因为我的项目目录中分3 ...

  8. oracle彻底删除干净

    Oracle数据库的安装这里就不说了,网上应该有很多,但是oracle数据库的卸载却找不到一个比较详细的完整卸载的说明.很多卸载不完全,会有遗留数据,影响后续的安装.所以自己整理一份以前上学的时候学习 ...

  9. Mysql五大约束

    Mysql五大约束 约束:对表中数据的限制.保证表中数据的准确和可靠 (1)NOT NULL:非空,用于保证该字段的值不能为空 (2)DEFAULT:默认,用于保证该字段有默认值(3)PRIMARY ...

  10. springboot集成mail实现邮件服务

    1,新建mailconfig类,对邮件服务固定配置进行实体封装: import java.util.Properties; import org.springframework.beans.facto ...