Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
7c622482
Unverified
Commit
7c622482
authored
May 03, 2021
by
Stas Bekman
Committed by
GitHub
May 03, 2021
Browse files
fix resize_token_embeddings (#11572)
parent
fe82b1bf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
src/transformers/modeling_utils.py
src/transformers/modeling_utils.py
+3
-1
No files found.
src/transformers/modeling_utils.py
View file @
7c622482
...
...
@@ -682,7 +682,9 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
)
# Build new embeddings
new_embeddings
=
nn
.
Embedding
(
new_num_tokens
,
old_embedding_dim
).
to
(
self
.
device
)
new_embeddings
=
nn
.
Embedding
(
new_num_tokens
,
old_embedding_dim
).
to
(
self
.
device
,
dtype
=
old_embeddings
.
weight
.
dtype
)
# initialize all new embeddings (in particular added tokens)
self
.
_init_weights
(
new_embeddings
)
...
...
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