美文网首页
梯度下降

梯度下降

作者: 刷刷人工智能 | 来源:发表于2016-12-22 17:50 被阅读23次

Gradient Descent

So we have our hypothesis function and we have a way of measuring how well it fits into the data. Now we need to estimate the parameters in the hypothesis function. That's where gradient descent comes in.

Imagine that we graph our hypothesis function based on its fieldsθ0andθ1(actually we are graphing the cost function as a function of the parameter estimates). We are not graphing x and y itself, but the parameter range of our hypothesis function and the cost resulting from selecting a particular set of parameters.

We putθ0on the x axis andθ1on the y axis, with the cost function on the vertical z axis. The points on our graph will be the result of the cost function using our hypothesis with those specific theta parameters. The graph below depicts such a setup.

We will know that we have succeeded when our cost function is at the very bottom of the pits in our graph, i.e. when its value is the minimum. The red arrows show the minimum points in the graph.

The way we do this is by taking the derivative (the tangential line to a function) of our cost function. The slope of the tangent is the derivative at that point and it will give us a direction to move towards. We make steps down the cost function in the direction with the steepest descent. The size of each step is determined by the parameter α, which is called the learning rate.

For example, the distance between each 'star' in the graph above represents a step determined by our parameter α. A smaller α would result in a smaller step and a larger α results in a larger step. The direction in which the step is taken is determined by the partial derivative ofJ(θ0,θ1). Depending on where one starts on the graph, one could end up at different points. The image above shows us two different starting points that end up in two different places.

The gradient descent algorithm is:

repeat until convergence:

θj:=θj−α∂∂θjJ(θ0,θ1)

where

j=0,1 represents the feature index number.

At each iteration j, one should simultaneously update the parametersθ1,θ2,...,θn. Updating a specific parameter prior to calculating another one on thej(th)iteration would yield to a wrong implementation.

相关文章

  • (三)线性回归--梯度下降

    一、梯度下降 二、代码的实现 (一.梯度下降) 导包 构建数据 梯度下降 使用梯度下降,可视化 (二。梯度下降矩阵...

  • 神经网络优化2

    梯度下降 梯度下降法 批梯度下降法(Batch Gradient Descent,BGD)是最常用的梯度下降形式,...

  • 深入浅出--梯度下降法及其实现

    梯度下降的场景假设梯度梯度下降算法的数学解释梯度下降算法的实例梯度下降算法的实现Further reading 本...

  • 机器学习-常用优化方法

    一阶方法:梯度下降、随机梯度下降、mini 随机梯度下降降法。 随机梯度下降不但速度上比原始梯度下降要快,局部最优...

  • ML-梯度下降代码-线性回归为例

    梯度下降代码线性回归为例 bgd 批量梯度下降 sbd 随机梯度下降 mbfd 小批量随机梯度下降

  • 2020-08-19--梯度下降法01

    梯度下降法简介 多元线性回归中的梯度下降法 随机梯度下降法 梯度下降法 的调试 1.梯度下降法简介 不是一个机器学...

  • 机器学习笔记(六)—— 梯度下降

    梯度下降 批量梯度下降(Batch Gradient Descent,BGD) 批量梯度下降法是最原始的形式,它是...

  • 更新权重的方式

    1、SGD 梯度下降(收敛最慢稳定) 梯度下降:+=- * d J() 批量梯度下降:将数据集切分为多批次, 分别...

  • 随机梯度下降法与批量梯度下降法的区别

    批量梯度下降法(batch gradient decent)就是我们平时所说的梯度下降,也就是梯度下降过程中,每次...

  • 梯度下降算法

    1. 三种梯度下降算法: Batch Gradient Descent: 全部样本梯度下降一次,批梯度下降每次更新...

网友评论

      本文标题:梯度下降

      本文链接:https://www.haomeiwen.com/subject/hkdhvttx.html