Size
- class paddle. Size ( iterable=(), / )
-
The result type of a call to
paddle.Tensor.size(). It describes the size of all dimensions of the original tensor. As a subclass of list, it supports all common sequence operations like indexing, slicing, concatenation, etc.- Parameters
-
*args – Either a sequence of integers or multiple integer arguments representing dimensions.
- Returns
-
A special list subclass representing tensor dimensions.
- Return type
-
Size
Examples
>>> import paddle >>> size = paddle.Size([2, 3, 4]) >>> print(size) paddle.Size([2, 3, 4])
-
append
(
object,
/
)
append¶
-
Append object to the end of the list.
-
clear
(
)
clear¶
-
Remove all items from list.
-
copy
(
)
copy¶
-
Return a shallow copy of the list.
-
count
(
value,
/
)
count¶
-
Return number of occurrences of value.
-
extend
(
iterable,
/
)
extend¶
-
Extend list by appending elements from the iterable.
-
index
(
value,
start=0,
stop=9223372036854775807,
/
)
index¶
-
Return first index of value.
Raises ValueError if the value is not present.
-
insert
(
index,
object,
/
)
insert¶
-
Insert object before index.
-
numel
(
)
[source]
numel¶
-
Calculates the total number of elements in the Size. It is the product of all dimensions.
- Returns
-
The total number of elements.
- Return type
-
int
Examples
>>> import paddle >>> size = paddle.Size([2, 3, 4]) >>> size.numel() 24 >>> empty_size = paddle.Size([]) >>> empty_size.numel() 1
-
pop
(
index=-1,
/
)
pop¶
-
Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove
(
value,
/
)
remove¶
-
Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse
(
)
reverse¶
-
Reverse IN PLACE.
-
sort
(
*,
key=None,
reverse=False
)
[source]
sort¶
-
Sort the list in ascending order and return None.
The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.
