class_docstr: An extension of Rainbow to perform implicit quantile regression.
docstr: Builds the IQN computations needed for acting and training.
  
  These are:
    self.online_convnet: For computing the current state's quantile values.
    self.target_convnet: For computing the next state's target quantile
      values.
    self._net_outputs: The actual quantile values.
    self._q_argmax: The action maximizing the current state's Q-values.
    self._replay_net_outputs: The replayed states' quantile values.
    self._replay_next_target_net_outputs: The replayed next states' target
      quantile values.
docstr_tok: ["Builds","the","IQN","computations","needed","for","acting","and","training",".","These","are",":","self.online_convnet",":","For","computing","the","current","state","'s","quantile","values",".","self.target_convnet",":","For","computing","the","next","state","'s","target","quantile","values",".","self._net_outputs",":","The","actual","quantile","values",".","self._q_argmax",":","The","action","maximizing","the","current","state","'s","Q-values",".","self._replay_net_outputs",":","The","replayed","states","'","quantile","values",".","self._replay_next_target_net_outputs",":","The","replayed","next","states","'","target","quantile","values","."]
code: def _build_networks(self):
      """Builds the IQN computations needed for acting and training.
  
      These are:
        self.online_convnet: For computing the current state's quantile values.
        self.target_convnet: For computing the next state's target quantile
          values.
        self._net_outputs: The actual quantile values.
        self._q_argmax: The action maximizing the current state's Q-values.
        self._replay_net_outputs: The replayed states' quantile values.
        self._replay_next_target_net_outputs: The replayed next states' target
          quantile values.
      """
      self.online_convnet = self._create_network(name="Online")
      self.target_convnet = self._create_network(name="Target")
  
      # Compute the Q-values which are used for action selection in the current
      # state.
      self._net_outputs = self.online_convnet(
          self.state_ph, self.num_quantile_samples
      )
      # Shape of self._net_outputs.quantile_values:
      # num_quantile_samples x num_actions.
      # e.g. if num_actions is 2, it might look something like this:
      # Vals for Quantile .2  Vals for Quantile .4  Vals for Quantile .6
      #    [[0.1, 0.5],         [0.15, -0.3],          [0.15, -0.2]]
      # Q-values = [(0.1 + 0.15 + 0.15)/3, (0.5 + 0.15 + -0.2)/3].
      self._q_values = tf.reduce_mean(
          self._net_outputs.quantile_values, axis=0
      )
      self._q_argmax = tf.argmax(self._q_values, axis=0)
  
      self._replay_net_outputs = self.online_convnet(
          self._replay.states, self.num_tau_samples
      )
      # Shape: (num_tau_samples x batch_size) x num_actions.
      self._replay_net_quantile_values = (
          self._replay_net_outputs.quantile_values
      )
      self._replay_net_quantiles = self._replay_net_outputs.quantiles
  
      # Do the same for next states in the replay buffer.
      self._replay_net_target_outputs = self.target_convnet(
          self._replay.next_states, self.num_tau_prime_samples
      )
      # Shape: (num_tau_prime_samples x batch_size) x num_actions.
      vals = self._replay_net_target_outputs.quantile_values
      self._replay_net_target_quantile_values = vals
  
      # Compute Q-values which are used for action selection for the next states
      # in the replay buffer. Compute the argmax over the Q-values.
      if self.double_dqn:
          outputs_action = self.online_convnet(
              self._replay.next_states, self.num_quantile_samples
          )
      else:
          outputs_action = self.target_convnet(
              self._replay.next_states, self.num_quantile_samples
          )
  
      # Shape: (num_quantile_samples x batch_size) x num_actions.
      target_quantile_values_action = outputs_action.quantile_values
      # Shape: num_quantile_samples x batch_size x num_actions.
      target_quantile_values_action = tf.reshape(
          target_quantile_values_action,
          [
              self.num_quantile_samples,
              self._replay.batch_size,
              self.num_actions,
          ],
      )
      # Shape: batch_size x num_actions.
      self._replay_net_target_q_values = tf.squeeze(
          tf.reduce_mean(target_quantile_values_action, axis=0)
      )
      self._replay_next_qt_argmax = tf.argmax(
          self._replay_net_target_q_values, axis=1
      )
  
file_path: dopamine/dopamine/agents/implicit_quantile/implicit_quantile_agent.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from dopamine.agents.rainbow import rainbow_agent
  from dopamine.discrete_domains import atari_lib
  import gin.tf
  import tensorflow
label_desc: Use image node_id 3 for calling the ImplicitQuantileAgent obj's underlying member method code with example usage: obj._build_networks() without return types