(N=15)
| 522 | |
| 523 | |
| 524 | def 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 | |
| 545 | def test_tanh_grad(N=15): |
nothing calls this directly
no test coverage detected