深度学习优化方法-AdaGrad

AdaGrad:自适应学习率下的梯度优化算法 在深度学习中,优化算法对于模型的收敛速度和性能起着至关重要的作用。AdaGrad是一种自适应学习率的梯度优化算法,它能够根据参数梯度的历史信息自适应地调整学习率,从而有效地解决了在训练过程中学习率衰减过快或过慢的问题。本文将深入介绍AdaGrad算法的原理、优势以及在深度学习中的应用。它在这些任务中都表现出了良好的优化效果,并被广泛应用于深度学习框架中,如TensorFlow和PyTorch等。在深度学习中的各个任务和模型中,AdaGrad已被广泛使用,并呈现出优秀的优化效果。 阅读详情

梯度下降算法、随机梯度下降算法(SGD)、小批量梯度下降算法(mini-batch SGD)、动量法(momentum)、Nesterov动量法有一个共同的特点是:对于每一个参数都用相同的学习率进行更新。
但是在实际应用中,各个参数的重要性肯定是不一样的,所以我们对于不同的参数要动态的采取不同的学习率,让目标函数更快的收敛。
AdaGrad算法就是将每一个参数的每一次迭代的梯度取平方累加后在开方,用全局学习率除以这个数,作为学习率的动态更新。
AdaGrad算法介绍

表示第i个参数的梯度,对于经典的SGD优化方法,参数θth的更新为:


再来看AdaGrad算法表示为:


其中,r为梯度累积变量,r的初始值为0。ε为全局学习率,需要自己设置。δ为小常数,为了数值稳定大约设置为。

AdaGrad算法分析

(1)从AdaGrad算法中可以看出,随着算法不断迭代,r会越来越大,整体的学习率会越来越小。所以,一般来说AdaGrad算法一开始是激励收敛,到了后面就慢慢变成惩罚收敛,速度越来越慢。

(2)在SGD中,随着梯度 的增大,我们的学习步长应该是增大的。但是在AdaGrad中,随着梯度g的增大,我们的r也在逐渐的增大,且在梯度更新时r在分母上,也就是整个学习率是减少的,这是为什么呢?
这是因为随着更新次数的增大,我们希望学习率越来越慢。因为我们认为在学习率的最初阶段,我们距离损失函数最优解还很远,随着更新次数的增加,越来越接近最优解,所以学习率也随之变慢。
(3)经验上已经发现,对于训练深度神经网络模型而言,从训练开始时积累梯度平方会导致有效学习率过早和过量的减小。AdaGrade在某些深度学习模型上效果不错,但不是全部。


Reference

【1】深度学习,Ian Goodfellow / Yoshua Bengio所著。

【2】深度学习优化函数详解(6)-- adagrad

【3】adagrad原理

AdaGrad优化器(理论、公式、代码实现) AdaGrad(Adaptive Gradient Algorithm)是一种自适应学习率的梯度下降算法,于2011年由Duchi等人提出。这个算法主要是为了解决标准的梯度下降算法中学习率一成不变的问题。在标准的梯度下降算法中,如果学习率过大,可能会导致算法在最小值附近震荡而不收敛;如果学习率过小,又会导致收敛速度过慢。AdaGrad算法通过自适应调整每个参数的学习率,尝试解决这个问题。 阅读详情

相关推荐

深度学习中的优化方法(Momentum,AdaGrad,RMSProp,Adam)详解及调用

深度学习中的优化方法(Momentum,AdaGrad,RMSProp,Adam)详解及调用

bbaaa123的博客 1823

深度学习中的优化算法之AdaGrad

之前在https://blog.youkuaiyun.com/fengbingchun/article/details/123955067 介绍过SGD(Mini-Batch Gradient Descent(MBGD),有时提到SGD的时候,其实指的是MBGD)。这里介绍下自适应梯度优化算法。 AdaGrad:全称Adaptive Gradient,自适应梯度,是梯度下降优化算法的扩展。AdaGrad是一种具有自适应学习率的梯度下降优化方法。它使参数的学习率自适应,对不频繁的参数执行较大的更...

网络资源是无限的 1万+

有史以来最小的GIF/png/jpg/jpeg

