当前位置:网站首页>5.过拟合,dropout,正则化
5.过拟合,dropout,正则化
2022-07-07 23:11:00 【booze-J】
过拟合


过拟合导致测试误差变大:
可以看到图中随着模型结构的越来越复杂,训练集的误差越来越小,测试集的误差先变小后变大,过拟合导致测试误差变大。
比较好的情况是训练误差和测试误差这两条线比较接近。
防止过拟合
1.增大数据集
数据挖掘领域流行着这样一句话,“有时候拥有更多的数据胜过一个好的模型”。一般来说更多的数据参与训练,训练得到的模型就越好。如果数据太少,而我们构建的神经网络又太复杂的话就比较容易产生过拟合的现象。
2.Early stopping
在训练模型的时候,我们往往会设置一个比较大的选代次数。Early stopping便是一种提前结束训练的策略用来防止过拟合。
一般的做法是记录到目前为止最好的validation accuracy,当连续10个Epoch没有达到最佳accuracy时,则可以认为accuracy不再提高了。此时便可以停止迭代了(Early Stopping)。
3.Dropout

每次训练的时候,都会随机的去关闭一些神经元,关闭的意思并不是去掉,而是这些画虚线的神经元不参与训练。注意一般训练完,测试模型的时候,是使用所有神经元,不会进行dropout。
4.正则化
C0代表原始的代价函数,n代表样本的个数, λ \lambda λ就是正则项系数,权衡正则项与C0项的比重。
L1正则化:

L1正则化可以达到模型参数稀疏化的效果。
L2正则化:
L2正则化可以使得模型的权值衰减,使模型参数值都接近于0。

当 λ \lambda λ=0.001时,出现了过拟合现象,当 λ \lambda λ=0.01时,有较轻微的过拟合,当 λ \lambda λ=0.1的时候没有出现过拟合现象。
边栏推荐
- 【愚公系列】2022年7月 Go教学课程 006-自动推导类型和输入输出
- 【obs】Impossible to find entrance point CreateDirect3D11DeviceFromDXGIDevice
- Interface test advanced interface script use - apipost (pre / post execution script)
- v-for遍历元素样式失效
- SDNU_ACM_ICPC_2022_Summer_Practice(1~2)
- Solution to the problem of unserialize3 in the advanced web area of the attack and defense world
- ReentrantLock 公平锁源码 第0篇
- Basic principle and usage of dynamic library, -fpic option context
- 接口测试进阶接口脚本使用—apipost(预/后执行脚本)
- 51与蓝牙模块通讯,51驱动蓝牙APP点灯
猜你喜欢

基于人脸识别实现课堂抬头率检测

They gathered at the 2022 ecug con just for "China's technological power"

【笔记】常见组合滤波电路

接口测试要测试什么?

C language 001: download, install, create the first C project and execute the first C language program of CodeBlocks

51与蓝牙模块通讯,51驱动蓝牙APP点灯

New library online | cnopendata China Star Hotel data

How does the markdown editor of CSDN input mathematical formulas--- Latex syntax summary

华为交换机S5735S-L24T4S-QA2无法telnet远程访问

Jouer sonar
随机推荐
How to learn a new technology (programming language)
51与蓝牙模块通讯,51驱动蓝牙APP点灯
詹姆斯·格雷克《信息简史》读后感记录
Binder core API
Which securities company has a low, safe and reliable account opening commission
牛客基础语法必刷100题之基本类型
【愚公系列】2022年7月 Go教学课程 006-自动推导类型和输入输出
Installation and configuration of sublime Text3
What is load balancing? How does DNS achieve load balancing?
大二级分类产品页权重低,不收录怎么办?
语义分割模型库segmentation_models_pytorch的详细使用介绍
What if the testing process is not perfect and the development is not active?
[Yugong series] go teaching course 006 in July 2022 - automatic derivation of types and input and output
FOFA-攻防挑战记录
Deep dive kotlin collaboration (the end of 23): sharedflow and stateflow
取消select的默认样式的向下箭头和设置select默认字样
STL--String类的常用功能复写
Stock account opening is free of charge. Is it safe to open an account on your mobile phone
Introduction to paddle - using lenet to realize image classification method II in MNIST
QT adds resource files, adds icons for qaction, establishes signal slot functions, and implements