PyTorch torch.full 関数
torch.fullPyTorch で指定された値を埋めたテンソルを作成するための関数です。
関数定義
torch.full(size, fill_value, dtype=None, device=None, requires_grad=False)
使用例
実例
import torch
# 3x4 のテンソルを作成し、値を 7 で埋める
x = torch.full((3, 4), 7)
print(x)
# 3x4 のテンソルを作成し、値を 7 で埋める
x = torch.full((3, 4), 7)
print(x)
出力結果は次のとおりです:
tensor([[7., 7., 7., 7.],
[7., 7., 7., 7.],
[7., 7., 7., 7.]])
その他の拡張
Pytorch torch リファレンスマニュアル