rewrite intro, simpel Model example

This commit is contained in:
svlandeg 2020-09-02 13:41:18 +02:00
parent 422df9c2e2
commit e29a33449d
1 changed files with 26 additions and 12 deletions

View File

@ -10,18 +10,32 @@ menu:
next: /usage/projects next: /usage/projects
--- ---
A **model architecture** is a function that wires up a > #### Example
[Thinc `Model`](https://thinc.ai/docs/api-model) instance, which you can then >
use in a component or as a layer of a larger network. You can use Thinc as a > ````python
thin wrapper around frameworks such as PyTorch, TensorFlow or MXNet, or you can > from thinc.api import Model, chain
implement your logic in Thinc directly. spaCy's built-in components will never >
construct their `Model` instances themselves, so you won't have to subclass the > def build_model(width: int, classes: int) -> Model:
component to change its model architecture. You can just **update the config** > tok2vec = build_tok2vec(width)
so that it refers to a different registered function. Once the component has > output_layer = build_output_layer(width, classes)
been created, its model instance has already been assigned, so you cannot change > model = chain(tok2vec, output_layer)
its model architecture. The architecture is like a recipe for the network, and > return model
you can't change the recipe once the dish has already been prepared. You have to > ````
make a new one.
A **model architecture** is a function that wires up a
[Thinc `Model`](https://thinc.ai/docs/api-model) instance. It describes the
neural network that is run internally as part of a component in a spaCy
pipeline. To define the actual architecture, you can implement your logic in
Thinc directly, but you can also use Thinc as a thin wrapper around frameworks
such as PyTorch, TensorFlow or MXNet.
spaCy's built-in components require a `Model` instance to be passed to them via
the config system. To change the model architecture of an existing component,
you just need to **update the config** so that it refers to a different
registered function. Once the component has been created from this config, you
won't be able to change it anymore. The architecture is like a recipe for the
network, and you can't change the recipe once the dish has already been
prepared. You have to make a new one.
## Type signatures {#type-sigs} ## Type signatures {#type-sigs}