Skip to content

Commit 5e11c71

Browse files
authored
Fix RuntimeError
Re-call model.train() from eval() to fix "RuntimeError:Cudnn RNN backward can only be called in training mode." error.
1 parent 28ad33e commit 5e11c71

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

train.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ def train(train_iter, dev_iter, model, args):
1414
steps = 0
1515
best_acc = 0
1616
last_step = 0
17-
model.train()
1817
for epoch in range(1, args.epochs+1):
1918
for batch in train_iter:
19+
model.train()
2020
feature, target = batch.text, batch.label
2121
feature.t_(), target.sub_(1) # batch first, index align
2222
if args.cuda:

0 commit comments

Comments
 (0)