Replies: 1 comment
-
Stared at this for a while and realized that there was a fairly simple solution that skirts the issue - just impose a maximum depth on the recursion (and the search.) Instead of calling the same function recursively, I'm now doing something like this:
Now, whether or not this is the best approach or will even play nicely with other JAX stuff like pmap, I haven't had a chance to see yet - but at least at low maximum depths, it seems to work. Still open to hearing any other ideas on the subject, but figured I would leave a note about this as a possibility in case anyone else stumbled across this while working on the same issue. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there! I'm trying to use Jax (and Haiku) to write a network that can navigate a very large (di)graph. It starts at the root node, looks at features of the connected edges, and assigns a probability to each edge that it wants to travel along it. My first attempt at this was to do it recursively.
(There's more to my search algorithm than that, but I tried to simplify it as much as possible.) This basic approach didn't work, though, because I pretty quickly ran into this:
RecursionError: maximum recursion depth exceeded while calling a Python object
. I searched a bit and found this comment explaining it: #4858 (comment)I thought about opening a feature request for what's discussed there, but the fact that it's not been talked about again since then tells me that I'm on the wrong track anyhow, and that maybe there's a way to do this already. But I'm kind of at a loss at how to continue. When I'm writing "normal" code, I know I can rewrite recursion as iteration by maintaining my own stack. I'm not sure how I could translate that to JAX, though. Has anyone run into anything similar, or do I just need to open a feature request and try a different library in the meantime? (Making that kind of contribution myself is way over my head right now, unfortunately.)
Beta Was this translation helpful? Give feedback.
All reactions