• 大小: 11MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-14
  • 语言: Matlab
  • 标签:

资源简介

深度学习模型-稀疏自编码matlab算法,内带数据集可直接运行。

资源截图

代码片段和文件信息

function [] = checkNumericalGradient()
% This code can be used to check your numerical gradient implementation 
% in computeNumericalGradient.m
% It analytically evaluates the gradient of a very simple function called
% simpleQuadraticFunction (see below) and compares the result with your numerical
% solution. Your numerical gradient implementation is incorrect if
% your numerical solution deviates too much from the analytical solution.
  
% Evaluate the function and gradient at x = [4; 10]; (Here x is a 2d vector.)
x = [4; 10];
[value grad] = simpleQuadraticFunction(x);

% Use your code to numerically compute the gradient of simpleQuadraticFunction at x.
% (The notation “@simpleQuadraticFunction“ denotes a pointer to a function.)
numgrad = computeNumericalGradient(@simpleQuadraticFunction x);

% Visually examine the two gradient computations.  The two columns
% you get should be very similar. 
disp([numgrad grad]);
fprintf(‘The above two columns you get should be very similar.\n(Left-Your Numerical Gradient Right-Analytical Gradient)\n\n‘);

% Evaluate the norm of the difference between two solutions.  
% If you have a correct implementation and assuming you used EPSILON = 0.0001 
% in computeNumericalGradient.m then diff below should be 2.1452e-12 
diff = norm(numgrad-grad)/norm(numgrad+grad);
disp(diff); 
fprintf(‘Norm of the difference between numerical and analytical gradient (should be < 1e-9)\n\n‘);
end


  
function [valuegrad] = simpleQuadraticFunction(x)
% this function accepts a 2D vector as input. 
% Its outputs are:
%   value: h(x1 x2) = x1^2 + 3*x1*x2
%   grad: A 2x1 vector that gives the partial derivatives of h with respect to x1 and x2 
% Note that when we pass @simpleQuadraticFunction(x) to computeNumericalGradients we‘re assuming
% that computeNumericalGradients will use only the first returned value of this function.

value = x(1)^2 + 3*x(1)*x(2);

grad = zeros(2 1);
grad(1)  = 2*x(1) + 3*x(2);
grad(2)  = 3*x(1);

end

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2011-01-06 02:46  starter\
     目录           0  2011-01-04 05:38  starter\minFunc\
     文件        3251  2011-01-04 05:39  starter\minFunc\ArmijoBacktrack.m
     文件         807  2011-01-04 05:39  starter\minFunc\autoGrad.m
     文件         901  2011-01-04 05:39  starter\minFunc\autoHess.m
     文件         317  2011-01-04 05:39  starter\minFunc\autoHv.m
     文件         870  2011-01-04 05:39  starter\minFunc\autoTensor.m
     文件         385  2011-01-04 05:39  starter\minFunc\callOutput.m
     文件        1845  2011-01-04 05:39  starter\minFunc\conjGrad.m
     文件         995  2011-01-04 05:39  starter\minFunc\dampedUpdate.m
     文件        2421  2011-01-04 05:39  starter\minFunc\example_minFunc.m
     文件        1604  2011-01-04 05:39  starter\minFunc\example_minFunc_LR.m
     文件         107  2011-01-04 05:39  starter\minFunc\isLegal.m
     文件         924  2011-01-04 05:39  starter\minFunc\lbfgs.m
     文件        2408  2011-01-04 05:39  starter\minFunc\lbfgsC.c
     文件        7707  2011-01-04 05:39  starter\minFunc\lbfgsC.mexa64
     文件        7733  2011-01-04 05:39  starter\minFunc\lbfgsC.mexglx
     文件        9500  2011-01-04 05:39  starter\minFunc\lbfgsC.mexmac
     文件        7168  2011-01-04 05:39  starter\minFunc\lbfgsC.mexw32
     文件        9728  2011-01-04 05:39  starter\minFunc\lbfgsC.mexw64
     文件         614  2011-01-04 05:39  starter\minFunc\lbfgsUpdate.m
     目录           0  2011-01-04 05:38  starter\minFunc\logistic\
     文件         417  2011-01-04 05:39  starter\minFunc\logistic\LogisticDiagPrecond.m
     文件         216  2011-01-04 05:39  starter\minFunc\logistic\LogisticHv.m
     文件         659  2011-01-04 05:39  starter\minFunc\logistic\LogisticLoss.m
     文件        1154  2011-01-04 05:39  starter\minFunc\logistic\mexutil.c
     文件         317  2011-01-04 05:39  starter\minFunc\logistic\mexutil.h
     文件         227  2011-01-04 05:39  starter\minFunc\logistic\mylogsumexp.m
     文件        3965  2011-01-04 05:39  starter\minFunc\logistic\repmatC.c
     文件        7680  2011-01-04 05:39  starter\minFunc\logistic\repmatC.dll
     文件       20682  2011-01-04 05:39  starter\minFunc\logistic\repmatC.mexglx
............此处省略26个文件信息

评论

共有 条评论