keep_dims -> keepdims (#1980)

keep_dims is deprecated.
This commit is contained in:
Alok Singh
2018-05-02 22:06:05 -07:00
committed by Philipp Moritz
parent 32fa862408
commit 677b1c85ae
+6 -6
View File
@@ -43,21 +43,21 @@ class Categorical(ActionDistribution):
def entropy(self):
a0 = self.inputs - tf.reduce_max(self.inputs, reduction_indices=[1],
keep_dims=True)
keepdims=True)
ea0 = tf.exp(a0)
z0 = tf.reduce_sum(ea0, reduction_indices=[1], keep_dims=True)
z0 = tf.reduce_sum(ea0, reduction_indices=[1], keepdims=True)
p0 = ea0 / z0
return tf.reduce_sum(p0 * (tf.log(z0) - a0), reduction_indices=[1])
def kl(self, other):
a0 = self.inputs - tf.reduce_max(self.inputs, reduction_indices=[1],
keep_dims=True)
keepdims=True)
a1 = other.inputs - tf.reduce_max(other.inputs, reduction_indices=[1],
keep_dims=True)
keepdims=True)
ea0 = tf.exp(a0)
ea1 = tf.exp(a1)
z0 = tf.reduce_sum(ea0, reduction_indices=[1], keep_dims=True)
z1 = tf.reduce_sum(ea1, reduction_indices=[1], keep_dims=True)
z0 = tf.reduce_sum(ea0, reduction_indices=[1], keepdims=True)
z1 = tf.reduce_sum(ea1, reduction_indices=[1], keepdims=True)
p0 = ea0 / z0
return tf.reduce_sum(p0 * (a0 - tf.log(z0) - a1 + tf.log(z1)),
reduction_indices=[1])