Skip to content

Commit 58945b1

Browse files
authored
Copying the changes I had on the nobias_fix branch
1 parent 2467678 commit 58945b1

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

deeplift/conversion/kerasapi_conversion.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ def conv2d_conversion(config,
119119
name=("preact_" if len(converted_activation) > 0
120120
else "")+name,
121121
kernel=config[KerasKeys.weights][0],
122-
bias=(config[KerasKeys.weights][1]
123-
if len(config[KerasKeys.weights]) > 1 else np.zeros(1)),
122+
bias=(config[KerasKeys.weights][1] if
123+
len(config[KerasKeys.weights]) > 1
124+
else np.zeros(config[KerasKeys.weights][0].shape[-1])),
124125
strides=config[KerasKeys.strides],
125126
padding=config[KerasKeys.padding].upper(),
126127
data_format=config[KerasKeys.data_format],
@@ -151,8 +152,9 @@ def conv1d_conversion(config,
151152
name=("preact_" if len(converted_activation) > 0
152153
else "")+name,
153154
kernel=config[KerasKeys.weights][0],
154-
bias=(config[KerasKeys.weights][1]
155-
if len(config[KerasKeys.weights]) > 1 else np.zeros(1)),
155+
bias=(config[KerasKeys.weights][1] if
156+
len(config[KerasKeys.weights]) > 1
157+
else np.zeros(config[KerasKeys.weights][0].shape[-1])),
156158
stride=config[KerasKeys.strides],
157159
padding=config[KerasKeys.padding].upper(),
158160
conv_mxts_mode=conv_mxts_mode)]
@@ -179,8 +181,9 @@ def dense_conversion(config,
179181
name=("preact_" if len(converted_activation) > 0
180182
else "")+name,
181183
kernel=config[KerasKeys.weights][0],
182-
bias=(config[KerasKeys.weights][1]
183-
if len(config[KerasKeys.weights]) > 1 else np.zeros(1)),
184+
bias=(config[KerasKeys.weights][1] if
185+
len(config[KerasKeys.weights]) > 1
186+
else np.zeros(config[KerasKeys.weights][0].shape[-1])),
184187
verbose=verbose,
185188
dense_mxts_mode=dense_mxts_mode)]
186189
to_return.extend(converted_activation)

0 commit comments

Comments
 (0)