MCPcopy
hub / github.com/ddbourgin/numpy-ml / test_tanh_grad

Function test_tanh_grad

numpy_ml/tests/test_nn.py:545–562  ·  view source on GitHub ↗
(N=15)

Source from the content-addressed store, hash-verified

543
544
545def test_tanh_grad(N=15):
546 from numpy_ml.neural_nets.activations import Tanh
547
548 np.random.seed(12345)
549
550 N = np.inf if N is None else N
551
552 mine = Tanh()
553 gold = torch_gradient_generator(torch.tanh)
554
555 i = 0
556 while i < N:
557 n_ex = np.random.randint(1, 100)
558 n_dims = np.random.randint(1, 100)
559 z = random_tensor((n_ex, n_dims))
560 assert_almost_equal(mine.grad(z), gold(z))
561 print("PASSED")
562 i += 1
563
564
565def test_relu_grad(N=15):

Callers

nothing calls this directly

Calls 4

gradMethod · 0.95
TanhClass · 0.90
random_tensorFunction · 0.90
torch_gradient_generatorFunction · 0.70

Tested by

no test coverage detected