Yoni_Keren:

Hi,
Trying to read the code for optim (I want to implement something a bit differently) and your previous example/explanation of what is a leaf Variable doesn’t seem to be valid anymore.
In particular,
you wrote
y = x + 1  # not a leaf variable

Well, here’s output from my termial for the code which you have mentioned:
>>> x = torch.autograd.Variable(torch.Tensor([1, 2, 3, 4]))
>>> x.is_leaf
True
>>> y = x + 1
>>> y.is_leaf
True
>>> y
Variable containing:
 2
 3
 4
 5
[torch.FloatTensor of size (4,)]

So, can someone please explain what is a leaf Variable, and what is not a leaf variable? Clearly a non-leaf-variable cannot be optimized, but what is it?


@colesbury can you address this question please?
Why is y a leaf when you claim it should not?
I also agree it shouldn’t be a leaf but Pytorch disagrees with us…why?