📄 da_net.m
字号:
%
% Neural test
%
global x y w1 w2 b1 b2 f1 f2 f3 yest
load cstrall.dat
x=cstrall(:,1:3);
y=cstrall(:,4);
%
% Split this into training and testing
%
[x y xtest ytest]=psplit(x,y,50);
%
% Scale all the data
%
maxx=max([x ; xtest]);
minx=min([x ; xtest]);
maxy=max([y ; ytest]);
miny=min([y ; ytest]);
[D L]=size(x);
for i=1:L
xtest(:,i)=(xtest(:,i)-minx(i))./(maxx(i)-minx(i));
x(:,i)=(x(:,i)-minx(i))./(maxx(i)-minx(i));
end
ytest(:,1)=(ytest(:,1)-miny(1))./(maxy(1)-miny(1));
y(:,1)=(y(:,1)-miny(1))./(maxy(1)-miny(1));
[D L]=size(x);
input_neurons=L;
hidden1_neurons=2;
w1=randn(input_neurons,hidden1_neurons).*0.1;
w1=randn(hidden1_neurons,1).*0.1;
%
% Weights for hidden layer #1 to output layer
% Bias terms are included
%
output_neurons=1;
w2=randn(hidden1_neurons,output_neurons).*0.1;
w2=randn(output_neurons).*0.1;
%
% Values for the filter constants
%
f1=zeros(input_neurons,1);
f2=zeros(hidden1_neurons,1);
f3=zeros(output_neurons,1);
%
% Calculate the total number of parameters
%
total_params=(input_neurons*hidden1_neurons)+(hidden1_neurons)+(hidden1_neurons*output_neurons)+(output_neurons);
X0=[w1;b1;w2;b2;f1;f2];
f3];
for i=1:10
x=leastsq('da_cost',X0);
plot([yest y]);
drawnow
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -