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
3bde773d
"cacheflow/core/server.py" did not exist on "cfae35b861c5fc0c9f3689f99c7aba2e4501beb8"
Unverified
Commit
3bde773d
authored
Mar 01, 2018
by
Myle Ott
Committed by
GitHub
Mar 01, 2018
Browse files
More fixes for recent PyTorch (incl. topk issue) (#113)
parent
21b8fb5c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
12 deletions
+15
-12
README.md
README.md
+1
-1
fairseq/sequence_generator.py
fairseq/sequence_generator.py
+9
-9
generate.py
generate.py
+4
-1
requirements.txt
requirements.txt
+1
-1
No files found.
README.md
View file @
3bde773d
...
...
@@ -24,7 +24,7 @@ If you use the code in your paper, then please cite it as:
*
Python version 3.6
*
A
[
PyTorch installation
](
http://pytorch.org/
)
Currently fairseq-py requires PyTorch version >= 0.
3
.0.
Currently fairseq-py requires PyTorch version >= 0.
4
.0.
Please follow the instructions here: https://github.com/pytorch/pytorch#installation.
If you use Docker make sure to increase the shared memory size either with
`--ipc=host`
or
`--shm-size`
as command line
...
...
fairseq/sequence_generator.py
View file @
3bde773d
...
...
@@ -271,8 +271,8 @@ class SequenceGenerator(object):
if
step
<
maxlen
:
if
prefix_tokens
is
not
None
and
step
<
prefix_tokens
.
size
(
1
):
probs_slice
=
probs
.
view
(
bsz
,
-
1
,
probs
.
size
(
-
1
))[:,
0
,
:]
cand_scores
=
probs_slice
.
gather
(
dim
=
1
,
cand_scores
=
torch
.
gather
(
probs_slice
,
dim
=
1
,
index
=
prefix_tokens
[:,
step
].
view
(
-
1
,
1
).
data
).
expand
(
-
1
,
cand_size
)
cand_indices
=
prefix_tokens
[:,
step
].
view
(
-
1
,
1
).
expand
(
bsz
,
cand_size
).
data
...
...
@@ -341,17 +341,17 @@ class SequenceGenerator(object):
# get the top beam_size active hypotheses, which are just the hypos
# with the smallest values in active_mask
active_hypos
,
_ignore
=
buffer
(
'active_hypos'
),
buffer
(
'_ignore'
)
active_mask
.
topk
(
k
=
beam_size
,
dim
=
1
,
largest
=
False
,
out
=
(
_ignore
,
active_hypos
)
,
torch
.
topk
(
active_mask
,
k
=
beam_size
,
dim
=
1
,
largest
=
False
,
out
=
(
_ignore
,
active_hypos
)
)
active_bbsz_idx
=
buffer
(
'active_bbsz_idx'
)
cand_bbsz_idx
.
gather
(
dim
=
1
,
index
=
active_hypos
,
torch
.
gather
(
cand_bbsz_idx
,
dim
=
1
,
index
=
active_hypos
,
out
=
active_bbsz_idx
,
)
active_scores
=
cand_scores
.
gather
(
dim
=
1
,
index
=
active_hypos
,
active_scores
=
torch
.
gather
(
cand_scores
,
dim
=
1
,
index
=
active_hypos
,
out
=
scores
[:,
step
].
view
(
bsz
,
beam_size
),
)
active_bbsz_idx
=
active_bbsz_idx
.
view
(
-
1
)
...
...
generate.py
View file @
3bde773d
...
...
@@ -127,7 +127,10 @@ def main(args):
hypo
[
'positional_scores'
].
tolist
(),
))
))
print
(
'A-{}
\t
{}'
.
format
(
sample_id
,
' '
.
join
(
map
(
str
,
alignment
))))
print
(
'A-{}
\t
{}'
.
format
(
sample_id
,
' '
.
join
(
map
(
lambda
x
:
str
(
utils
.
item
(
x
)),
alignment
))
))
# Score only the top hypothesis
if
i
==
0
:
...
...
requirements.txt
View file @
3bde773d
cffi
numpy
torch
>=0.
3
.0
torch
>=0.
4
.0
tqdm
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