Fix bug from 1963530
to show last instead of 2nd layer gradients
This commit is contained in:
parent
d768aadb36
commit
33fd13e4ac
@ -365,20 +365,20 @@ def train(epoch, loader, model, criterion, optimizer, scheduler,
|
||||
# gradients of the weights of the first and the last layer
|
||||
grads = list(p.grad for n, p in model.named_parameters()
|
||||
if n.endswith('weight'))
|
||||
grads = [grads[0], grads[1]]
|
||||
grads = [grads[0], grads[-1]]
|
||||
grads = [g.detach().norm().item() for g in grads]
|
||||
logger.add_scalars('grad', {
|
||||
'first': grads[0],
|
||||
'last': grads[1],
|
||||
'last': grads[-1],
|
||||
}, global_step=batch)
|
||||
if args.adv and epoch >= args.adv_start:
|
||||
grads = list(p.grad for n, p in adv_model.named_parameters()
|
||||
if n.endswith('weight'))
|
||||
grads = [grads[0], grads[1]]
|
||||
grads = [grads[0], grads[-1]]
|
||||
grads = [g.detach().norm().item() for g in grads]
|
||||
logger.add_scalars('grad/adv', {
|
||||
'first': grads[0],
|
||||
'last': grads[1],
|
||||
'last': grads[-1],
|
||||
}, global_step=batch)
|
||||
|
||||
if args.adv and epoch >= args.adv_start:
|
||||
|
Loading…
Reference in New Issue
Block a user