Thanks for the quick reply!
I’m still thinking where to insert this line?
weights.grad.data[1:].zero_()
Should it be inserted after
data, target = Variable(data), Variable(target)
optimizer.zero_grad()
before
output = model(data)
or after
optimizer.step()
?