Calculate_qparams should not be called for NoopObserver

I’m trying to use Pytorch’s quantization scheme.
I’d like to quantize only weight with fake-quantization(QAT), not activation.

I tried this:

import torch.quantization as Q

model = load_model(my_config) # currently I'm using resnet architecture
qat_model = Q.fuse_modules(model, my_modules_to_fuse)
qat_model = Q.Qconfig(activation=Q.NoopObserver, weight=Q.FakeQuantize)

and this process from pytorch quantization tutorial

for nepoch in range(8):
    train_one_epoch(qat_model, criterion, optimizer, data_loader, torch.device('cpu'), num_train_batches)
    if nepoch > 3:
        # Freeze quantizer parameters
    if nepoch > 2:
        # Freeze batch norm mean and variance estimates

    # Check the accuracy after each epoch
    quantized_model = torch.quantization.convert(qat_model.eval(), inplace=False)
    top1, top5 = evaluate(quantized_model,criterion, data_loader_test, neval_batches=num_eval_batches)
    print('Epoch %d :Evaluation accuracy on %d images, %2.2f'%(nepoch, num_eval_batches * eval_batch_size, top1.avg))

But the program gives this error:

calculate_qparams should not be called for NoopObserver

the reason I why used NoopObserver is avoiding calculate_qparams for activation… but It’s confused result.
How to solve this problem? any suggestion will be appreciated.

You can’t skip quantizing just by setting the observer to NoopObserver. I don’t think weight only quantization is support in convert stage. You can evaluate the accuracy of the qat module directly without convert.