jax.numpy.hsplit

Contents

jax.numpy.hsplit#

jax.numpy.hsplit(ary, indices_or_sections)[source]#

Split an array into sub-arrays horizontally.

JAX implementation of numpy.hsplit().

Refer to the documentation of jax.numpy.split() for details. hsplit is equivalent to split with axis=1, or axis=0 for one-dimensional arrays.

Examples

1D array:

>>> x = jnp.array([1, 2, 3, 4, 5, 6])
>>> x1, x2 = jnp.hsplit(x, 2)
>>> print(x1, x2)
[1 2 3] [4 5 6]

2D array:

>>> x = jnp.array([[1, 2, 3, 4],
...                [5, 6, 7, 8]])
>>> x1, x2 = jnp.hsplit(x, 2)
>>> print(x1)
[[1 2]
 [5 6]]
>>> print(x2)
[[3 4]
 [7 8]]

See also

Parameters:
  • ary (ArrayLike)

  • indices_or_sections (int | Sequence[int] | ArrayLike)

Return type:

list[Array]