From 3bf29d426b19e45987a6d92c0c26830b247c5ef3 Mon Sep 17 00:00:00 2001 From: Ryan Julian Date: Tue, 20 Mar 2018 14:23:22 -0700 Subject: [PATCH] [tf] Symbolic entropy for DiagonalGaussian --- sandbox/rocky/tf/distributions/diagonal_gaussian.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sandbox/rocky/tf/distributions/diagonal_gaussian.py b/sandbox/rocky/tf/distributions/diagonal_gaussian.py index d8ac41361..22835aba9 100644 --- a/sandbox/rocky/tf/distributions/diagonal_gaussian.py +++ b/sandbox/rocky/tf/distributions/diagonal_gaussian.py @@ -92,6 +92,10 @@ def entropy(self, dist_info): log_stds = dist_info["log_std"] return np.sum(log_stds + np.log(np.sqrt(2 * np.pi * np.e)), axis=-1) + def entropy_sym(self, dist_info_var): + log_std_var = dist_info_var["log_std"] + return tf.reduce_sum(log_std_var + np.log(np.sqrt(2 * np.pi * np.e)), axis=-1) + @property def dist_info_specs(self): return [("mean", (self.dim,)), ("log_std", (self.dim,))]