torch.full — PyTorch 2.7 documentation (original) (raw)

torch.full(size, fill_value, *, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) → Tensor

Creates a tensor of size size filled with fill_value. The tensor’s dtype is inferred from fill_value.

Parameters

Keyword Arguments

Example:

torch.full((2, 3), 3.141592) tensor([[ 3.1416, 3.1416, 3.1416], [ 3.1416, 3.1416, 3.1416]])