Skip to content

Commit ab7a542

Browse files
committed
Updated some unittests.
1 parent 4bd3f07 commit ab7a542

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

angorapy/common/policies.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import abc
44
import math
5-
from typing import Union, Tuple
5+
from typing import Union, Tuple, List
66

77
import gym
88
import numpy as np
@@ -341,7 +341,7 @@ def _entropy_from_params(self, stdevs: tf.Tensor):
341341
342342
Input Shape: (B, A) or (B, S, A) for recurrent
343343
344-
Since the given r.v.'serialization are independent, the subadditivity property of entropy narrows down to an equality
344+
Since the given r.v.'s are independent, the sub-additivity property of entropy narrows down to an equality
345345
of the joint entropy and the sum of marginal entropies.
346346
"""
347347
entropy = .5 * tf.math.log(2 * math.pi * math.e * tf.pow(stdevs, 2))
@@ -373,7 +373,7 @@ def _approx_entropy_from_log(self, log_stdevs: tf.Tensor):
373373
return tf.reduce_sum(log_stdevs, axis=-1)
374374

375375
@tf.function
376-
def entropy(self, params: tf.Tensor):
376+
def entropy(self, params: Tuple[tf.Tensor, tf.Tensor]):
377377
"""Calculate the joint entropy of Gaussian random variables described by their log standard deviations.
378378
379379
Input Shape: (B, A) or (B, S, A) for recurrent

tests/test_distributions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_gaussian_entropy(self):
3939
sig = tf.convert_to_tensor([[1.0, 1.0], [1.0, 5.0]], dtype=tf.float32)
4040

4141
result_reference = np.sum(norm.entropy(loc=mu, scale=sig), axis=-1)
42-
result_log = distro.entropy(np.log(sig)).numpy()
42+
result_log = distro.entropy([mu, np.log(sig)]).numpy()
4343
result = distro._entropy_from_params(sig).numpy()
4444

4545
self.assertTrue(np.allclose(result_reference, result), msg="Gaussian entropy returns wrong result")

0 commit comments

Comments
 (0)