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
a7d0bd0e
"git@developer.sourcefind.cn:change/sglang.git" did not exist on "21514ff5bdad2ae598bf3070d3a583aa4fa35ae7"
Commit
a7d0bd0e
authored
Jul 02, 2018
by
alexeib
Committed by
Myle Ott
Jul 25, 2018
Browse files
fix token block rotation
parent
0e9e7f7b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
fairseq/data/token_block_dataset.py
fairseq/data/token_block_dataset.py
+9
-5
No files found.
fairseq/data/token_block_dataset.py
View file @
a7d0bd0e
...
@@ -76,13 +76,17 @@ class TokenBlockDataset(torch.utils.data.Dataset):
...
@@ -76,13 +76,17 @@ class TokenBlockDataset(torch.utils.data.Dataset):
def
__getitem__
(
self
,
index
):
def
__getitem__
(
self
,
index
):
s
,
e
=
self
.
slice_indices
[
index
]
s
,
e
=
self
.
slice_indices
[
index
]
item
=
torch
.
LongTensor
(
self
.
tokens
[
s
:
e
])
item
=
torch
.
LongTensor
(
self
.
tokens
[
s
:
e
])
if
self
.
include_targets
:
if
self
.
include_targets
:
if
e
==
self
.
total_size
:
# target is the sentence, for source, rotate item one token to the left (would start with eos)
return
item
[:
-
1
],
item
[
1
:]
if
s
==
0
:
else
:
source
=
np
.
concatenate
([
self
.
tokens
[
-
1
:],
self
.
tokens
[
0
:
e
-
1
]])
return
item
,
torch
.
LongTensor
(
self
.
tokens
[
s
+
1
:
e
+
1
])
else
:
else
:
source
=
self
.
tokens
[
s
-
1
:
e
-
1
]
return
torch
.
LongTensor
(
source
),
item
return
item
return
item
def
__len__
(
self
):
def
__len__
(
self
):
...
...
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