exnet.m

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

M
52
字号
function [W1,B1,W2,B2,F1,F2,F3]=exnet2(mb,s1,s2,s3);
%
% Extracts a network from one population member
%
% [W1 B1 W2 B2]=exnet2(coefs,s1,s2,s3);
%
% W1,W2,B1,B2 = weights and bias
%
% F1,F2,F3    = Filter constants for each dynamic neuron
%
% s1,s2,s3    = network size
%
% mb          = coeficients of this population member
%

%
% Extract the information for the connections
% between the input layer and the first hidden
% layer:
%

dat=mb;
W1=coef2w(dat,s1,s2);

[D L]=size(dat);
dat=dat(:,((s1*s2)+1):L);
B1=coef2b(dat,s2);


%
% Now do the same for the connections between
% the hidden layer and the output layer:
%
[D L]=size(dat);
dat=dat(:,(s2+1):L);
W2=coef2w(dat,s2,s3);

[D L]=size(dat);
dat=dat(:,((s2*s3)+1):L);
B2=coef2b(dat,s3);

%
% Now take the rest of the parameters as filter constants
%
total_weights=(s1*s2)+(s2)+(s2*s3)+(s3);
[D L]=size(mb);
dat=mb(:,total_weights+1:L);
F1=dat(:,1:s1);
F2=dat(:,(s1+1):(s1+s2));
F3=dat(:,(s1+s2+1):(s1+s2+s3));

⌨️ 快捷键说明

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