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
47fbc491
"git@developer.sourcefind.cn:OpenDAS/ktransformers.git" did not exist on "bbcc5481bbe40c7d92601671da1b3190abf33986"
Commit
47fbc491
authored
May 10, 2019
by
myleott
Browse files
fbshipit-source-id: 682b375c6e7535f12faaf9ca32811051f9e874da
parent
cfeb2163
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
8 deletions
+12
-8
fairseq/data/indexed_dataset.py
fairseq/data/indexed_dataset.py
+2
-4
fairseq/data/round_robin_zip_datasets.py
fairseq/data/round_robin_zip_datasets.py
+1
-1
fairseq/data/token_block_dataset.py
fairseq/data/token_block_dataset.py
+3
-1
fairseq/progress_bar.py
fairseq/progress_bar.py
+5
-0
fairseq/tasks/cross_lingual_lm.py
fairseq/tasks/cross_lingual_lm.py
+1
-2
No files found.
fairseq/data/indexed_dataset.py
View file @
47fbc491
...
@@ -134,8 +134,7 @@ class IndexedDataset(torch.utils.data.Dataset):
...
@@ -134,8 +134,7 @@ class IndexedDataset(torch.utils.data.Dataset):
@
staticmethod
@
staticmethod
def
exists
(
path
):
def
exists
(
path
):
return
(
return
(
os
.
path
.
exists
(
index_file_path
(
path
))
and
os
.
path
.
exists
(
index_file_path
(
path
))
and
os
.
path
.
exists
(
data_file_path
(
path
))
os
.
path
.
exists
(
data_file_path
(
path
))
)
)
@
property
@
property
...
@@ -432,8 +431,7 @@ class MMapIndexedDataset(torch.utils.data.Dataset):
...
@@ -432,8 +431,7 @@ class MMapIndexedDataset(torch.utils.data.Dataset):
@
staticmethod
@
staticmethod
def
exists
(
path
):
def
exists
(
path
):
return
(
return
(
os
.
path
.
exists
(
index_file_path
(
path
))
and
os
.
path
.
exists
(
index_file_path
(
path
))
and
os
.
path
.
exists
(
data_file_path
(
path
))
os
.
path
.
exists
(
data_file_path
(
path
))
)
)
...
...
fairseq/data/round_robin_zip_datasets.py
View file @
47fbc491
...
@@ -43,7 +43,7 @@ class RoundRobinZipDatasets(FairseqDataset):
...
@@ -43,7 +43,7 @@ class RoundRobinZipDatasets(FairseqDataset):
def
_map_index
(
self
,
key
,
index
):
def
_map_index
(
self
,
key
,
index
):
assert
self
.
_ordered_indices
is
not
None
,
\
assert
self
.
_ordered_indices
is
not
None
,
\
'Must call RoundRobinZipDatasets.ordered_indices() first'
'Must call RoundRobinZipDatasets.ordered_indices() first'
return
self
.
_ordered_indices
[
key
][
index
%
len
(
self
.
datasets
[
key
])]
return
self
.
_ordered_indices
[
key
][
index
%
len
(
self
.
datasets
[
key
])]
def
__getitem__
(
self
,
index
):
def
__getitem__
(
self
,
index
):
...
...
fairseq/data/token_block_dataset.py
View file @
47fbc491
...
@@ -40,6 +40,7 @@ class TokenBlockDataset(FairseqDataset):
...
@@ -40,6 +40,7 @@ class TokenBlockDataset(FairseqDataset):
self
.
slice_indices
=
[]
self
.
slice_indices
=
[]
assert
len
(
dataset
)
==
len
(
sizes
)
assert
len
(
dataset
)
==
len
(
sizes
)
assert
len
(
dataset
)
>
0
sizes
=
np
.
array
(
sizes
,
dtype
=
int
)
sizes
=
np
.
array
(
sizes
,
dtype
=
int
)
if
break_mode
is
None
or
break_mode
==
'none'
:
if
break_mode
is
None
or
break_mode
==
'none'
:
total_size
=
sum
(
sizes
)
total_size
=
sum
(
sizes
)
...
@@ -71,7 +72,8 @@ class TokenBlockDataset(FairseqDataset):
...
@@ -71,7 +72,8 @@ class TokenBlockDataset(FairseqDataset):
sizes
=
torch
.
tensor
(
sizes
)
sizes
=
torch
.
tensor
(
sizes
)
cumsum
=
torch
.
cumsum
(
sizes
,
dim
=
0
)
cumsum
=
torch
.
cumsum
(
sizes
,
dim
=
0
)
self
.
slice_indices
[
0
]
=
[
0
,
sizes
[
0
]]
self
.
slice_indices
[
0
]
=
[
0
,
sizes
[
0
]]
self
.
slice_indices
[
1
:]
=
cumsum
.
unfold
(
0
,
2
,
1
)
if
len
(
cumsum
)
>
1
:
self
.
slice_indices
[
1
:]
=
cumsum
.
unfold
(
0
,
2
,
1
)
else
:
else
:
raise
ValueError
(
'Invalid break_mode: '
+
break_mode
)
raise
ValueError
(
'Invalid break_mode: '
+
break_mode
)
...
...
fairseq/progress_bar.py
View file @
47fbc491
...
@@ -252,6 +252,11 @@ class tensorboard_log_wrapper(progress_bar):
...
@@ -252,6 +252,11 @@ class tensorboard_log_wrapper(progress_bar):
self
.
_log_to_tensorboard
(
stats
,
tag
,
step
)
self
.
_log_to_tensorboard
(
stats
,
tag
,
step
)
self
.
wrapped_bar
.
print
(
stats
,
tag
=
tag
,
step
=
step
)
self
.
wrapped_bar
.
print
(
stats
,
tag
=
tag
,
step
=
step
)
def
__exit__
(
self
,
*
exc
):
for
writer
in
getattr
(
self
,
'_writers'
,
{}).
values
():
writer
.
close
()
return
False
def
_log_to_tensorboard
(
self
,
stats
,
tag
=
''
,
step
=
None
):
def
_log_to_tensorboard
(
self
,
stats
,
tag
=
''
,
step
=
None
):
writer
=
self
.
_writer
(
tag
)
writer
=
self
.
_writer
(
tag
)
if
writer
is
None
:
if
writer
is
None
:
...
...
fairseq/tasks/cross_lingual_lm.py
View file @
47fbc491
...
@@ -181,6 +181,5 @@ class CrossLingualLMTask(FairseqTask):
...
@@ -181,6 +181,5 @@ class CrossLingualLMTask(FairseqTask):
dataset_map
,
default_key
=
self
.
default_key
dataset_map
,
default_key
=
self
.
default_key
)
)
print
(
'| {} {} {} examples'
.
format
(
print
(
'| {} {} {} examples'
.
format
(
self
.
args
.
data
.
split
(
':'
)[
epoch
],
split
,
len
(
self
.
datasets
[
split
])
self
.
args
.
data
.
split
(
':'
)[
epoch
],
split
,
len
(
self
.
datasets
[
split
]))
)
)
)
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