(N=15)
| 543 | |
| 544 | |
| 545 | def 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 | |
| 565 | def test_relu_grad(N=15): |
nothing calls this directly
no test coverage detected