網(wǎng)站建站客戶需求表單鄭州網(wǎng)站制作選擇樂云seo
這個(gè)是層歸一化。我們輸入一個(gè)參數(shù),這個(gè)參數(shù)就必須與最后一個(gè)維度對(duì)應(yīng)。但是我們也可以輸入多個(gè)維度,但是必須從后向前對(duì)應(yīng)。
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)