1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PyTorch | Leaf Variableとは

Last updated at Posted at 2021-04-20

grad_fnがNoneではないのtensorはleaf variable
https://blog.csdn.net/a1367666195/article/details/105654101

Tensorの確認

print(tensor.is_leaf)
for name, param in model.named_parameters():
     if param.requires_grad and name == 'module.model.conv1.weight':
           print("module.model.conv1.weight.grad:", param.grad) # Noneが出ると、微分不可

要注意:leaf variableを無効化する操作

view()
代わりに:

x_fused = x_fused.reshape(-1, 5, 3, x_fused.shape[-2], x_fused.shape[-1])
x_fused.retain_grad()
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?