prop1.m

来自「王小平《遗传算法——理论、应用与软件实现》随书光盘」· M 代码 · 共 59 行

M
59
字号
function [out]=prop1(in,w,b,t,f);
%
% Propagates an input vector
% through one layer of a network
%
% call:
%
% [out]=prop(in,w,b,t);
%
% w   = weight matrix
% b   = bias weights (column vector. Same size a second layer)
% in  = input vector
% out = propagated signal
% t   = transfer option:
%		= 1  Linear transfer with bias
%		= 2  Sigmoidal transfer
% 		= 3  Linear transfer without bias
% f   = filter constants for this layer
%
% [Uses the MATLAB filter routine, otherwise it would be stupidly
% slow!]
%

%
% Determine the size of the two layers
%
[prsize thsize]=size(w);

%
% Calculate the input for each neuron
% in the second layer
%

if t == 2
	net=in*w;
	for i = 1:thsize
		net(:,i)=net(:,i)+b(i);
	end
	net=sig(net);
elseif t == 1
	net=in*w;
	for i = 1:thsize
		net(:,i)=net(:,i)+b(i);
	end
elseif t == 3
	net=in*w;
end


[D L]=size(net);
for i = 1:L
%	x1=net(1,i);
%	net(:,i)=net(:,i)-x1;
	out(:,i)=filter([1-f(i)],[1 -f(i)],net(:,i));
%	out(:,i)=out(:,i)+x1;
end


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?