mirror of https://github.com/explosion/spaCy.git
Fix serialization of weight offsets
This commit is contained in:
parent
c044e9c21c
commit
f1acdaab55
|
@ -434,20 +434,20 @@ def model_to_bytes(model):
|
|||
weights.append(layer._mem.weights)
|
||||
else:
|
||||
weights.append(layer._mem.weights.get())
|
||||
metas.append(tuple(layer._mem._offsets))
|
||||
metas.append(layer._mem._offsets)
|
||||
dims.append(getattr(layer, '_dims', None))
|
||||
i += 1
|
||||
if hasattr(layer, '_layers'):
|
||||
queue.extend(layer._layers)
|
||||
data = {'metas': metas, 'weights': weights, 'dims': dims}
|
||||
data = {'metas': ujson.dumps(metas), 'weights': weights, 'dims': ujson.dumps(dims)}
|
||||
return msgpack.dumps(data)
|
||||
|
||||
|
||||
def model_from_bytes(model, bytes_data):
|
||||
data = msgpack.loads(bytes_data)
|
||||
weights = data['weights']
|
||||
metas = data['metas']
|
||||
dims = data['dims']
|
||||
metas = ujson.loads(data['metas'])
|
||||
dims = ujson.loads(data['dims'])
|
||||
queue = [model]
|
||||
i = 0
|
||||
for layer in queue:
|
||||
|
|
Loading…
Reference in New Issue