my neural network training code goes to an infinite loop
Mostrar comentarios más antiguos
Hi. I am writing a neural network training code, the big problem is that when i run the program it goes to an infinite loop. I debugged the code and i discovered that it isn't comparing two variables correctly. The if loop if (u ~= result(1,i)) seems to be the problem, i look at the code many times and for me its ok. Can anyone tell me what's i am doing wrong, please.
The code is below, and the excel table is attached.
Thank You.
close all;clear all;clc
file = 'amostras.xlsx';
Amostras = xlsread(file)
result = Amostras (1,:)
amostra = Amostras(2:end,:)
y = size(Amostras)
n1 = y(1)
n2 = y(2)
Amostras(1,:) = -1
w = rand (1,n1)
n = (n1*n2)+(n1*n2)
n = 1/n
epoch = 0;
T = 1;
i=1;
for i = 1:n2,
err=1;
while err == 1,
u = w * Amostras(:,i)
des = result(1,i)
if (u ~= result(1,i))
rap = (n*(result(1,i)-u)*Amostras(:,i))
w = w + rap'
err = 1
epoch = epoch +1
T = T
else
err = 0
epoch = epoch
T = T +1
end
end
i = i +1;
end
disp(w)
disp(err)
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!