From 914b4166c00fca2534c3c7ee6ab1a86c937d328c Mon Sep 17 00:00:00 2001
From: "Daniel.Frisinghelli" <daniel.frisinghelli@eurac.edu>
Date: Tue, 5 Oct 2021 17:01:02 +0200
Subject: [PATCH] Activate shape parameter of GenPareto with Exp.

---
 climax/core/loss.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/climax/core/loss.py b/climax/core/loss.py
index 7ea7f33..ff9f29c 100644
--- a/climax/core/loss.py
+++ b/climax/core/loss.py
@@ -132,16 +132,16 @@ class BernoulliGenParetoLoss(NaNLoss):
         # clip probabilities to (0, 1)
         p_pred = torch.sigmoid(y_pred[:, 0, ...].squeeze()[mask])
 
-        # clip scale to (0, +infinity)
+        # clip shape and scale to (0, +infinity)
+        gshape = torch.exp(y_pred[:, 1, ...].squeeze()[mask])
         gscale = torch.exp(y_pred[:, 2, ...].squeeze()[mask])
-        gshape = y_pred[:, 1, ...].squeeze()[mask]
 
         # negative log-likelihood function of Bernoulli-GenPareto distribution
 
         # Bernoulli contribution
         loss = - (1 - p_true) * torch.log(1 - p_pred + self.epsilon)
 
-        # Gamma contribution
+        # GenPareto contribution
         loss -= p_true * (torch.log(p_pred + self.epsilon) + torch.log(
             1 - (1 +  (gshape * y_true / gscale)) ** (- 1 / gshape) +
             self.epsilon))
-- 
GitLab