(x, n_categories, dtype=jnp.float32)
return jnp.array(x[..., jnp.newaxis] == indices_less_than_n, dtype)
Makes a one-hot array (n+1 dims) from an int-categorical array (n dims).
Makes a one-hot array (n+1 dims) from an int-categorical array (n dims).
Makes a one - hot array ( n + 1 dims ) from an int - categorical array ( n dims ) .
def one_hot(x, n_categories, dtype=jnp.float32):  # pylint: disable=invalid-name
  """Makes a one-hot array (n+1 dims) from an int-categorical array (n dims)."""
  indices_less_than_n = jnp.arange(n_categories)
  return jnp.array(x[..., jnp.newaxis] == indices_less_than_n, dtype)
def one_hot ( x , n_categories , dtype = jnp . float32 ) : # pylint: disable=invalid-name indices_less_than_n = jnp . arange ( n_categories ) return jnp . array ( x [ ... , jnp . newaxis ] == indices_less_than_n , dtype )