Skip to content

Instantly share code, notes, and snippets.

@dongqifong
Created July 2, 2021 13:27
Show Gist options
  • Save dongqifong/caec9bbcb5e3636cdc29679e7df19fe4 to your computer and use it in GitHub Desktop.
Save dongqifong/caec9bbcb5e3636cdc29679e7df19fe4 to your computer and use it in GitHub Desktop.
validation
model.eval() # 取消dropout or batch normalization
with torch.no_grad(): # 不計算梯度
predict = []
for data, labels in test_loader:
# Forward
out = model(data)
predict.append(out.numpy())
model.train() # 重新開啟dropout or batch normalization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment