1 |
(****************************************************************** |
(****************************************************************** |
2 |
[LibNN - Neural Networks Library] |
[LibNN - Neural Networks Library] |
3 |
http://libnn.org |
http://libnn.org |
4 |
Copyright (C) 2002 - 2003 LAGACHERIE Matthieu RICORDEAU Olivier |
Copyright (C) 2002 - 2003 LAGACHERIE Matthieu RICORDEAU Olivier |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
7 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
8 |
as published by the Free Software Foundation; either version 2 |
as published by the Free Software Foundation; either version 2 |
9 |
of the License, or (at your option) any later version. This |
of the License, or (at your option) any later version. This |
10 |
program is distributed in the hope that it will be useful, |
program is distributed in the hope that it will be useful, |
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
GNU General Public License for more details. You should have |
GNU General Public License for more details. You should have |
14 |
received a copy of the GNU General Public License |
received a copy of the GNU General Public License |
15 |
along with this program; if not, write to the Free Software |
along with this program; if not, write to the Free Software |
16 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
17 |
USA. |
USA. |
18 |
|
|
19 |
SPECIAL NOTE (the beerware clause): |
SPECIAL NOTE (the beerware clause): |
20 |
This software is free software. However, it also falls under the beerware |
This software is free software. However, it also falls under the beerware |
21 |
special category. That is, if you find this software useful, or use it |
special category. That is, if you find this software useful, or use it |
22 |
every day, or want to grant us for our modest contribution to the |
every day, or want to grant us for our modest contribution to the |
23 |
free software community, feel free to send us a beer from one of |
free software community, feel free to send us a beer from one of |
24 |
your local brewery. Our preference goes to Belgium abbey beers and |
your local brewery. Our preference goes to Belgium abbey beers and |
25 |
irish stout (Guiness for strength!), but we like to try new stuffs. |
irish stout (Guiness for strength!), but we like to try new stuffs. |
26 |
|
|
27 |
Authors: |
Authors: |
28 |
LAGACHERIE Matthieu |
LAGACHERIE Matthieu |
29 |
Paper mail : 7 rue Delescluzes 94280 LE KREMLIN BICETRE, FRANCE |
Paper mail : 7 rue Delescluzes 94280 LE KREMLIN BICETRE, FRANCE |
30 |
E-mail : matthieu@libnn.org |
E-mail : matthieu@libnn.org |
31 |
|
|
32 |
RICORDEAU Olivier |
RICORDEAU Olivier |
33 |
Paper mail : 69 avenue d'Italie 75013 PARIS, FRANCE |
Paper mail : 69 avenue d'Italie 75013 PARIS, FRANCE |
34 |
E-mail : olivier@libnn.org |
E-mail : olivier@libnn.org |
35 |
|
|
36 |
*****************************************************************) |
*****************************************************************) |
37 |
|
|
38 |
(** |
(** |
39 |
The inputTdnnVisitor class |
The inputTdnnVisitor class |
40 |
|
|
41 |
@author Matthieu Lagacherie |
@author Matthieu Lagacherie |
42 |
@author Olivier Ricordeau |
@author Olivier Ricordeau |
43 |
@since 10/08/2003 |
@since 10/08/2003 |
44 |
*) |
*) |
45 |
|
|
46 |
open Nn |
open Nn |
47 |
open InputVisitor |
open InputVisitor |
49 |
open TdNN |
open TdNN |
50 |
|
|
51 |
class inputTdnnVisitor = |
class inputTdnnVisitor = |
52 |
object |
object |
53 |
inherit [tdNN] inputVisitor |
inherit [tdNN] inputVisitor |
54 |
|
|
55 |
initializer |
initializer |
56 |
_moduleName <- "TDNN input layer activation" |
_moduleName <- "TDNN input layer activation" |
57 |
|
|
58 |
(** |
(** |
59 |
The method which activate the input layer. |
The method which activate the input layer. |
60 |
The activation of the Tdnn can be done with several methods : |
The activation of the Tdnn can be done with several methods : |
61 |
* ^ * ^ * ^ * ^ |
* ^ * ^ * ^ * ^ |
62 |
* / * / * / * / |
* / * / * / * / |
63 |
* / * / * / * / |
* / * / * / * / |
64 |
Here a tdnn with an input layer of 4 neurons on the temporal |
Here a tdnn with an input layer of 4 neurons on the temporal |
65 |
direction and 3 neurons on the feature drection. |
direction and 3 neurons on the feature drection. |
66 |
The signal (the kind of arrow --->) is initialized in a first |
The signal (the kind of arrow --->) is initialized in a first |
67 |
time on the feature direction and in a second time on the temporal |
time on the feature direction and in a second time on the temporal |
68 |
direction. |
direction. |
69 |
*) |
*) |
70 |
method visit (network : tdNN) = |
method visit (network : tdNN) = |
71 |
let inputSum = network#getInputSum and |
let inputSum = network#getInputSum and |
72 |
inputLearnVector = network#getInputLearnVector in |
inputLearnVector = network#getInputLearnVector in |
73 |
match (!inputSum, inputLearnVector) with |
match (!inputSum, inputLearnVector) with |
74 |
(a, b) when |
(a, b) when |
75 |
(Array.length a.(0) * Array.length a.(0).(0)) != |
(Array.length a.(0) * Array.length a.(0).(0)) != |
76 |
Array.length inputLearnVector |
Array.length inputLearnVector |
77 |
-> (Env.getEnv())#err "tdnn/input" |
-> (Env.getEnv())#err "tdnn/input" |
78 |
"inputSum and inputLearnVector don't have the same size. skipping task." 1 |
"inputSum and inputLearnVector don't have the same size. skipping task." 1 |
79 |
| _ -> |
| _ -> |
80 |
begin |
begin |
81 |
for i = 0 to network#getLayerNb - 1 do |
for j = 0 to (network#getFeaturesNb.(0)) - 1 do |
82 |
for j = 0 to (network#getFeaturesNb.(i)) - 1 do |
for k = 0 to (network#getTimeNb.(0)) - 1 do |
83 |
for k = 0 to (network#getTimeNb.(i)) - 1 do |
(* |
84 |
!inputSum.(i).(j).(k) <- inputLearnVector.(i + j + k) |
Debug |
85 |
done |
Printf.printf "!inputSum.(0).(%d).(%d) <- inputLearnVector.(%d + %d)\n" j k j k; |
86 |
done |
*) |
87 |
|
!inputSum.(0).(j).(k) <- inputLearnVector.(j + k) |
88 |
done |
done |
89 |
end |
done |
90 |
|
end |
91 |
|
|
92 |
end |
end |