When I use Layer Norm I get an errro while without using Layer Norm I do not get this error

How to solve this problem

out_layer1 = nn.Sequential(
    nn.Conv2d(80, 32,kernel_size=3,groups=2),
    nn.LayerNorm(32),
    nn.Dropout(0.1)
)
data= torch.Tensor(64, 80, 3,3)
out = out_layer1(data)
print(out.shape)

RuntimeError: Given normalized_shape=[32], expected input with shape [*, 32], but got input of size[64, 32, 1, 1]

data= torch.Tensor(64, 80, 3,3)
out_w, out_h = 1, 1
out_layer1 = nn.Sequential(
    nn.Conv2d(80, 32,kernel_size=3,groups=2),
    nn.LayerNorm([32,out_w,out_h]),
    nn.Dropout(0.1)
)
out = out_layer1(data)
print(out.shape)

data= torch.Tensor(64, 80, 5,5)
out_w, out_h = 3, 3
out_layer1 = nn.Sequential(
    nn.Conv2d(80, 32,kernel_size=3,groups=2),
    nn.LayerNorm([32,out_w,out_h]),
    nn.Dropout(0.1)
)
out = out_layer1(data)
print(out.shape)
1 Like

Thank you very much @KaiHoo

Could you tell me how to solve problems like this with other data? Or how do you fix this bug?