Skip to content

Commit

Permalink
clamp concentration
Browse files Browse the repository at this point in the history
  • Loading branch information
kashif committed Sep 13, 2024
1 parent 065757e commit f1e524a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/gluonts/torch/distributions/generalized_pareto.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ def domain_map(
concentration: torch.Tensor,
): # type: ignore
scale = F.softplus(scale)
# Clamp concentration to avoid numerical issues
concentration = torch.tanh(concentration)

# Adjust loc for negative concentration
neg_conc = concentration < 0
loc = torch.where(neg_conc, loc - scale / concentration, loc)
return loc.squeeze(-1), scale.squeeze(-1), concentration.squeeze(-1)

@property
Expand Down

0 comments on commit f1e524a

Please sign in to comment.