Beispiel #1
0
def test_gmsd_loss_forward_backward(prediction: torch.Tensor, target: torch.Tensor, device: str) -> None:
    prediction.requires_grad_()
    loss_value = GMSDLoss()(prediction.to(device), target.to(device))
    loss_value.backward()
    assert torch.isfinite(prediction.grad).all(), LEAF_VARIABLE_ERROR_MESSAGE
Beispiel #2
0
def test_gmsd_loss_forward_backward(x, y, device: str) -> None:
    x.requires_grad_()
    loss_value = GMSDLoss()(x.to(device), y.to(device))
    loss_value.backward()
    assert torch.isfinite(x.grad).all(), LEAF_VARIABLE_ERROR_MESSAGE