Skip to content
Discussion options

You must be logged in to vote

Hi, thanks for the question! In this case the best way to proceed is probably to continue operating on fixed-size vectors while accounting for the missing data entries, without constructing intermediate values that have data-dependent shapes. So, for example, you could construct a log-likelihood that skips the missing values, something like this:

def loglikelihood(b, X, y):
  valid_mask = (y != -9)
  return -1 * (jnp.sum(valid_mask * (y * jnp.log(predict(X, b)) + (1 - y) * jnp.log(1 - predict(X, b)))))

Then you can vmap over your minimization without having to construct variable shaped arrays.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@jzluo
Comment options

@jakevdp
Comment options

@jzluo
Comment options

@jakevdp
Comment options

@jzluo
Comment options

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