From ad02c961c61a409a78faa545a54a4bf1a058f817 Mon Sep 17 00:00:00 2001 From: Julien Chaumond Date: Fri, 15 May 2020 17:09:11 -0400 Subject: [PATCH] Fix UserWarning: This overload of add_ is deprecated in pytorch==1.5.0 --- src/transformers/optimization.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/transformers/optimization.py b/src/transformers/optimization.py index 5ab7647638..3bd7fef0b7 100644 --- a/src/transformers/optimization.py +++ b/src/transformers/optimization.py @@ -152,7 +152,7 @@ class AdamW(Optimizer): # Decay the first and second moment running average coefficient # In-place operations to update the averages at the same time - exp_avg.mul_(beta1).add_(1.0 - beta1, grad) + exp_avg.mul_(beta1).add_(grad, alpha=1.0 - beta1) exp_avg_sq.mul_(beta2).addcmul_(1.0 - beta2, grad, grad) denom = exp_avg_sq.sqrt().add_(group["eps"]) @@ -173,6 +173,6 @@ class AdamW(Optimizer): # of the weights to the loss with plain (non-momentum) SGD. # Add weight decay at the end (fixed version) if group["weight_decay"] > 0.0: - p.data.add_(-group["lr"] * group["weight_decay"], p.data) + p.data.add_(p.data, alpha=-group["lr"] * group["weight_decay"]) return loss