You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2017/11/16 19:32:16 UTC
[GitHub] jermainewang commented on issue #8673: Autograd variable scope confusion
jermainewang commented on issue #8673: Autograd variable scope confusion
URL: https://github.com/apache/incubator-mxnet/issues/8673#issuecomment-345037256
Update:
I further simplify the program a little bit to demo one of the weird behaviors:
```python
def test1():
a = nd.ones((2, 3), ctx=ctx) # a is 1
a_grad = nd.zeros((2, 3), ctx=ctx)
ag.mark_variables(a, a_grad, 'write')
with ag.record():
b = a * 2
#b.attach_grad()
t = b * 3
t.backward()
PP(a.grad)
PP(b.grad)
```
In this example, `a.grad` should be 6, `b.grad` should be 3. However, if I uncomment the line `b.attach_grad()`. `a.grad` becomes zero.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services