torch.Tensor.new_zeros¶
-
Tensor.new_zeros(size, dtype=None, device=None, requires_grad=False) → Tensor¶ Returns a Tensor of size
sizefilled with0. By default, the returned Tensor has the sametorch.dtypeandtorch.deviceas this tensor.- Parameters
size (int...) – a list, tuple, or
torch.Sizeof integers defining the shape of the output tensor.dtype (
torch.dtype, optional) – the desired type of returned tensor. Default: if None, sametorch.dtypeas this tensor.device (
torch.device, optional) – the desired device of returned tensor. Default: if None, sametorch.deviceas this tensor.requires_grad (bool, optional) – If autograd should record operations on the returned tensor. Default:
False.
Example:
>>> tensor = torch.tensor((), dtype=torch.float64) >>> tensor.new_zeros((2, 3)) tensor([[ 0., 0., 0.], [ 0., 0., 0.]], dtype=torch.float64)