class_docstr: Grid search oracle.
  
  Args:
      objective: A string, `keras_tuner.Objective` instance, or a list of
          `keras_tuner.Objective`s and strings. If a string, the direction of
          the optimization (min or max) will be inferred. If a list of
          `keras_tuner.Objective`, we will minimize the sum of all the
          objectives to minimize subtracting the sum of all the objectives to
          maximize. The `objective` argument is optional when
          `Tuner.run_trial()` or `HyperModel.fit()` returns a single float as
          the objective to minimize.
      max_trials: Optional integer, the total number of trials (model
          configurations) to test at most. Note that the oracle may interrupt
          the search before `max_trial` models have been tested if the search
          space has been exhausted. If left unspecified, it runs till the
          search space is exhausted.
      seed: Optional integer, the random seed.
      hyperparameters: Optional `HyperParameters` instance. Can be used to
          override (or register in advance) hyperparameters in the search
          space.
      tune_new_entries: Boolean, whether hyperparameter entries that are
          requested by the hypermodel but that were not specified in
          `hyperparameters` should be added to the search space, or not. If
          not, then the default value for these parameters will be used.
          Defaults to True.
      allow_new_entries: Boolean, whether the hypermodel is allowed to
          request hyperparameter entries not listed in `hyperparameters`.
          Defaults to True.
      max_retries_per_trial: Integer. Defaults to 0. The maximum number of
          times to retry a `Trial` if the trial crashed or the results are
          invalid.
      max_consecutive_failed_trials: Integer. Defaults to 3. The maximum
          number of consecutive failed `Trial`s. When this number is reached,
          the search will be stopped. A `Trial` is marked as failed when none
          of the retries succeeded.
class_docstr_tok: ["Grid","search","oracle",".","Args",":","objective",":","A","string",",","`","keras_tuner.Objective","`","instance",",","or","a","list","of","`","keras_tuner.Objective","`","s","and","strings",".","If","a","string",",","the","direction","of","the","optimization","(","min","or","max",")","will","be","inferred",".","If","a","list","of","`","keras_tuner.Objective","`",",","we","will","minimize","the","sum","of","all","the","objectives","to","minimize","subtracting","the","sum","of","all","the","objectives","to","maximize",".","The","`","objective","`","argument","is","optional","when","`","Tuner.run_trial","(",")","`","or","`","HyperModel.fit","(",")","`","returns","a","single","float","as","the","objective","to","minimize",".","max_trials",":","Optional","integer",",","the","total","number","of","trials","(","model","configurations",")","to","test","at","most",".","Note","that","the","oracle","may","interrupt","the","search","before","`","max_trial","`","models","have","been","tested","if","the","search","space","has","been","exhausted",".","If","left","unspecified",",","it","runs","till","the","search","space","is","exhausted",".","seed",":","Optional","integer",",","the","random","seed",".","hyperparameters",":","Optional","`","HyperParameters","`","instance",".","Can","be","used","to","override","(","or","register","in","advance",")","hyperparameters","in","the","search","space",".","tune_new_entries",":","Boolean",",","whether","hyperparameter","entries","that","are","requested","by","the","hypermodel","but","that","were","not","specified","in","`","hyperparameters","`","should","be","added","to","the","search","space",",","or","not",".","If","not",",","then","the","default","value","for","these","parameters","will","be","used",".","Defaults","to","True",".","allow_new_entries",":","Boolean",",","whether","the","hypermodel","is","allowed","to","request","hyperparameter","entries","not","listed","in","`","hyperparameters","`",".","Defaults","to","True",".","max_retries_per_trial",":","Integer",".","Defaults","to","0",".","The","maximum","number","of","times","to","retry","a","`","Trial","`","if","the","trial","crashed","or","the","results","are","invalid",".","max_consecutive_failed_trials",":","Integer",".","Defaults","to","3",".","The","maximum","number","of","consecutive","failed","`","Trial","`","s",".","When","this","number","is","reached",",","the","search","will","be","stopped",".","A","`","Trial","`","is","marked","as","failed","when","none","of","the","retries","succeeded","."]
docstr: Fill the hyperparameter space with values.
  
  Args:
      trial_id: A string, the ID for this Trial.
  
  Returns:
      A dictionary with keys "values" and "status", where "values" is
      a mapping of parameter names to suggested values, and "status"
      should be one of "RUNNING" (the trial can start normally), "IDLE"
      (the oracle is waiting on something and cannot create a trial), or
      "STOPPED" (the oracle has finished searching and no new trial should
      be created).
