Exemple #1
0
def test_check_shape():
    ck = CohenKappa()

    with pytest.raises(ValueError, match=r"Predictions should be of shape"):
        ck._check_shape((torch.tensor(0), torch.tensor(0)))

    with pytest.raises(ValueError, match=r"Predictions should be of shape"):
        ck._check_shape((torch.rand(4, 3, 1), torch.rand(4, 3)))

    with pytest.raises(ValueError, match=r"Targets should be of shape"):
        ck._check_shape((torch.rand(4, 3), torch.rand(4, 3, 1)))
def test_check_shape():
    ck = CohenKappa()

    with pytest.raises(ValueError, match=r"Predictions should be of shape"):
        ck._check_shape((torch.randint(0, 2, size=(10, 1, 5, 12)).long(),
                         torch.randint(0, 2, size=(10, 5, 6)).long()))

    with pytest.raises(ValueError, match=r"Predictions should be of shape"):
        ck._check_shape((torch.randint(0, 2, size=(10, 1, 6)).long(),
                         torch.randint(0, 2, size=(10, 5, 6)).long()))

    with pytest.raises(ValueError, match=r"Targets should be of shape"):
        ck._check_shape((torch.randint(0, 2, size=(10, 1)).long(),
                         torch.randint(0, 2, size=(10, 5, 2)).long()))