Coursera | Andrew Ng (02-week-2-2.5)— 指数加权平均的偏差修正

该系列仅在原课程基础上部分知识点添加个人学习笔记,或相关推导补充等。如有错误,还请批评指教。在学习了 Andrew Ng 课程的基础上,为了更方便的查阅复习,将其整理成文字。因本人一直在学习英语,所以该系列以英文为主,同时也建议读者以英文为主,中文辅助,以便后期进阶时,为学习相关领域的学术论文做铺垫。- ZJ

Coursera 课程 |deeplearning.ai |网易云课堂


转载请注明作者和出处:ZJ 微信公众号-「SelfImprovementLab」

知乎https://zhuanlan.zhihu.com/c_147249273

CSDNhttp://blog.csdn.net/JUNJUN_ZHAO/article/details/79099040


2.5 Bias correction in Exponentially weighted averages (指数加权平均的偏差修正)

(字幕来源:网易云课堂)

这里写图片描述

You’ve learned how to implement exponentially weighted averages.There’s one technical detail called bias correction that can make you computation of these averages more accurately.Let’s see how that works.In a previous video, you saw this figure for beta = 0.9.This figure for beta = 0.98.But it turns out that if you implement the formula as written here,you won’t actually get the green curve when, say, beta = 0.98.You actually get the purple curve here.And you notice that the purple curve starts off really low.So let’s see how to fix that.When you’re implementing a moving average,you initialize it with v0 = 0,and then v1 = 0.98 V0 + 0.02 data 1.But V0 is equal to 0 so that term just goes away.So V1 is just 0.02 times data 1.So that’s why if the first day’s temperature is, say 40 degrees Fahrenheit,then v1 will be 0.02 times 40, which is 8.So you get a much lower value down here.

这里写图片描述

你学过了如何计算指数加权平均数,有一个技术名词叫做偏差修正,可以让平均数运算更加准确,来看看它是怎么运作的,在上个视频中这个曲线对应 β 的值为 0.9,这个曲线对应的 β = 0.98,如果你执行写在这里的公式,在 β 等于 0.98 的时候 得到的并不是绿色曲线,而是紫色曲线,你可以注意到紫色曲线的起点较低,我们来看看怎么处理,计算移动平均数的时候,初始化 v0 = 0, v1 = 0.98 * v0 + 0.02 乘以1号数据,但是 v0 = 0 所以这部分没有了,所以 v1 等于 0.02 乘以 1 号数据,所以如果第一天温度是 40 华氏度,那么 v1 就是 0.02 乘以 40 也就是 8,因此得到的值会小很多,所以第一天温度的估测不准。

So it’s not a very good estimate of the first day’s temperature. v2 will be 0.98 times v1 + 0.02 times data 2.And if you plug in v1, which is this down here and multiply it out,then you find that v2 is actually equal to 0.98 times 0.02 times data 1plus 0.02 times data 2.And that 0.0 196 data1 + 0.02 data2.So again, assuming data1 and data2 are positive numbers,when you compute this v2 will be much less than data1 or data2.So v2 isn’t a very good estimate of the first two days’ temperature of the year.So it turns out that there is a way to modify this estimate that makes it much better, that makes it more accurate,especially during this initial phase of your estimate.

这里写图片描述

v2 等于 0.98 乘以 v1 加上 0.02 乘以 2 号数据,如果代入 v1 然后相乘,所以 v2 = 0.98 * 0.02 乘以1号数据,加上 0.02 乘上2号数据,也就是 0.0196 乘以 1 号数据加上 0.02 乘上 2 号数据,假设 1 号和 2 号数据都是正数,计算后 v2 要远小于 1 号和 2 号数据,所以 v2 不能很好估测出这一年前两天的温度有个办法可以修改这一估测,让估测变得更好 更准确,特别是在估测初期

Which is that, instead of taking vt , take vt divided by 1-Beta to the power of t where t is the current day you’re on.So let’s take a concrete example.When t = 2, 1- beta to the power of t is1- 0.98 squaredand it urns out that this is 0.0396.And so your estimate of the temperature on day 2becomes v2 divided by 0.0396 andthis is going to be 0.0196 times data 1 + 0.02 data 2.You notice that these two things adds up to the denominator 0.0396.And so this becomes a weighted average of data 1 and data 2,and this removes this bias.So you notice that as t becomes large,beta to the t will approach 0which is why when t is large enough,the bias correction makes almost no difference.This is why when t is large,the purple line and the green, line they are much over that.But during this initial phase of learning when you’re still warming up your estimates when the bias correction can help you to obtain a better estimate of this temperature.And it is this bias correction that helps yougo from the purple line to the green line.

这里写图片描述

也就是不用 vt 而是用 vt 除以( 1βt ),t 就是现在的天数,举个具体例子,当 t = 2 时 1βt ,也就是 10.982 ,答案是0.0396,因此对第二天温度的估测,变成了 v2 除以 0.0396,也就是 0.0196 乘以 1 号数据加上 0.02 乘以 2 号数据,然后二者相加 分母为 0.0396,这也就是 1 号和 2 号数据的加权平均数,并去除了偏差,你会发现随着 t 增加,β 的 t 次方将接近于 0,所以当 t 很大的时候,偏差修正几乎没有作用,因此当t较大的时候,紫线基本和绿线重合了。不过在开始学习阶段,你才开始预测热身练习,偏差修正可以帮助你更好预测温度,偏差修正可以帮助你,使结果从紫线变成绿线。

