Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop passing None to compile() in TF examples #29597

Merged
merged 2 commits into from Mar 12, 2024

Conversation

Rocketknight1
Copy link
Member

TensorFlow used to accept a value of None for the optimizer argument in compile(), as long as you didn't actually try to fit() the resulting model, but now it doesn't. This PR passes a dummy sgd optimizer instead to avoid that issue.

It also reworks the sample invocation given for run_text_classification.py to avoid confusion.

Fixes #29584

@Rocketknight1 Rocketknight1 changed the title Stop passing None to compile() Stop passing None to compile() in TF examples Mar 11, 2024
Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing!

Just a tiny tiny nit

@@ -706,7 +706,7 @@ def compute_metrics(p: EvalPrediction):
model.compile(optimizer=optimizer, jit_compile=training_args.xla, metrics=["accuracy"])

else:
model.compile(optimizer=None, jit_compile=training_args.xla, metrics=["accuracy"])
model.compile(optimizer="sgd", jit_compile=training_args.xla, metrics=["accuracy"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment here saying optimizer value doesn't mattr as it won't be used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Rocketknight1 Rocketknight1 merged commit 81ec802 into main Mar 12, 2024
8 checks passed
@Rocketknight1 Rocketknight1 deleted the tf_example_compatibility_fix branch March 12, 2024 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug when trying to run examples in the directory tensorflow/text-classification module run_text-classification
3 participants