Skip to content
Discussion options

You must be logged in to vote

What I mean by "define a function with respect to its flattened contents" is defining a function that accepts arrays or scalars as arguments. For example:

def f(EL, ET):
  fiber = Material("Fiber", EL, ET)
  return fiber.Stiffness().sum()

print(jax.grad(f, argnums=1)(1.0, 1.0))

It's not very convenient, but since there's currently no way to construct the gradient with respect to a class attribute, this is the best workaround.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@AlvaroDFC
Comment options

@jakevdp
Comment options

Answer selected by AlvaroDFC
@AlvaroDFC
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants