PyTorch torch.full Function
Pytorch torch Reference Manual
torch.fullis a function in PyTorch used to create a tensor filled with a specified value.
Function Definition
torch.full(size, fill_value, dtype=None, device=None, requires_grad=False)
Usage Example
Example
import torch
# Create a 3x4 tensor with fill value 7
x = torch.full((3, 4), 7)
print(x)
# Create a 3x4 tensor with fill value 7
x = torch.full((3, 4), 7)
print(x)
The output result is:
tensor([[7., 7., 7., 7.],
[7., 7., 7., 7.],
[7., 7., 7., 7.]])
Other Extensions