(nx)
| 691 | |
| 692 | |
| 693 | def test_kl_div(nx): |
| 694 | n = 10 |
| 695 | rng = np.random.RandomState(0) |
| 696 | # test on non-negative tensors |
| 697 | x = rng.randn(n) |
| 698 | x = x - x.min() + 1e-5 |
| 699 | y = rng.randn(n) |
| 700 | y = y - y.min() + 1e-5 |
| 701 | xb = nx.from_numpy(x) |
| 702 | yb = nx.from_numpy(y) |
| 703 | kl = nx.kl_div(xb, yb) |
| 704 | kl_mass = nx.kl_div(xb, yb, True) |
| 705 | recovered_kl = kl_mass - nx.sum(yb - xb) |
| 706 | np.testing.assert_allclose(kl, recovered_kl) |
| 707 | |
| 708 | |
| 709 | def test_exp_bures(nx): |
nothing calls this directly
no test coverage detected