1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'''import torch
import torch.nn as nn
import torch
norm = torch.nn.LayerNorm(3)
tensor = torch.tensor([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]).reshape((2, 3))
out = norm(tensor)
print(out)'''
'''n_channel = 6
norm = nn.LayerNorm(10)
height = 10
width = 10
n_elements = height * width * n_channel
t = torch.arange(0, n_elements, dtype=torch.float32).mul_(10.0 / n_elements).sin().reshape(1, n_channel, height, width)
out = norm(t)
print(out)'''
= // 2
=
= *
return
=
= 10
=
'''n_group = 3
n_channel = 6
norm = nn.GroupNorm(n_group, n_channel)
height = 10
width = 10
n_elements = height * width * n_channel
t = torch.arange(0, n_elements, dtype=torch.float32).mul_(10.0 / n_elements).sin().reshape(1, n_channel, height, width)
out = norm(t)
print(out.flatten())'''