docs: Fixed variables in f-strings (#20087)

* 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>
This commit is contained in:
Tom Aarsen
2022-11-07 19:18:09 +01:00
committed by GitHub
parent 2bdd9fa284
commit d44ac47bac
4 changed files with 20 additions and 8 deletions

View File

@@ -55,9 +55,9 @@ class ResnetConfig(PretrainedConfig):
**kwargs, **kwargs,
): ):
if block_type not in ["basic", "bottleneck"]: 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"]: 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.block_type = block_type
self.layers = layers self.layers = layers
@@ -146,6 +146,9 @@ class ResnetModel(PreTrainedModel):
For the model that will classify images, we just change the forward method: For the model that will classify images, we just change the forward method:
```py ```py
import torch
class ResnetModelForImageClassification(PreTrainedModel): class ResnetModelForImageClassification(PreTrainedModel):
config_class = ResnetConfig config_class = ResnetConfig

View File

@@ -55,9 +55,9 @@ class ResnetConfig(PretrainedConfig):
**kwargs, **kwargs,
): ):
if block_type not in ["basic", "bottleneck"]: 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"]: 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.block_type = block_type
self.layers = layers self.layers = layers
@@ -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`): Para el modelo que clasificará las imágenes, solo cambiamos el método de avance (es decir, el método `forward`):
```py ```py
import torch
class ResnetModelForImageClassification(PreTrainedModel): class ResnetModelForImageClassification(PreTrainedModel):
config_class = ResnetConfig config_class = ResnetConfig

View File

@@ -54,9 +54,9 @@ class ResnetConfig(PretrainedConfig):
**kwargs, **kwargs,
): ):
if block_type not in ["basic", "bottleneck"]: 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"]: 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.block_type = block_type
self.layers = layers self.layers = layers
@@ -146,6 +146,9 @@ class ResnetModel(PreTrainedModel):
Per il modello che classificherà le immagini, cambiamo soltanto il metodo forward: Per il modello che classificherà le immagini, cambiamo soltanto il metodo forward:
```py ```py
import torch
class ResnetModelForImageClassification(PreTrainedModel): class ResnetModelForImageClassification(PreTrainedModel):
config_class = ResnetConfig config_class = ResnetConfig

View File

@@ -54,9 +54,9 @@ class ResnetConfig(PretrainedConfig):
**kwargs, **kwargs,
): ):
if block_type not in ["basic", "bottleneck"]: 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"]: 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.block_type = block_type
self.layers = layers self.layers = layers
@@ -145,6 +145,9 @@ class ResnetModel(PreTrainedModel):
Para o modelo que irá classificar as imagens, vamos apenas alterar o método forward: Para o modelo que irá classificar as imagens, vamos apenas alterar o método forward:
```py ```py
import torch
class ResnetModelForImageClassification(PreTrainedModel): class ResnetModelForImageClassification(PreTrainedModel):
config_class = ResnetConfig config_class = ResnetConfig