Closed
Description
TensorFlow and PyTorch have unstack()
functions (Torch calls it unbind()
) for converting an array into a Python sequence of arrays, unpacked along a dimension:
>>> torch.unbind(torch.tensor([[1, 2, 3],
>>> [4, 5, 6],
>>> [7, 8, 9]]))
(tensor([1, 2, 3]), tensor([4, 5, 6]), tensor([7, 8, 9]))
I think this could potentially make sense in the API standard, especially because unlike in NumPy you cannot iterate over the first axis of arrays: #481