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
4a82f4f8
Commit
4a82f4f8
authored
Apr 11, 2019
by
thomwolf
Browse files
update special token addition
parent
991b8e65
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
0 deletions
+1
-0
pytorch_pretrained_bert/modeling_openai.py
pytorch_pretrained_bert/modeling_openai.py
+1
-0
No files found.
pytorch_pretrained_bert/modeling_openai.py
View file @
4a82f4f8
...
@@ -608,6 +608,7 @@ class OpenAIGPTModel(OpenAIGPTPreTrainedModel):
...
@@ -608,6 +608,7 @@ class OpenAIGPTModel(OpenAIGPTPreTrainedModel):
# Build new embeddings and initialize all new embeddings (in particular the special tokens)
# Build new embeddings and initialize all new embeddings (in particular the special tokens)
old_embed
=
self
.
tokens_embed
old_embed
=
self
.
tokens_embed
self
.
tokens_embed
=
nn
.
Embedding
(
self
.
config
.
total_tokens_embeddings
,
self
.
config
.
n_embd
)
self
.
tokens_embed
=
nn
.
Embedding
(
self
.
config
.
total_tokens_embeddings
,
self
.
config
.
n_embd
)
self
.
tokens_embed
.
to
(
old_embed
.
device
.
weight
.
device
)
self
.
init_weights
(
self
.
tokens_embed
)
self
.
init_weights
(
self
.
tokens_embed
)
# Copy word embeddings from the previous weights
# Copy word embeddings from the previous weights
self
.
tokens_embed
.
weight
.
data
[:
self
.
config
.
vocab_size
,
:]
=
old_embed
.
weight
.
data
[:
self
.
config
.
vocab_size
,
:]
self
.
tokens_embed
.
weight
.
data
[:
self
.
config
.
vocab_size
,
:]
=
old_embed
.
weight
.
data
[:
self
.
config
.
vocab_size
,
:]
...
...
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