parameters: (self,
                 game,
                 policy_network_layers=(256, 256),
                 advantage_network_layers=(128, 128),
                 num_iterations: int = 100,
                 num_traversals: int = 20,
                 learning_rate: float = 1e-4,
                 batch_size_advantage=None,
                 batch_size_strategy=None,
                 memory_capacity: int = int(1e6),
                 policy_network_train_steps: int = 1,
                 advantage_network_train_steps: int = 1,
                 reinitialize_advantage_networks: bool = True)
docstring: Initialize the Deep CFR algorithm.
  
      Args:
        game: Open Spiel game.
        policy_network_layers: (list[int]) Layer sizes of strategy net MLP.
        advantage_network_layers: (list[int]) Layer sizes of advantage net MLP.
        num_iterations: (int) Number of training iterations.
        num_traversals: (int) Number of traversals per iteration.
        learning_rate: (float) Learning rate.
        batch_size_advantage: (int or None) Batch size to sample from advantage
          memories.
        batch_size_strategy: (int or None) Batch size to sample from strategy
          memories.
        memory_capacity: Number af samples that can be stored in memory.
        policy_network_train_steps: Number of policy network training steps (per
          iteration).
        advantage_network_train_steps: Number of advantage network training steps
          (per iteration).
        reinitialize_advantage_networks: Whether to re-initialize the advantage
          network before training on each iteration.
docstring_summary: Initialize the Deep CFR algorithm.
docstring_tokens: Initialize the Deep CFR algorithm .
function: def __init__(self,
                 game,
                 policy_network_layers=(256, 256),
                 advantage_network_layers=(128, 128),
                 num_iterations: int = 100,
                 num_traversals: int = 20,
                 learning_rate: float = 1e-4,
                 batch_size_advantage=None,
                 batch_size_strategy=None,
                 memory_capacity: int = int(1e6),
                 policy_network_train_steps: int = 1,
                 advantage_network_train_steps: int = 1,
                 reinitialize_advantage_networks: bool = True):
      """Initialize the Deep CFR algorithm.
  
      Args:
        game: Open Spiel game.
        policy_network_layers: (list[int]) Layer sizes of strategy net MLP.
        advantage_network_layers: (list[int]) Layer sizes of advantage net MLP.
        num_iterations: (int) Number of training iterations.
        num_traversals: (int) Number of traversals per iteration.
        learning_rate: (float) Learning rate.
        batch_size_advantage: (int or None) Batch size to sample from advantage
          memories.
        batch_size_strategy: (int or None) Batch size to sample from strategy
          memories.
        memory_capacity: Number af samples that can be stored in memory.
        policy_network_train_steps: Number of policy network training steps (per
          iteration).
        advantage_network_train_steps: Number of advantage network training steps
          (per iteration).
        reinitialize_advantage_networks: Whether to re-initialize the advantage
          network before training on each iteration.
      """
      all_players = list(range(game.num_players()))
      super(DeepCFRSolver, self).__init__(game, all_players)
      self._game = game
      if game.get_type().dynamics == pyspiel.GameType.Dynamics.SIMULTANEOUS:
        # `_traverse_game_tree` does not take into account this option.
        raise ValueError("Simulatenous games are not supported.")
      self._batch_size_advantage = batch_size_advantage
      self._batch_size_strategy = batch_size_strategy
      self._policy_network_train_steps = policy_network_train_steps
      self._advantage_network_train_steps = advantage_network_train_steps
      self._num_players = game.num_players()
      self._root_node = self._game.new_initial_state()
      self._embedding_size = len(self._root_node.information_state_tensor(0))
      self._num_iterations = num_iterations
      self._num_traversals = num_traversals
      self._reinitialize_advantage_networks = reinitialize_advantage_networks
      self._num_actions = game.num_distinct_actions()
      self._iteration = 1
  
      # Define strategy network, loss & memory.
      self._strategy_memories = ReservoirBuffer(memory_capacity)
      self._policy_network = MLP(self._embedding_size,
                                 list(policy_network_layers),
                                 self._num_actions)
      # Illegal actions are handled in the traversal code where expected payoff
      # and sampled regret is computed from the advantage networks.
      self._policy_sm = nn.Softmax(dim=-1)
      self._loss_policy = nn.MSELoss()
      self._optimizer_policy = torch.optim.Adam(
          self._policy_network.parameters(), lr=learning_rate)
  
      # Define advantage network, loss & memory. (One per player)
      self._advantage_memories = [
          ReservoirBuffer(memory_capacity) for _ in range(self._num_players)
      ]
      self._advantage_networks = [
          MLP(self._embedding_size, list(advantage_network_layers),
              self._num_actions) for _ in range(self._num_players)
      ]
      self._loss_advantages = nn.MSELoss(reduction="mean")
      self._optimizer_advantages = []
      for p in range(self._num_players):
        self._optimizer_advantages.append(
            torch.optim.Adam(
                self._advantage_networks[p].parameters(), lr=learning_rate))
      self._learning_rate = learning_rate
function_tokens: def __init__ ( self , game , policy_network_layers = ( 256 , 256 ) , advantage_network_layers = ( 128 , 128 ) , num_iterations : int = 100 , num_traversals : int = 20 , learning_rate : float = 1e-4 , batch_size_advantage = None , batch_size_strategy = None , memory_capacity : int = int ( 1e6 ) , policy_network_train_steps : int = 1 , advantage_network_train_steps : int = 1 , reinitialize_advantage_networks : bool = True ) : all_players = list ( range ( game . num_players ( ) ) ) super ( DeepCFRSolver , self ) . __init__ ( game , all_players ) self . _game = game if game . get_type ( ) . dynamics == pyspiel . GameType . Dynamics . SIMULTANEOUS : # `_traverse_game_tree` does not take into account this option. raise ValueError ( "Simulatenous games are not supported." ) self . _batch_size_advantage = batch_size_advantage self . _batch_size_strategy = batch_size_strategy self . _policy_network_train_steps = policy_network_train_steps self . _advantage_network_train_steps = advantage_network_train_steps self . _num_players = game . num_players ( ) self . _root_node = self . _game . new_initial_state ( ) self . _embedding_size = len ( self . _root_node . information_state_tensor ( 0 ) ) self . _num_iterations = num_iterations self . _num_traversals = num_traversals self . _reinitialize_advantage_networks = reinitialize_advantage_networks self . _num_actions = game . num_distinct_actions ( ) self . _iteration = 1 # Define strategy network, loss & memory. self . _strategy_memories = ReservoirBuffer ( memory_capacity ) self . _policy_network = MLP ( self . _embedding_size , list ( policy_network_layers ) , self . _num_actions ) # Illegal actions are handled in the traversal code where expected payoff # and sampled regret is computed from the advantage networks. self . _policy_sm = nn . Softmax ( dim = - 1 ) self . _loss_policy = nn . MSELoss ( ) self . _optimizer_policy = torch . optim . Adam ( self . _policy_network . parameters ( ) , lr = learning_rate ) # Define advantage network, loss & memory. (One per player) self . _advantage_memories = [ ReservoirBuffer ( memory_capacity ) for _ in range ( self . _num_players ) ] self . _advantage_networks = [ MLP ( self . _embedding_size , list ( advantage_network_layers ) , self . _num_actions ) for _ in range ( self . _num_players ) ] self . _loss_advantages = nn . MSELoss ( reduction = "mean" ) self . _optimizer_advantages = [ ] for p in range ( self . _num_players ) : self . _optimizer_advantages . append ( torch . optim . Adam ( self . _advantage_networks [ p ] . parameters ( ) , lr = learning_rate ) ) self . _learning_rate = learning_rate