51 |
class propagateCommonVisitor = |
class propagateCommonVisitor = |
52 |
object |
object |
53 |
inherit [commonNN] propagateVisitor |
inherit [commonNN] propagateVisitor |
54 |
method visitCommon (network : commonNN) = () |
val mutable _transfertFunction = function x -> (1. /. (1. +. exp (-.x))) |
55 |
|
method visitCommon (network : commonNN) = |
56 |
|
let step = network#getStep and |
57 |
|
transFun = _transfertFunction and |
58 |
|
outputActivation = network#getOutputActivation and |
59 |
|
inputSum = network#getInputSum and |
60 |
|
weights = network#getWeights in |
61 |
|
begin |
62 |
|
(** |
63 |
|
Activation of the input layer. |
64 |
|
*) |
65 |
|
for i = 0 to (network#getNeuronsPerLayer 0) - 1 do |
66 |
|
!outputActivation.(0).(i) <- transFun !inputSum.(0).(i) |
67 |
|
done; |
68 |
|
(** |
69 |
|
Propagation of the activation. |
70 |
|
//FIXME step handling |
71 |
|
*) |
72 |
|
for l = 1 to network#getLayerNb - 1 do |
73 |
|
for i = 0 to (network#getNeuronsPerLayer l) - 1 do |
74 |
|
!inputSum.(l).(i) <- !outputActivation.(l - 1).(0) |
75 |
|
*. !weights.(l - 1).(i).(0); |
76 |
|
for j = 1 to (network#getNeuronsPerLayer (l - 1)) - 1 do |
77 |
|
!inputSum.(l).(i) <- !inputSum.(l).(i) |
78 |
|
+. !outputActivation.(l - 1).(j) |
79 |
|
*. !weights.(l - 1).(i).(j) |
80 |
|
done; |
81 |
|
!outputActivation.(l).(i) <- transFun !inputSum.(l).(i) |
82 |
|
done |
83 |
|
done |
84 |
|
end |
85 |
end |
end |