Pytorchの「.detach()」と「with no_grad():」と「.requires_grad = False」の違い
LGTM: 6
#Python #DeepLearning #PyTorch #勾配
Link: https://qiita.com/tttamaki/items/28f13a1507eb63387901
LGTM: 6
#Python #DeepLearning #PyTorch #勾配
Link: https://qiita.com/tttamaki/items/28f13a1507eb63387901
Qiita
Pytorchの「.detach()」と「with no_grad():」と「.requires_grad = False」の違い - Qiita
内容
pytorchで勾配計算をしない方法には
tensorの.detach()を使って計算グラフを切る
GANのサンプルコードでよく見かける
with文を使ってtorch.no_grad()で囲んで計算グラフを作ら...
pytorchで勾配計算をしない方法には
tensorの.detach()を使って計算グラフを切る
GANのサンプルコードでよく見かける
with文を使ってtorch.no_grad()で囲んで計算グラフを作ら...