class_docstr: DQN from https://arxiv.org/pdf/1312.5602.pdf.
  
  Known as Deep Q-Network, it estimates the Q-value function by deep neural
  networks. It enables Q-Learning to be applied on high complexity
  environments. To deal with pixel environments, numbers of tricks are
  usually needed, e.g. skipping frames and stacking frames as single
  observation.
  
  Args:
      env_spec (EnvSpec): Environment specification.
      policy (Policy): Policy.
      qf (object): The q value network.
      replay_buffer (ReplayBuffer): Replay buffer.
      sampler (garage.sampler.Sampler): Sampler.
      exploration_policy (ExplorationPolicy): Exploration strategy.
      steps_per_epoch (int): Number of train_once calls per epoch.
      min_buffer_size (int): The minimum buffer size for replay buffer.
      buffer_batch_size (int): Batch size for replay buffer.
      max_episode_length_eval (int or None): Maximum length of episodes used
          for off-policy evaluation. If None, defaults to
          `env_spec.max_episode_length`.
      n_train_steps (int): Training steps.
      qf_lr (float): Learning rate for Q-Function.
      qf_optimizer (tf.compat.v1.train.Optimizer): Optimizer for Q-Function.
      discount (float): Discount factor for rewards.
      target_network_update_freq (int): Frequency of updating target
          network.
      grad_norm_clipping (float): Maximum clipping value for clipping
          tensor values to a maximum L2-norm. It must be larger than 0.
          If None, no gradient clipping is done. For detail, see
          docstring for tf.clip_by_norm.
      double_q (bool): Bool for using double q-network.
      reward_scale (float): Reward scale.
      name (str): Name of the algorithm.
class_docstr_tok: ["DQN","from","https",":","\/\/arxiv.org\/pdf\/1312.5602.pdf",".","Known","as","Deep","Q-Network",",","it","estimates","the","Q-value","function","by","deep","neural","networks",".","It","enables","Q-Learning","to","be","applied","on","high","complexity","environments",".","To","deal","with","pixel","environments",",","numbers","of","tricks","are","usually","needed",",","e.g",".","skipping","frames","and","stacking","frames","as","single","observation",".","Args",":","env_spec","(","EnvSpec",")",":","Environment","specification",".","policy","(","Policy",")",":","Policy",".","qf","(","object",")",":","The","q","value","network",".","replay_buffer","(","ReplayBuffer",")",":","Replay","buffer",".","sampler","(","garage.sampler.Sampler",")",":","Sampler",".","exploration_policy","(","ExplorationPolicy",")",":","Exploration","strategy",".","steps_per_epoch","(","int",")",":","Number","of","train_once","calls","per","epoch",".","min_buffer_size","(","int",")",":","The","minimum","buffer","size","for","replay","buffer",".","buffer_batch_size","(","int",")",":","Batch","size","for","replay","buffer",".","max_episode_length_eval","(","int","or","None",")",":","Maximum","length","of","episodes","used","for","off-policy","evaluation",".","If","None",",","defaults","to","`","env_spec.max_episode_length","`",".","n_train_steps","(","int",")",":","Training","steps",".","qf_lr","(","float",")",":","Learning","rate","for","Q-Function",".","qf_optimizer","(","tf.compat.v1.train.Optimizer",")",":","Optimizer","for","Q-Function",".","discount","(","float",")",":","Discount","factor","for","rewards",".","target_network_update_freq","(","int",")",":","Frequency","of","updating","target","network",".","grad_norm_clipping","(","float",")",":","Maximum","clipping","value","for","clipping","tensor","values","to","a","maximum","L2-norm",".","It","must","be","larger","than","0",".","If","None",",","no","gradient","clipping","is","done",".","For","detail",",","see","docstring","for","tf.clip_by_norm",".","double_q","(","bool",")",":","Bool","for","using","double","q-network",".","reward_scale","(","float",")",":","Reward","scale",".","name","(","str",")",":","Name","of","the","algorithm","."]
docstr: Perform one step of policy optimization given one batch of samples.
  
  Args:
      itr (int): Iteration number.
      episodes (EpisodeBatch): Batch of episodes.
  
  Returns:
      list[float]: Q function losses
docstr_tok: ["Perform","one","step","of","policy","optimization","given","one","batch","of","samples",".","Args",":","itr","(","int",")",":","Iteration","number",".","episodes","(","EpisodeBatch",")",":","Batch","of","episodes",".","Returns",":","list","[","float","]",":","Q","function","losses"]
code: def _train_once(self, itr, episodes):
      """Perform one step of policy optimization given one batch of samples.
  
      Args:
          itr (int): Iteration number.
          episodes (EpisodeBatch): Batch of episodes.
  
      Returns:
          list[float]: Q function losses
  
      """
      self._replay_buffer.add_episode_batch(episodes)
      qf_losses = []
      for _ in range(self._n_train_steps):
          if (
              self._replay_buffer.n_transitions_stored
              >= self._min_buffer_size
          ):
              qf_losses.append(self._optimize_policy())
  
      if (
          self._replay_buffer.n_transitions_stored
          >= self._min_buffer_size
      ):
          if itr % self._target_network_update_freq == 0:
              self._qf_update_ops()
      return qf_losses
  
file_path: garage/src/garage/tf/algos/dqn.py
imports: import akro
  from dowel import tabular
  import numpy
  import tensorflow
  from garage import log_performance, make_optimizer, obtain_evaluation_episodes
  from garage.np.algos import RLAlgorithm
  from garage.tf import compile_function, get_target_ops
label_desc: Use image node_id 4 for calling the DQN obj's underlying member method code with example usage: obj._train_once(itr, episodes) and returns: qf_losses