昨天我对图像进行了 base64 编码,这样我就可以将它发送到 CouchDB 以测试我正在为客户编写的一些代码。它让我想起了我之前在远程服务器上设置 cookie 时所做的事情。基本上,一个小的 PHP 脚本被放在远程服务器上,它接受几个 GET 参数并根据它们的值设置一些 cookie。然后脚本输出一个 1x1 的透明 GIF。本地服务器上的 PHP 脚本生成了一个 IMG 标签,该标签链接到该图像并根据本地服务器上的 COOKIES 设置参数。

凌凌1301的博客 1417

深度学习常见优化算法,图解AdaGrad、RMSProp,Adam

该优化算法在较为平缓处学习速率大,有比较高的学习效率,在陡峭处学习率小,在一定程度上可以避免越过极小值点。在SDG优化算法中不能自适应学习率,如图1所示,在函数的初始位置比较平缓,利用AdaGrad优化算法可以很快的到达较优点,而SGD几乎没有移动。如图2所示,初始位置比较陡峭,AdaGrad优化算法会自动调整学习率,然后顺利的到达最优点,而SGD在学习率比较大的情况下会在斜坡两边来回摆动。也就是说在当前梯度与之前梯度之间添加了权重,如果当前梯度的权重较大,那么响应速度也就更快。为常数,表示学习率。

鸥鹭忘机 5790

强化学习入门8—深入理解DDPG

本文是强化学习入门系列的第八篇,前面我们讲Actor-Critic时提到了DDPG。DDPG是google DeepMind团队提出的一种用于输出确定性动作的算法,它解决了Actor-Critic 神经网络每次参数更新前后都存在相关性,导致神经网络只能片面的看待问题这一缺点。同时也解决了DQN不能用于连续性动作的缺点。

小菜羊的博客 4318

BugkuCTF-PWN题pwn2-overflow超详细讲解

解题思路 1)计算出get_shell_的地址偏移量 2)算出来之后就直接溢出到后门函数 知识点 x64函数调用规则 解题之前我们先学下linux x64的函数调用规则。 x64机器在调用某个函数前,比如int func(int a, int b, int c, int d, int e, int f, int g, int h),首先他会把前6个参数从左往右存入到寄存器rdi、rsi、rdx、rcx、r8、r9,其余参数存入到栈里,保存的顺序是从右往左入栈。比如abcdef会存入到寄存器里,然后一次入栈h

am_03的博客 3014

【从零开始学习深度学习】40. 算法优化之AdaGrad算法介绍及其Pytorch实现

【从零开始学习深度学习】40. 算法优化之AdaGrad算法介绍及其Pytorch实现

阿旭的博客 2837

国产系统迁移实战:在银河麒麟V10上搞定Wine32位支持,让老Windows软件跑起来

本文详细介绍了在银河麒麟V10操作系统上构建Wine32位支持的全过程,帮助用户解决Windows应用迁移难题。从系统架构差异分析到Wine环境配置,再到实战应用部署与优化,提供了一套完整的解决方案,确保老Windows软件在国产系统上稳定运行。

weixin_32288959的博客 649

【DL】深度学习优化方法:SGD、SGDM、Adagrad、RMSProp、Adam

Gradient Descent 1. 算法框架 2. 理论原理 假设参数θ\thetaθ是二维的,损失函数在(a,b)(a,b)(a,b)处的一阶泰勒展开, L(θ)=L(a,b)+∂L(a,b)∂θ1(θ1−a)+∂L(a,b)∂θ2(θ2−b)+o(θ1−a)+o(θ2−b)L(\theta)=L(a,b)+\frac{\partial L(a,b)}{\partial \theta_1}...

Explore 3231

cuda安装时出现错误 Unable to locate package cuda-toolkit-12-4

cuda安装时出现错误 Unable to locate package cuda-toolkit-12-4

4870

基于改进YOLOv5的小目标检测 | 添加CBAM注意机制 + 更换Neck网络之BiFPN + 增加高分辨率检测头

本文针对图像中小目标难以检测的问题,提出了一种基于YOLOv5的改进模型。在主干网络中,加入CBAM注意力模块增强网络特征提取能力;在颈部网络部分,使用BiFPN结构替换PANet结构,强化底层特征利用;在检测头部分,增加高分辨率检测头,改善对于微小目标的检测能力。本文算法在无人机数据集VisDrone2019数据集上进行了多次对比实验,结果表明本文算法可以有效地检测小目标。🌈

小哥谈 2937

Deep Learning 最优化方法之AdaGrad

