 function [W1,W2]=MLPinit(Xi,Yi,m)

%MLPinit initializes weight matrices for a MLP

%

%       [W1,W2]=MLPinit(Xi,Yi,m)

%

% Xi the learning set input data

% Yi the learning set output data

% m the number of hidden unit of the MLP

%

% The function returns [W1,W2] the modified weights.

%

%	21/04/97 S. Canu, modified on Nov. 15th, 1999. (Evry, France)



if nargin < 3;

   help MLPinit

   error(sprintf('\n *** MLPinit error: invalid call***\n\n\t[W1,W2]=MLPinit(Xi,Yi,m);\n\n'));

end;



[n,d]   = size(Xi);

[n,q]   = size(Yi);





%W1 = k1*randn(d+1,m);

Xmax=max(Xi);		%modified on Nov. 15th, 1999 

Xmin=min(Xi);
%W1(d+1,:) = (Xmax-Xmin)*(rand(1,m)-0.5)+(Xmax+Xmin)/2; %%%modifier locean le 18/avril2008

W1(d+1,:) = (Xmax-Xmin)*(rand(d,m)-0.5)+(Xmax+Xmin)*ones(d,m)/(2*d); %%%%actualiser ici 18/avril2008

W1(1:d,:) = 10*randn(d,m);					%



W2 = 0.1*randn(m+1,q);


W2(m+1,:) = mean(Yi);



if max(max(abs(Xi))) > 10

	disp('Warning*** Input data may be too high - use normalized data')

end



if max(max(abs(Yi))) > 10

	disp('Warning*** Output data may be too high - use normalized data')

end




