F.softmax()の使い方

380 ワード

F.softmax()の使い方
>>> import torch
>>> import torch.nn.functional as F
>>> logits = torch.rand(2,2)
>>> pred = F.softmax(logits, dim=1)
>>> logits
tensor([[0.4140, 0.4571],
        [0.9392, 0.6504]])
>>> pred
tensor([[0.4892, 0.5108],
        [0.5717, 0.4283]])
>>>

行ごとに1行ずつ正規化されていることがわかります