For the max recursion, this is a know issue in Theano.
If Adam updates fix work while raising the max recursion limit use that.
Otherwise, you could help us fix the issue. Or make an op that does part of
the work to make the graph even smaller, but it would need a GPU version if
you want it to
My bad, that one gives wrong result, fixed version:
def recursive_dot_reduce(A_, K_):
if K_<=1: return A_
if K&1:
return recursive_dot_reduce(T.dot(T.batched_dot(A_[:-1:2], A_[::
2]), A_[-1]), K_//2)
else
return
Just for the dot reduction part, using batched_dot should give a O(log(n))
graph depth:
# assumes K > 1
B = A
for i in reversed(bin(K)[3:]):
if not int(i):
B = T.batched_dot(B[::2], B[1::2])
else:
B = T.dot(T.batched_dot(B[:-1:2], B[1::2]), B[-1])
This works if K is
P.S.
If it helps, yes the indices are exactly the ones I have in the code.
Thanks
Oussama
On 16 February 2017 at 23:00, Oussama Souihli wrote:
> Hi Fred,
>
> Thank you for the quick reply and clever suggestions, you really hit the
> nail on the head !
>
> I tried the
Hi Fred,
Thank you for the quick reply and clever suggestions, you really hit the
nail on the head !
I tried the suggested vectorized code, but unfortunately still experienced
the max recursion limit exception.
I also tried the workaround, but still get the max recusion limit until I
set it to
Hi Fred, Adam, Kiuhnm, all
Thank you for the detailed and quick replies and multiple suggestions.
I tried bacthed_dot but still experienced both issues (maximum depth
recursion when using a for loop and very slow epochs when using
theano.scan),
so now I'm thinking the problem is also possibly
He's saying that the factorization of len(A) mustn't contain big primes,
but I'd rather look at the binary expansion of len(A) instead.
On Wednesday, February 15, 2017 at 6:02:36 PM UTC+1, nouiz wrote:
>
> Why do you tell it should only work well if len(A) is small?
>
> batched_dot should work
Why do you tell it should only work well if len(A) is small?
batched_dot should work well for a big len(A).
Fred
On Wed, Feb 15, 2017 at 10:50 AM Adam Becker wrote:
> Besides that, use subtensor and batched_dot can further vectorize things.
>
>
> A =