From 512c03a9b87097816a7469ac34a7e6957dda03dc Mon Sep 17 00:00:00 2001 From: jiangjiajun Date: Mon, 8 Apr 2019 10:31:34 +0800 Subject: [PATCH] update ndarray writting method --- tensorflow2fluid/tf2fluid/paddle_emitter.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/tensorflow2fluid/tf2fluid/paddle_emitter.py b/tensorflow2fluid/tf2fluid/paddle_emitter.py index 2415828..42a98d2 100644 --- a/tensorflow2fluid/tf2fluid/paddle_emitter.py +++ b/tensorflow2fluid/tf2fluid/paddle_emitter.py @@ -179,18 +179,7 @@ class PaddleEmitter(object): desc_size = tensor_desc.ByteSize() filew.write(struct.pack('i', desc_size)) filew.write(tensor_desc.SerializeToString()) - if len(shape) == 0: - if weight.size == 1: - tensor_size = 1 - weight = numpy.array([weight]) - else: - tensor_size = 0 - else: - tensor_size = reduce(lambda x, y: x * y, shape) - weight = weight.flatten() - for i in range(0, tensor_size): - filew.write( - struct.pack(struct_write_format[str(weight.dtype)], weight[i])) + weight.tofile(filew) filew.close() @property -- GitLab