torch.Tensor.new_full¶
-
Tensor.
new_full
(size, fill_value, dtype=None, device=None, requires_grad=False) → Tensor¶ Returns a Tensor of size
size
filled withfill_value
. By default, the returned Tensor has the sametorch.dtype
andtorch.device
as this tensor.- Parameters
fill_value (scalar) – the number to fill the output tensor with.
dtype (
torch.dtype
, optional) – the desired type of returned tensor. Default: if None, sametorch.dtype
as this tensor.device (
torch.device
, optional) – the desired device of returned tensor. Default: if None, sametorch.device
as this tensor.requires_grad (bool, optional) – If autograd should record operations on the returned tensor. Default:
False
.
Example:
>>> tensor = torch.ones((2,), dtype=torch.float64) >>> tensor.new_full((3, 4), 3.141592) tensor([[ 3.1416, 3.1416, 3.1416, 3.1416], [ 3.1416, 3.1416, 3.1416, 3.1416], [ 3.1416, 3.1416, 3.1416, 3.1416]], dtype=torch.float64)