MATLAB Neural Network - Forward Propagation
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Erica Dos Santos Saraiva
el 24 de Jul. de 2021
Comentada: Erica Dos Santos Saraiva
el 28 de Jul. de 2021
I am trying to implement a forward propogation with a foor loop as advices on neural smithing. I keep recieveing an error when iterating through my for loop. How do I get rid of this error.
I have checked the sizes for both NOUTPUTS(i+1) and NPATS(i) which both are = 1 however keep receiving this error.
Patterns = x'; Desired = y; NHIDDENS = 1; prnout=Desired;
% Patterns become x so number of inputs becomes size of patterns
[NINPUTS,NPATS] = size(Patterns); [NOUTPUTS,NP] = size(Desired);
%apply the backprop here...
LearnRate = 0.15; Momentum = 0; DerivIncr = 0; deltaW1 = 0; deltaW2 = 0;
% Keeps the tan ordering of the examples of x
Inputs1= [Patterns;ones(1,NPATS)]; %Inputs1 = [ones(1,NPATS); Patterns];
% Weight initialisation
Weights1 = 0.5*(rand(NHIDDENS,1+NINPUTS)-0.5);
Weights2 = 0.5*(rand(1,1+NHIDDENS)-0.5);
TSS_Limit = 0.02;
for epoch = 1:10
% FORWARD LOOP
size(NOUTPUTS)
size(NPATS)
for ii = 0: ii < length(NINPUTS)
NOUTPUTS(ii+1) = NPATS(ii);
% Sets bias to 1
NOUTPUTS(1) = 1;
end
for ii = NHIDDENS: ii < NINPUTS
sum = 0;
for ij = 0: ij < ii
sum = sum + deltaW1(ii,ij) * NOUTPUTS(ij);
NOUTPUTS(ii) = tanh(sum);
end
end
Unable to perform assignment because the
left and right sides have a different
number of elements.
Error in mlpts (line 66)
NOUTPUTS(i+1) = NPATS(i);
0 comentarios
Respuestas (1)
Swetha Polemoni
el 27 de Jul. de 2021
Hi,
You might want to check on the format of for loops you have used(for ii = 0: ii < length(NINPUTS)). This can be replaced with following code snippet.
ii = intial value;
while condition
end
Ver también
Categorías
Más información sobre Deep Learning Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!