So in machine learning,for most implementations of the exponential weighted average,people don’t often bother to implement bias corrections.Because most people would rather just wait that initial period and have a slightly more biased estimate and go from there.But if you are concerned about the bias during this initial phase,while your exponentially weighted moving average is still warming up.Then bias correction can help you get a better estimate early on.So you now know how to implement exponentially weighted moving averages.Let’s go on and use this to build some better optimization algorithms.

在机器学习中,在计算指数加权平均数的大部分时候,大家不在乎执行偏差修正,因为大部分人宁愿熬过初始时期,拿到具有偏差的估测 然后继续计算下去,如果你关心初始时期的偏差,在刚开始计算指数加权移动平均数的时候,偏差修正能帮助你在早期获得更好的估测,所以你学会了计算指数加权移动平均数,我们接着就用它来构建更好的优化算法吧!


重点总结:

指数加权平均的偏差修正

在我们执行指数加权平均的公式时,当 β=0.98 时,我们得到的并不是图中的绿色曲线,而是下图中的紫色曲线,其起点比较低。

这里写图片描述

  • 原因:

v0=0v1=0.98v0+0.02θ1=0.02θ1v2=0.98v1+0.02θ2=0.98×0.02θ1+0.02θ2=0.0196θ1+0.02θ2

如果第一天的值为如40,则得到的 v1=0.02×40=8 ,则得到的值要远小于实际值,后面几天的情况也会由于初值引起的影响,均低于实际均值。

  • 偏差修正:

使用: vt1βt

当 t=2 时:

1βt=1(0.98)2=0.0396

v20.0396=0.0196θ1+0.02θ20.0396

偏差修正得到了绿色的曲线,在开始的时候,能够得到比紫色曲线更好的计算平均的效果。随着 t 逐渐增大, βt 接近于 0,所以后面绿色的曲线和紫色的曲线逐渐重合了。

虽然存在这种问题,但是在实际过程中,一般会忽略前期均值偏差的影响。

参考文献:

[1]. 大树先生.吴恩达Coursera深度学习课程 DeepLearning.ai 提炼笔记(2-2)– 优化算法


PS: 欢迎扫码关注公众号:「SelfImprovementLab」!专注「深度学习」,「机器学习」,「人工智能」。以及 「早起」,「阅读」,「运动」,「英语 」「其他」不定期建群 打卡互助活动。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
### 回答1: Coursera-ml-andrewng-notes-master.zip是一个包含Andrew Ng的机器学习课程笔记和代码的压缩包。这门课程是由斯坦福大学提供的计算机科学和人工智能实验室(CSAIL)的教授Andrew Ng教授开设的,旨在通过深入浅出的方式介绍机器学习的基础概念,包括监督学习、无监督学习、逻辑回归、神经网络等等。 这个压缩包中的笔记和代码可以帮助机器学习初学者更好地理解和应用所学的知识。笔记中包含了课程中涉及到的各种公式、算法和概念的详细解释,同时也包括了编程作业的指导和解答。而代码部分包含了课程中使用的MATLAB代码,以及Python代码的实现。 这个压缩包对机器学习爱好者和学生来说是一个非常有用的资源,能够让他们深入了解机器学习的基础,并掌握如何运用这些知识去解决实际问题。此外,这个压缩包还可以作为教师和讲师的教学资源,帮助他们更好地传授机器学习的知识和技能。 ### 回答2: coursera-ml-andrewng-notes-master.zip 是一个 Coursera Machine Learning 课程的笔记和教材的压缩包,由学生或者讲师编写。这个压缩包中包括了 Andrew Ng 教授在 Coursera 上发布的 Machine Learning 课程的全部讲义、练习题和答案等相关学习材料。 Machine Learning 课程是一个介绍机器学习的课程,它包括了许多重要的机器学习算法和理论,例如线性回归、神经网络、决策树、支持向量机等。这个课程的目标是让学生了解机器学习的方法,学习如何使用机器学习来解决实际问题,并最终构建自己的机器学习系统。 这个压缩包中包含的所有学习材料都是免费的,每个人都可以从 Coursera 的网站上免费获取。通过学习这个课程,你将学习到机器学习的基础知识和核心算法,掌握机器学习的实际应用技巧,以及学会如何处理不同种类的数据和问题。 总之,coursera-ml-andrewng-notes-master.zip 是一个非常有用的学习资源,它可以帮助人们更好地学习、理解和掌握机器学习的知识和技能。无论你是机器学习初学者还是资深的机器学习专家,它都将是一个重要的参考工具。 ### 回答3: coursera-ml-andrewng-notes-master.zip是一份具有高价值的文件,其中包含了Andrew NgCoursera上开授的机器学习课程的笔记。这份课程笔记可以帮助学习者更好地理解掌握机器学习技术和方法,提高在机器学习领域的实践能力。通过这份文件,学习者可以学习到机器学习的算法、原理和应用,其中包括线性回归、逻辑回归、神经网络、支持向量机、聚类、降维等多个内容。同时,这份笔记还提供了很多代码实现和模板,学习者可以通过这些实例来理解、运用和进一步深入研究机器学习技术。 总的来说,coursera-ml-andrewng-notes-master.zip对于想要深入学习和掌握机器学习技术和方法的学习者来说是一份不可多得的资料,对于企业中从事机器学习相关工作的从业人员来说也是进行技能提升或者知识更新的重要资料。因此,对于机器学习领域的学习者和从业人员来说,学习并掌握coursera-ml-andrewng-notes-master.zip所提供的知识和技能是非常有价值的。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值