mirror of
https://github.com/explosion/spaCy.git
synced 2025-04-27 12:23:42 +03:00
Fix serialization of pretrained_dims property
This commit is contained in:
parent
2489dcaccf
commit
b36a38f63d
|
@ -214,6 +214,7 @@ class TokenVectorEncoder(BaseThincComponent):
|
||||||
self.vocab = vocab
|
self.vocab = vocab
|
||||||
self.model = model
|
self.model = model
|
||||||
self.cfg = dict(cfg)
|
self.cfg = dict(cfg)
|
||||||
|
self.cfg['pretrained_dims'] = self.vocab.vectors.data.shape[1]
|
||||||
|
|
||||||
def __call__(self, doc):
|
def __call__(self, doc):
|
||||||
"""Add context-sensitive vectors to a `Doc`, e.g. from a CNN or LSTM
|
"""Add context-sensitive vectors to a `Doc`, e.g. from a CNN or LSTM
|
||||||
|
@ -458,7 +459,7 @@ class NeuralTagger(BaseThincComponent):
|
||||||
token_vector_width = util.env_opt('token_vector_width',
|
token_vector_width = util.env_opt('token_vector_width',
|
||||||
self.cfg.get('token_vector_width', 128))
|
self.cfg.get('token_vector_width', 128))
|
||||||
self.model = self.Model(self.vocab.morphology.n_tags, token_vector_width,
|
self.model = self.Model(self.vocab.morphology.n_tags, token_vector_width,
|
||||||
pretrained_dims=self.vocab.vectors_length)
|
**self.cfg)
|
||||||
self.model.from_bytes(p.open('rb').read())
|
self.model.from_bytes(p.open('rb').read())
|
||||||
|
|
||||||
def load_tag_map(p):
|
def load_tag_map(p):
|
||||||
|
@ -470,10 +471,10 @@ class NeuralTagger(BaseThincComponent):
|
||||||
exc=self.vocab.morphology.exc)
|
exc=self.vocab.morphology.exc)
|
||||||
|
|
||||||
deserialize = OrderedDict((
|
deserialize = OrderedDict((
|
||||||
|
('cfg', lambda p: self.cfg.update(_load_cfg(p))),
|
||||||
('vocab', lambda p: self.vocab.from_disk(p)),
|
('vocab', lambda p: self.vocab.from_disk(p)),
|
||||||
('tag_map', load_tag_map),
|
('tag_map', load_tag_map),
|
||||||
('model', load_model),
|
('model', load_model),
|
||||||
('cfg', lambda p: self.cfg.update(_load_cfg(p)))
|
|
||||||
))
|
))
|
||||||
util.from_disk(path, deserialize, exclude)
|
util.from_disk(path, deserialize, exclude)
|
||||||
return self
|
return self
|
||||||
|
|
Loading…
Reference in New Issue
Block a user