in my impression, the gradient descent is for finding the independent variable that can get the minimum/maximum value of an objective function. So we need an obj. function: \(\mathcal{L}\)

  • an obj. function: \(\mathcal{L}\)
  • The gradient of \(\mathcal{L}: 2x+2\)
  • \(\Delta x\) , The value of idependent variable needs to be updated: \(x \leftarrow x+\Delta x\)

1. the \(\mathcal{L}\) is a context function: \(f(x)=x^2+2x+1\)

how to find the \(x_0\) that makes the \(f(x)\) has the minimum value, via gradient descent?

Start with an arbitrary \(x\), calculate the value of \(f(x)\) :

import random
def func(x):
return x*x + 2*x +1
def gred(x): # the gradient of f(x)
return 2*x + 2 x = random.uniform(-10.0,10.0) #randomly pick a float in interval of (-10, 10)
# x = 10
print('x starts at:', x) y0 = func(x) #first cal
delta = 0.5 #the value of delta_x, each iteration
x = x + delta # === interation ===
for i in range(100):
print('i=',i)
y1 = func(x)
delta = -0.08*gred(x)
print(' delta=',delta)
if y1 > y0:
print(' y1>y0')
# if gred(x) is positive, the x should decrease.
# if gred(x) is negative, the x should increase.
else:
print(' y1<=y0')
# if gred(x) is positive, the x should increase.
# if gred(x) is negative, the x should decrease.
x = x+delta
y0 = y1
print(' x=', x, 'f(x)=', y1)

Let's disscuss how to determin the some_value in the psudo code above.

if \(y_1-y_0\) has a large positive difference, i.e. \(y1 >> y0\), the x should shift backward heavily. so the some_value can be a ratio of \((y_1-y_0)\times(-gradient)\) , Let's say, some_value: \(\lambda = r \times\) gred(x) , here, \(r=0.08\) is the step-size.

The basic gradient descent has many shortcomings which can be found by search the 'shortcoming of gd'.

Another problem of GD algorithm is , What if the \(\mathcal{L}\) does not have explicit expression of its gradient?

Stochastic Gradient Descent(SGD) is another GD algorithm.

The component and implementation of a basic gradient descent in python的更多相关文章

  1. (转)Introduction to Gradient Descent Algorithm (along with variants) in Machine Learning

    Introduction Optimization is always the ultimate goal whether you are dealing with a real life probl ...

  2. Logistic Regression and Gradient Descent

    Logistic Regression and Gradient Descent Logistic regression is an excellent tool to know for classi ...

  3. (转) An overview of gradient descent optimization algorithms

    An overview of gradient descent optimization algorithms Table of contents: Gradient descent variants ...

  4. 机器学习-随机梯度下降(Stochastic gradient descent)

    sklearn实战-乳腺癌细胞数据挖掘(博主亲自录制视频) https://study.163.com/course/introduction.htm?courseId=1005269003& ...

  5. An overview of gradient descent optimization algorithms

    原文地址:An overview of gradient descent optimization algorithms An overview of gradient descent optimiz ...

  6. 机器学习数学基础- gradient descent算法(上)

    为什么要了解点数学基础 学习大数据分布式计算时多少会涉及到机器学习的算法,所以理解一些机器学习基础,有助于理解大数据分布式计算系统(比如spark)的设计.机器学习中一个常见的就是gradient d ...

  7. flink 批量梯度下降算法线性回归参数求解(Linear Regression with BGD(batch gradient descent) )

    1.线性回归 假设线性函数如下: 假设我们有10个样本x1,y1),(x2,y2).....(x10,y10),求解目标就是根据多个样本求解theta0和theta1的最优值. 什么样的θ最好的呢?最 ...

  8. 梯度下降(Gradient Descent)小结

    在求解机器学习算法的模型参数,即无约束优化问题时,梯度下降(Gradient Descent)是最常采用的方法之一,另一种常用的方法是最小二乘法.这里就对梯度下降法做一个完整的总结. 1. 梯度 在微 ...

  9. 机器学习基础——梯度下降法(Gradient Descent)

    机器学习基础--梯度下降法(Gradient Descent) 看了coursea的机器学习课,知道了梯度下降法.一开始只是对其做了下简单的了解.随着内容的深入,发现梯度下降法在很多算法中都用的到,除 ...

随机推荐

  1. Hibernate5.3 + mysql8.0遇到的问题

    今天学习Hibernate看的是旧版本的视频Hibernate4.0版本 遇到几个新旧版本的区别. 1.方言,这个是因为SQL不是因为Hibernate 新版方言 2.将编译的类配置进congifur ...

  2. mininet的学习之三----------mininet中流表应用实战

    我们看的同一个视频,工整的整理见以下网址 https://blog.csdn.net/weixin_36372879/article/details/86371583#commentBox

  3. SDL中 so库的使用

    用到的项目:Tocy-Android-SDLv2 JAVA层:只有一个 SDLActivity.java 路径\Android-SDLv2\src\org\libsdl\app 项目简单分析: 默认在 ...

  4. ECharts 从后台动态获取数据 (asp.net)

    (一) 使用工具 visual studio 2017:Web开发:asp.net (代码中的js引用路径以及ajax方法调用的url,记得修改哦) (二) 准备工作(此处写给和我一样小白) 1.动态 ...

  5. FlexRay通信机制

    通信周期是 FlexRay 的基本通信单元[6~7,19].每个通信周期包括四个时间层,如图 2-9 所示.通信周期由静态段(Static Segment).动态段(Dynamic Segment). ...

  6. Http数据协商

    一.定义: 客户端发送给服务端请求的时候,声明拿到的数据格式以及相关的限制.服务端根据请求做出判断,返回相应的数据. 二.分类 1.请求 Accept : 想要的的数据类型 Accept-Encodi ...

  7. 1、IT人思维之投资开篇 - IT人思维之投资

    在IT圈中,很多人的认识就只在于工作中获取收益,这个观点是狭隘的,本身就不符合投资领域的内容.所以,在工作之余,笔者就对投资领域的内容进行的分析和收集整理相关的投资方面的内容,一方面对笔者自己的投资方 ...

  8. Kafka win10下启动

     启动kafka之前先要启动zookeeper,而kafka里面时自带有zookeeper的,建议独立部署一套zookeeper服务,kafka下的zookeeper启动命令: zookeeper-s ...

  9. Base64字符 转图片乱码问题

    网站做了个随机验证码图片功能,遇到了一个奇怪的问题——Base64字符集转图片乱码问题,问题描述如下 1.用java画笔将随机验证码绘制成图片 2.再将图片的二进制代码转换成Base64字符集,返回给 ...

  10. Eclipse上传项目到Git

    转载自:http://blog.csdn.net/fan510988896/article/details/56277822 Git有和Svn类似的功能. 我们想使用Eclipse上传项目到自己的Gi ...