jax.numpy.hsplit#
- jax.numpy.hsplit(ary, indices_or_sections)[source]#
将数组水平分割成子数组。
numpy.hsplit()
的 JAX 实现。有关详细信息,请参阅
jax.numpy.split()
的文档。hsplit
等效于split
,其中axis=1
,或者对于一维数组,axis=0
。示例
一维数组
>>> x = jnp.array([1, 2, 3, 4, 5, 6]) >>> x1, x2 = jnp.hsplit(x, 2) >>> print(x1, x2) [1 2 3] [4 5 6]
二维数组
>>> 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]]
另请参阅
jax.numpy.split()
:沿任何轴分割数组。jax.numpy.vsplit()
:垂直分割,即沿 axis=0jax.numpy.dsplit()
:深度分割,即沿 axis=2jax.numpy.array_split()
:类似于split
,但允许indices_or_sections
是一个不能均匀分割数组大小的整数。