Skip to content

Commit 4896cef

Browse files
authored
Merge pull request yunjey#143 from AutuanLiu/patch01
clip_grad_norm is now deprecated
2 parents c48008b + a16173f commit 4896cef

File tree

1 file changed

+2
-2
lines changed
  • tutorials/02-intermediate/language_model

1 file changed

+2
-2
lines changed

tutorials/02-intermediate/language_model/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import torch
44
import torch.nn as nn
55
import numpy as np
6-
from torch.nn.utils import clip_grad_norm
6+
from torch.nn.utils import clip_grad_norm_
77
from data_utils import Dictionary, Corpus
88

99

@@ -78,7 +78,7 @@ def detach(states):
7878
# Backward and optimize
7979
model.zero_grad()
8080
loss.backward()
81-
clip_grad_norm(model.parameters(), 0.5)
81+
clip_grad_norm_(model.parameters(), 0.5)
8282
optimizer.step()
8383

8484
step = (i+1) // seq_length

0 commit comments

Comments
 (0)