docstr: DQN algorithm
  
  Args:
      model (parl.Model): model defining forward network of Q function.
      gamma (float): discounted factor for reward computation.
      lr (float): learning rate.
docstr_tok: ["DQN","algorithm","Args",":","model","(","parl.Model",")",":","model","defining","forward","network","of","Q","function",".","gamma","(","float",")",":","discounted","factor","for","reward","computation",".","lr","(","float",")",":","learning","rate","."]
code: def __init__(self, model, gamma=None, lr=None):
      """DQN algorithm
  
      Args:
          model (parl.Model): model defining forward network of Q function.
          gamma (float): discounted factor for reward computation.
          lr (float): learning rate.
      """
      # checks
      check_model_method(model, "forward", self.__class__.__name__)
      assert isinstance(gamma, float)
      assert isinstance(lr, float)
  
      self.model = model
      self.target_model = copy.deepcopy(model)
      device = torch.device(
          "cuda:0" if torch.cuda.is_available() else "cpu"
      )
      self.model.to(device)
      self.target_model.to(device)
  
      self.gamma = gamma
      self.lr = lr
  
      self.mse_loss = torch.nn.MSELoss()
      self.optimizer = optim.Adam(self.model.parameters(), lr=self.lr)
  
file_path: PARL/parl/algorithms/torch/dqn.py
imports: import warnings
  import copy
  import torch
  import torch.optim
  import torch.nn.functional
  import parl
  from parl.utils.utils import check_model_method
  import numpy
label_desc: Use image node_id 1 to create a new DQN object from inherited base classes: parl with example: obj = DQN(model, gamma, lr)