[GitHub] szha commented on issue #8494: Autograd bug in mxnet-cu80: 0.12

2017-11-03 Thread GitBox
szha commented on issue #8494: Autograd bug in mxnet-cu80: 0.12
URL: 
https://github.com/apache/incubator-mxnet/issues/8494#issuecomment-341633045
 
 
   I haven't had the time to look into the details of the code yet. I found 
[the part that your pseudo-code corresponds 
to](https://github.com/roggiezhang-nv/mxnet-sample/blob/master/python/ml/vision/style_transfer/classic.py#L103-L111),
 though I haven't found any apparent problem. How are you adjusting the weights 
given that your code doesn't use trainer?
   
   BTW you may want to check out @zhanghang1989's work on 
[style-transfer](https://github.com/zhanghang1989/MXNet-Gluon-Style-Transfer).


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] szha commented on issue #8494: Autograd bug in mxnet-cu80: 0.12

2017-10-31 Thread GitBox
szha commented on issue #8494: Autograd bug in mxnet-cu80: 0.12
URL: 
https://github.com/apache/incubator-mxnet/issues/8494#issuecomment-340983575
 
 
   Your code just made `b` an alias of `a` which isn't computation.
   
   The following three examples show
   1. the "what have you tried to solve it"
   2. the snippet you posted with the addition of id check for `a` and `b`. it 
printed `True`.
   3. the snippet where in-place assignment happens. the same id check printed 
`False`
   
   ```python
   In [1]: import mxnet as mx
  ...:
  ...: a = mx.random.normal(shape = (3, 3, 3))
  ...: a.attach_grad()
  ...:
  ...: b = 0
  ...: with mx.autograd.record():
  ...: b = a+1
  ...: b.backward()
  ...: a.grad
  ...:
   Out[1]:
   
   [[[ 1.  1.  1.]
 [ 1.  1.  1.]
 [ 1.  1.  1.]]
   
[[ 1.  1.  1.]
 [ 1.  1.  1.]
 [ 1.  1.  1.]]
   
[[ 1.  1.  1.]
 [ 1.  1.  1.]
 [ 1.  1.  1.]]]
   
   
   In [2]: import mxnet as mx
  ...:
  ...: a = mx.random.normal(shape = (3, 3, 3))
  ...: a.attach_grad()
  ...:
  ...: b = 0
  ...: with mx.autograd.record():
  ...: b = a
  ...: print(id(a) == id(b))
  ...: b.backward()
  ...: a.grad
  ...:
   True
   Out[2]:
   
   [[[ 0.  0.  0.]
 [ 0.  0.  0.]
 [ 0.  0.  0.]]
   
[[ 0.  0.  0.]
 [ 0.  0.  0.]
 [ 0.  0.  0.]]
   
[[ 0.  0.  0.]
 [ 0.  0.  0.]
 [ 0.  0.  0.]]]
   
   
   In [3]: import mxnet as mx
  ...:
  ...: a = mx.random.normal(shape = (3, 3, 3))
  ...: a.attach_grad()
  ...:
  ...: b = mx.nd.zeros_like(a)
  ...: with mx.autograd.record():
  ...: b[:] = a
  ...: print(id(a) == id(b))
  ...: b.backward()
  ...: a.grad
  ...:
   False
   Out[3]:
   
   [[[ 1.  1.  1.]
 [ 1.  1.  1.]
 [ 1.  1.  1.]]
   
[[ 1.  1.  1.]
 [ 1.  1.  1.]
 [ 1.  1.  1.]]
   
[[ 1.  1.  1.]
 [ 1.  1.  1.]
 [ 1.  1.  1.]]]
   
   ```


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:
us...@infra.apache.org


With regards,
Apache Git Services