mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-03 12:50:06 +06:00
Add config tip to custom model docs (#28601)
Add tip to custom model docs
This commit is contained in:
parent
d336c56d94
commit
692c3c6b73
@ -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
|
||||
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
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user