当前位置:网站首页>Tensorflow 2: use neural network to classify and compare fashion MNIST
Tensorflow 2: use neural network to classify and compare fashion MNIST
2022-06-21 19:44:00 【WihauShe】
Experimental setup
In this experiment, neural networks with different activation functions are used to MNIST Data sets are classified , At the same time, the influence of the number of hidden layers on the experimental results . The hidden layer of the experiment is mainly 1 Layer and the 2 layer , The activation functions are ReLU、Laaky ReLU and Softmax, Output functions are unchanged Softmax. The experimental data set is Fashion MNIST Data sets , It is mainly used for multi classification of handwriting recognition .
Code and experimental results
Hidden layer is 1 The different activation functions of layer
# TensorFlow and tf.keras
import tensorflow as tf
from tensorflow import keras
# Helper libraries
import numpy as np
# Fashion MNIST input data
fashion_mnist = keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
# preprocess
train_images = train_images / 255.0
test_images = test_images / 255.0
# build model, loss, and train op
model = keras.Sequential([
keras.layers.Flatten(input_shape=(28, 28)),
keras.layers.Dense(196, activation='relu'), # change the activation
keras.layers.Dense(10, activation='softmax')
])
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
model.fit(train_images, train_labels, epochs=10)
test_loss, test_acc = model.evaluate(test_images, test_labels)
print('\nTest Accuracy:', test_acc)
relu
elu
softmax
Hidden layer is 2 Performance of different activation functions in layer
# build model, loss, and train op
model = keras.Sequential([
keras.layers.Flatten(input_shape=(28, 28)),
keras.layers.Dense(196, activation='relu'), # change activation
keras.layers.Dense(98, activation='relu'), # change activation
keras.layers.Dense(10, activation='softmax')
])
relu

elu

softmax

边栏推荐
- Huawei launches new products again? These models have excellent functions
- Sword finger offer II 029 Sorted circular linked list
- 技术分享 | MySQL:caching_sha2_password 快速问答
- 在Qt中设置程序图标的方法介绍
- Dynamic programming [II] (linear DP)
- [high frequency interview questions] the difficulty is 1.5/5. Common two point double pointer interview questions
- The R language uses the DOTPLOT function of epidisplay package to visualize the frequency of data points in different intervals in the form of point graph, uses the by parameter to specify the groupin
- Medical expense list can be entered at a second speed, and OCR recognition can help double the efficiency
- 基于ASP.NET开发的企信通源码 短信管理平台源码
- SQL操作:WITH表达式及其应用
猜你喜欢

Insert class collation

系统集成项目管理工程师(软考中级)怎么备考?

How to set the picture background to transparent

论文解读(USIB)《Towards Explanation for Unsupervised Graph-Level Representation Learning》

11 Beautiful Soup 解析庫的簡介及安裝

11 brève introduction et installation de la Bibliothèque d'analyse de soup beautiful

yolov5训练自己的数据集报错记录

API de table & SQL et module d'échantillon pour le système Flink

SQL operation: with expression and its application

How to use devaxpress WPF to create the first MVVM application in winui?
随机推荐
ThreadLocal与线程池在使用中可能会出现的两个问题
CloudCompare&PCL 点云点匹配(基于欧式距离)
API de table & SQL et module d'échantillon pour le système Flink
Excel文件加密的两种方式
R语言glm函数构建二分类logistic回归模型(family参数为binomial)、使用summary函数查看模型汇总统计信息并解读特征
2022年下半年传统产品经理国际资格认证招生简章(NPDP)
How to create network redundancy for network managed national production reinforced switch
Hongmeng version of "Tiktok" is a great experience
全国产加固以太网交换机选择技巧
The GLM function of R language is used to build a binary logistic regression model (the family parameter is binomial), and the summary function is used to view the summary statistical information of t
机器学习之聚类和降维与度量技术
将图片背景设置为透明的方法介绍
Kubernetes migration of persistent volumes across storageclasses Complete Guide
[pwn基础]Pwntools学习
动态规划【一】(背包问题)
vivo 容器集群监控系统架构与实践
homeassistant addons
homeassistant addons
R语言使用epiDisplay包的statStack函数基于因子变量通过分层的方式查看连续变量的统计量(均值、中位数等)以及对应的假设检验
GetEmptyBlcoksPre Info