深度学习 Deep Learning UFLDL 最新Tutorial 学习笔记 4:Debugging: Gradient Checking
1 Gradient Checking 说明
2 代码实现
% 说明:grad_check 參数
% fun为函数
% num_checks 检查次数
% varagin为參数列 var1,var2,var3...这个varagin必须放在function最后一个项
function average_error = grad_check(fun, theta0, num_checks, varargin) delta=1e-3;
sum_error=0; fprintf(' Iter i err');
fprintf(' g_est g f\n') for i=1:num_checks
T = theta0;
j = randsample(numel(T),1);
T0=T; T0(j) = T0(j)-delta;
T1=T; T1(j) = T1(j)+delta; [f,g] = fun(T, varargin{:}); %因为fun是linear_regression或logistic_regression
f0 = fun(T0, varargin{:}); %所以这里的varagin{:}參数为train.X,train.y
f1 = fun(T1, varargin{:}); g_est = (f1-f0) / (2*delta);
error = abs(g(j) - g_est); fprintf('% 5d % 6d % 15g % 15f % 15f % 15f\n', ...
i,j,error,g(j),g_est,f); sum_error = sum_error + error;
end average_error =sum_error/num_checks;
那么在使用中。比方在ex1a_linreg.m中,能够这样使用:
% Gradient Check
average_error = grad_check(@linear_regression_vec,theta,50,train.X,train.y);
fprintf('Average error :%f\n',average_error);
【本文为原创文章。转载请注明出处:blog.csdn.net/songrotek 欢迎交流哦QQ:363523441】
深度学习 Deep Learning UFLDL 最新Tutorial 学习笔记 4:Debugging: Gradient Checking的更多相关文章
- 深度学习 Deep Learning UFLDL 最新 Tutorial 学习笔记 1:Linear Regression
1 前言 Andrew Ng的UFLDL在2014年9月底更新了. 对于開始研究Deep Learning的童鞋们来说这真的是极大的好消息! 新的Tutorial相比旧的Tutorial添加了Conv ...
- 深度学习 Deep Learning UFLDL 最新Tutorial 学习笔记 5:Softmax Regression
Softmax Regression Tutorial地址:http://ufldl.stanford.edu/tutorial/supervised/SoftmaxRegression/ 从本节開始 ...
- 深度学习 Deep Learning UFLDL 最新Tutorial 学习笔记 3:Vectorization
1 Vectorization 简述 Vectorization 翻译过来就是向量化,各简单的理解就是实现矩阵计算. 为什么MATLAB叫MATLAB?大概就是Matrix Lab,最根本的差别于其它 ...
- 【深度学习Deep Learning】资料大全
最近在学深度学习相关的东西,在网上搜集到了一些不错的资料,现在汇总一下: Free Online Books by Yoshua Bengio, Ian Goodfellow and Aaron C ...
- 机器学习(Machine Learning)&深度学习(Deep Learning)资料【转】
转自:机器学习(Machine Learning)&深度学习(Deep Learning)资料 <Brief History of Machine Learning> 介绍:这是一 ...
- 机器学习(Machine Learning)&深度学习(Deep Learning)资料
机器学习(Machine Learning)&深度学习(Deep Learning)资料 機器學習.深度學習方面不錯的資料,轉載. 原作:https://github.com/ty4z2008 ...
- 机器学习(Machine Learning)&深度学习(Deep Learning)资料(Chapter 2)
##机器学习(Machine Learning)&深度学习(Deep Learning)资料(Chapter 2)---#####注:机器学习资料[篇目一](https://github.co ...
- 机器学习——深度学习(Deep Learning)
Deep Learning是机器学习中一个非常接近AI的领域,其动机在于建立.模拟人脑进行分析学习的神经网络,近期研究了机器学习中一些深度学习的相关知识,本文给出一些非常实用的资料和心得. Key W ...
- (转)深度学习(Deep Learning, DL)的相关资料总结
from:http://blog.sciencenet.cn/blog-830496-679604.html 深度学习(Deep Learning,DL)的相关资料总结 有人认为DL是人工智能的一场革 ...
随机推荐
- 轻松八步搞定Cacti配置安装(原创视频)
轻松八步搞定Cacti配置安装 1.安装web server $sudo apt-get install apache2 验证 http://localhost 2.$sudo apt-get ins ...
- iOS QQ第三方登实现
我们常常会见到应用登陆的时候会有QQ,微信,微博等的第三方登陆 如图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbHdqb2syMDA3/font/5 ...
- [翻译]魅族的M1 Note是十分廉价(dirt-cheap)的iphone5C增强版
Meizu's M1 Note is a dirt-cheap iPhone 5c on steroids 魅族的M1 Note是十分廉价(dirt-cheap)的ihone5C增强版 While m ...
- Problem C: Celebrity Split
题目描写叙述 Problem C: Celebrity Split Jack and Jill have decided to separate and divide their property e ...
- BASH 文本模版的简单实现 micro_template_compile
详细代码 ############################### # # Funciton: micro_template_compile # # Parameter: # [1] => ...
- 相似group by的分组计数功能
之前同事发过一个语句,实现的功能比較简单,相似group by的分组计数功能,由于where条件有like,又无法用group by来实现. SELECT a.N0,b.N1,c.N2,d.N3,e. ...
- 在VS中设置比较和谐的字体和颜色的方法
作者:朱金灿 来源:http://blog.csdn.net/clever101 先在studiostyl.es网站选择你喜欢的字体方案,我个人比较喜欢这款: Humane Studio,注意在网页上 ...
- Android 在滚动列表中实现视频的播放(ListView & RecyclerView)
这片文章基于开源项目: VideoPlayerManager. 所有的代码和示例都在那里.本文将跳过许多东西.因此如果你要真正理解它是如何工作的,最好下载源码,并结合源代码一起阅读本文.但是即便是没有 ...
- Codefroces Round#427 div2
A. Key races time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- 关于EJB--实体Bean的BMP和CMP选择
EJB有两种主要类型BMP(Bean managed persistence )和CMP(Container managed persistence ),这两种类型各有优缺点. BMP是在Bean中完 ...