ModelTC/MQBench

model.zero_grad() ?

Closed this issue · 2 comments

in

if calibration_flag:

        if opt.quantize:
            if calibration_flag:
                if i >= 50:
                    calibration_flag = False
                    model.zero_grad()
                    enable_quantization(model)
                    print('close calibration')
                else:
                    print('calibration iter{}'.format(i))
                    continue

I am wondering why there is " model.zero_grad() ", what is the purpose?

Tracin commented

Calibration stage only for initialize the range (min / max) not for backward, so we can zero_grad().

This issue has not received any updates in 120 days. Please reply to this issue if this still unresolved!