iCub-main
Loading...
Searching...
No Matches
saveNetwork.m
Go to the documentation of this file.
1function saveNetwork(net)
2% Save the file 'network.ini' containing the network 'net'
3% in the proper format required by the ctrlLib framework.
4%
5% Copyright: (C) 2010 RobotCub Consortium
6% Author: Ugo Pattacini
7% CopyPolicy: Released under the terms of the GNU GPL v2.0.
8
9fid=fopen('network.ini','w');
10
11szIW=size(net.IW{1});
12szLW=size(net.LW{2,1});
13
14fprintf(fid,'\n');
15fprintf(fid,'numInputNodes\t\t%d\n',uint8(szIW(2)));
16fprintf(fid,'numHiddenNodes\t\t%d\n',uint8(szIW(1)));
17fprintf(fid,'numOutputNodes\t\t%d\n',uint8(szLW(1)));
18fprintf(fid,'\n');
19
20fprintf(fid,'// hidden layer neurons\n');
21for i=1:szIW(1)
22 fprintf(fid,'IW_%d\t\t( ',uint8(i-1));
23 for j=1:szIW(2)
24 fprintf(fid,'%.15f ',net.IW{1}(i,j));
25 end
26 fprintf(fid,')\n');
27end
28fprintf(fid,'\n');
29
30fprintf(fid,'// output layer neurons\n');
31for i=1:szLW(1)
32 fprintf(fid,'LW_%d\t\t( ',uint8(i-1));
33 for j=1:szLW(2)
34 fprintf(fid,'%.15f ',net.LW{2,1}(i,j));
35 end
36 fprintf(fid,')\n');
37end
38fprintf(fid,'\n');
39
40fprintf(fid,'// bias hidden layer neurons\n');
41fprintf(fid,'b1\t\t( ');
42for i=1:length(net.b{1})
43 fprintf(fid,'%.15f ',net.b{1}(i));
44end
45fprintf(fid,')\n\n');
46
47fprintf(fid,'// bias output layer neurons\n');
48fprintf(fid,'b2\t\t( ');
49for i=1:length(net.b{2})
50 fprintf(fid,'%.15f ',net.b{2}(i));
51end
52fprintf(fid,')\n\n');
53
54fprintf(fid,'// input preprocessing\n');
55params=net.inputs{1}.processSettings{end};
56for i=1:szIW(2)
57 fprintf(fid,'inMinMaxX_%d\t\t( %.15f %.15f )\n',uint8(i-1),params.xmin(i),params.xmax(i));
58end
59for i=1:szIW(2)
60 fprintf(fid,'inMinMaxY_%d\t\t( %.15f %.15f )\n',uint8(i-1),params.ymin,params.ymax);
61end
62fprintf(fid,'\n');
63
64fprintf(fid,'// output postprocessing\n');
65params=net.outputs{2}.processSettings{end};
66for i=1:szLW(1)
67 fprintf(fid,'outMinMaxY_%d\t\t( %.15f %.15f )\n',uint8(i-1),params.ymin,params.ymax);
68end
69for i=1:szLW(1)
70 fprintf(fid,'outMinMaxX_%d\t\t( %.15f %.15f )\n',uint8(i-1),params.xmin(i),params.xmax(i));
71end
72fprintf(fid,'\n');
73
74fclose(fid);
75
76
77
int n
FILE * file
Definition main.cpp:81
fprintf(fid,'\n')
szLW
Definition saveNetwork.m:12
function saveNetwork(net) % Save the file 'network.ini' containing the network 'net' % in the proper format required by the ctrlLib framework. % % Copyright szIW
Definition saveNetwork.m:11
fclose(fileID)