(self, restricted_classes_per_split=None)
Initializes a HierarchicalDatasetSpecification.

    Args:
      restricted_classes_per_split: A dict that specifies for each split, a
        number to restrict its classes to. This number must be no greater than
        the total number of classes of that split. By default this is None and
        no restrictions are applied (all classes are used).
Initializes a HierarchicalDatasetSpecification.
Initializes a HierarchicalDatasetSpecification .
def initialize(self, restricted_classes_per_split=None):
    """Initializes a HierarchicalDatasetSpecification.

    Args:
      restricted_classes_per_split: A dict that specifies for each split, a
        number to restrict its classes to. This number must be no greater than
        the total number of classes of that split. By default this is None and
        no restrictions are applied (all classes are used).
    """
    # Set self.class_names_to_ids to the inverse dict of self.class_names.
    self.class_names_to_ids = dict(
        zip(self.class_names.values(), self.class_names.keys()))

    # Maps each Split enum to the number of its classes.
    self.classes_per_split = self.get_classes_per_split()

    # Map each class ID to its corresponding number of examples.
    examples_per_class = {}
    for split in learning_spec.Split:
      leaves = imagenet_specification.get_leaves(self.split_subgraphs[split])
      for node in leaves:
        num_examples = self.images_per_class[split][node]
        examples_per_class[self.class_names_to_ids[node.wn_id]] = num_examples
    self.examples_per_class = examples_per_class

    if restricted_classes_per_split is not None:
      _check_validity_of_restricted_classes_per_split(
          restricted_classes_per_split, self.classes_per_split)
      # Apply the restriction.
      for split, restricted_num_classes in restricted_classes_per_split.items():
        self.classes_per_split[split] = restricted_num_classes
def initialize ( self , restricted_classes_per_split = None ) : # Set self.class_names_to_ids to the inverse dict of self.class_names. self . class_names_to_ids = dict ( zip ( self . class_names . values ( ) , self . class_names . keys ( ) ) ) # Maps each Split enum to the number of its classes. self . classes_per_split = self . get_classes_per_split ( ) # Map each class ID to its corresponding number of examples. examples_per_class = { } for split in learning_spec . Split : leaves = imagenet_specification . get_leaves ( self . split_subgraphs [ split ] ) for node in leaves : num_examples = self . images_per_class [ split ] [ node ] examples_per_class [ self . class_names_to_ids [ node . wn_id ] ] = num_examples self . examples_per_class = examples_per_class if restricted_classes_per_split is not None : _check_validity_of_restricted_classes_per_split ( restricted_classes_per_split , self . classes_per_split ) # Apply the restriction. for split , restricted_num_classes in restricted_classes_per_split . items ( ) : self . classes_per_split [ split ] = restricted_num_classes