Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Morvan Zhou committed Oct 24, 2017
1 parent b90547f commit 83ca375
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions contents/5_Deep_Q_Network/DQN_modified.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ def __init__(

t_params = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, scope='target_net')
e_params = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, scope='eval_net')
self.target_replace_op = [tf.assign(t, e) for t, e in zip(t_params, e_params)]

with tf.variable_scope('soft_replacement'):
self.target_replace_op = [tf.assign(t, e) for t, e in zip(t_params, e_params)]

self.sess = tf.Session()

if output_graph:
# $ tensorboard --logdir=logs
# tf.train.SummaryWriter soon be deprecated, use following
tf.summary.FileWriter("logs/", self.sess.graph)

self.sess.run(tf.global_variables_initializer())
Expand All @@ -77,16 +78,16 @@ def _build_net(self):
# ------------------ build evaluate_net ------------------
with tf.variable_scope('eval_net'):
e1 = tf.layers.dense(self.s, 20, tf.nn.relu, kernel_initializer=w_initializer,
bias_initializer=b_initializer)
bias_initializer=b_initializer, name='e1')
self.q_eval = tf.layers.dense(e1, self.n_actions, kernel_initializer=w_initializer,
bias_initializer=b_initializer)
bias_initializer=b_initializer, name='q')

# ------------------ build target_net ------------------
with tf.variable_scope('target_net'):
t1 = tf.layers.dense(self.s_, 20, tf.nn.relu, kernel_initializer=w_initializer,
bias_initializer=b_initializer)
bias_initializer=b_initializer, name='t1')
self.q_next = tf.layers.dense(t1, self.n_actions, kernel_initializer=w_initializer,
bias_initializer=b_initializer)
bias_initializer=b_initializer, name='t2')

with tf.variable_scope('q_target'):
q_target = self.r + self.gamma * tf.reduce_max(self.q_next, axis=1, name='Qmax_s_') # shape=(None, )
Expand Down

0 comments on commit 83ca375

Please sign in to comment.