Fix serialization of weight offsets

This commit is contained in:
Matthew Honnibal 2017-05-29 13:23:11 -05:00
parent c044e9c21c
commit f1acdaab55
1 changed files with 5 additions and 5 deletions

View File

@ -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: