define pretrained_dims which is used by build_text_classifier (#5004)

This commit is contained in:
Sofie Van Landeghem 2020-02-16 17:21:18 +01:00 committed by GitHub
parent 3b22eb651b
commit 72c964bcf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View File

@ -608,6 +608,7 @@ class Language(object):
link_vectors_to_models(self.vocab)
if self.vocab.vectors.data.shape[1]:
cfg["pretrained_vectors"] = self.vocab.vectors.name
cfg['pretrained_dims'] = self.vocab.vectors.data.shape[1]
if sgd is None:
sgd = create_default_optimizer(Model.ops)
self._optimizer = sgd

View File

@ -1044,6 +1044,7 @@ class TextCategorizer(Pipe):
self.add_label(cat)
if self.model is True:
self.cfg["pretrained_vectors"] = kwargs.get("pretrained_vectors")
self.cfg["pretrained_dims"] = kwargs.get("pretrained_dims")
self.require_labels()
self.model = self.Model(len(self.labels), **self.cfg)
link_vectors_to_models(self.vocab)