網站建站客戶需求表單鄭州網站制作選擇樂云seo
這個是層歸一化。我們輸入一個參數,這個參數就必須與最后一個維度對應。但是我們也可以輸入多個維度,但是必須從后向前對應。
import torch
import torch.nn as nna = torch.rand((100,5))
c = nn.LayerNorm([5])
print(c(a).shape)a = torch.rand((100,5,8,9))
c = nn.LayerNorm([9])
print(c(a).shape)a = torch.rand((100,5,8,9))
c = nn.LayerNorm([8,9])
print(c(a).shape)a = torch.rand((100,5,8,9))
c = nn.LayerNorm([5,8,9])
print(c(a).shape)