How to quantize only specific layers

How to quantize weights in pointwise convolution layer in MobileNet V2, not all the entire model’s parameters. I searched a lot, but most of the source code quantized the entire model’s parameters.

1 Like

you can set qconfig only for the sub module that you want to quantize. e.g.

class M(torch.nn.Module):
   def __init__(self):
      self.conv1 = ...
      self.conv2 = ...
m  = M()
m.conv1 = qconfig # if you only want to quantize conv1
1 Like

Just to be clear, this would be exactly like this:

m.conv1.qconfig = qconfig