PyTorch torch.full function
PyTorch torch reference manual
torch.full A function in PyTorch for creating a tensor filled with a specified value.
Function definition
torch.full(size, fill_value, dtype=None, device=None, requires_grad=False)
Usage examples
Example
import
torch
Create a 3x4 tensor filled with the value 7
x
=
torch.
full
(
(
3
,
4
)
,
7
)
(
x
)
The output is:
tensor([[7., 7., 7., 7.],
[7., 7., 7., 7.],
[7., 7., 7., 7.]])