-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Description
🐛 Bug
Working from the output of a Conv2d module, create_graph
option on torch.autograd.grad
fails to create a gradient with a graph for higher order gradients.
To Reproduce
import torch
from torch import nn, autograd
m = nn.Conv2d(2, 3, 3)
x = torch.rand(1,2,4,4, requires_grad=True)
y = m(x)
g, = autograd.grad(y.sum(), x, create_graph=True)
print(g.requires_grad)
Prints False
for v1.0.0, prints True
for v0.4.1
Expected behavior
Expect g.requires_grad == True
, and expect to be able to compute second derivative of Conv2d output.
Environment
PyTorch version: 1.0.0
Is debug build: No
CUDA used to build PyTorch: None
OS: Ubuntu 18.04.1 LTS
GCC version: (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
CMake version: Could not collect
Python version: 3.6
Is CUDA available: No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
Versions of relevant libraries:
[pip] Could not collect
[conda] blas 1.0 mkl
[conda] mkl 2019.1 144
[conda] mkl_fft 1.0.6 py36hd81dba3_0
[conda] mkl_random 1.0.2 py36hd81dba3_0
[conda] pytorch-cpu 1.0.0 py3.6_cpu_1 pytorch
[conda] torchvision-cpu 0.2.1 py_2 pytorch