定义
torch.full(size,num)
用法
话不多说,直接看示例
示例
import torch
a = torch.full((4,4),3)
b = torch.full((5,6),9)
print(a)
print(b)
>>>tensor([[3, 3, 3, 3],
[3, 3, 3, 3],
[3, 3, 3, 3],
[3, 3, 3, 3]])
tensor([[9, 9, 9, 9, 9, 9],
[9, 9, 9, 9, 9, 9],
[9, 9, 9, 9, 9, 9],
[9, 9, 9, 9, 9, 9],
[9, 9, 9, 9, 9, 9]])