Double differentiation with MSELoss?

Since multi differentiation is not yet in stable, maybe the response is simply that something is not implemented yet.

Otherwise, why is the last line raising the error in comment?

from torch import nn, Tensor
from torch.autograd import Variable, grad

criterion = nn.MSELoss()

x = Variable(Tensor(5).normal_(), requires_grad = True)
y = Variable(Tensor(5).normal_())

l1 = (x - y).pow(2).sum().div(y.numel())
a = grad(l1, x, create_graph = True)
b = grad(a[0][3], x)

l2 = criterion(x, y)
a = grad(l2, x, create_graph = True)
b = grad(a[0][3], x) # "RuntimeError: differentiated input is unreachable"

Yes, we’ve converted all of torch.* functions to support double differentiation, and we’re working through nn.* now.

Ok, great. So this piece of code should / will work “as expected” in 0.2?

On a related note, when is the 0.2 release expected?

1 Like