function [crit,WW]=Leve_Mar_optm(InpPat, TarPat, Wini, n_iter,NP) % %[crit,WW]=Leve_Mar(InpPat, TarPat, Wini, alfa, n_iter,NP) % %This function computes the 2-norm of the error vector, considering a Levenberg-Marquardt algorithm % %Input Arguments: InpPat - Matrix of input data % TarPat - Matrix of output desired data % Wini - vector of initial weights % n_iter - how many iterations % NP - toplogy of the MLP - Two hidden layers network, with just 1 output % The weights are arranged as: % ni*NP(1) % NP(1)`*NP(2) % NP(2)*1 % Bias for the 1st hidden layer % Bias for the 2nd hidden layer % Bias for the output neuron % %Output arguments:crit - vector of the 2-morm of the errors % WW - matrix of the evolution of the weights W=Wini; Ini=1; spare=[]; for iter=1:n_iter [Y,G,E]=TwoLayer(InpPat,TarPat,W,NP); F=(Y-TarPat); crit(iter)=norm(F); WW(iter,:)=W; [W,spare]=LM(W,F,G,Ini,spare); Ini=0; end