This is great to see the accuracy is getting better!
Are these results obtained after fixing the issue @raghuramank100 pointed out?
For option 3 there’s a typo, there should only be one quant() as:
def forward(self, X):
h = self.slice1(X)
h_relu2_2 = h
h = self.slice2(h)
h_relu3_2 = h
h = self.slice3(h)
h_relu4_3 = h
h = self.slice4(h)
h_relu5_3 = h
h = self.slice5(h)
h_fc7 = h
h_fc7 = self.dequant(h_fc7)
h_relu5_3 = self.dequant(h_relu5_3)
h_relu4_3 = self.dequant(h_relu4_3)
h_relu3_2 = self.dequant(h_relu3_2)
h_relu2_2 = self.dequant(h_relu2_2)
vgg_outputs = namedtuple("VggOutputs", ['fc7', 'relu5_3', 'relu4_3', 'relu3_2', 'relu2_2'])
out = vgg_outputs(h_fc7, h_relu5_3, h_relu4_3, h_relu3_2, h_relu2_2)
And we may not need 5 dequant(), previously I thought each output activation has different distribution so we need 5 of them so that each dequant collects statistics of the specific output activations. But in fact the input of the dequant is already the int8 activation with qparames and dequant doesn’t have state, so we can share dequant().
If you make changes above, you can just set qconfig at model.basenet level instead of model level:
model.basenet.qconfig = torch.quantization.QConfig(activation=torch.quantization.default_histogram_observer,weight=torch.quantization.default_per_channel_weight_observer)
I think this way you don’t need to set any qconfig to be None and PyTorch will only quantize the basenet.