import tensorflow as tf

        self.c_grads, _ = tf.clip_by_global_norm(self.c_grads, 20.0)
        opt = tf.train.AdamOptimizer(self.LR)
        self.update_a_op = opt.apply_gradients(zip(self.a_grads, self.pi_params))
        self.update_c_op = opt.apply_gradients(zip(self.c_grads, self.vf_params))
        self.sess.run(tf.global_variables_initializer())

        # Tensorboard
        if summary_dir is not None:
            self.writer = tf.summary.FileWriter(summary_dir)
        tf.summary.scalar('Loss/Policy', loss_pg)
        tf.summary.scalar('Loss/Value', loss_vf)
        tf.summary.scalar('Loss/Entropy', - 0.01 * tf.reduce_mean(pi.entropy()))
        tf.summary.scalar('Var/Policy Mode', tf.reduce_mean(pi.mode()))
        tf.summary.scalar('Var/Policy Sigma', tf.reduce_mean(pi.stddev()))
        tf.summary.scalar('Var/Value', tf.reduce_mean(self.vf))
        self.summarise = tf.summary.merge(tf.get_collection(tf.GraphKeys.SUMMARIES))
