kshitij12345 edited a comment on issue #14613: [MXNET-978] Higher order 
gradient support for some unary operators
URL: https://github.com/apache/incubator-mxnet/pull/14613#issuecomment-497920495
 
 
   @apeforest As mentioned in the #14992 for `log` , ~~I guess the check will 
fail with given script.~~
   Sorry for missing this earlier.
   I have checked that it fails with
   ```Python
   from mxnet import nd, autograd
   import numpy
   import math
   grad_grad_op = lambda x: -nd.sin(x) # -nd.cos(x)
   
   x = nd.random.normal(0,1,(3,3))
   x.attach_grad()
   with autograd.record():
     y = nd.sin(x) # nd.cos(x)
     y_grad = autograd.grad(y, x, head_grads= nd.ones_like(y) * 0.5, 
create_graph=True, retain_graph=True)[0]
   y_grad.backward(nd.ones_like(y_grad) * 0.6)
   
   numpy.testing.assert_allclose(x.grad.asnumpy() , ( grad_grad_op(x) * 0.5 * 
0.6).asnumpy(), rtol=1e-7, atol=1e-7)
   ```
   
   As the `grad` from upper layer is not preserved for `sin` and `cos`. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

Reply via email to