Skip to content

Commit ac3ae20

Browse files
author
ruiliLaMeilleure
committed
avoid possible NaN error
1 parent 4abdde1 commit ac3ae20

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

contents/10_A3C/A3C_discrete_action.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __init__(self, scope, globalAC=None):
5959
self.c_loss = tf.reduce_mean(tf.square(td))
6060

6161
with tf.name_scope('a_loss'):
62-
log_prob = tf.reduce_sum(tf.log(self.a_prob) * tf.one_hot(self.a_his, N_A, dtype=tf.float32), axis=1, keep_dims=True)
62+
log_prob = tf.reduce_sum(tf.log(self.a_prob + 1e-5) * tf.one_hot(self.a_his, N_A, dtype=tf.float32), axis=1, keep_dims=True)
6363
exp_v = log_prob * tf.stop_gradient(td)
6464
entropy = -tf.reduce_sum(self.a_prob * tf.log(self.a_prob + 1e-5),
6565
axis=1, keep_dims=True) # encourage exploration

0 commit comments

Comments
 (0)