input_ = torch.randn((3, 4))
a = torch.nn.Softmax()(input_)
b = torch.nn.functional.normalize(a)
# a是[
[11 12 13],
[21 22 23],
[31 32 33]
]
a的结果为:
tensor([[0.2074, 0.2850, 0.1973, 0.3103],
[0.2773, 0.1442, 0.3652, 0.2132],
[0.3244, 0.3206, 0.0216, 0.3334]])
# softmax计算时11/11+12+13---0.2074 0.2074+0.2850+0.1973+0.3103= 1
b的结果为:
tensor([[0.4071, 0.5595, 0.3874, 0.6092],
[0.5274, 0.2743, 0.6945, 0.4054],
[0.5738, 0.5671, 0.0381, 0.5896]])
#b中的0.4071其实就是a中的 0.2074/根号下(0.2074*0.2074+0.285*0.285+0.1973*0.1973+0.3103*0.3103) = 0.4071