예제 #1
0
def test_vif_loss_computes_grad_for_zeros_tensors() -> None:
    x = torch.zeros(4, 3, 256, 256, requires_grad=True)
    y = torch.zeros(4, 3, 256, 256)
    loss_value = VIFLoss()(x, y)
    loss_value.backward()
    assert x.grad is not None, NONE_GRAD_ERR_MSG
예제 #2
0
def test_vif_loss_computes_grad(x, y, device: str) -> None:
    x.requires_grad_()
    loss_value = VIFLoss()(x.to(device), y.to(device))
    loss_value.backward()
    assert x.grad is not None, NONE_GRAD_ERR_MSG
예제 #3
0
파일: test_vif.py 프로젝트: pyd1998/piq
def test_vif_loss_computes_grad(prediction: torch.Tensor, target: torch.Tensor,
                                device: str) -> None:
    prediction.requires_grad_()
    loss_value = VIFLoss()(prediction.to(device), target.to(device))
    loss_value.backward()
    assert prediction.grad is not None, NONE_GRAD_ERR_MSG
예제 #4
0
파일: test_vif.py 프로젝트: pyd1998/piq
def test_vif_loss_computes_grad_for_zeros_tensors() -> None:
    prediction = torch.zeros(4, 3, 256, 256, requires_grad=True)
    target = torch.zeros(4, 3, 256, 256)
    loss_value = VIFLoss()(prediction, target)
    loss_value.backward()
    assert prediction.grad is not None, NONE_GRAD_ERR_MSG
예제 #5
0
def test_vif_loss_computes_grad_on_gpu(prediction: torch.Tensor,
                                       target: torch.Tensor) -> None:
    prediction.requires_grad_()
    loss_value = VIFLoss()(prediction.cuda(), target.cuda())
    loss_value.backward()
    assert prediction.grad is not None, NONE_GRAD_ERR_MSG