FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nlp-paper/paper-code/group_normalization.py at master · DengBoCong/nlp-paper · GitHub
DengBoCong
/
nlp-paper
Public
Notifications
You must be signed in to change notification settings
Fork
188
Star
1.3k
Code
Issues
1
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nlp-paper
/
paper-code
/
group_normalization.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
11 lines (10 loc) · 394 Bytes
Breadcrumbs
nlp-paper
/
paper-code
/
group_normalization.py
Copy path
File metadata and controls
11 lines (10 loc) · 394 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
def
GroupNorm
(
x
,
gamma
,
beta
,
G
,
eps
=
1e-5
):
# x: 举例输入shape为[N, C, H, W]
# gamma, beta: scale和offset,shape为[1, C, 1, 1]
# G: GN数量
N
,
C
,
H
,
W
=
x
.
shape
x
=
tf
.
reshape
(
x
, [
N
,
G
,
C
//
G
,
H
,
W
])
mean
,
var
=
tf
.
nn
.
moments
(
x
, [
2
,
3
,
4
],
keep_dims
=
True
)
x
=
(
x
-
mean
)
/
tf
.
sqrt
(
var
+
eps
)
x
=
tf
.
reshape
(
x
, [
N
,
C
,
H
,
W
])
return
x
*
gamma
+
beta
Back
|
FazBrowse Home
|
New Git URL