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

Move transformations to corresponding loss functions.

parent 6e3d8716
No related branches found
No related tags found
No related merge requests found
...@@ -108,7 +108,7 @@ class BernoulliGammaLoss(BernoulliLoss): ...@@ -108,7 +108,7 @@ class BernoulliGammaLoss(BernoulliLoss):
@staticmethod @staticmethod
def predict(p, shape, scale): def predict(p, shape, scale):
# pr = p * shape * scale # pr = p * shape * scale
return p * shape * scale return p * np.exp(shape) * np.exp(scale)
class BernoulliGenParetoLoss(BernoulliLoss): class BernoulliGenParetoLoss(BernoulliLoss):
...@@ -219,4 +219,4 @@ class BernoulliWeibullLoss(BernoulliLoss): ...@@ -219,4 +219,4 @@ class BernoulliWeibullLoss(BernoulliLoss):
@staticmethod @staticmethod
def predict(p, shape, scale): def predict(p, shape, scale):
# pr = p * scale * gamma(1 + 1 / shape) # pr = p * scale * gamma(1 + 1 / shape)
return p * scale * gamma(1 + 1 / shape) return p * np.exp(scale) * gamma(1 + 1 / np.exp(shape))
...@@ -75,8 +75,8 @@ def predict_ERA5(net, ERA5_ds, predictand, loss, batch_size=16, **kwargs): ...@@ -75,8 +75,8 @@ def predict_ERA5(net, ERA5_ds, predictand, loss, batch_size=16, **kwargs):
dtype=torch.float32)).numpy() dtype=torch.float32)).numpy()
# shape and scale parameters # shape and scale parameters
shape = np.exp(target[:, 1, ...].squeeze()) shape = target[:, 1, ...].squeeze()
scale = np.exp(target[:, 2, ...].squeeze()) scale = target[:, 2, ...].squeeze()
# precipitation amount # precipitation amount
pr = loss.predict(prob, shape, scale) pr = loss.predict(prob, shape, scale)
......
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