-
Notifications
You must be signed in to change notification settings - Fork 33.8k
add doctests to TF ViT #16462
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
add doctests to TF ViT #16462
Changes from 1 commit
56b9b2c
fbd0461
f9d231f
946e4b4
8529562
ed31ab3
5216607
45abb37
aebca69
86cff21
b62ac4d
3015d12
6358a4c
875e07a
0540d1b
7a9ef81
5b40a37
781af73
d7c8ce5
ee18d4d
2b48323
277d49a
ffd19ee
147c816
d04adc3
ae189ef
c2f8eaf
c4deb7b
a73281e
81ac45f
857eb87
a8b6443
99a0142
98939e6
c551add
6a4dbba
05b4c32
b808d8a
e4b2348
5807054
bfeff6c
9de70f2
483a945
afc5a1e
59a9c83
9947dd0
5fe06b9
823dbf8
2199382
61ee26a
53a4d6b
60d27b1
9ac49ab
f4f0f6c
92e0b2d
1cb3323
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -662,7 +662,6 @@ def call( | |
| Returns: | ||
|
|
||
| Examples: | ||
|
|
||
| ```python | ||
| >>> from transformers import ViTFeatureExtractor, TFViTModel | ||
| >>> from PIL import Image | ||
|
|
@@ -677,6 +676,8 @@ def call( | |
| >>> inputs = feature_extractor(images=image, return_tensors="tf") | ||
| >>> outputs = model(**inputs) | ||
| >>> last_hidden_states = outputs.last_hidden_state | ||
| >>> list(last_hidden_states.shape) | ||
| [1, 197, 768] | ||
| ```""" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also wasn't sure about the style here, keep ``` and """ in the same line or split to two lines
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be more or less a style choice. In the model files, we usually keep it as ```""" |
||
|
|
||
| outputs = self.vit( | ||
|
|
@@ -768,7 +769,6 @@ def call( | |
| Returns: | ||
|
|
||
| Examples: | ||
|
|
||
| ```python | ||
| >>> from transformers import ViTFeatureExtractor, TFViTForImageClassification | ||
| >>> import tensorflow as tf | ||
|
|
@@ -787,6 +787,7 @@ def call( | |
| >>> # model predicts one of the 1000 ImageNet classes | ||
| >>> predicted_class_idx = tf.math.argmax(logits, axis=-1)[0] | ||
| >>> print("Predicted class:", model.config.id2label[int(predicted_class_idx)]) | ||
| Predicted class: Egyptian cat | ||
| ```""" | ||
|
|
||
| outputs = self.vit( | ||
|
|
||
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.
I wasn't sure if there is supposed to be an empty line here or not, for me it looked better without it
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 just keep the empty line. It is done this way in other places.