我尝试为葡萄酒数据集实现神经网络,并使用反向传播算法训练网络。但是代码中的错误值大约是100,我不知道如何减少它。该程序也没有给出测试数据的任何正确输出。我在matlab代码中做错了吗?请解释我如何为学习率和时期数选择合适的值。我是计算智能的新手。请帮我解决这个问题。提前谢谢。
% Wine dataset
[x,t] = wine_dataset;
x = x'; % Measurements or features
t = t';
N0 = size(x,2);
N1 = 10;
N2 = 3;
N = size(x,1);
w1 = 0.5 - rand(N1, N0+1);
w2 = 0.5 - rand(N2, N1);
eta = 0.001;
kmax = 100;
k=1;
while k < kmax
error = 0;
k = k+1;
for n = 1:size(x,1)
xn = [1, x(1,:)]';
y1 = sigmoid(w1*xn);
y2 = sigmoid(w2*y1);
epsilon2 = t(n,:)' - y2;
delta2 = epsilon2.*y2.*(1-y2);
error = error + sum(epsilon2.^2);
epsilon1 = w2'*delta2;
delta1 = epsilon1.*y1.*(1-y1);
w1 = w1 + eta*delta1*xn';
w2 = w2 + eta*delta2*y1';
end
mse = error/(N*N0);
end
error
mse