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
e65445b4
Unverified
Commit
e65445b4
authored
Dec 16, 2022
by
Matt
Committed by
GitHub
Dec 16, 2022
Browse files
Stop calling expand_1d on newer TF versions (#20786)
parent
3ee95820
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
src/transformers/modeling_tf_utils.py
src/transformers/modeling_tf_utils.py
+4
-2
No files found.
src/transformers/modeling_tf_utils.py
View file @
e65445b4
...
...
@@ -1473,7 +1473,8 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
label_kwargs
=
find_labels
(
self
.
__class__
)
label_to_output
=
self
.
get_label_to_output_name_mapping
()
output_to_label
=
{
val
:
key
for
key
,
val
in
label_to_output
.
items
()}
if
not
self
.
_using_dummy_loss
:
if
not
self
.
_using_dummy_loss
and
parse
(
tf
.
__version__
)
<
parse
(
"2.11.0"
):
# Newer TF train steps leave this out
data
=
data_adapter
.
expand_1d
(
data
)
x
,
y
,
sample_weight
=
data_adapter
.
unpack_x_y_sample_weight
(
data
)
# If the inputs are mutable dictionaries, make a shallow copy of them because we will modify
...
...
@@ -1580,7 +1581,8 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
label_kwargs
=
find_labels
(
self
.
__class__
)
label_to_output
=
self
.
get_label_to_output_name_mapping
()
output_to_label
=
{
val
:
key
for
key
,
val
in
label_to_output
.
items
()}
if
not
self
.
_using_dummy_loss
:
if
not
self
.
_using_dummy_loss
and
parse
(
tf
.
__version__
)
<
parse
(
"2.11.0"
):
# Newer versions leave this out
data
=
data_adapter
.
expand_1d
(
data
)
x
,
y
,
sample_weight
=
data_adapter
.
unpack_x_y_sample_weight
(
data
)
# If the inputs are mutable dictionaries, make a shallow copy of them because we will modify
...
...
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