Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoming0625 committed Apr 11, 2024
1 parent 71cdd68 commit 302e574
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions brainpy/_src/math/object_transform/tests/test_autograd.py
Expand Up @@ -1173,48 +1173,6 @@ def f(a, b):


class TestHessian(unittest.TestCase):
def test_hessian1(self):
def f(x):
return jnp.sum(x ** 2)

x = bm.ones(5)
h = bm.hessian(f)(x)
pprint(h)
self.assertTrue(bm.array_equal(h, 2 * jnp.eye(5)))

def test_hessian2(self):
def f(x):
return jnp.sum(x ** 2)

x = bm.ones(5)
h = bm.hessian(f, argnums=0)(x)
pprint(h)
self.assertTrue(bm.array_equal(h, 2 * jnp.eye(5)))

def test_hessian3(self):
def f(x, y):
return jnp.sum(x ** 2) + jnp.sum(y ** 2)

x = bm.ones(5)
y = bm.ones(5)
h = bm.hessian(f)(x, y)
pprint(h)
self.assertTrue(bm.array_equal(h[0], 2 * jnp.eye(5)))
self.assertTrue(bm.array_equal(h[1], 2 * jnp.eye(5)))

def test_hessian4(self):
def f(x, y):
return jnp.sum(x ** 2) + jnp.sum(y ** 2)

x = bm.ones(5)
y = bm.ones(5)
h = bm.hessian(f, argnums=(0, 1))(x, y)
pprint(h)
self.assertTrue(bm.array_equal(h[0][0], 2 * jnp.eye(5)))
self.assertTrue(bm.array_equal(h[0][1], jnp.zeros((5, 5))))
self.assertTrue(bm.array_equal(h[1][0], jnp.zeros((5, 5))))
self.assertTrue(bm.array_equal(h[1][1], 2 * jnp.eye(5)))

def test_hessian5(self):
bm.set_mode(bm.training_mode)

Expand Down

0 comments on commit 302e574

Please sign in to comment.