Hi
I use convolutional layers from a officially implemented pre-trained ResNet-18 followed by a new fc layer. Here is my training code:
optimizer = torch.optim.Adam(model.parameters(), 
                             lr=args.lr,
                             betas=(args.momentum, 0.999),
                             weight_decay=args.weight_decay)

out = model(input_var)
loss = criterion(out, target_var)

h = model.classifier.weight.register_hook(lambda grad: grad * 0)
model.zero_grad()
loss.backward()
optimizer.step()


The model.classifier is the self-defined fc layer and the args.momentum is set to 0.9. The fc layer has two output neurons so the dimension of the weight is 2*512.
The Pytorch that I am using has the version of 0.3.0.post4.