Merge pull request #6188 from svlandeg/feature/small-fixes

This commit is contained in:
Ines Montani 2020-10-03 11:44:24 +02:00 committed by GitHub
commit 5413358ba1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 8 deletions

View File

@ -972,8 +972,9 @@ class Language:
raise ValueError(Errors.E003.format(component=type(proc), name=name)) raise ValueError(Errors.E003.format(component=type(proc), name=name))
try: try:
doc = proc(doc, **component_cfg.get(name, {})) doc = proc(doc, **component_cfg.get(name, {}))
except KeyError: except KeyError as e:
raise ValueError(Errors.E109.format(name=name)) from None # This typically happens if a component is not initialized
raise ValueError(Errors.E109.format(name=name)) from e
if doc is None: if doc is None:
raise ValueError(Errors.E005.format(name=name)) raise ValueError(Errors.E005.format(name=name))
return doc return doc

View File

@ -93,7 +93,7 @@ def build_Tok2Vec_model(
@registry.architectures.register("spacy.MultiHashEmbed.v1") @registry.architectures.register("spacy.MultiHashEmbed.v1")
def MultiHashEmbed( def MultiHashEmbed(
width: int, rows: int, also_embed_subwords: bool, also_use_static_vectors: bool width: int, rows: int, also_embed_subwords: bool, also_use_static_vectors: bool
): ) -> Model[List[Doc], List[Floats2d]]:
"""Construct an embedding layer that separately embeds a number of lexical """Construct an embedding layer that separately embeds a number of lexical
attributes using hash embedding, concatenates the results, and passes it attributes using hash embedding, concatenates the results, and passes it
through a feed-forward subnetwork to build a mixed representations. through a feed-forward subnetwork to build a mixed representations.
@ -167,7 +167,7 @@ def MultiHashEmbed(
def CharacterEmbed( def CharacterEmbed(
width: int, rows: int, nM: int, nC: int, also_use_static_vectors: bool, width: int, rows: int, nM: int, nC: int, also_use_static_vectors: bool,
feature: Union[int, str]="LOWER" feature: Union[int, str]="LOWER"
): ) -> Model[List[Doc], List[Floats2d]]:
"""Construct an embedded representation based on character embeddings, using """Construct an embedded representation based on character embeddings, using
a feed-forward network. A fixed number of UTF-8 byte characters are used for a feed-forward network. A fixed number of UTF-8 byte characters are used for
each word, taken from the beginning and end of the word equally. Padding is each word, taken from the beginning and end of the word equally. Padding is

View File

@ -1065,7 +1065,6 @@ def import_file(name: str, loc: Union[str, Path]) -> ModuleType:
loc (str / Path): Path to the file. loc (str / Path): Path to the file.
RETURNS: The loaded module. RETURNS: The loaded module.
""" """
loc = str(loc)
spec = importlib.util.spec_from_file_location(name, str(loc)) spec = importlib.util.spec_from_file_location(name, str(loc))
module = importlib.util.module_from_spec(spec) module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module) spec.loader.exec_module(module)

View File

@ -287,7 +287,7 @@ fixed. To auto-fill a partial config and save the result, you can use the
[`init fill-config`](/api/cli#init-fill-config) command. [`init fill-config`](/api/cli#init-fill-config) command.
```cli ```cli
$ python -m spacy debug config [config_path] [--code-path] [--show-functions] [--show-variables] [overrides] $ python -m spacy debug config [config_path] [--code] [--show-functions] [--show-variables] [overrides]
``` ```
> #### Example > #### Example
@ -430,7 +430,7 @@ File /path/to/thinc/thinc/schedules.py (line 91)
| Name | Description | | Name | Description |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `config_path` | Path to [training config](/api/data-formats#config) file containing all settings and hyperparameters. ~~Path (positional)~~ | | `config_path` | Path to [training config](/api/data-formats#config) file containing all settings and hyperparameters. ~~Path (positional)~~ |
| `--code-path`, `-c` | Path to Python file with additional code to be imported. Allows [registering custom functions](/usage/training#custom-functions) for new architectures. ~~Optional[Path] \(option)~~ | | `--code`, `-c` | Path to Python file with additional code to be imported. Allows [registering custom functions](/usage/training#custom-functions) for new architectures. ~~Optional[Path] \(option)~~ |
| `--show-functions`, `-F` | Show an overview of all registered function blocks used in the config and where those functions come from, including the module name, Python file and line number. ~~bool (flag)~~ | | `--show-functions`, `-F` | Show an overview of all registered function blocks used in the config and where those functions come from, including the module name, Python file and line number. ~~bool (flag)~~ |
| `--show-variables`, `-V` | Show an overview of all variables referenced in the config, e.g. `${paths.train}` and their values that will be used. This also reflects any config overrides provided on the CLI, e.g. `--paths.train /path`. ~~bool (flag)~~ | | `--show-variables`, `-V` | Show an overview of all variables referenced in the config, e.g. `${paths.train}` and their values that will be used. This also reflects any config overrides provided on the CLI, e.g. `--paths.train /path`. ~~bool (flag)~~ |
| `--help`, `-h` | Show help message and available arguments. ~~bool (flag)~~ | | `--help`, `-h` | Show help message and available arguments. ~~bool (flag)~~ |
@ -1194,7 +1194,7 @@ examples, see the usage guide on
[integration](/usage/projects#ray). [integration](/usage/projects#ray).
```cli ```cli
$ python -m spacy ray train [config_path] [--code-path] [--output] [--n-workers] [--address] [--gpu-id] [--verbose] [overrides] $ python -m spacy ray train [config_path] [--code] [--output] [--n-workers] [--address] [--gpu-id] [--verbose] [overrides]
``` ```
> #### Example > #### Example