Computing gradient using JAX of a function that outputs a list of arrays
I have a function which returns a list of arrays, and I need to find its derivative with respect to a single parameter. For instance, let’s say we have
transform DeviceArray into Array for jax
I have a .pkl
file I downloaded from a public GitHub repository and when I read it using pickle.load
, i.e. using
Basic Hutchinson-Skilling estimator in Jax
I’m trying to implement the Hutchinson-Skilling estimator (later used in the context of diffusion models) in Jax, but I’m having difficuly understanding why even in some very basic cases, I need so many gaussian samples to have an accurate estimator.
jax.lax.cond executing both branches instead of just the True branch
I’m encountering an AttributeError: 'NoneType' object has no attribute
in my Python code using JAX’s jax.lax.cond
. Here’s a simplified version of what I’m trying to do:
constant-memory vectorized sum of function values with jax
Let’s say I have a function f
that takes an integer argument and returns a fixed-size array. I want to evaluate the sum of f(i)
over range(N)
for some large N
, such that storing all values in memory becomes problematic. With a simple for
loop I can fix this easily and evaluate the sum with constant memory use:
jax complaining about static start/stop/step
Here is a very simple computation in jax which errors out with complaints about static indices:
deque-like data structure in JAX
I am trying to create a data structure that has a fixed length, appends to the right and pops from the left in JAX, similar to a deque.
Multiplying chains of matrices in JAX
Suppose I have a vector of parameters p
which parameterizes a set of matrices A_1(p), A_2(p),...,A_N(p)
. I have a computation in which for some list of indices q
, I have to compute A_{q_M} * ... * A_{q_2} * A_{q_1} * v
for several different q
s. Each q
has a different length, but crucially doesn’t change! What changes, and what I wish to take gradients against is p
.
save integration every nth steps
I would like to be able to solve an ODE with Forward Euler and save the results every nth iteration.
jax parallel multiplication of pairs of matrix with different shapes
Task:
I have two lists of matrices A,B with length N. For each pair of elements A[i], B[i] shapes are such that matrix product is well-defined, however for each i in $0,dots, N-1$ shapes can be different. Hence, I can not stack them in array. Shapes are static.