print("=============更新之前===========") temp = 0 #控制打印的参数个数 for name, parms in model.named_parameters(): temp += 1 if temp == 2: break print('-->name:', name) print('-->para:', parms) print('-->grad_requirs:', parms.requires_grad) print('-->grad_value:', parms.grad) print("===")
print("=============更新之后===========") temp = 0 ##控制打印的参数个数 for name, parms in model.named_parameters(): temp += 1 if temp == 2: break print('-->name:', name) print('-->para:', parms) print('-->grad_requirs:', parms.requires_grad) print('-->grad_value:', parms.grad) print("===") print(optimizer)