From d44ac47bac4471703651675c8abd9d6e1b6c3db6 Mon Sep 17 00:00:00 2001 From: Tom Aarsen <37621491+tomaarsen@users.noreply.github.com> Date: Mon, 7 Nov 2022 19:18:09 +0100 Subject: [PATCH] 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> --- docs/source/en/custom_models.mdx | 7 +++++-- docs/source/es/custom_models.mdx | 7 +++++-- docs/source/it/custom_models.mdx | 7 +++++-- docs/source/pt/custom_models.mdx | 7 +++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/docs/source/en/custom_models.mdx b/docs/source/en/custom_models.mdx index 50770be844..f08291cef0 100644 --- a/docs/source/en/custom_models.mdx +++ b/docs/source/en/custom_models.mdx @@ -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 @@ -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 diff --git a/docs/source/es/custom_models.mdx b/docs/source/es/custom_models.mdx index b1a7c9cb62..c216739a8e 100644 --- a/docs/source/es/custom_models.mdx +++ b/docs/source/es/custom_models.mdx @@ -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 @@ -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 diff --git a/docs/source/it/custom_models.mdx b/docs/source/it/custom_models.mdx index 39e118275a..73814c9d89 100644 --- a/docs/source/it/custom_models.mdx +++ b/docs/source/it/custom_models.mdx @@ -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 @@ -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 diff --git a/docs/source/pt/custom_models.mdx b/docs/source/pt/custom_models.mdx index 0150348a74..8328b50cce 100644 --- a/docs/source/pt/custom_models.mdx +++ b/docs/source/pt/custom_models.mdx @@ -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 @@ -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