Skip to content

Commit

Permalink
Update tensorflow_probability/python/distributions/categorical.py
Browse files Browse the repository at this point in the history
Updated Categorical Distribution to use xlogy instead of a boolean mask.

Co-Authored-By: harrismirza <[email protected]>
  • Loading branch information
axch and harrismirza authored Dec 4, 2018
1 parent ee50a4c commit eaf626a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tensorflow_probability/python/distributions/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def _log_prob(self, k):

def _entropy(self):
entropies = self.probs * tf.log(self.probs)
return -tf.reduce_sum(tf.boolean_mask(entropies, tf.is_finite(entropies)), axis=-1)
return -tf.reduce_sum(tf.xlogy(self.probs, self.probs), axis=-1)

def _mode(self):
ret = tf.argmax(self.logits, axis=self._batch_rank)
Expand Down

0 comments on commit eaf626a

Please sign in to comment.