当前位置:网站首页>Machine Learning - Gradient Descent Optimization - C language implementation
Machine Learning - Gradient Descent Optimization - C language implementation
2022-07-30 05:59:00 【Jack Ju】
1.Introduction
Gradient descent is a method in optimization theory to find the best solution. The purpose is to use gradient descent to find the local minimum of a function.
This article will show you how to implement a gradient descent solver yourself based on the basic principles of gradient descent, focusing on how to do it.
2. Gradient Descent of Unary Functions
First of all, starting from a simple one, only considering the unary function, how do we implement the gradient descent method?
The optimization function is: f(x) = x^2-10x+1
Steps of gradient descent:
x(t+1) = x(t) - Y*df(x(t))/dx(t),
Calculate x(0),x(1),x(2),x(3),..., we can solve f(0), f(1), f(2), f(3), ... through f(x) = x^2-10x+1, when f(k+1)-f(k) is very small, and we think that x(k+1) is the solution we are looking for.
So for the optimization function: f(x) = x^2-10x+1, the iterative formula is:
x(k+1) = x(k) - Y*(2*x(k)-10), where Y is the learning rate, generally a number between 0-1.
The c language code for the implementation of this example is:
/* * Description:Gradient Descent Optimization * x(t+1) = x(t) - Y*df(x(t))/dx *f(x) = x^2-10x+1 */边栏推荐
猜你喜欢
随机推荐
This article will take you through js to deal with the addition, deletion, modification and inspection of tree structure data
文档在线化管理系统Confluce使用
nacos-2.0.3启动报错出现no datasource set的坑
丑陋的程序员
Nacos 原理
asyncawait和promise的区别
leetcode hot 100(刷题篇11)(231/235/237/238/292/557/240/36)offer/3/4/5
路径依赖:穷人很难逆袭突破的科学道理
MySQL基础(DDL、DML、DQL)
排列数字(DAY90)dfs
分布式事务之 Atomikos 原理和使用(一)
Mysql8.+学习笔记
上交所行情文件解析之mktdt04
CSDN Meetup 回顾 丨从数据湖到指标中台,提升数据分析 ROI
MySQL(4)
成绩排序(华中科技大学考研机试题)(DAY 87)
MySql字符串拆分实现split功能(字段分割转列、转行)
MySql的初识感悟,以及sql语句中的DDL和DML和DQL的基本语法
[Mysql] CONVERT函数
微信小程序开发学习









![[Redis Master Cultivation Road] Jedis - the basic use of Jedis](/img/e3/0c6efd03432a01f857796f0bf648ef.png)