61 |
output = network#getOutputLearnVector and |
output = network#getOutputLearnVector and |
62 |
outputActivation = network#getOutputActivation and |
outputActivation = network#getOutputActivation and |
63 |
inputSum = network#getInputSum and |
inputSum = network#getInputSum and |
64 |
weights = network#getWeights in |
weights = network#getWeights and |
65 |
|
derivate = _derivateFunction in |
66 |
begin |
begin |
67 |
(** |
(** |
68 |
Compute the error of the output layer |
Compute the error of the output layer |
69 |
*) |
*) |
70 |
for i = 0 to (Array.length !error.(network#getLayerNb - 1)) - 1 do |
for i = 0 to (Array.length !error.(network#getLayerNb - 1)) - 1 do |
71 |
!error.(network#getLayerNb - 1).(i) |
!error.(network#getLayerNb - 1).(i) |
72 |
<- output.(i) -. !outputActivation.(network#getLayerNb - 1).(i) |
<- derivate(!inputSum.(network#getLayerNb - 1).(i)) |
73 |
|
*. (output.(i) -. !outputActivation.(network#getLayerNb - 1).(i)) |
74 |
done; |
done; |
75 |
(** |
(** |
76 |
Compute the error and gradient of the hidden layers. |
Compute the error and gradient of the hidden layers. |
81 |
for j = 0 to (Array.length !error.(l + 1)) - 1 do |
for j = 0 to (Array.length !error.(l + 1)) - 1 do |
82 |
!error.(l).(i) |
!error.(l).(i) |
83 |
<- !error.(l).(i) |
<- !error.(l).(i) |
84 |
+. !error.(l + 1).(j) *. _derivateFunction(!inputSum.(l + 1).(j)) |
+. !error.(l + 1).(j) *. derivate(!inputSum.(l + 1).(j)) |
85 |
*. !weights.(l).(i).(j); |
*. !weights.(l).(i).(j); |
86 |
|
|
87 |
!gradients.(l).(i).(j) |
!gradients.(l).(i).(j) |
88 |
<- !error.(l + 1).(j) *. _derivateFunction(!inputSum.(l).(i)) |
<- !error.(l + 1).(j) *. !outputActivation.(l).(i) |
|
*. !outputActivation.(l).(i) |
|
89 |
done |
done |
90 |
done |
done |
91 |
done |
done |