mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-11 04:08:09 +03:00
Serialize in consistent order
This commit is contained in:
parent
9bf22a94aa
commit
293d1b425b
|
@ -294,10 +294,10 @@ class NeuralTagger(object):
|
||||||
yield
|
yield
|
||||||
|
|
||||||
def to_bytes(self, **exclude):
|
def to_bytes(self, **exclude):
|
||||||
serialize = {
|
serialize = OrderedDict((
|
||||||
'model': lambda: util.model_to_bytes(self.model),
|
('model', lambda: util.model_to_bytes(self.model)),
|
||||||
'vocab': lambda: self.vocab.to_bytes()
|
('vocab', lambda: self.vocab.to_bytes())
|
||||||
}
|
))
|
||||||
return util.to_bytes(serialize, exclude)
|
return util.to_bytes(serialize, exclude)
|
||||||
|
|
||||||
def from_bytes(self, bytes_data, **exclude):
|
def from_bytes(self, bytes_data, **exclude):
|
||||||
|
@ -306,10 +306,10 @@ class NeuralTagger(object):
|
||||||
token_vector_width = util.env_opt('token_vector_width', 128)
|
token_vector_width = util.env_opt('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)
|
||||||
util.model_from_bytes(self.model, b)
|
util.model_from_bytes(self.model, b)
|
||||||
deserialize = {
|
deserialize = OrderedDict((
|
||||||
'vocab': lambda b: self.vocab.from_bytes(b),
|
('vocab', lambda b: self.vocab.from_bytes(b)),
|
||||||
'model': lambda b: load_model(b)
|
('model', lambda b: load_model(b)),
|
||||||
}
|
))
|
||||||
util.from_bytes(bytes_data, deserialize, exclude)
|
util.from_bytes(bytes_data, deserialize, exclude)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user