import tensorflow as tf

        self.a_grads = tf.gradients(loss_pg, self.pi_params)
        self.c_grads = tf.gradients(loss_vf, self.vf_params)
        self.a_grads, _ = tf.clip_by_global_norm(self.a_grads, 20.0)
        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)
