提交 36009059 编写于 作者: L luxuhui

fix prelu&validate bug

N/A
Signed-off-by: NLuxuhui <luxuhui@xiaomi.com>
上级 874129dc
......@@ -963,7 +963,7 @@ class Transformer(base_converter.ConverterInterface):
if consumer_op.type == MaceOp.Activation.name \
and ConverterUtil.get_arg(
consumer_op,
MaceKeyword.mace_activation_type_str).s != 'PRELU':
MaceKeyword.mace_activation_type_str).s != b'PRELU': # noqa
print("Fold activation: %s(%s)" % (op.name, op.type))
op.name = consumer_op.name
op.output[0] = consumer_op.output[0]
......
......@@ -64,7 +64,16 @@ def calculate_similarity(u, v, data_type=np.float64):
u = u.astype(data_type)
if v.dtype is not data_type:
v = v.astype(data_type)
return np.dot(u, v) / (np.linalg.norm(u) * np.linalg.norm(v))
u_norm = np.linalg.norm(u)
v_norm = np.linalg.norm(v)
norm = u_norm * v_norm
if norm == 0:
if u_norm == 0 and v_norm == 0:
return 1
else:
return 0
else:
return np.dot(u, v) / norm
def calculate_pixel_accuracy(out_value, mace_out_value):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册