Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
FastMoE
Commits
5dc62b41
Commit
5dc62b41
authored
Feb 24, 2021
by
Jiezhong Qiu
Browse files
use nn.Sequential as activation
activation passed by func can not be saved
parent
61e4533f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
examples/transformer-xl/mem_transformer.py
examples/transformer-xl/mem_transformer.py
+6
-4
No files found.
examples/transformer-xl/mem_transformer.py
View file @
5dc62b41
...
...
@@ -821,11 +821,13 @@ class RelLearnableMultiHeadAttn(RelMultiHeadAttn):
from
fmoe
import
FMoETransformerMLP
class
CustomizedMoEPositionwiseFF
(
FMoETransformerMLP
):
def
__init__
(
self
,
d_model
,
d_inner
,
dropout
,
pre_lnorm
=
False
,
moe_num_expert
=
64
,
moe_top_k
=
2
):
def
activation
(
x
):
return
self
.
dropout
(
F
.
relu
(
x
))
activation
=
nn
.
Sequential
(
nn
.
Dropout
(
dropout
),
nn
.
ReLU
()
)
super
().
__init__
(
num_expert
=
moe_num_expert
,
d_model
=
d_model
,
d_hidden
=
d_inner
,
top_k
=
moe_top_k
,
do_lnorm
=
True
,
pre_lnorm
=
pre_lnorm
,
activation
=
activation
)
self
.
dropout
=
nn
.
Dropout
(
dropout
)
do_lnorm
=
True
,
pre_lnorm
=
pre_lnorm
,
activation
=
activation
,
dropout
=
dropout
)
#
self.dropout = nn.Dropout(dropout)
def
forward
(
self
,
x
):
x
=
super
().
forward
(
x
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment