Skip to content

Commit

Permalink
docs: Fixed variables in f-strings (huggingface#20087)
Browse files Browse the repository at this point in the history
* docs: Fixed variables in f-strings

* Replace unknown `block` with known `block_type` in ValueError

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Add missing torch import in docs code block

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
  • Loading branch information
2 people authored and Magnus Pierrau committed Dec 15, 2022
1 parent 685ea11 commit d6e0f53
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
7 changes: 5 additions & 2 deletions docs/source/en/custom_models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class ResnetConfig(PretrainedConfig):
**kwargs,
):
if block_type not in ["basic", "bottleneck"]:
raise ValueError(f"`block` must be 'basic' or bottleneck', got {block}.")
raise ValueError(f"`block_type` must be 'basic' or bottleneck', got {block_type}.")
if stem_type not in ["", "deep", "deep-tiered"]:
raise ValueError(f"`stem_type` must be '', 'deep' or 'deep-tiered', got {block}.")
raise ValueError(f"`stem_type` must be '', 'deep' or 'deep-tiered', got {stem_type}.")

self.block_type = block_type
self.layers = layers
Expand Down Expand Up @@ -146,6 +146,9 @@ class ResnetModel(PreTrainedModel):
For the model that will classify images, we just change the forward method:

```py
import torch


class ResnetModelForImageClassification(PreTrainedModel):
config_class = ResnetConfig

Expand Down
7 changes: 5 additions & 2 deletions docs/source/es/custom_models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class ResnetConfig(PretrainedConfig):
**kwargs,
):
if block_type not in ["basic", "bottleneck"]:
raise ValueError(f"`block` must be 'basic' or bottleneck', got {block}.")
raise ValueError(f"`block_type` must be 'basic' or bottleneck', got {block_type}.")
if stem_type not in ["", "deep", "deep-tiered"]:
raise ValueError(f"`stem_type` must be '', 'deep' or 'deep-tiered', got {block}.")
raise ValueError(f"`stem_type` must be '', 'deep' or 'deep-tiered', got {stem_type}.")

self.block_type = block_type
self.layers = layers
Expand Down Expand Up @@ -145,6 +145,9 @@ class ResnetModel(PreTrainedModel):
Para el modelo que clasificará las imágenes, solo cambiamos el método de avance (es decir, el método `forward`):

```py
import torch


class ResnetModelForImageClassification(PreTrainedModel):
config_class = ResnetConfig

Expand Down
7 changes: 5 additions & 2 deletions docs/source/it/custom_models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class ResnetConfig(PretrainedConfig):
**kwargs,
):
if block_type not in ["basic", "bottleneck"]:
raise ValueError(f"`block` must be 'basic' or bottleneck', got {block}.")
raise ValueError(f"`block_type` must be 'basic' or bottleneck', got {block_type}.")
if stem_type not in ["", "deep", "deep-tiered"]:
raise ValueError(f"`stem_type` must be '', 'deep' or 'deep-tiered', got {block}.")
raise ValueError(f"`stem_type` must be '', 'deep' or 'deep-tiered', got {stem_type}.")

self.block_type = block_type
self.layers = layers
Expand Down Expand Up @@ -146,6 +146,9 @@ class ResnetModel(PreTrainedModel):
Per il modello che classificherà le immagini, cambiamo soltanto il metodo forward:

```py
import torch


class ResnetModelForImageClassification(PreTrainedModel):
config_class = ResnetConfig

Expand Down
7 changes: 5 additions & 2 deletions docs/source/pt/custom_models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class ResnetConfig(PretrainedConfig):
**kwargs,
):
if block_type not in ["basic", "bottleneck"]:
raise ValueError(f"`block` must be 'basic' or bottleneck', got {block}.")
raise ValueError(f"`block_type` must be 'basic' or bottleneck', got {block_type}.")
if stem_type not in ["", "deep", "deep-tiered"]:
raise ValueError(f"`stem_type` must be '', 'deep' or 'deep-tiered', got {block}.")
raise ValueError(f"`stem_type` must be '', 'deep' or 'deep-tiered', got {stem_type}.")

self.block_type = block_type
self.layers = layers
Expand Down Expand Up @@ -145,6 +145,9 @@ class ResnetModel(PreTrainedModel):
Para o modelo que irá classificar as imagens, vamos apenas alterar o método forward:

```py
import torch


class ResnetModelForImageClassification(PreTrainedModel):
config_class = ResnetConfig

Expand Down

0 comments on commit d6e0f53

Please sign in to comment.