Rate this Page
★★★★★
torch.Tensor.size#
- Tensor.size(dim=None)→torch.Sizeorint#
Returns the size of the
selftensor. Ifdimis not specified,the returned value is atorch.Size, a subclass oftuple.Ifdimis specified, returns an int holding the size of that dimension.- Parameters
dim (int,optional) – The dimension for which to retrieve the size.
Example:
>>>t=torch.empty(3,4,5)>>>t.size()torch.Size([3, 4, 5])>>>t.size(dim=1)4
On this page