matlab在点内加入权值,MATLAB神经网络工具箱中感知器权值和阈值的学习函数learnp | 学步园...

我先把代码贴过来!慢慢研究!

function [out1,out2] = learnp(varargin)

%LEARNP Perceptron weight/bias learning function.

%

% learnp is the perceptron weight/bias learning function.

%

% learnp(W,P,Z,N,A,T,E,gW,gA,D,LP,LS) takes several inputs,

% W - SxR weight matrix (or b, an Sx1 bias vector).

% P - RxQ input vectors (or ones(1,Q)).

% Z - SxQ weighted input vectors.

% N - SxQ net input vectors.

% A - SxQ output vectors.

% T - SxQ layer target vectors.

% E - SxQ layer error vectors.

% gW - SxR gradient with respect to performance.

% gA - SxQ output gradient with respect to performance.

% D - SxS neuron distances.

% LP - Learning parameters, none, LP = [].

% LS - Learning state, initially should be = [].

% and returns,

% dW - SxR weight (or bias) change matrix.

% LS - New learning state.

%

% learnp(CODE) returns useful information for each CODE string:

% 'pnames' - Returns names of learning parameters.

% 'pdefaults' - Returns default learning parameters.

% 'needg' - Returns 1 if this function uses gW or gA.

%

% Here we define a random input P and error E to a layer

% with a 2-element input and 3 neurons.

%

% p = rand(2,1);

% e = rand(3,1);

%

% LEARNP only needs these values to calculate a weight change.

%

% dW = learnp([],p,[],[],[],[],e,[],[],[],[],[])

%

% See also LEARNPN, NEWP, ADAPT, TRAIN.

% Mark Beale, 1-31-92

% Revised 11-31-97, MB

% Copyright 1992-2010 The MathWorks, Inc.

% $Revision: 1.1.6.8 $ $Date: 2010/04/24 18:09:27 $

%% =======================================================

% BOILERPLATE_START

% This code is the same for all Learning Functions.

persistent INFO;

if isempty(INFO), INFO = get_info; end

if (nargin < 1), nnerr.throw('Not enough arguments.'); end

in1 = varargin{1};

if ischar(in1)

switch in1

case 'info'

out1 = INFO;

case 'check_param'

out1 = check_param(varargin{2});

otherwise,

try

out1 = eval(['INFO.' in1]);

catch me

nnerr.throw(['Unrecognized first argument: ''' in1 ''''])

end

end

else

[out1,out2] = apply(varargin{:});

end

end

function sf = subfunctions

sf.apply = @apply;

end

function v = fcnversion

v = 7;

end

% BOILERPLATE_END

%% =======================================================

function info = get_info

info = nnfcnLearning(mfilename,'Perceptron',...

fcnversion,subfunctions,false,true,true,false,[]);

% TODO - Indicate that it requires error

end

function err = check_param(param)

err = '';

end

function [dw,ls] = apply(w,p,z,n,a,t,e,gW,gA,d,lp,ls)

dw = e*p';

end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值