def __call__(self, y_pred: torch.Tensor, y_true: torch.Tensor) -> torch.Tensor: y_pred = convert_to_tensor(y_pred) y_true = convert_to_tensor(y_true) check_same_shape(y_pred, y_true) diff = y_pred - y_true return torch.mean(torch.log((torch.exp(diff) + torch.exp(-1.0 * diff)) / 2.0))
def __call__(self, y_pred: torch.Tensor, y_true: torch.Tensor) -> torch.Tensor: y_pred = convert_to_tensor(y_pred) y_true = convert_to_tensor(y_true) check_same_shape(y_pred, y_true) squared_log = torch.pow(torch.log1p(y_pred) - torch.log1p(y_true), 2) return torch.mean(squared_log)
def __call__(self, y_pred: torch.Tensor, y_true: torch.Tensor) -> torch.Tensor: y_pred = convert_to_tensor(y_pred) y_true = convert_to_tensor(y_true) check_same_shape(y_pred, y_true) y_pred = torch.clamp(y_pred, self.epsilon, 1) y_true = torch.clamp(y_true, self.epsilon, 1) kld = torch.sum(y_true * torch.log(y_true / y_pred), axis=-1) return torch.mean(kld)
def __call__(self, y_pred: torch.Tensor, y_true: torch.Tensor, delta: float = 1.0) -> torch.Tensor: y_pred = convert_to_tensor(y_pred) y_true = convert_to_tensor(y_true) check_same_shape(y_pred, y_true) abs_error = torch.abs(y_pred - y_true) quadratic = torch.clamp(abs_error, max=delta) linear = abs_error - quadratic loss = 0.5 * quadratic.pow(2) + delta * linear return loss.mean()