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
cb0d7b2a
Commit
cb0d7b2a
authored
Sep 25, 2017
by
Louis Martin
Committed by
Myle Ott
Oct 19, 2017
Browse files
Fix flake8 warnings
parent
7333d04d
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
11 additions
and
4 deletions
+11
-4
fairseq/__init__.py
fairseq/__init__.py
+2
-0
fairseq/bleu.py
fairseq/bleu.py
+1
-1
fairseq/data.py
fairseq/data.py
+1
-1
fairseq/sequence_generator.py
fairseq/sequence_generator.py
+1
-1
fairseq/utils.py
fairseq/utils.py
+1
-1
generate.py
generate.py
+1
-0
preprocess.py
preprocess.py
+1
-0
score.py
score.py
+1
-0
setup.py
setup.py
+1
-0
train.py
train.py
+1
-0
No files found.
fairseq/__init__.py
View file @
cb0d7b2a
...
@@ -7,3 +7,5 @@
...
@@ -7,3 +7,5 @@
#
#
from
.multiprocessing_pdb
import
pdb
from
.multiprocessing_pdb
import
pdb
__all__
=
[
'pdb'
]
fairseq/bleu.py
View file @
cb0d7b2a
...
@@ -97,7 +97,7 @@ class Scorer(object):
...
@@ -97,7 +97,7 @@ class Scorer(object):
def
result_string
(
self
,
order
=
4
):
def
result_string
(
self
,
order
=
4
):
assert
order
<=
4
,
"BLEU scores for order > 4 aren't supported"
assert
order
<=
4
,
"BLEU scores for order > 4 aren't supported"
fmt
=
'BLEU{} = {:2.2f}, {:2.1f}'
fmt
=
'BLEU{} = {:2.2f}, {:2.1f}'
for
i
in
range
(
1
,
order
):
for
_
in
range
(
1
,
order
):
fmt
+=
'/{:2.1f}'
fmt
+=
'/{:2.1f}'
fmt
+=
' (BP={:.3f}, ratio={:.3f}, syslen={}, reflen={})'
fmt
+=
' (BP={:.3f}, ratio={:.3f}, syslen={}, reflen={})'
bleup
=
[
p
*
100
for
p
in
self
.
precision
()[:
order
]]
bleup
=
[
p
*
100
for
p
in
self
.
precision
()[:
order
]]
...
...
fairseq/data.py
View file @
cb0d7b2a
...
@@ -326,7 +326,7 @@ def shuffled_batches_by_size(src, dst, max_tokens=None, epoch=1, sample=0, max_p
...
@@ -326,7 +326,7 @@ def shuffled_batches_by_size(src, dst, max_tokens=None, epoch=1, sample=0, max_p
batches
=
result
batches
=
result
else
:
else
:
for
i
in
range
(
epoch
-
1
):
for
_
in
range
(
epoch
-
1
):
np
.
random
.
shuffle
(
batches
)
np
.
random
.
shuffle
(
batches
)
return
batches
return
batches
...
...
fairseq/sequence_generator.py
View file @
cb0d7b2a
...
@@ -126,7 +126,7 @@ class SequenceGenerator(object):
...
@@ -126,7 +126,7 @@ class SequenceGenerator(object):
# helper function for allocating buffers on the fly
# helper function for allocating buffers on the fly
buffers
=
{}
buffers
=
{}
def
buffer
(
name
,
type_of
=
tokens
):
def
buffer
(
name
,
type_of
=
tokens
):
# noqa
if
name
not
in
buffers
:
if
name
not
in
buffers
:
buffers
[
name
]
=
type_of
.
new
()
buffers
[
name
]
=
type_of
.
new
()
return
buffers
[
name
]
return
buffers
[
name
]
...
...
fairseq/utils.py
View file @
cb0d7b2a
...
@@ -41,7 +41,7 @@ def torch_persistent_save(*args, **kwargs):
...
@@ -41,7 +41,7 @@ def torch_persistent_save(*args, **kwargs):
for
i
in
range
(
3
):
for
i
in
range
(
3
):
try
:
try
:
return
torch
.
save
(
*
args
,
**
kwargs
)
return
torch
.
save
(
*
args
,
**
kwargs
)
except
:
except
Exception
:
if
i
==
2
:
if
i
==
2
:
logging
.
error
(
traceback
.
format_exc
())
logging
.
error
(
traceback
.
format_exc
())
...
...
generate.py
View file @
cb0d7b2a
#!/usr/bin/env python3
# Copyright (c) 2017-present, Facebook, Inc.
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
# All rights reserved.
#
#
...
...
preprocess.py
View file @
cb0d7b2a
#!/usr/bin/env python3
# Copyright (c) 2017-present, Facebook, Inc.
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
# All rights reserved.
#
#
...
...
score.py
View file @
cb0d7b2a
#!/usr/bin/env python3
# Copyright (c) 2017-present, Facebook, Inc.
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
# All rights reserved.
#
#
...
...
setup.py
View file @
cb0d7b2a
#!/usr/bin/env python3
# Copyright (c) 2017-present, Facebook, Inc.
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
# All rights reserved.
#
#
...
...
train.py
View file @
cb0d7b2a
#!/usr/bin/env python3
# Copyright (c) 2017-present, Facebook, Inc.
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
# All rights reserved.
#
#
...
...
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