Skip to content

Commit

Permalink
revise 6-2
Browse files Browse the repository at this point in the history
  • Loading branch information
lyhue1991 committed Jul 16, 2020
1 parent 2874e83 commit 077429a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions 6-2,训练模型的3种方法.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ for epoch in range(1,epochs+1):
val_step = 1

for val_step, (features,labels) in enumerate(dl_valid, 1):

predictions = net(features)
val_loss = loss_func(predictions,labels)
val_metric = metric_func(predictions,labels)
with torch.no_grad():
predictions = net(features)
val_loss = loss_func(predictions,labels)
val_metric = metric_func(predictions,labels)

val_loss_sum += val_loss.item()
val_metric_sum += val_metric.item()
Expand Down Expand Up @@ -375,6 +375,7 @@ def train_step(model,features,labels):

return loss.item(),metric.item()

@torch.no_grad()
def valid_step(model,features,labels):

# 预测模式,dropout层不发生作用
Expand Down
2 changes: 1 addition & 1 deletion push-to-github.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# !git rm --cached .ipynb_checkpoints/*

# !git commit -m "add 6-3"
# !git commit -m "revise 6-3"

# !git remote add origin https://github.com/lyhue1991/eat_pytorch_in_20_days

Expand Down

0 comments on commit 077429a

Please sign in to comment.