Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ml-agents/mlagents/trainers/tests/torch/test_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def test_gaussian_dist_instance():
assert log_prob == pytest.approx(-0.919, abs=0.01)

for ent in dist_instance.entropy().flatten():
# entropy of standard normal at 0
assert ent == pytest.approx(2.83, abs=0.01)
# entropy of standard normal at 0, based on 1/2 + ln(sqrt(2pi)sigma)
assert ent == pytest.approx(1.42, abs=0.01)


def test_tanh_gaussian_dist_instance():
Expand Down
2 changes: 1 addition & 1 deletion ml-agents/mlagents/trainers/tests/torch/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_get_probs_and_entropy():

for ent in entropies.flatten():
# entropy of standard normal at 0
assert ent == pytest.approx(2.83, abs=0.01)
assert ent == pytest.approx(1.42, abs=0.01)

# Test continuous
# Add two dists to the list.
Expand Down
2 changes: 1 addition & 1 deletion ml-agents/mlagents/trainers/torch/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def pdf(self, value):
return torch.exp(log_prob)

def entropy(self):
return torch.log(2 * math.pi * math.e * self.std + EPSILON)
return 0.5 * torch.log(2 * math.pi * math.e * self.std + EPSILON)


class TanhGaussianDistInstance(GaussianDistInstance):
Expand Down