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
699bc7e8
"git@developer.sourcefind.cn:modelzoo/resnet50_tensorflow.git" did not exist on "80f1d815f3f29836ef329b465d5e745a1f9cbf22"
Commit
699bc7e8
authored
Jul 12, 2019
by
thomwolf
Browse files
fix gpt-2 unk token test
parent
762ded9b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
docs/README.md
docs/README.md
+1
-1
pytorch_transformers/tokenization_gpt2.py
pytorch_transformers/tokenization_gpt2.py
+3
-1
No files found.
docs/README.md
View file @
699bc7e8
pytorch_transformers/tokenization_gpt2.py
View file @
699bc7e8
...
@@ -177,7 +177,9 @@ class GPT2Tokenizer(PreTrainedTokenizer):
...
@@ -177,7 +177,9 @@ class GPT2Tokenizer(PreTrainedTokenizer):
def
_convert_token_to_id
(
self
,
token
):
def
_convert_token_to_id
(
self
,
token
):
""" Converts a token (str/unicode) in an id using the vocab. """
""" Converts a token (str/unicode) in an id using the vocab. """
if
token
in
self
.
encoder
:
return
self
.
encoder
.
get
(
token
)
return
self
.
encoder
.
get
(
token
)
return
self
.
encoder
.
get
(
self
.
unk_token
)
def
_convert_id_to_token
(
self
,
index
):
def
_convert_id_to_token
(
self
,
index
):
"""Converts an index (integer) in a token (string/unicode) using the vocab."""
"""Converts an index (integer) in a token (string/unicode) using the vocab."""
...
...
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