当前位置:网站首页>Fashion MNIST dataset classification training
Fashion MNIST dataset classification training
2022-04-23 02:37:00 【Colored sponge】
First of all, the previous article recorded MNIST Simple classification play . At present, there is no challenge , As its replacement Fashion MNIST . Of course we're going to play
It grows like this. , There are also 10 class . and MNIST The size and number of classified pictures are the same
Implementation code : I use jupyter. The installation of the previous blog post tf2.6.0 Written in the environment
import tensorflow as tf
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# First import the required package
# Load data set , You can introduce yourself here , No need to download , For speed , You can download several files , Put corresponding jupyter File location , Let me see the picture below , There is sharing in the document comments
(train_image, train_lable), (test_image, test_label) = tf.keras.datasets.fashion_mnist.load_data()
# The following is not necessary , This is to look at the contents of the data set
train_image.shape,train_lable.shape,test_image.shape, test_label.shape
plt.imshow(train_image[1])
# Next
train_image = train_image/255
test_image = test_image/255 # normalization
# Creating models , This part can be complicated by increasing the number of layers
model = tf.keras.Sequential()
model.add(tf.keras.layers.Flatten(input_shape=(28,28)))
# 28*28 Flatten
model.add(tf.keras.layers.Dense(128, activation='relu'))
# 128 Number of hidden layer units , Too big is easy to fit , Too small to miss information
model.add(tf.keras.layers.Dense(10, activation='softmax'))
# Output layer ,10 A probability
model.summary()
'''
model = tf.keras.Sequential()
model.add(tf.keras.layers.Flatten(input_shape=(28,28))) # 28*28
model.add(tf.keras.layers.Dense(128, activation='relu'))
model.add(tf.keras.layers.Dropout(0.5))
model.add(tf.keras.layers.Dense(128, activation='relu'))
model.add(tf.keras.layers.Dropout(0.5))
model.add(tf.keras.layers.Dense(128, activation='relu'))
model.add(tf.keras.layers.Dropout(0.5))
model.add(tf.keras.layers.Dense(10, activation='softmax'))
'''
# Finally, choose the optimizer adam, Loss function
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['acc']
)
# Start training , I use this epochs=5.50 You can achieve 96% many
model.fit(train_image, train_lable, epochs=5)
The dataset has 60000 Zhang 28*28 Training set of , and 10000 Zhang test set
Take out the second picture of the training set and see what it looks like
The content of the model is like this :
Add a hidden layer to the model content, so :
5 individual epochs Time accurate removal rate acc=89.18%
50 individual epochs Time accurate removal rate acc=96.76%
additional : 100% complete and clean 96.75 The simple code of
import tensorflow as tf
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
(train_image, train_lable), (test_image, test_label) = tf.keras.datasets.fashion_mnist.load_data()
train_image = train_image/255
test_image = test_image/255 # normalization
model = tf.keras.Sequential()
model.add(tf.keras.layers.Flatten(input_shape=(28,28))) # 28*28 Flatten
model.add(tf.keras.layers.Dense(128, activation='relu')) # 128 Number of hidden layer units
model.add(tf.keras.layers.Dense(10, activation='softmax'))# Output layer ,10 A probability
model.summary()
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['acc']
)
model.fit(train_image, train_lable, epochs=50)
版权声明
本文为[Colored sponge]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230236378157.html
边栏推荐
- 每日一题冲刺大厂第十六天 NOIP普及组 三国游戏
- Tp6 Alibaba cloud SMS window reports curl error 60: SSL certificate problem: unable to get local issuer certificate
- Go language ⌈ mutex and state coordination ⌋
- Day 3 of learning rhcsa
- Preliminary understanding of stack and queue
- 机器学习(周志华) 第十四章概率图模型
- Consider defining a bean of type ‘com.netflix.discovery.AbstractDiscoveryClientOptionalArgs‘
- php+mysql对下拉框搜索的内容修改
- go语言打怪通关之 ⌈互斥锁和状态协程⌋
- day18--栈队列
猜你喜欢
使用Go语言构建Web服务器
十六、异常检测
Global, exclusive and local routing guard
After idea is successfully connected to H2 database, there are no sub files
全局、獨享、局部路由守衛
Flink stream processing engine system learning (I)
一个国产图像分割项目重磅开源!
The 16th day of sprint to the big factory, noip popularization Group Three Kingdoms game
arduino esp8266 网络升级 OTA
【无标题】
随机推荐
牛客手速月赛 48 C(差分都玩不明白了属于是)
Program design: l1-49 ladder race, allocation of seats (simulation), Buxiang pill hot
Develop a chrome plug-in from 0 (2)
day18--栈队列
tp6阿裏雲短信 window 報 cURL error 60: SSL certificate problem: unable to get local issuer certificate
010_ StringRedisTemplate
IAR嵌入式開發STM32f103c8t6之點亮LED燈
Go语言web中间件的使用
Explain JS prototype and prototype chain in detail
RT_Thread自问自答
SO库依赖问题
[nk]牛客月赛48 D
If 404 page is like this | daily anecdotes
Hack the box optimum
Consider defining a bean of type ‘com.netflix.discovery.AbstractDiscoveryClientOptionalArgs‘
wordpress 调用指定页面内容详解2 get_children()
Understanding process (multithreading primary)
How to recognize products from the perspective of Dialectics
JVM运行时数据区(一)
Halo open source project learning (I): project launch