Skip to content

[add-fire] Halve Gaussian entropy #4319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 7, 2020
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