kshitij12345 commented 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. ```Python from mxnet import nd, autograd import numpy import math grad_grad_op = lambda x: (-1/x**2) x = nd.random.normal(0,1,(3,3)) x.attach_grad() with autograd.record(): y = nd.log(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: [email protected] With regards, Apache Git Services
