kshitij12345 commented on a change in pull request #15413: [MXNET-978] Higher
Order Gradient Support `reciprocal`, `abs`.
URL: https://github.com/apache/incubator-mxnet/pull/15413#discussion_r300452292
##########
File path: tests/python/unittest/test_higher_order_grad.py
##########
@@ -106,6 +106,35 @@ def grad_grad_op(x):
check_second_order_unary(array, log10, grad_grad_op)
+@with_seed()
+def test_reciprocal():
+ def reciprocal(x):
+ return nd.reciprocal(x)
+
+ def grad_grad_op(x):
+ return 2/x**3
+
+ for dim in range(1, 5):
+ shape = rand_shape_nd(dim)
+ array = random_arrays(shape)
+ check_second_order_unary(array, reciprocal, grad_grad_op)
+
+
+@with_seed()
+def test_abs():
+ def abs(x):
+ return nd.abs(x)
+
+ def grad_grad_op(x):
+ return nd.zeros_like(x)
+
+ for dim in range(1, 5):
+ shape = rand_shape_nd(dim)
+ array = random_arrays(shape)
+ check_second_order_unary(array, abs, grad_grad_op)
+
Review comment:
It is fixed actually. I guess I removed the lower line so it is not showing
up here.
----------------------------------------------------------------
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