当前位置:网站首页>[Deep Learning 21 Days Learning Challenge] Memo: What does our neural network model look like? - detailed explanation of model.summary()
[Deep Learning 21 Days Learning Challenge] Memo: What does our neural network model look like? - detailed explanation of model.summary()
2022-08-04 06:05:00 【Live up to [email protected]】
活动地址:CSDN21天学习挑战赛
学完手写识别和服装分类,Want to stop for a while to digest what I've learned,也总结一下,今天就从keras的model.summary()Let's start the output!
1、model.summary()是什么
构建深度学习模型,我们会通过model.summary()输出模型各层的参数状况,Have we had just learned model as an example:

这里可以看出,model.summary()打印出的内容,is the same as the hierarchical relationship in which we build the model,Clothing classification model as an example:
#Build model code
model = models.Sequential([
layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)), #卷积层1,卷积核3*3
layers.MaxPooling2D((2, 2)), #池化层1,2*2采样
layers.Conv2D(64, (3, 3), activation='relu'), #卷积层2,卷积核3*3
layers.MaxPooling2D((2, 2)), #池化层2,2*2采样
layers.Conv2D(64, (3, 3), activation='relu'), #卷积层3,卷积核3*3
layers.Flatten(), #Flatten层,连接卷积层与全连接层
layers.Dense(64, activation='relu'), #全连接层,特征进一步提取
layers.Dense(10) #输出层,输出预期结果
])

2、model.summary()输出含义
Still take the clothing classification model as an example:
Model: "sequential_2"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d_6 (Conv2D) (None, 26, 26, 32) 320
#创建: layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)), #卷积层1,卷积核3*3
_________________________________________________________________
max_pooling2d_4 (MaxPooling2 (None, 13, 13, 32) 0
#创建:layers.MaxPooling2D((2, 2)), #池化层1,2*2采样
_________________________________________________________________
conv2d_7 (Conv2D) (None, 11, 11, 64) 18496
#创建:layers.Conv2D(64, (3, 3), activation='relu'), #卷积层2,卷积核3*3
_________________________________________________________________
max_pooling2d_5 (MaxPooling2 (None, 5, 5, 64) 0
#创建:layers.MaxPooling2D((2, 2)), #池化层2,2*2采样
_________________________________________________________________
conv2d_8 (Conv2D) (None, 3, 3, 64) 36928
#创建:layers.Conv2D(64, (3, 3), activation='relu'), #卷积层3,卷积核3*3
_________________________________________________________________
flatten_2 (Flatten) (None, 576) 0
#创建:layers.Flatten(), #Flatten层,连接卷积层与全连接层
_________________________________________________________________
dense_4 (Dense) (None, 64) 36928
#创建:layers.Dense(64, activation='relu'), #全连接层,特征进一步提取
_________________________________________________________________
dense_5 (Dense) (None, 10) 650
#创建:layers.Dense(10) #输出层,输出预期结果
=================================================================
Total params: 93,322
Trainable params: 93,322
Non-trainable params: 0
_________________________________________________________________
Param:该层输入参数个数, So how did this number come about??
a、The formula for calculating the number of parameters of the convolution layer:(卷积核长度*卷积核宽度*通道数+1)*卷积核个数
例:
第一个卷积层:(3*3*1+1)*32 = 320
第二个卷积层:(3*3*32+1)*64 = 18496
第三个卷积层:(3*3*64+1)*64 = 36928b、The formula for calculating the number of parameters of the fully connected layer:
(输入数据维度+1)* 神经元个数
例:
Fully connected layer before the output layer:(64+1)*10=650
这里之所以要加1,Because every neuron has a偏置(Bias).Output Shape :The output data shape of this layer
Total params: Total number of model parameters,
The parameters of each layer are accumulatedTrainable params: 模型可训练参数
Non-trainable params:Model untrainable parameters
3、Understand the shape model process
通过model.summary(),Let's look at this picture again,就清楚多了

版权声明
本文为[Live up to [email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/216/202208040525326927.html
边栏推荐
猜你喜欢
随机推荐
读研碎碎念
MySql的concat和group_concat的区别
Kubernetes集群安装
Dictionary feature extraction, text feature extraction.
MySql--存储引擎以及索引
Matplotlib中的fill_between;np.argsort()函数
记一次flink程序优化
智能合约安全——私有数据访问
字典特征提取,文本特征提取。
SQL练习 2022/7/1
自动化运维工具Ansible(4)变量
【深度学习21天学习挑战赛】0、搭建学习环境
智能合约安全——溢出漏洞
二月、三月校招面试复盘总结(二)
with recursive用法
多项式回归(PolynomialFeatures)
【深度学习21天学习挑战赛】1、我的手写被模型成功识别——CNN实现mnist手写数字识别模型学习笔记
Upload靶场搭建&&第一二关
【go语言入门笔记】13、 结构体(struct)
flink-sql查询配置与性能优化参数详解




![[Introduction to go language] 12. Pointer](/img/c8/4489993e66f1ef383ce49c95d78b1f.png)



