Skip to content

Commit

Permalink
Use expm1 in Bilog outcome transform (#2541)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #2541

Similar to #2540, replaces `exp(x) - 1` with the numerically more stable `expm1`.

Reviewed By: Balandat

Differential Revision: D62813775

fbshipit-source-id: 3e6b7730e8db0d089c123a3477885593f4c7c2ad
  • Loading branch information
saitcakmak authored and facebook-github-bot committed Sep 17, 2024
1 parent 238f05a commit 509bccc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions botorch/models/transforms/outcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ def untransform(
- The un-transformed outcome observations.
- The un-transformed observation noise (if applicable).
"""
Y_utf = Y.sign() * (Y.abs().exp() - 1.0)
Y_utf = Y.sign() * Y.abs().expm1()
outputs = normalize_indices(self._outputs, d=Y.size(-1))
if outputs is not None:
Y_utf = torch.stack(
Expand Down Expand Up @@ -822,5 +822,5 @@ def untransform_posterior(self, posterior: Posterior) -> TransformedPosterior:
)
return TransformedPosterior(
posterior=posterior,
sample_transform=lambda x: x.sign() * (x.abs().exp() - 1.0),
sample_transform=lambda x: x.sign() * x.abs().expm1(),
)

0 comments on commit 509bccc

Please sign in to comment.