-
Notifications
You must be signed in to change notification settings - Fork 31.3k
Adding doctest example for image-classification pipeline.
#20254
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
Adding doctest example for image-classification pipeline.
#20254
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. |
| >>> from transformers.testing_utils import nested_simplify | ||
| >>> nested_simplify(potential_words) # The scores might vary slightly across pytorch/tensorflow versions. | ||
| [{'score': 0.442, 'label': 'macaw'}, {'score': 0.088, 'label': 'popinjay'}, {'score': 0.075, 'label': 'parrot'}, {'score': 0.073, 'label': 'parodist, lampooner'}, {'score': 0.046, 'label': 'poll, poll_parrot'}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to use this, doctest will only compare the floats to the precision you write them. So the test will pass without using nested_simplify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really ?? That's awesome, I can remove it in a lot of places then !
sgugger
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's avoid using Transformers internal testing tools in examples. Rounding shouldn't be necessary, and even if it was I'd prefer to see it done in a dict comprehension, not by using nested_simplify.
stevhliu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. |
…ace#20254) * adding doctest example for `image-classification` pipeline. * Remove nested simplify.
What does this PR do?
Fixes # (issue)
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.