当前位置:网站首页>对L1正则化和L2正则化的理解[通俗易懂]
对L1正则化和L2正则化的理解[通俗易懂]
2022-07-27 18:59:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
一、 奥卡姆剃刀(Occam’s razor)原理:
在所有可能选择的模型中,我们应选择能够很好的解释数据,并且十分简单的模型。从贝叶斯的角度来看,正则项对应于模型的先验概率。可以假设复杂模型有较小的先验概率,简单模型有较大的先验概率。
二、正则化项
2.1、什么是正则化?
正则化是结构风险最小化策略的实现,在经验风险上加一个正则项或罚项,正则项一共有两种L1正则化和L2正则化,或者L1范数和L2范数。对于线性回归模型,使用L1正则化的模型叫做Lasso回归;使用L2正则化的模型叫做Ridge回归(岭回归)
2.2、正则化项和模型复杂度之间的关系
正则化项一般是模型复杂度的单调递增的函数,模型越复杂,正则化值越大。
一般来说,监督学习可以看做最小化下面的目标函数:
上式中的第1项为经验风险,即模型f(x)关于训练数据集的平均损失;第2项为正则化项,去约束我们的模型更加简单
三、L1范数
3.1概念: L1范数是指向量中各个元素绝对值之和。
3.2 为什么L1范数会使权值稀疏?
任何的正则化算子,如果他在Wi=0的地方不可微,并且可以分解为“求和” 的形式,那么这个正则化算子就可以实现稀疏。
3.3 参数稀疏有什么好处?
(1)特征选择(Feature Selection)
参数稀疏规则化能够实现特征的自动选择,在特征工程的过程中,一般来说,xi的大部分元素(特征)都和其标签yi没有关系的。我们在最小化目标函数的时候,考虑了这些无关特征,虽然可以获得最小的训练误差,但是对于新的样本时,这些没用的信息反而被考虑,干扰了对样本的预测。稀疏规则化将这些没用的特征的权重置为0,去掉这些没用的特征。
(2)可解释性
将无关特征置为0,模型更容易解释。例如:患某种病的概率为y,我们收集到的数据x是1000维的,我们的任务是寻找这1000种因素是如何影响患上这种病的概率。假设,我们有一个回归模型:y=w1*x1+w2*x2+…+w1000*x1000+b,通过学习,我们最后学习到w*只有很少的非零元素。例如只有5个非零的w*,那么这5个w*含有患上这种病的关键信息。也就是说,是否患上这种病和这5个特征相关,那事情变得容易处理多了。
四、L2范数
4.1 概念:L2范数是指向量各元素的平方和然后再求平方根。
正则化项可以取不同的形式。对于回归问题中,损失函数是平方损失,正则化项为参数向量L2的范数。
4.2 为什么L2范数可以防止过拟合?
左一:欠拟合;中间:正常拟合;右侧:过拟合
线性回归拟合图
让L2范数的正则项||W||2最小,可以使得W的每个元素都很小,都接近于0。(L1范数让W等于0),而越小的参数说明模型越简单,越简单的模型越不容易产生过拟合的现象。(结合上图线性回归拟合图可知,限制了某些参数很小,其实也就限制了多项式的某些分量的影响很小,这也就相当于减少了变量的个数)
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/128182.html原文链接:https://javaforall.cn
边栏推荐
- Unity installs personal free edition
- Knife4j dynamically refreshes global parameters through JS
- MySQL back to table, SQL optimization, four isolation levels, three logs binlog, redo log, undo log
- The dplyr package of R language performs aggregation transformations of data packets and calculates the sum of packets of dataframe data
- Understand the communication mode of transmission media
- Second uncle, why is it so hot?
- [what subjects does Huawei hcie security test? What knowledge points does Huawei hcie security test have?]
- Comprehensively design an oppe home page -- the style of the search and oper part of the page
- Chinese and English instructions - human alpha fetoprotein (AFP) ELISA quantitative Kit
- LabVIEW learning note 5: you cannot return to the original state after pressing the button
猜你喜欢

Unity installs personal free edition

Win11 widget prompts how to solve the error when loading this content?

图解 SQL,这也太形象了吧!

MAPGIS 3D scene rendering technology and Application

Dual process theory and triple mental model

基于DSP 回传音通话降噪链路设计

多人协作开发规范

Force buckle 919. Complete binary tree inserter
![论文赏析[AAAI18]面向序列建模的元多任务学习](/img/2b/345b5a287fcd9c9b1a86ae683f124b.png)
论文赏析[AAAI18]面向序列建模的元多任务学习

Leetcode daily practice - the penultimate node in the linked list
随机推荐
Thesis appreciation [emnlp18] uses sequence tagging for component parsing
Implicit intent
Postgresql源码(65)新快照体系Globalvis工作原理分析
The maximum recommended number of rows for MySQL is 2000W. Is it reliable?
Custom learning rate
LabVIEW learning note 9: capture the "value change" event generated by the program modifying the control value
Leetcode daily practice 206. Reverse the linked list
Pytest failed and rerun
puzzle(021)消除问题
Process management process monitoring and management ps/pstree/top/lsof
30分钟彻底弄懂 synchronized 锁升级过程
One of IOU target tracking: IOU tracker
多人协作开发规范
综合设计一个OPPE主页--页面的搜素欧珀部分的样式
CBAM学习笔记
Worthington毒液中核酸外切酶的特征及相关文献
ECCV 2022 | China University of science and Technology & jd.com proposed: data efficient transformer target detector
zibbix安装部署
监听服务器jar运行,及重启脚本
Summary of common methods and attributes of arrays and strings in JS