Skip to content

Commit

Permalink
Fix doc example (#16448)
Browse files Browse the repository at this point in the history
* Fix doc

* Make fixup

Co-authored-by: Niels Rogge <nielsrogge@nielss-mbp.home>
  • Loading branch information
NielsRogge and Niels Rogge authored Apr 7, 2022
1 parent febe42b commit dc99180
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/transformers/utils/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,10 @@ def _prepare_output_docstrings(output_type, config_class, min_indent=None):
```python
>>> # To train a model on `num_labels` classes, you can pass `num_labels=num_labels` to `.from_pretrained(...)`
>>> num_labels = len(model.config.id2label)
>>> model = {model_class}.from_pretrained("{checkpoint}", num_labels=num_labels)
>>> model = {model_class}.from_pretrained(
... "{checkpoint}", num_labels=num_labels, problem_type="multi_label_classification"
... )
>>> num_labels = len(model.config.id2label)
>>> labels = torch.nn.functional.one_hot(torch.tensor([predicted_class_id]), num_classes=num_labels).to(
... torch.float
... )
Expand Down

0 comments on commit dc99180

Please sign in to comment.