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:
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user