class_docstr: PPO class
class_docstr_tok: ["PPO","class"]
docstr: Update parameter with the constraint of KL divergent
  :return: None
docstr_tok: ["Update","parameter","with","the","constraint","of","KL","divergent",":","return",":","None"]
code: def update(self):
      """
      Update parameter with the constraint of KL divergent
      :return: None
      """
      s = np.array(self.state_buffer, np.float32)
      a = np.array(self.action_buffer, np.float32)
      r = np.array(self.cumulative_reward_buffer, np.float32)
      mean, std = self.actor(s), tf.exp(self.actor.logstd)
      pi = tfp.distributions.Normal(mean, std)
      adv = r - self.critic(s)
  
      # update actor
      if self.method == "kl_pen":
          for _ in range(ACTOR_UPDATE_STEPS):
              kl = self.train_actor(s, a, adv, pi)
          if kl < self.kl_target / 1.5:
              self.lam /= 2
          elif kl > self.kl_target * 1.5:
              self.lam *= 2
      else:
          for _ in range(ACTOR_UPDATE_STEPS):
              self.train_actor(s, a, adv, pi)
  
      # update critic
      for _ in range(CRITIC_UPDATE_STEPS):
          self.train_critic(r, s)
  
      self.state_buffer.clear()
      self.action_buffer.clear()
      self.cumulative_reward_buffer.clear()
      self.reward_buffer.clear()
  
file_path: TensorLayer/examples/reinforcement_learning/tutorial_PPO.py
imports: import argparse
  import os
  import time
  import gym
  import matplotlib.pyplot
  import numpy
  import tensorflow
  import tensorflow_probability
  import tensorlayer
label_desc: Use image node_id 4 for calling the PPO obj's underlying member method code with example usage: obj.update() without return types