/[marvin]/marvin/src/libnn/initCommonVisitor.ml
ViewVC logotype

Diff of /marvin/src/libnn/initCommonVisitor.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by srv89, Fri Jul 11 02:08:57 2003 UTC revision 1.3 by matthieu, Tue Jul 15 16:51:07 2003 UTC
# Line 58  object Line 58  object
58    inherit [commonNN] initVisitor    inherit [commonNN] initVisitor
59    
60    (**    (**
61      The method which initializes the weights.      The method which initializes the networks.
62      It uses the random      It uses the random
63      @see      @see
64      <http://caml.inria.fr/oreilly-book/html/book-ora076.html>      <http://caml.inria.fr/oreilly-book/html/book-ora076.html>
# Line 67  object Line 67  object
67      @see <http://caml.inria.fr/devtools/doc_ocaml/Unix.html#VALtime>      @see <http://caml.inria.fr/devtools/doc_ocaml/Unix.html#VALtime>
68      Used to initialize the random number generator.      Used to initialize the random number generator.
69    *)    *)
70    method visitCommon (network : ((commonNN) defaultVisitor) nn) =    method visitCommon (network : commonNN) =
71      Random.self_init()      let outputActivation = Array.create network#get_layer_nb [||] and
72          inputSum = Array.create network#get_layer_nb [||] and
73          error = Array.create network#get_layer_nb [||] and
74          weights = Array.create (network#get_layer_nb - 1) [||] and
75          gradients = Array.create (network#get_layer_nb - 1) [||] in
76          begin
77            Random.self_init();
78            (**
79              Initialization of the 2 dimensions arrays
80            *)
81            for i = 0 to network#get_layer_nb - 1 do
82              outputActivation.(i) <- Array.create (network#get_neurons_per_layer i) 0.0;
83              inputSum.(i) <- Array.create (network#get_neurons_per_layer i) 0.0;
84              error.(i) <- Array.create (network#get_neurons_per_layer i) 0.0
85            done;
86            (**
87              Initialization of the 3 dimensions arrays
88            *)
89            for i = 0 to network#get_layer_nb - 2 do
90              weights.(i) <- Array.create (network#get_neurons_per_layer i + 1) [||];
91              gradients.(i) <- Array.create (network#get_neurons_per_layer i + 1) [||];
92              for j = 0 to (network#get_neurons_per_layer i + 1) - 1 do
93                weights.(i).(j) <- Array.create (network#get_neurons_per_layer i) ((Env.getEnv())#getRandLimit);
94                gradients.(i).(j) <- Array.create (network#get_neurons_per_layer i) 0.0
95              done
96            done;
97            network#set_outputActivation outputActivation;
98            network#set_intputSum inputSum;
99            network#set_error error;
100            network#set_weights weights;
101            network#set_gradients gradients
102          end
103  end  end

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26