mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-27 09:44:36 +03:00
custom-architectures section
This commit is contained in:
parent
3d9ae9286f
commit
6fd7f140ec
|
@ -669,7 +669,7 @@ def custom_logger(log_path):
|
||||||
|
|
||||||
#### Example: Custom batch size schedule {#custom-code-schedule}
|
#### Example: Custom batch size schedule {#custom-code-schedule}
|
||||||
|
|
||||||
For example, let's say you've implemented your own batch size schedule to use
|
You can also implement your own batch size schedule to use
|
||||||
during training. The `@spacy.registry.schedules` decorator lets you register
|
during training. The `@spacy.registry.schedules` decorator lets you register
|
||||||
that function in the `schedules` [registry](/api/top-level#registry) and assign
|
that function in the `schedules` [registry](/api/top-level#registry) and assign
|
||||||
it a string name:
|
it a string name:
|
||||||
|
@ -806,7 +806,37 @@ def filter_batch(size: int) -> Callable[[Iterable[Example]], Iterator[List[Examp
|
||||||
|
|
||||||
### Defining custom architectures {#custom-architectures}
|
### Defining custom architectures {#custom-architectures}
|
||||||
|
|
||||||
<!-- TODO: this should probably move to new section on models -->
|
Built-in pipeline components such as the tagger or named entity recognizer are
|
||||||
|
constructed with default neural network [models](/api/architectures).
|
||||||
|
You can change the model architecture
|
||||||
|
entirely by implementing your own custom models and providing those in the config
|
||||||
|
when creating the pipeline component. See the
|
||||||
|
documentation on
|
||||||
|
[layers and model architectures](/usage/layers-architectures) for more details.
|
||||||
|
|
||||||
|
|
||||||
|
```python
|
||||||
|
### functions.py
|
||||||
|
from typing import List
|
||||||
|
from thinc.types import Floats2d
|
||||||
|
from thinc.api import Model
|
||||||
|
import spacy
|
||||||
|
from spacy.tokens import Doc
|
||||||
|
|
||||||
|
@spacy.registry.architectures("custom_neural_network.v1")
|
||||||
|
def MyModel(output_width: int) -> Model[List[Doc], List[Floats2d]]:
|
||||||
|
# ...
|
||||||
|
```
|
||||||
|
|
||||||
|
```ini
|
||||||
|
### config.cfg (excerpt)
|
||||||
|
[components.tagger]
|
||||||
|
factory = "tagger"
|
||||||
|
|
||||||
|
[components.tagger.model]
|
||||||
|
@architectures = "custom_neural_network.v1"
|
||||||
|
output_width = 512
|
||||||
|
```
|
||||||
|
|
||||||
## Internal training API {#api}
|
## Internal training API {#api}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user