Skip to content

Commit

Permalink
Merge pull request #1 from harrismirza/master
Browse files Browse the repository at this point in the history
Update categorical_test.py
  • Loading branch information
harrismirza authored Dec 4, 2018
2 parents eaf626a + 45347a7 commit d691538
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tensorflow_probability/python/distributions/categorical_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,19 @@ def testEntropyGradient(self):
res["categorical_entropy"])
self.assertAllClose(res["true_entropy_g"],
res["categorical_entropy_g"])


def testEntropyWithZeroProbabilities(self):
probs = [[0, 0.5, 0.5], [0, 1, 0]]
dist = categorical.Categorical(probs=probs)
dist_entropy = dist.entropy()

with self.cached_session():
self.assertAllClose(dist_entropy.eval(),
[
-(0.5*np.log(0.5) + 0.5*np.log(0.5)),
-(np.log(1))
])

def testSample(self):
with self.cached_session():
Expand Down

0 comments on commit d691538

Please sign in to comment.