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
Megatron-LM
Commits
6d45a903
Commit
6d45a903
authored
Nov 22, 2022
by
Yu Yao
Browse files
Fix DropPath for hidden shape [s, b, h]
parent
70169453
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
megatron/model/transformer.py
megatron/model/transformer.py
+2
-1
No files found.
megatron/model/transformer.py
View file @
6d45a903
...
@@ -45,7 +45,8 @@ class DropPath(MegatronModule):
...
@@ -45,7 +45,8 @@ class DropPath(MegatronModule):
return
hidden_state
return
hidden_state
keep_prob
=
1
-
self
.
drop_prob
keep_prob
=
1
-
self
.
drop_prob
# work with diff dim tensors, not just 2D ConvNets
# work with diff dim tensors, not just 2D ConvNets
shape
=
(
hidden_state
.
shape
[
0
],)
+
(
1
,)
*
(
hidden_state
.
ndim
-
1
)
# hidden_state: [s, b, h]
shape
=
(
1
,)
+
(
hidden_state
.
shape
[
1
],)
+
(
1
,)
*
(
hidden_state
.
ndim
-
2
)
random_tensor
=
keep_prob
+
\
random_tensor
=
keep_prob
+
\
torch
.
rand
(
shape
,
dtype
=
hidden_state
.
dtype
,
device
=
hidden_state
.
device
)
torch
.
rand
(
shape
,
dtype
=
hidden_state
.
dtype
,
device
=
hidden_state
.
device
)
random_tensor
.
floor_
()
# binarize
random_tensor
.
floor_
()
# binarize
...
...
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