torch.max和torch.softmax

 

softmax 先exp,再在上面求總和的百分比

解決了負數相互抵消的問題。

 

if __name__ == '__main__':
    import torch
    import torch.nn.functional as F

    input = torch.randn(2, 2)
    print(input)

    b = torch.softmax(input, dim=0)  # 按列SoftMax,列和爲1
    print(b)
    b = torch.max(input, dim=0)  # 按列SoftMax,列和爲1
    print(b)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章