PyTorch torch.softmax 関数
torch.softmaxこれは、PyTorch で要素ごとの softmax 関数を計算するための関数です。
関数定義
torch.softmax(input, dim, dtype=None)
使用例
実例
import torch
# softmax を計算する
x = torch.tensor([1.0, 2.0, 3.0])
result = torch.softmax(x, dim=0)
print(result)
# softmax を計算する
x = torch.tensor([1.0, 2.0, 3.0])
result = torch.softmax(x, dim=0)
print(result)
その他の拡張
Pytorch torch リファレンスマニュアル