Skip to content

Commit 0da7a4e

Browse files
authored
Add check before setting bias of conv_weights in SeparableConvQuantize
Not to copy the weights if bias is not used in the SeperableConv2D layer
1 parent 973f5b3 commit 0da7a4e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tensorflow_model_optimization/python/core/quantization/keras/default_8bit/default_8bit_transforms.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,8 @@ def replacement(self, match_layer):
482482
)
483483
conv_weights = collections.OrderedDict()
484484
conv_weights['kernel:0'] = sepconv_weights[1]
485-
conv_weights['bias:0'] = sepconv_weights[2]
485+
if sepconv_layer['config']['use_bias']:
486+
conv_weights['bias:0'] = sepconv_weights[2]
486487
conv_layer_config = keras.layers.serialize(conv_layer)
487488
conv_layer_config['name'] = conv_layer.name
488489
# Needed to ensure these new layers are considered for quantization.

0 commit comments

Comments
 (0)