我想用 matlab 编写自己的感知器网络。我试图运行这段代码
input = [0 0; 0 1; 1 0; 1 1];
bias = [1 1 1];
coeff = 0.7;
iterations = 10000;
rand('state',sum(100*clock));
weights = -1 +2.*rand(3,3);
for i = 1:iterations
out = zeros(4,1);
numIn = length (input(:,1));
for j = 1:numIn
H1 = bias(1,1)*weights(1,1)
+ input(j,1)*weights(1,2)
+ input(j,2)*weights(1,3);
for k = 1:3
if k == 1
weights(1,k) = weights(1,k) + coeff*bias(1,1)*delta2_1;
weights(2,k) = weights(2,k) + coeff*bias(1,2)*delta2_2;
weights(3,k) = weights(3,k) + coeff*bias(1,3)*delta3_1;
else
weights(1,k) = weights(1,k) + coeff*input(j,1)*delta2_1;
weights(2,k) = weights(2,k) + coeff*input(j,2)*delta2_2;
weights(3,k) = weights(3,k) + coeff*x2(k-1)*delta3_1;
end
end
end
end
但它给了我错误的结果(0.499524196804705,0.477684866785518,0.500475803195295,0.522315133214482)。你能帮我找出我的错误吗?