写在前面本文主要是对Deep Learning一书最优化方法的总结,具体详细的算法,另起博文展开。    整个优化系列文章列表: Deep Learning 之 最优化方法 Deep Learning 最优化方法之SGD Deep Learning 最优化方法之Momentum(动量) Deep Learning 最优化方法之Nesterov(牛顿动量)

wzy的博客 1578

【使用DeepSeek辅助Python接口性能自动化测试教程-实战教程】

访问DeepSeek官方网站,注册账号并获取API Key。此Key是调用DeepSeek API的必要凭证,务必妥善保管。安装时,注意勾选“Add Python to PATH”选项,以便系统能识别Python命令。确保你已安装Python 3.8或更高版本。会自动发现并执行所有以。

Dreams°的博客 2467

深度学习笔记:优化方法总结(BGD,SGD,Momentum,AdaGrad,RMSProp,Adam)

最近在看Google的Deep Learning一书,看到优化方法那一部分,正巧之前用tensorflow也是对那些优化方法一知半解的,所以看完后就整理了下放上来,主要是一阶的梯度法,包括SGD, Momentum, Nesterov Momentum, AdaGrad, RMSProp, Adam。 其中SGD,Momentum,Nesterov Momentum是手动指定学习速率的,而后面的Ad

Multiangle's Notepad 8万+

【YOLOv8全方位学习手册】第四章 数据增强:从扩充数据到塑造模型的认知边界

"""使用 Albumentations 做自定义增强,兼容 YOLO 格式"""])# 转成 numpy# boxes 必须是 [[x_min,y_min,x_max,y_max], ...]# 在数据加载时调用你可以把集成到 PyTorch 的 Dataset 类里,或使用 Ultralytics 自带的DataLoader。

VectorShift的博客 213

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

深度学习最全优化方法总结比较(SGD,Adagrad,Adadelta,Adam,Adamax,Nadam)

深度学习最全优化方法总结比较(SGD,Adagrad,Adadelta,Adam,Adamax,Nadam) ycszen Semantic Segmentation / changqianyu.me 1,652 人赞同了该文章 前言 (标题不能再中二了)本文仅对一些常见的优化方法进行直观介绍和简单的比...

weixin_30853329的博客 992

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

深度学习模型组件之优化器-自适应学习率优化方法(Adagrad、RMSprop)

在深度学习模型的训练过程中,选择合适的优化算法对于模型的收敛速度和性能至关重要。自适应学习率优化方法通过根据梯度信息动态调整学习率,能够更有效地处理稀疏数据和非平稳目标函数。本文将介绍两种常用的自适应学习率优化方法:Adagrad(Adaptive Gradient Algorithm)和RMSprop(Root Mean Square Propagation),并提供相应的代码示例。

404 Not Found 1408

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

主流的深度学习优化方法(SGD,SGDM,Adagrad,RMSProp,Adam)

0 前言 介绍主流的深度学习优化方法(SGD,SGD with Momentum,Adagrad,RMSProp,Adam),梯度优化的基本原则是起始的时候降得快,后来降的慢,以此原则来理解下面这些算法。理解不是非常深,有问题希望大家指出。 1 SGD 一般的梯度下降所用的损失函数会计算所有样本的损失,但是随机梯度下降比梯度下降多了随机两个字,也即用样本中的一个例子的损失值来代替整体的损失。 因而随机梯度下降是会带来一定的问题,因为计算得到的并不是准确的一个梯度。如下图,SGD是按照单个样本更新,所以前面几

双鸭山•克里菲斯•北方孤星之堕 5006

深度学习中的优化方法-AdaGrad

码字不易,转载请注明出处~ tags: optimizer;AdaGrad 本文来源于下面博客: https://medium.com/konvergen/an-introduction-to-adagrad-f130ae871827 前面讲到梯度下降法以及带动量的梯度下降法、NAG等,它们的一个共同的特点是都包含学习率η\etaη这个参数,而这个参数的选择属于超参数的范围。个人感觉超参数包含了两...

hanjiangxue_wei的博客 1024

深度学习中所使用的优化方法综述,包括SGD,Adagrad,Momentum,Adadelta等

优化算法

Tiger数学之家的博客 481
上一篇: 深度学习中Dropout原理解析
下一篇: 牛客网在线编程专题《剑指offer》(1)二维数组中的查找
Microstrong0305
Microstrong0305 领域专家: 算法与数据结构技术领域 领域专家: 算法与数据结构技术领域
博客等级 码龄12年 6405粉丝 312原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值