Open talex5 opened 2 years ago
I'm not entirely sure if this is the issue, but I think it might have to do with F 1.
not being the same shape as x
. I would try using an array of ones instead of F 1.
.
I would try using an array of ones instead of F 1.
That doesn't help:
utop # #require "owl-top";;
utop # open Owl
module AD = Owl.Algodiff.D
let a = AD.Arr (Arr.zeros [| 1; 1 |])
let b = AD.make_reverse (AD.Arr (Arr.zeros [| 1 |])) (AD.tag ())
let () =
let x = AD.Maths.(a + b) in
AD.Mat.print x;
AD.reverse_prop (Arr (Arr.ones [| 1 |])) x;
AD.Mat.print (AD.adjval b);;
C0
R0 0
Exception: Invalid_argument "index out of bounds".
Anyway, I can fix this myself by extending b
. I'm just reporting it in case you want to fix it.
By mistake, I just found out that it does not fail the second time... Try this
try AD.reverse_prop (Arr (Arr.ones [| 1 |])) x with e -> AD.reverse_prop (Arr (Arr.ones [| 1 |])) x;
or
try AD.reverse_prop (F 1.) x with e -> AD.reverse_prop (F 1.) x;
and it will return unit fine 😮
This program adds two arrays together using Algodiff:
It fails at the
reverse_prop
step with:I assume that since the forwards part works, the reverse step should work too. I guess it's something to do with the shape of
b
. If I use[|1; 1|]
then it works.