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

Corrected expected value of Gamma-Bernoulli distribution.

parent 3a136056
No related branches found
No related tags found
No related merge requests found
...@@ -62,18 +62,18 @@ def predict_ERA5(net, ERA5_ds, predictand, batch_size=16, **kwargs): ...@@ -62,18 +62,18 @@ def predict_ERA5(net, ERA5_ds, predictand, batch_size=16, **kwargs):
ds = {'tasmax': target[:, 0, ...].squeeze(), ds = {'tasmax': target[:, 0, ...].squeeze(),
'tasmin': target[:, 1, ...].squeeze()} 'tasmin': target[:, 1, ...].squeeze()}
elif predictand == 'pr': elif predictand == 'pr':
ds = {
# probability of precipitation # probability of precipitation
'prob': torch.sigmoid( prob = torch.sigmoid(torch.as_tensor(target[:, 0, ...].squeeze(),
torch.as_tensor(target[:, 0, ...].squeeze(), dtype=torch.float32)).numpy()
dtype=torch.float32)).numpy(),
# amount of precipitation: expected value of Bernoulli-Gamma distribution
# amount of precipitation: expected value of Bernoulli-Gamma # pr = p * shape * scale
# distribution pr = (prob * np.exp(target[:, 1, ...].squeeze()) *
# pr = p * shape * scale np.exp(target[:, 2, ...].squeeze()))
'precipitation': (ds['prob'] * np.exp(target[:, 1, ...].squeeze())
* np.exp(target[:, 2, ...].squeeze())) ds = {'prob': prob, 'precipitation': pr}
}
else: else:
# single predictand # single predictand
ds = {predictand: target} ds = {predictand: target}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment