class_docstr: # Arguments
      model__: A Keras model.
      policy__: A Keras-rl policy that are defined in [policy](https://github.com/keras-rl/keras-rl/blob/master/rl/policy.py).
      test_policy__: A Keras-rl policy.
      enable_double_dqn__: A boolean which enable target network as a second network proposed by van Hasselt et al. to decrease overfitting.
      enable_dueling_dqn__: A boolean which enable dueling architecture proposed by Mnih et al.
      dueling_type__: If `enable_dueling_dqn` is set to `True`, a type of dueling architecture must be chosen which calculate Q(s,a) from V(s) and A(s,a) differently. Note that `avg` is recommanded in the [paper](https://arxiv.org/abs/1511.06581).
          `avg`: Q(s,a;theta) = V(s;theta) + (A(s,a;theta)-Avg_a(A(s,a;theta)))
          `max`: Q(s,a;theta) = V(s;theta) + (A(s,a;theta)-max_a(A(s,a;theta)))
          `naive`: Q(s,a;theta) = V(s;theta) + A(s,a;theta)
code: def __init__(
      self,
      model,
      policy=None,
      test_policy=None,
      enable_double_dqn=False,
      enable_dueling_network=False,
      dueling_type="avg",
      *args,
      **kwargs,
  ):
      super(DQNAgent, self).__init__(*args, **kwargs)
  
      # Validate (important) input.
      if hasattr(model.output, "__len__") and len(model.output) > 1:
          raise ValueError(
              'Model "{}" has more than one output. DQN expects a model that has a single output.'.format(
                  model
              )
          )
      if model.output._keras_shape != (None, self.nb_actions):
          raise ValueError(
              'Model output "{}" has invalid shape. DQN expects a model that has one dimension for each action, in this case {}.'.format(
                  model.output, self.nb_actions
              )
          )
  
      # Parameters.
      self.enable_double_dqn = enable_double_dqn
      self.enable_dueling_network = enable_dueling_network
      self.dueling_type = dueling_type
      if self.enable_dueling_network:
          # get the second last layer of the model, abandon the last layer
          layer = model.layers[-2]
          nb_action = model.output._keras_shape[-1]
          # layer y has a shape (nb_action+1,)
          # y[:,0] represents V(s;theta)
          # y[:,1:] represents A(s,a;theta)
          y = Dense(nb_action + 1, activation="linear")(layer.output)
          # caculate the Q(s,a;theta)
          # dueling_type == 'avg'
          # Q(s,a;theta) = V(s;theta) + (A(s,a;theta)-Avg_a(A(s,a;theta)))
          # dueling_type == 'max'
          # Q(s,a;theta) = V(s;theta) + (A(s,a;theta)-max_a(A(s,a;theta)))
          # dueling_type == 'naive'
          # Q(s,a;theta) = V(s;theta) + A(s,a;theta)
          if self.dueling_type == "avg":
              outputlayer = Lambda(
                  lambda a: K.expand_dims(a[:, 0], -1)
                  + a[:, 1:]
                  - K.mean(a[:, 1:], axis=1, keepdims=True),
                  output_shape=(nb_action,),
              )(y)
          elif self.dueling_type == "max":
              outputlayer = Lambda(
                  lambda a: K.expand_dims(a[:, 0], -1)
                  + a[:, 1:]
                  - K.max(a[:, 1:], axis=1, keepdims=True),
                  output_shape=(nb_action,),
              )(y)
          elif self.dueling_type == "naive":
              outputlayer = Lambda(
                  lambda a: K.expand_dims(a[:, 0], -1) + a[:, 1:],
                  output_shape=(nb_action,),
              )(y)
          else:
              assert (
                  False
              ), "dueling_type must be one of {'avg','max','naive'}"
  
          model = Model(inputs=model.input, outputs=outputlayer)
  
      # Related objects.
      self.model = model
      if policy is None:
          policy = EpsGreedyQPolicy()
      if test_policy is None:
          test_policy = GreedyQPolicy()
      self.policy = policy
      self.test_policy = test_policy
  
      # State.
      self.reset_states()
  
imports: from __future__ import division
  import warnings
  import keras.backend
  from keras.models import Model
  from keras.layers import Lambda, Input, Layer, Dense
  from rl.core import Agent
  from rl.policy import EpsGreedyQPolicy, GreedyQPolicy
  from rl.util import *
label_desc: Use image node_id 1 to create a new DQNAgent object from inherited base classes: AbstractDQNAgent with example: obj = DQNAgent(model, policy, test_policy, enable_double_dqn, enable_dueling_network, dueling_type)