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
7d0b6fc3
Unverified
Commit
7d0b6fc3
authored
Jun 08, 2022
by
Joao Gante
Committed by
GitHub
Jun 08, 2022
Browse files
CLI: Properly detect encoder-decoder models (#17605)
parent
ee82c86b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
src/transformers/commands/pt_to_tf.py
src/transformers/commands/pt_to_tf.py
+1
-1
No files found.
src/transformers/commands/pt_to_tf.py
View file @
7d0b6fc3
...
...
@@ -207,7 +207,7 @@ class PTtoTFCommand(BaseTransformersCLICommand):
tf_from_pt_model
=
tf_class
.
from_pretrained
(
self
.
_local_dir
,
from_pt
=
True
)
# Extra input requirements, in addition to the input modality
if
hasattr
(
pt_model
,
"encoder"
)
and
hasattr
(
pt_model
,
"decoder"
):
if
config
.
is_encoder_decoder
or
(
hasattr
(
pt_model
,
"encoder"
)
and
hasattr
(
pt_model
,
"decoder"
)
)
:
decoder_input_ids
=
np
.
asarray
([[
1
],
[
1
]],
dtype
=
int
)
*
pt_model
.
config
.
decoder_start_token_id
pt_input
.
update
({
"decoder_input_ids"
:
torch
.
tensor
(
decoder_input_ids
)})
tf_input
.
update
({
"decoder_input_ids"
:
tf
.
convert_to_tensor
(
decoder_input_ids
)})
...
...
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