Skip to content

Extracting Data from traced ConcreteArray #5789

Answered by jakevdp
vasilavramov asked this question in Q&A
Discussion options

You must be logged in to vote

You can use the val attribute of the ConcreteArray to extract the concrete value; for example:

import jax.numpy as jnp
from jax import grad

extracted_value = None

def add(a, b):
  global extracted_value
  extracted_value = a.val
  return jnp.add(a, b)

_ = grad(add)(2.0, 10.)

print(extracted_value)
# 2.0

However, for most uses of JAX you should not need to do this. Can you say more about the application that inspired this question?

Replies: 1 comment 3 replies

Comment options

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

@vasilavramov
Comment options

@mattjj
Comment options

Answer selected by vasilavramov
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