From df3551b50d9200d30f55abf39264b0c1dc82ac4c Mon Sep 17 00:00:00 2001 From: kshitij12345 Date: Thu, 11 Jul 2019 19:51:36 +0530 Subject: [PATCH] add relevant tests --- .../python/unittest/test_higher_order_grad.py | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/python/unittest/test_higher_order_grad.py b/tests/python/unittest/test_higher_order_grad.py index 0f07d014d435..041aadfcbebf 100644 --- a/tests/python/unittest/test_higher_order_grad.py +++ b/tests/python/unittest/test_higher_order_grad.py @@ -50,6 +50,44 @@ def grad_grad_op(x): check_second_order_unary(array, cos, grad_grad_op) +@with_seed() +def test_arcsin(): + def arcsin(x): + return nd.arcsin(x) + + def grad_grad_op(x): + return x / nd.sqrt((1-x**2)**3) + + for dim in range(1, 5): + shape = rand_shape_nd(dim) + array = random_arrays(shape) + # Hack: Decrease std_dev to make + # sure all elements + # are in range -1 to 1 + # i.e. Domain of arcsin + array *= 0.2 + check_second_order_unary(array, arcsin, grad_grad_op) + + +@with_seed() +def test_arccos(): + def arccos(x): + return nd.arccos(x) + + def grad_grad_op(x): + return -x / nd.sqrt((1-x**2)**3) + + for dim in range(1, 5): + shape = rand_shape_nd(dim) + array = random_arrays(shape) + # Hack: Decrease std_dev to make + # sure all elements + # are in range -1 to 1 + # i.e. Domain of arccos + array *= 0.2 + check_second_order_unary(array, arccos, grad_grad_op) + + @with_seed() def test_relu(): def relu(x):