当前位置:网站首页>[Deep Learning] Note 2 - The accuracy of the model in the test set is greater than that in the training set
[Deep Learning] Note 2 - The accuracy of the model in the test set is greater than that in the training set
2022-08-11 11:57:00 【aaaafeng】
Preface
Activity address: CSDN 21-day Learning Challenge
Blogger homepage: Aaaafeng's homepage_CSDN
Keep input, keep output!(quoting a sentence from my a friend)
Article table of contents
1. Description of the problem
In the process of model training, I suddenly found that the accuracy rate of the model is actually higher on the test set than on the training set.But we know that the way we train the model is to minimize the loss on the training set.Therefore, it should be normal for the model to perform better on the training set.
So, what caused the higher accuracy on the test set?
Model training results:

2. Fix the problem
2. 1. Underfitting
Later I consulted a big boss, she said: "Train a few more times to see, the first few times have been underfitting", I immediately felt, Good suggestionstrong>!
Increase the number of training epochs:
Sure enough!With increasing training epochs, the model accuracy slowly returned to the right track.The accuracy on the training set again exceeds that on the test set.
2. 2. Hysteresis of mini-batch statistics
But I still have some doubts, why in the underfitting state with fewer training cycles, the model has a higher accuracy on the test set?What is the relationship between them?
There is a part of the explanation given by a blog post, which I think is very reasonable and more in line with the situation I encountered:
The accuracy of the training set is generated after each batch, while the accuracy of the validation set is generally generated after an epoch. The model during validation is trained after batches, and there is a lag.It can be said that the model that has been trained about the same is used for verification, of course, the accuracy rate is higher.
That is, the problem arises with the way individuals specifically count the accuracy of the training set.If the accuracy of the model on the training set is counted after each training cycle, rather than at the end of each mini-batch, this will not happenThe problem.
Of course, just talking is not enough, you have to practice.I checked the previous model code and found that the accuracy on my training set was indeed counted after each mini-batch.Then you might as well try the accuracy of the training set and count it after each cycle.
Accuracy on the training set after each training cycle (train acc 2):
It is easy to find that even in the state of underfitting, if the training set and test set accuracy are statistically the same, the model will still be more accurate on the training set.
Summary
When you encounter a problem, looking at other people's thoughts may make you feel stunned in an instant.It is not advisable for a person to drill into a bull's horn.
边栏推荐
猜你喜欢

Application practice of low-latency real-time audio and video in 5G remote control scenarios

重要消息丨.NET Core 3.1 将于今年12月13日结束支持

RTP协议浅析

关于b/s技术的一些思考--模板技术

SpinalHDL资料汇总

陕西cas:2055042-71-0N-(炔-四聚乙二醇)-生物素价格

edusoho兑换码功能二次开发

为什么最好的光刻机来自荷兰,而不是芯片大国美国?

Through the thermal lens focus on different types of gaussian model

通过热透镜聚焦不同类型的高斯模式
随机推荐
五分钟教你内网穿透
error: ‘const char* libc_name_p(const char*, unsigned int)’ redeclared inline with ‘gnu_inline’ attr
ESI VA One 2021软件安装包和安装教程
鸿海董事长刘扬伟:市场对智能手机和其他消费电子产品的需求正在放缓
pgr_createTopology
Jmeter性能测试
面试官:Redis Zset的实现为什么用跳表,而不用平衡树?
OpenHarmony如何选择图片在Image组件上显示(eTS)
路测数据合并
Tool_RE_IDA基础字符串修改
条件竞争 && pipe_buffer + 堆喷射
MySQL --- 存储引擎
vending machine
CSDN文章抓取
SQL Runtime SLX主要包括哪两方面?
公共管理学选择题(最终版)
目标检测学习笔记——小目标检测
基于 TLS 1.3的百度安全通信协议 bdtls 介绍
通过热透镜聚焦不同类型的高斯模式
三面蚂蚁金服,分享面试经历总结(已拿offer)