From 5ae862857108db67d331ed68e703b034436b9e08 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Wed, 29 Jul 2020 13:38:30 +0200 Subject: [PATCH] Fix CharacterEmbed layer --- spacy/ml/_character_embed.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spacy/ml/_character_embed.py b/spacy/ml/_character_embed.py index 57fbf73b3..ab0cb85c7 100644 --- a/spacy/ml/_character_embed.py +++ b/spacy/ml/_character_embed.py @@ -1,16 +1,18 @@ +from typing import List from thinc.api import Model +from thinc.types import Floats2d +from ..tokens import Doc -def CharacterEmbed(nM, nC): +def CharacterEmbed(nM: int, nC: int) -> Model[List[Doc], List[Floats2d]]: # nM: Number of dimensions per character. nC: Number of characters. - nO = nM * nC if (nM is not None and nC is not None) else None return Model( "charembed", forward, init=init, - dims={"nM": nM, "nC": nC, "nO": nO, "nV": 256}, + dims={"nM": nM, "nC": nC, "nO": nM * nC, "nV": 256}, params={"E": None}, - ).initialize() + ) def init(model, X=None, Y=None):