A issue I found in source code of quant_models.py:
According the guide, I was trying to quantize ds-cnn model by command:
python quant_test.py --act_max 0 0 0 0 0 0 0 0 0 0 0 0
which should output a accuracy equal to "test.py ....." because we use floating point for all activation parameters, but it is not the case and I found the reason. In file quant_models.py
A
if(act_max[2layer_no]>0):
depthwise_conv = tf.fake_quant_with_min_max_vars(depthwise_conv,
min=-act_max[2layer_no],
max=act_max[2layer_no]-(act_max[2layer_no]/128.0),
num_bits=8, name='quant_ds_conv'+str(layer_no))
bn = tf.nn.relu(depthwise_conv)
we need a else branch to handle case when act_max[2*layer_no] == 0
we need a else branch to handle case when act_max[2*layer_no+1] == 0
C
if act_max[1]>0:
net = tf.fake_quant_with_min_max_vars(net, min=-act_max[1],
max=act_max[1]-(act_max[1]/128.0), num_bits=8, name='quant_conv1')
net = tf.nn.relu(net)
# we need a else branch to handle case when act_max[1] == 0
#net = slim.batch_norm(net, scope='conv_1/batch_norm')
A issue I found in source code of quant_models.py: According the guide, I was trying to quantize ds-cnn model by command: python quant_test.py --act_max 0 0 0 0 0 0 0 0 0 0 0 0 which should output a accuracy equal to "test.py ....." because we use floating point for all activation parameters, but it is not the case and I found the reason. In file quant_models.py A if(act_max[2layer_no]>0): depthwise_conv = tf.fake_quant_with_min_max_vars(depthwise_conv, min=-act_max[2layer_no], max=act_max[2layer_no]-(act_max[2layer_no]/128.0), num_bits=8, name='quant_ds_conv'+str(layer_no)) bn = tf.nn.relu(depthwise_conv)
we need a else branch to handle case when act_max[2*layer_no] == 0
batch-norm weights folded into depthwise conv
bn = slim.batch_norm(depthwise_conv, scope=sc+'/dw_conv/batch_norm')
B
if(act_max[2layer_no+1]>0): pointwise_conv = tf.fake_quant_with_min_max_vars(pointwise_conv, min=-act_max[2layer_no+1], max=act_max[2layer_no+1]-(act_max[2layer_no+1]/128.0), num_bits=8, name='quant_pw_conv'+str(layer_no+1)) bn = tf.nn.relu(pointwise_conv)
we need a else branch to handle case when act_max[2*layer_no+1] == 0 C
can you provide a patch for this issue? thanks