]> Creatis software - CreaPhase.git/blob - octave_packages/nnet-0.1.13/saveMLPStruct.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nnet-0.1.13 / saveMLPStruct.m
1 ## Copyright (C) 2005 Michel D. Schmid  <michaelschmid@users.sourceforge.net>
2 ##
3 ##
4 ## This program is free software; you can redistribute it and/or modify it
5 ## under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; either version 2, or (at your option)
7 ## any later version.
8 ##
9 ## This program is distributed in the hope that it will be useful, but
10 ## WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 ## General Public License for more details.
13 ##
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program; see the file COPYING.  If not, see
16 ## <http://www.gnu.org/licenses/>.
17
18 ## -*- texinfo -*-
19 ## @deftypefn {Function File} {} saveMLPStruct (@var{net},@var{strFileName})
20 ## @code{saveStruct} saves a neural network structure to *.txt files
21 ## @end deftypefn
22
23 ## Author: Michel D. Schmid
24
25 function saveMLPStruct(net,strFileName)
26
27   ## the variable net holds the neural network structure..
28   # check if "net" is a structure type
29   if !__checknetstruct(net)
30     error("Structure doesn't seem to be a neural network")
31   endif
32
33   # open the first level file
34   fid1 = fopen(strFileName,"w+t","ieee-le");
35
36   if (fid1 < 0)
37     error ("Can not open %s", strFileName);
38   endif
39
40   ## print header
41 #   try            ## wird nicht mehr benötigt..
42     __printMLPHeader(fid1);
43 #   catch
44 #     ## Add saveMLPStructure directory to the path and try again
45 #     addpath ([fileparts(mfilename()),"/saveMLPStructure"]);
46 #     __printMLPHeader(fid1);
47 #   end_try_catch
48   
49   ## check for field "networkType"
50   __printNetworkType(fid1,net);
51
52   ## check for field "numInputs"
53   __printNumInputs(fid1,net);
54
55   ## check for field "numLayers"
56   __printNumLayers(fid1,net)
57
58   ## check for field "biasConnect"
59   __printBiasConnect(fid1,net)
60
61   ## check for field "inputConnect"
62   __printInputConnect(fid1,net)
63
64   ## check for field "layerConnect"
65   __printLayerConnect(fid1,net)
66
67   ## check for field "outputConnect"
68   __printOutputConnect(fid1,net)
69
70   ## check for field "targetConnect"
71   __printTargetConnect(fid1,net)
72
73   ## print one empty line
74   fprintf(fid1,"\n");
75
76   ## check for numOutputs
77   __printNumOutputs(fid1,net);
78
79   ## check for numTargets
80   __printNumTargets(fid1,net);
81
82   ## check for numInputDelays
83   __printNumInputDelays(fid1,net);
84
85   ## check for numLayerDelays
86   __printNumLayerDelays(fid1,net);
87
88   ## print one empty line
89   fprintf(fid1,"\n");
90
91   ## print subobject structures:
92   fprintf(fid1,"  subobject structures:\n");
93
94   ## print one empty line
95   fprintf(fid1,"\n");
96
97   ## print inputs
98   __printInputs(fid1,net);
99
100   ## print layers
101   __printLayers(fid1,net);
102
103   ## print outputs
104   __printOutputs(fid1,net);
105
106   ## print targets
107   __printTargets(fid1,net);
108
109   ## print biases
110   __printBiases(fid1,net);
111
112   ## print inputweights
113   __printInputWeights(fid1,net);
114
115   ## print layerweights
116   __printLayerWeights(fid1,net);
117
118   ## print one empty line
119   fprintf(fid1,"\n");
120
121   ## print subobject structures:
122   fprintf(fid1,"  functions:\n");
123
124   ## print one empty line
125   fprintf(fid1,"\n");
126
127   ## print adaptFcn
128   __printAdaptFcn(fid1,net);
129
130   ## print initFcn
131   __printInitFcn(fid1,net);
132
133   ## print performFcn
134   __printPerformFcn(fid1,net);
135
136   ## print performFcn
137   __printTrainFcn(fid1,net);
138
139   ## print one empty line
140   fprintf(fid1,"\n");
141
142   ## print subobject structures:
143   fprintf(fid1,"  parameters:\n");
144
145   ## print one empty line
146   fprintf(fid1,"\n");
147
148   ## print adaptParam
149   __printAdaptParam(fid1,net);
150
151   ## print initParam
152   __printInitParam(fid1,net);
153
154   ## print performParam
155   __printPerformParam(fid1,net);
156
157   ## print trainParam
158   __printTrainParam(fid1,net);
159
160   ## print one empty line
161   fprintf(fid1,"\n");
162
163   ## print subobject structures:
164   fprintf(fid1,"  weight & bias values:\n");
165
166   ## print one empty line
167   fprintf(fid1,"\n");
168
169   ## print IW
170   __printIW(fid1,net);
171
172   ## print LW
173   __printLW(fid1,net);
174
175   ## print b
176   __printB(fid1,net);
177
178   ## print one empty line
179   fprintf(fid1,"\n");
180
181   ## print subobject structures:
182   fprintf(fid1,"  other:\n");
183
184
185   fclose(fid1);
186
187 endfunction