Please add a method for splitting on a given axis, returning an iterator over subtensors selected in that axis.
For example, suppose mytensor is this 2x3 tensor:
[
[1, 2, 3],
[4, 5, 6],
]
Then mytensor.split(0) should return the iterator of length 2 containing tensors [1, 2, 3] and [4, 5, 6], and mytensor.split(1) should return the iterator of length 3 containing tensors [1, 4], [2, 5], and [3, 6].
Note, this is close to what select does (IIUC), but select consumes its input and so can't be used to construct an iterator like this.
Also, if the general case doesn't seem worth it, I'd be happy just having the function split_0 which would just split on the first axis.
Thanks!
Please add a method for splitting on a given axis, returning an iterator over subtensors selected in that axis.
For example, suppose
mytensoris this2x3tensor:Then
mytensor.split(0)should return the iterator of length 2 containing tensors[1, 2, 3]and[4, 5, 6], andmytensor.split(1)should return the iterator of length 3 containing tensors[1, 4],[2, 5], and[3, 6].Note, this is close to what
selectdoes (IIUC), butselectconsumes its input and so can't be used to construct an iterator like this.Also, if the general case doesn't seem worth it, I'd be happy just having the function
split_0which would just split on the first axis.Thanks!