Skip to content

Commit 509bccc

Browse files
saitcakmakfacebook-github-bot
authored andcommitted
Use expm1 in Bilog outcome transform (#2541)
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
1 parent 238f05a commit 509bccc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

botorch/models/transforms/outcome.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ def untransform(
790790
- The un-transformed outcome observations.
791791
- The un-transformed observation noise (if applicable).
792792
"""
793-
Y_utf = Y.sign() * (Y.abs().exp() - 1.0)
793+
Y_utf = Y.sign() * Y.abs().expm1()
794794
outputs = normalize_indices(self._outputs, d=Y.size(-1))
795795
if outputs is not None:
796796
Y_utf = torch.stack(
@@ -822,5 +822,5 @@ def untransform_posterior(self, posterior: Posterior) -> TransformedPosterior:
822822
)
823823
return TransformedPosterior(
824824
posterior=posterior,
825-
sample_transform=lambda x: x.sign() * (x.abs().exp() - 1.0),
825+
sample_transform=lambda x: x.sign() * x.abs().expm1(),
826826
)

0 commit comments

Comments
 (0)