slice¶
- dragon.- slice(
 inputs,
 starts,
 sizes,
 **kwargs
 )[source]¶
- Select the elements according to the given sections. - Each section should be hinted by a pair of - [start, start + size):- x = dragon.constant([[[0, 1, 2], [3, 4, 5]]]) print(dragon.slice(x, [0, 1, 2], [1, 1, 1])) # [[[5]]] print(x[0:1, 1:2:, 2:3]) # Equivalent - sizesaccepts value- -1or- 0:- x = dragon.constant([[[0, 1, 2], [3, 4, 5]]]) # Set ``0`` to squeeze dimensions with size 1 print(dragon.slice(x, [0, 1, 2], [0, 0, 0])) # 5 # Set ``-1`` to take all the remained elements print(dragon.slice(x, [0, 0, 0], [-1, -1, -1])) # [[[0, 1, 2], [3, 4, 5]]] - Parameters:
- inputs (dragon.Tensor) – The input tensor.
- starts (Union[Sequence[int], dragon.Tensor]) – The start location for each dimension.
- sizes (Union[Sequence[int], dragon.Tensor]) – The number of elements sliced from start.
 
 - Returns:
- dragon.Tensor – The output tensor. 
 
