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
783b0dd5
Unverified
Commit
783b0dd5
authored
Jun 13, 2021
by
Jonathan Chang
Committed by
GitHub
Jun 13, 2021
Browse files
Fix t5 error message (#12136)
* Fix t5 error message * Fix again
parent
3b1f5caf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
src/transformers/models/t5/modeling_t5.py
src/transformers/models/t5/modeling_t5.py
+2
-2
src/transformers/models/t5/modeling_tf_t5.py
src/transformers/models/t5/modeling_tf_t5.py
+2
-2
No files found.
src/transformers/models/t5/modeling_t5.py
View file @
783b0dd5
...
@@ -881,7 +881,7 @@ class T5Stack(T5PreTrainedModel):
...
@@ -881,7 +881,7 @@ class T5Stack(T5PreTrainedModel):
if
input_ids
is
not
None
and
inputs_embeds
is
not
None
:
if
input_ids
is
not
None
and
inputs_embeds
is
not
None
:
err_msg_prefix
=
"decoder_"
if
self
.
is_decoder
else
""
err_msg_prefix
=
"decoder_"
if
self
.
is_decoder
else
""
raise
ValueError
(
raise
ValueError
(
f
"You cannot specify both
{
err_msg_prefix
}
inputs and
{
err_msg_prefix
}
inputs_embeds at the same time"
f
"You cannot specify both
{
err_msg_prefix
}
input
_id
s and
{
err_msg_prefix
}
inputs_embeds at the same time"
)
)
elif
input_ids
is
not
None
:
elif
input_ids
is
not
None
:
input_shape
=
input_ids
.
size
()
input_shape
=
input_ids
.
size
()
...
@@ -890,7 +890,7 @@ class T5Stack(T5PreTrainedModel):
...
@@ -890,7 +890,7 @@ class T5Stack(T5PreTrainedModel):
input_shape
=
inputs_embeds
.
size
()[:
-
1
]
input_shape
=
inputs_embeds
.
size
()[:
-
1
]
else
:
else
:
err_msg_prefix
=
"decoder_"
if
self
.
is_decoder
else
""
err_msg_prefix
=
"decoder_"
if
self
.
is_decoder
else
""
raise
ValueError
(
f
"You have to specify either
{
err_msg_prefix
}
inputs or
{
err_msg_prefix
}
inputs_embeds"
)
raise
ValueError
(
f
"You have to specify either
{
err_msg_prefix
}
input
_id
s or
{
err_msg_prefix
}
inputs_embeds"
)
if
inputs_embeds
is
None
:
if
inputs_embeds
is
None
:
assert
self
.
embed_tokens
is
not
None
,
"You have to initialize the model with valid token embeddings"
assert
self
.
embed_tokens
is
not
None
,
"You have to initialize the model with valid token embeddings"
...
...
src/transformers/models/t5/modeling_tf_t5.py
View file @
783b0dd5
...
@@ -625,7 +625,7 @@ class TFT5MainLayer(tf.keras.layers.Layer):
...
@@ -625,7 +625,7 @@ class TFT5MainLayer(tf.keras.layers.Layer):
if
inputs
[
"input_ids"
]
is
not
None
and
inputs
[
"inputs_embeds"
]
is
not
None
:
if
inputs
[
"input_ids"
]
is
not
None
and
inputs
[
"inputs_embeds"
]
is
not
None
:
err_msg_prefix
=
"decoder_"
if
self
.
is_decoder
else
""
err_msg_prefix
=
"decoder_"
if
self
.
is_decoder
else
""
raise
ValueError
(
raise
ValueError
(
f
"You cannot specify both
{
err_msg_prefix
}
inputs and
{
err_msg_prefix
}
inputs_embeds at the same time"
f
"You cannot specify both
{
err_msg_prefix
}
input
_id
s and
{
err_msg_prefix
}
inputs_embeds at the same time"
)
)
elif
inputs
[
"input_ids"
]
is
not
None
:
elif
inputs
[
"input_ids"
]
is
not
None
:
input_shape
=
shape_list
(
inputs
[
"input_ids"
])
input_shape
=
shape_list
(
inputs
[
"input_ids"
])
...
@@ -634,7 +634,7 @@ class TFT5MainLayer(tf.keras.layers.Layer):
...
@@ -634,7 +634,7 @@ class TFT5MainLayer(tf.keras.layers.Layer):
input_shape
=
shape_list
(
inputs
[
"inputs_embeds"
])[:
-
1
]
input_shape
=
shape_list
(
inputs
[
"inputs_embeds"
])[:
-
1
]
else
:
else
:
err_msg_prefix
=
"decoder_"
if
self
.
is_decoder
else
""
err_msg_prefix
=
"decoder_"
if
self
.
is_decoder
else
""
raise
ValueError
(
f
"You have to specify either
{
err_msg_prefix
}
inputs or
{
err_msg_prefix
}
inputs_embeds"
)
raise
ValueError
(
f
"You have to specify either
{
err_msg_prefix
}
input
_id
s or
{
err_msg_prefix
}
inputs_embeds"
)
if
inputs
[
"inputs_embeds"
]
is
None
:
if
inputs
[
"inputs_embeds"
]
is
None
:
assert
self
.
embed_tokens
is
not
None
,
"You have to initialize the model with valid token embeddings"
assert
self
.
embed_tokens
is
not
None
,
"You have to initialize the model with valid token 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