Skip to content

Modular functions in JAX #25260

Answered by patrick-kidger
Mo-rpheus asked this question in Q&A
Discussion options

You must be logged in to vote

Unsurprisingly I'll advocate for equinox.Module as the best way to do this. :)

Of the options you list:

  • dict: unstructured, probably not recommended in the same way that we prefer classes over dicts in regular Python.
  • namedtuples: generally also recommended against in the same way as in regular Python; largely superseded by dataclasses.
  • equinox.Module: this is just a dataclass-as-pytree, which handles all the edge cases for you (bound methods, inheritance, etc.) If you have multiple solvers that you want to treat interchangeably then I think one of the big advantages here is its strong support for abstract classes. (AbstractVar, __check_init__, see also this advanced guide.)
  • custom class…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Mo-rpheus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants