Skip to content

Trying to encapsulate jax code into a class #14347

Answered by jakevdp
tw40210 asked this question in Show and tell
Discussion options

You must be logged in to vote

The reason your code is not working as expected is because you are marking self as static when JIT-compiling the update method. This is incompatible with in-place mutation of a class instance, and you are mutating your class instance in the loop when you set or modify the params method.

See https://jax.readthedocs.io/en/latest/faq.html#how-to-use-jit-with-methods for a discussion of this problem and some potential solutions.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@tw40210
Comment options

Comment options

You must be logged in to vote
1 reply
@tw40210
Comment options

Answer selected by tw40210
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants