Function autograd::ops::slice
[−]
[src]
pub fn slice(x: &Tensor, starts: &[isize], ends: &[isize]) -> Tensor
Slices input tensor with indices.
Arguments
x
- Tensor with arbitrary shape.starts
- Start indices for each dimensionsends
- End indices for each dimensions.-1
representing the last index is acceptable for each dimension.
extern crate autograd as ag; let ref a = ag::zeros(&[4, 4]); let ref b = ag::slice(a, &[0, 0], &[-1, 2]); // numpy equivalent is a[:, 0:2] assert_eq!(b.eval(&[]).unwrap().shape(), &[4, 2]);