docstr_tok: ["Fill","the","hyperparameter","space","with","values",".","Args",":","trial_id",":","A","string",",","the","ID","for","this","Trial",".","Returns",":","A","dictionary","with","keys","``","values","''","and","``","status","''",",","where","``","values","''","is","a","mapping","of","parameter","names","to","suggested","values",",","and","``","status","''","should","be","one","of","``","RUNNING","''","(","the","trial","can","start","normally",")",",","``","IDLE","''","(","the","oracle","is","waiting","on","something","and","can","not","create","a","trial",")",",","or","``","STOPPED","''","(","the","oracle","has","finished","searching","and","no","new","trial","should","be","created",")","."]
code: def populate_space(self, trial_id):
      """Fill the hyperparameter space with values.
  
      Args:
          trial_id: A string, the ID for this Trial.
  
      Returns:
          A dictionary with keys "values" and "status", where "values" is
          a mapping of parameter names to suggested values, and "status"
          should be one of "RUNNING" (the trial can start normally), "IDLE"
          (the oracle is waiting on something and cannot create a trial), or
          "STOPPED" (the oracle has finished searching and no new trial should
          be created).
      """
      values = None
  
      # See if this is the first trial.
      if len(self.start_order) == 0:
          # Use all default values for the first trial.
          self._ordered_ids.insert(trial_id)
          hps = self.get_space()
          values = {
              hp.name: hp.default
              for hp in self.get_space().space
              if hps.is_active(hp)
          }
          # Although the trial is not finished, we still push it into
          # _populate_next to quickly generate values for the first few trials
          # for multiple workers. The same trial_id will be pushed into
          # _populate_next again when the trial is finished just in case of
          # new hps appeared during the trial.
          self._populate_next.append(trial_id)
  
      # Pick tried values to create its next combination if not tried.
      while len(self._populate_next) > 0 and values is None:
          old_trial_id = self._populate_next.pop(0)
  
          # Create its immediate next combination.
          old_values = self.trials[old_trial_id].hyperparameters.values
          new_values = self._get_next_combination(old_values)
          if new_values is None:
              continue
  
          # Skip if tried next combination.
          next_id = self._ordered_ids.next(old_trial_id)
          if next_id is not None:
              next_values = self.trials[next_id].hyperparameters.values
              if self._compare(new_values, next_values) >= 0:
                  continue
  
          self._ordered_ids.insert(trial_id, old_trial_id)
  
          values = new_values
  
      if values is not None:
          return {
              "status": trial_module.TrialStatus.RUNNING,
              "values": values,
          }
  
      # Wait for the ongoing trials to finish when the values queue is empty
      # in case of any new hp discovered.
      if len(self.ongoing_trials) > 0:
          return {
              "status": trial_module.TrialStatus.IDLE,
              "values": None,
          }
  
      # Reaching this point means ongoing_trial, values, populate_next
      # are all empty.
      return {
          "status": trial_module.TrialStatus.STOPPED,
          "values": None,
      }
  
file_path: keras-tuner/keras_tuner/tuners/gridsearch.py
imports: import collections
  import copy
  from keras_tuner.api_export import keras_tuner_export
  from keras_tuner.engine import oracle
  from keras_tuner.engine import trial
  from keras_tuner.engine import tuner
label_desc: Use image node_id 2 for calling the GridSearchOracle obj's underlying member method code with example usage: obj.populate_space(trial_id) and returns: dict, dict, dict