92 |
stop := if ((!step + field - 1) >= currentTimeNb) then (currentTimeNb - 1) else (!step + field - 1); |
stop := if ((!step + field - 1) >= currentTimeNb) then (currentTimeNb - 1) else (!step + field - 1); |
93 |
startState := if ((!step <= state) && (state <= !stop) && (!startState == -1)) then i else !startState; |
startState := if ((!step <= state) && (state <= !stop) && (!startState == -1)) then i else !startState; |
94 |
endState := if ((state < !step) && (!endState == -1)) then (i - 1) else !endState; |
endState := if ((state < !step) && (!endState == -1)) then (i - 1) else !endState; |
95 |
step := !step + delay; |
step := !step + delay |
96 |
Printf.printf "Index [i=%d] [stop=%d] [step=%d] [startState=%d] [endState=%d] [state=%d] [field=%d] [delay=%d] [current=%d] [next=%d]\n" |
(* Printf.printf "Index [i=%d] [stop=%d] [step=%d] [startState=%d] [endState=%d] [state=%d] [field=%d] [delay=%d] [current=%d] [next=%d]\n" |
97 |
i !stop !step !startState !endState state field delay currentTimeNb nextTimeNb |
i !stop !step !startState !endState state field delay currentTimeNb nextTimeNb *) |
98 |
done; |
done; |
99 |
endState := if (!endState == -1) then nextTimeNb - 1 else !endState |
endState := if (!endState == -1) then nextTimeNb - 1 else !endState |
100 |
end; (!startState, !endState) and |
end; (!startState, !endState) and |
137 |
(** |
(** |
138 |
Backpropagation of the error term |
Backpropagation of the error term |
139 |
*) |
*) |
140 |
Printf.printf "Index [l=%d] [m=%d] [k=%d] [j=%d] [i=%d] [start=%d] [endD=%d]\n" l m k j i (fst !startEnd) (snd !startEnd); |
(* Printf.printf "Index [l=%d] [m=%d] [k=%d] [j=%d] [i=%d] [start=%d] [endD=%d]\n" l m k j i (fst !startEnd) (snd !startEnd); *) |
141 |
!error.(l).(k).(m) |
!error.(l).(k).(m) |
142 |
<- !error.(l).(k).(m) |
<- !error.(l).(k).(m) |
143 |
+. !error.(l + 1).(i).(j) *. !weights.(l).(k).(m).(i); |
+. !error.(l + 1).(i).(j) *. !weights.(l).(k).(m).(i); |
144 |
Printf.printf "!error.(%d).(%d).(%d) <- !error.(%d).(%d).(%d) +. !error.(%d).(%d).(%d) *. !weights.(%d).(%d).(%d).(%d);\n" |
(* Printf.printf "!error.(%d).(%d).(%d) <- !error.(%d).(%d).(%d) +. !error.(%d).(%d).(%d) *. !weights.(%d).(%d).(%d).(%d);\n" |
145 |
l k m l k m (l+1) i j l k m i; |
l k m l k m (l+1) i j l k m i; *) |
146 |
(** |
(** |
147 |
We compute the gradient with the error term of |
We compute the gradient with the error term of |
148 |
the layer l + 1. |
the layer l + 1. |
149 |
*) |
*) |
150 |
!gradients.(l).(k).(m).(i) |
!gradients.(l).(k).(m).(i) |
151 |
<- !error.(l + 1).(i).(j) *. !outputActivation.(l).(k).(m); |
<- !error.(l + 1).(i).(j) *. !outputActivation.(l).(k).(m) |
152 |
Printf.printf "!gradients.(%d).(%d).(%d).(%d) <- !error.(%d).(%d).(%d) *. !outputActivation.(%d).(%d).(%d)\n\n" |
(* Printf.printf "!gradients.(%d).(%d).(%d).(%d) <- !error.(%d).(%d).(%d) *. !outputActivation.(%d).(%d).(%d)\n\n" |
153 |
l k m i (l+1) i j l k m |
l k m i (l+1) i j l k m *) |
154 |
done |
done |
155 |
done; |
done; |
156 |
!error.(l).(k).(m) <- !error.(l).(k).(m) |
!error.(l).(k).(m) <- !error.(l).(k).(m) |