class_docstr: User-facing API for accessing the NASBench dataset.
docstr: Initialize dataset, this should only be done once per experiment.
  
  Args:
    dataset_file: path to .tfrecord file containing the dataset.
    seed: random seed used for sampling queried models. Two NASBench objects
      created with the same seed will return the same data points when queried
      with the same models in the same order. By default, the seed is randomly
      generated.
docstr_tok: ["Initialize","dataset",",","this","should","only","be","done","once","per","experiment",".","Args",":","dataset_file",":","path","to",".tfrecord","file","containing","the","dataset",".","seed",":","random","seed","used","for","sampling","queried","models",".","Two","NASBench","objects","created","with","the","same","seed","will","return","the","same","data","points","when","queried","with","the","same","models","in","the","same","order",".","By","default",",","the","seed","is","randomly","generated","."]
code: def __init__(self, dataset_file, seed=None, data_format="pickle"):
      """Initialize dataset, this should only be done once per experiment.
  
      Args:
        dataset_file: path to .tfrecord file containing the dataset.
        seed: random seed used for sampling queried models. Two NASBench objects
          created with the same seed will return the same data points when queried
          with the same models in the same order. By default, the seed is randomly
          generated.
      """
      self.config = {
          "module_vertices": 7,
          "max_edges": 9,
          "num_repeats": 3,
          "available_ops": [
              "conv3x3-bn-relu",
              "conv1x1-bn-relu",
              "maxpool3x3",
          ],
      }
      random.seed(seed)
  
      print(
          "Loading dataset from file... This may take a few minutes..."
      )
      start = time.time()
  
      # Stores the fixed statistics that are independent of evaluation (i.e.,
      # adjacency matrix, operations, and number of parameters).
      # hash --> metric name --> scalar
      self.fixed_statistics = {}
  
      # Stores the statistics that are computed via training and evaluating the
      # model on CIFAR-10. Statistics are computed for multiple repeats of each
      # model at each max epoch length.
      # hash --> epochs --> repeat index --> metric name --> scalar
      self.computed_statistics = {}
  
      # Valid queriable epoch lengths. {4, 12, 36, 108} for the full dataset or
      # {108} for the smaller dataset with only the 108 epochs.
      self.valid_epochs = set()
  
      # open the database
      if data_format == "shelve":
          with shelve.open(dataset_file, "r") as shelf:
              for module_hash in shelf:
                  # Parse the data from the data file.
                  fixed_statistics, computed_statistics = shelf[
                      module_hash
                  ]
  
                  self.fixed_statistics[module_hash] = fixed_statistics
                  self.computed_statistics[
                      module_hash
                  ] = computed_statistics
  
                  self.valid_epochs.update(
                      set(computed_statistics.keys())
                  )
      elif data_format == "pickle":
          with open(dataset_file, "rb") as f:
              data = pickle.load(f)
          for module_hash, stats in data.items():
              self.fixed_statistics[module_hash] = stats[0]
              self.computed_statistics[module_hash] = stats[1]
  
              self.valid_epochs.update(set(stats[1].keys()))
      else:
          raise Exception("Data format not supported")
  
      elapsed = time.time() - start
      print("Loaded dataset in %d seconds" % elapsed)
  
      self.history = {}
      self.training_time_spent = 0.0
      self.total_epochs_spent = 0
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import copy
  import random
  import time
  import shelve
  import hashlib
  import _pickle
  import numpy
label_desc: Use image node_id 1 to create a new NASBench object from inherited base classes: object with example: obj = NASBench(dataset_file, seed, data_format)