Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
692c3c6b
Unverified
Commit
692c3c6b
authored
Jan 22, 2024
by
Matt
Committed by
GitHub
Jan 22, 2024
Browse files
Add config tip to custom model docs (#28601)
Add tip to custom model docs
parent
d336c56d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
docs/source/en/custom_models.md
docs/source/en/custom_models.md
+10
-0
No files found.
docs/source/en/custom_models.md
View file @
692c3c6b
...
@@ -34,6 +34,16 @@ Before we dive into the model, let's first write its configuration. The configur
...
@@ -34,6 +34,16 @@ Before we dive into the model, let's first write its configuration. The configur
will contain all the necessary information to build the model. As we will see in the next section, the model can only
will contain all the necessary information to build the model. As we will see in the next section, the model can only
take a
`config`
to be initialized, so we really need that object to be as complete as possible.
take a
`config`
to be initialized, so we really need that object to be as complete as possible.
<Tip>
Models in the
`transformers`
library itself generally follow the convention that they accept a
`config`
object
in their
`__init__`
method, and then pass the whole
`config`
to sub-layers in the model, rather than breaking the
config object into multiple arguments that are all passed individually to sub-layers. Writing your model in this
style results in simpler code with a clear "source of truth" for any hyperparameters, and also makes it easier
to reuse code from other models in
`transformers`
.
</Tip>
In our example, we will take a couple of arguments of the ResNet class that we might want to tweak. Different
In our example, we will take a couple of arguments of the ResNet class that we might want to tweak. Different
configurations will then give us the different types of ResNets that are possible. We then just store those arguments,
configurations will then give us the different types of ResNets that are possible. We then just store those arguments,
after checking the validity of a few of them.
after checking the validity of a few of them.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment