Esempio n. 1
0
def test_ndcg(value, output, gain, device_id, precision):
    dt = PRECISION_TO_TYPE[precision]

    score = AA(output, dtype=dt).reshape(-1,1,1)
    gain  = AA(gain, dtype=dt).reshape(-1,1,1)
    group = np.ones_like(score).reshape(-1,1,1)

    expected_value = AA(value, dtype=dt)

    from cntk.metrics import ndcg_at_1

    g = input((1,))
    s = input((1,))
    n = input((1,))
    f = ndcg_at_1(s, n, g)

    actual_value = f.eval({s:score, n:gain, g:group})

    assert np.allclose(actual_value, expected_value)
Esempio n. 2
0
def test_ndcg(value, output, gain, device_id, precision):
    dt = PRECISION_TO_TYPE[precision]

    score = AA(output, dtype=dt).reshape(-1,1,1)
    gain  = AA(gain, dtype=dt).reshape(-1,1,1)
    group = np.ones_like(score).reshape(-1,1,1)

    expected_value = AA(value, dtype=dt)

    from cntk.metrics import ndcg_at_1

    g = I((1,))
    s = I((1,))
    n = I((1,))
    f = ndcg_at_1(s, n, g)

    actual_value = f.eval({s:score, n:gain, g:group})

    assert np.allclose(actual_value, expected_value)