From 8a6b1b2f591c60c44bf31c8a189cc33e30777405 Mon Sep 17 00:00:00 2001 From: Chang Sun Date: Fri, 12 Jan 2024 18:48:45 -0800 Subject: [PATCH] fix sign inference for dense layer --- src/HGQ/proxy/precision_derivation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/HGQ/proxy/precision_derivation.py b/src/HGQ/proxy/precision_derivation.py index e35b9ea..b1b6999 100644 --- a/src/HGQ/proxy/precision_derivation.py +++ b/src/HGQ/proxy/precision_derivation.py @@ -146,7 +146,8 @@ def _(layer: keras.layers.Dense | Conv): assert len(kifs) == 1, f'Dense layer {layer.name} has more than one input. This is not supported.' k, i, f = kifs[0] w_k, w_i, w_f = get_arr_container(layer.kernel.numpy()) - k, i, f = int(k or w_k), i + w_i, f + w_f + k = int(k or w_k or np.any(layer.bias < 0)) # type: ignore + i, f = i + w_i, f + w_f if isinstance(layer, Conv): div = layer.filters else: