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
Fairseq
Commits
fd28c880
"graphbolt/git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "4546e54f2145b07275065aada9bf1a5f79a8e238"
Commit
fd28c880
authored
Jan 08, 2018
by
Myle Ott
Browse files
Fix LearnedPositionalEmbedding
parent
4db6579a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
2 deletions
+1
-2
fairseq/modules/learned_positional_embedding.py
fairseq/modules/learned_positional_embedding.py
+1
-2
No files found.
fairseq/modules/learned_positional_embedding.py
View file @
fd28c880
...
@@ -22,7 +22,6 @@ class LearnedPositionalEmbedding(nn.Embedding):
...
@@ -22,7 +22,6 @@ class LearnedPositionalEmbedding(nn.Embedding):
def
__init__
(
self
,
num_embeddings
,
embedding_dim
,
padding_idx
,
left_pad
):
def
__init__
(
self
,
num_embeddings
,
embedding_dim
,
padding_idx
,
left_pad
):
super
().
__init__
(
num_embeddings
,
embedding_dim
,
padding_idx
)
super
().
__init__
(
num_embeddings
,
embedding_dim
,
padding_idx
)
self
.
left_pad
=
left_pad
self
.
left_pad
=
left_pad
self
.
register_buffer
(
'range_buf'
,
None
)
self
.
_is_incremental_eval
=
False
self
.
_is_incremental_eval
=
False
def
incremental_eval
(
self
,
mode
=
True
):
def
incremental_eval
(
self
,
mode
=
True
):
...
@@ -44,7 +43,7 @@ class LearnedPositionalEmbedding(nn.Embedding):
...
@@ -44,7 +43,7 @@ class LearnedPositionalEmbedding(nn.Embedding):
def
make_positions
(
self
,
input
):
def
make_positions
(
self
,
input
):
"""Replace non-padding symbols with their position numbers."""
"""Replace non-padding symbols with their position numbers."""
if
self
.
range_buf
is
None
:
if
not
hasattr
(
self
,
'
range_buf
'
)
:
self
.
range_buf
=
input
.
new
()
self
.
range_buf
=
input
.
new
()
seqlen
=
input
.
size
(
1
)
seqlen
=
input
.
size
(
1
)
if
self
.
range_buf
.
numel
()
<
seqlen
:
if
self
.
range_buf
.
numel
()
<
seqlen
:
...
...
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