fn
hsplit
→list[Tensor]hsplit(x: Tensor, indices_or_sections: int | Sequence[int])Split a tensor horizontally (along axis 1 for rank ).
NumPy-style horizontal split: cuts the input column-wise along axis 1 for tensors of rank . For 1-D inputs the axis collapses to 0, since there is only one dimension available.
Parameters
xTensorInput tensor. At least 1-D.
indices_or_sectionsint | Sequence[int]int: number of (near-)equal-sized splits. If the axis length is not divisible byk, the firstaxis_len % kpieces get one extra element.Sequence[int]: cut indices along the split axis (axis 1 for rank , axis 0 for 1-D).
Returns
list[Tensor]Sub-tensors whose concatenation along the split axis reproduces
x.
Notes
Companion to vsplit (axis 0) and dsplit (axis 2).
The axis-selection rule
matches NumPy's convention so that 1-D inputs behave intuitively rather than raising on the missing column axis.
Examples
>>> import lucid
>>> x = lucid.arange(12).reshape(3, 4)
>>> [s.shape for s in lucid.hsplit(x, 2)]
[(3, 2), (3, 2)]
>>> v = lucid.arange(6)
>>> [s.shape for s in lucid.hsplit(v, 3)]
[(2,), (2,), (2,)]