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
chenpangpang
transformers
Commits
e83d9f1c
Commit
e83d9f1c
authored
Jan 10, 2020
by
VictorSanh
Browse files
cleaning - change ' to " (black requirements)
parent
ebba9e92
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
examples/distillation/lm_seqs_dataset.py
examples/distillation/lm_seqs_dataset.py
+4
-4
No files found.
examples/distillation/lm_seqs_dataset.py
View file @
e83d9f1c
...
@@ -114,17 +114,17 @@ class LmSeqsDataset(Dataset):
...
@@ -114,17 +114,17 @@ class LmSeqsDataset(Dataset):
"""
"""
Remove sequences with a (too) high level of unknown tokens.
Remove sequences with a (too) high level of unknown tokens.
"""
"""
if
'
unk_token
'
not
in
self
.
params
.
special_tok_ids
:
if
"
unk_token
"
not
in
self
.
params
.
special_tok_ids
:
return
return
else
:
else
:
unk_token_id
=
self
.
params
.
special_tok_ids
[
'
unk_token
'
]
unk_token_id
=
self
.
params
.
special_tok_ids
[
"
unk_token
"
]
init_size
=
len
(
self
)
init_size
=
len
(
self
)
unk_occs
=
np
.
array
([
np
.
count_nonzero
(
a
==
unk_token_id
)
for
a
in
self
.
token_ids
])
unk_occs
=
np
.
array
([
np
.
count_nonzero
(
a
==
unk_token_id
)
for
a
in
self
.
token_ids
])
indices
=
(
unk_occs
/
self
.
lengths
)
<
0.5
indices
=
(
unk_occs
/
self
.
lengths
)
<
0.5
self
.
token_ids
=
self
.
token_ids
[
indices
]
self
.
token_ids
=
self
.
token_ids
[
indices
]
self
.
lengths
=
self
.
lengths
[
indices
]
self
.
lengths
=
self
.
lengths
[
indices
]
new_size
=
len
(
self
)
new_size
=
len
(
self
)
logger
.
info
(
f
'
Remove
{
init_size
-
new_size
}
sequences with a high level of unknown tokens (50%).
'
)
logger
.
info
(
f
"
Remove
{
init_size
-
new_size
}
sequences with a high level of unknown tokens (50%).
"
)
def
print_statistics
(
self
):
def
print_statistics
(
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