Skip to content
Snippets Groups Projects
Commit 7b6fa4e7 authored by Frisinghelli Daniel's avatar Frisinghelli Daniel
Browse files

Implemented median reduction.

parent 1cbb8233
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,8 @@ class NaNLoss(_Loss):
return tensor.mean()
elif self.reduction == 'sum':
return tensor.sum()
elif self.reduction == 'median':
return tensor.median()
class MSELoss(NaNLoss):
......@@ -133,13 +135,9 @@ class BernoulliWeibullLoss(BernoulliLoss):
# clip probabilities to (0, 1)
p_pred = torch.sigmoid(y_pred[:, 0, ...].squeeze()[mask])
# clip scale to (0, +infinity)
scale = torch.exp(y_pred[:, 2, ...].squeeze()[mask][~mask_p])
# clip shape to (0, 10)
# NOTE: in general shape in (0, +infinity), clipping is required for
# numerical stability
# clip shape and scale to (0, +infinity)
shape = torch.exp(y_pred[:, 1, ...].squeeze()[mask][~mask_p])
scale = torch.exp(y_pred[:, 2, ...].squeeze()[mask][~mask_p])
# negative log-likelihood function of Bernoulli-Weibull distribution
loss = torch.zeros_like(y_true)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment