Solving Misunderstandings 1

1. softmax and dim

a=nn.functional.softmax(torch.tensor([[1,2],[2,5]],dtype=torch.float32),dim =1)
print(a[0][0]+a[0][1])
#print()

#dim为1表示softmax后dim那维度做变量,其余不变 加起来为1  这里意思是dim=1是列 在某行每一列加起来为1

2. In softmax, if positive numbers are normal, negative numbers are reversed

For example, if it is a positive number, 0, 1, 2, 5, 0 is undoubtedly the smallest result. Just from the perspective of thought, the proportion is the smallest, and 5 is the largest.

After adding the sign, the order is directly opposite 0 is the largest

ab=nn.functional.softmax(torch.tensor([0,-1,-2,-5],dtype=torch.float32))
print()

 

 

おすすめ

転載: blog.csdn.net/qq_36632604/article/details/129838205