当前位置:网站首页>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 */边栏推荐
猜你喜欢

无代码开发平台子管理员入门教程

Programmers care guide, give yourself a chance to make the occasional relaxation of body and mind

IDEA的database使用教程(使用mysql数据库)

JVM面试总结

An old programmer's summary review of 2020, how to become more awesome in 2021

无代码开发平台重新申请入门教程

【图像处理】基于中轴变换实现图像骨架提取附matlab代码

使用DataEase开源工具制作一个高质量的数据大屏

429. N 叉树的层序遍历(两种解法)

mysql 中 in 的用法
随机推荐
《后浪》程序员版,献给新一代程序员的演讲,何冰《后浪》演讲模仿秀
Concurrent Programming Review
子查询作为检索表时的不同使用场景以及是否需要添加别名的问题
分布式事务之 Seata框架的原理和实战使用(三)
asyncawait和promise的区别
Internet (software) company project management software research report
22-07-29 西安 分布式事务、Seata
cnpm安装步骤
MySQL夺命10问,你能坚持到第几问?
2022 Pengcheng Cup web
剑指offer(刷题篇12)
从底层结构开始学习FPGA(6)----分布式RAM(DRAM,Distributed RAM)
CISP-PTE真题演示
Golang——从入门到放弃
curl (7) Failed connect to localhost8080; Connection refused
JVM之GC 调优基础知识(一)
MySQL - 函数及约束命令
[Mysql] CONVERT函数
[GStreamer] 插件的名字要和GST_PLUGIN_DEFINE匹配
MySQL - Function and Constraint Commands