1 | function [W1,W2]=MLPinit(Xi,Yi,m) |
---|
2 | |
---|
3 | %MLPinit initializes weight matrices for a MLP |
---|
4 | |
---|
5 | % |
---|
6 | |
---|
7 | % [W1,W2]=MLPinit(Xi,Yi,m) |
---|
8 | |
---|
9 | % |
---|
10 | |
---|
11 | % Xi the learning set input data |
---|
12 | |
---|
13 | % Yi the learning set output data |
---|
14 | |
---|
15 | % m the number of hidden unit of the MLP |
---|
16 | |
---|
17 | % |
---|
18 | |
---|
19 | % The function returns [W1,W2] the modified weights. |
---|
20 | |
---|
21 | % |
---|
22 | |
---|
23 | % 21/04/97 S. Canu, modified on Nov. 15th, 1999. (Evry, France) |
---|
24 | |
---|
25 | |
---|
26 | |
---|
27 | if nargin < 3; |
---|
28 | |
---|
29 | help MLPinit |
---|
30 | |
---|
31 | error(sprintf('\n *** MLPinit error: invalid call***\n\n\t[W1,W2]=MLPinit(Xi,Yi,m);\n\n')); |
---|
32 | |
---|
33 | end; |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | [n,d] = size(Xi); |
---|
38 | |
---|
39 | [n,q] = size(Yi); |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | %W1 = k1*randn(d+1,m); |
---|
46 | |
---|
47 | Xmax=max(Xi); %modified on Nov. 15th, 1999 |
---|
48 | |
---|
49 | Xmin=min(Xi); |
---|
50 | %W1(d+1,:) = (Xmax-Xmin)*(rand(1,m)-0.5)+(Xmax+Xmin)/2; %%%modifier locean le 18/avril2008 |
---|
51 | |
---|
52 | W1(d+1,:) = (Xmax-Xmin)*(rand(d,m)-0.5)+(Xmax+Xmin)*ones(d,m)/(2*d); %%%%actualiser ici 18/avril2008 |
---|
53 | |
---|
54 | W1(1:d,:) = 10*randn(d,m); % |
---|
55 | |
---|
56 | |
---|
57 | |
---|
58 | W2 = 0.1*randn(m+1,q); |
---|
59 | |
---|
60 | |
---|
61 | W2(m+1,:) = mean(Yi); |
---|
62 | |
---|
63 | |
---|
64 | |
---|
65 | if max(max(abs(Xi))) > 10 |
---|
66 | |
---|
67 | disp('Warning*** Input data may be too high - use normalized data') |
---|
68 | |
---|
69 | end |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | if max(max(abs(Yi))) > 10 |
---|
74 | |
---|
75 | disp('Warning*** Output data may be too high - use normalized data') |
---|
76 | |
---|
77 | end |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | |
---|