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

Function test_elu_grad

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

Source from the content-addressed store, hash-verified

522
523
524def test_elu_grad(N=15):
525 from numpy_ml.neural_nets.activations import ELU
526
527 np.random.seed(12345)
528
529 N = np.inf if N is None else N
530
531 i = 0
532 while i < N:
533 n_ex = np.random.randint(1, 10)
534 n_dims = np.random.randint(1, 10)
535 alpha = np.random.uniform(0, 10)
536 z = random_tensor((n_ex, n_dims))
537
538 mine = ELU(alpha)
539 gold = torch_gradient_generator(F.elu, alpha=alpha)
540 assert_almost_equal(mine.grad(z), gold(z), decimal=5)
541 print("PASSED")
542 i += 1
543
544
545def test_tanh_grad(N=15):

Callers

nothing calls this directly

Calls 4

gradMethod · 0.95
random_tensorFunction · 0.90
ELUClass · 0.90
torch_gradient_generatorFunction · 0.70

Tested by

no test coverage detected