Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
96b5d7db
Unverified
Commit
96b5d7db
authored
Aug 01, 2022
by
amyeroberts
Committed by
GitHub
Aug 01, 2022
Browse files
Remove pt-like calls on tf tensor (#18393)
parent
679d68a1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
src/transformers/models/deit/modeling_tf_deit.py
src/transformers/models/deit/modeling_tf_deit.py
+3
-3
No files found.
src/transformers/models/deit/modeling_tf_deit.py
View file @
96b5d7db
...
@@ -934,9 +934,9 @@ class TFDeiTForImageClassification(TFDeiTPreTrainedModel, TFSequenceClassificati
...
@@ -934,9 +934,9 @@ class TFDeiTForImageClassification(TFDeiTPreTrainedModel, TFSequenceClassificati
>>> outputs = model(**inputs)
>>> outputs = model(**inputs)
>>> logits = outputs.logits
>>> logits = outputs.logits
>>> # model predicts one of the 1000 ImageNet classes
>>> # model predicts one of the 1000 ImageNet classes
>>> predicted_class_idx =
logits
.argmax(
-1).item()
>>> predicted_class_idx =
tf.math
.argmax(
logits, axis=-1)[0]
>>> print("Predicted class:", model.config.id2label[predicted_class_idx])
>>> print("Predicted class:", model.config.id2label[
int(
predicted_class_idx
)
])
Predicted class:
maillot
Predicted class:
ptarmigan
```"""
```"""
return_dict
=
return_dict
if
return_dict
is
not
None
else
self
.
config
.
use_return_dict
return_dict
=
return_dict
if
return_dict
is
not
None
else
self
.
config
.
use_return_dict
...
...
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