Skip to content

Commit

Permalink
add T.clip to bernoulli distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
haowen-xu committed Dec 10, 2021
1 parent c55ca34 commit 6354a95
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tensorkit/distributions/bernoulli.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ def logits(self) -> T.Tensor:
def probs(self) -> T.Tensor:
"""Get the probability of being 1."""
if self._probs is None:
self._probs = T.random.bernoulli_logits_to_probs(self._logits)
self._probs = T.clip(
T.random.bernoulli_logits_to_probs(self._logits),
0.,
1.
)
return self._probs

def _sample(self,
Expand Down

0 comments on commit 6354a95

Please sign in to comment.