Ejemplo n.º 1
0
def test_content_loss_computes_grad(input_tensors: Tuple[torch.Tensor,
                                                         torch.Tensor],
                                    device: str) -> None:
    x, y = input_tensors
    x.requires_grad_()
    loss_value = ContentLoss()(x.to(device), y.to(device))
    loss_value.backward()
    assert x.grad is not None, NONE_GRAD_ERR_MSG
Ejemplo n.º 2
0
def test_content_loss_computes_grad(input_tensors: Tuple[torch.Tensor,
                                                         torch.Tensor],
                                    device: str) -> None:
    prediction, target = input_tensors
    prediction.requires_grad_()
    loss_value = ContentLoss()(prediction.to(device), target.to(device))
    loss_value.backward()
    assert prediction.grad is not None, NONE_GRAD_ERR_MSG