Beispiel #1
0
  def make_all_possible_edges(self):
    if self.edge_policy_sample_mode == "aggregate_edges":
      self.all_possible_edges = []
      chunk_index = 0
      for i in range(len(self.all_layer_sizes) - 1):
        sector_before = list(
            range(chunk_index, chunk_index + self.all_layer_sizes[i]))
        sector_after = list(
            range(
                chunk_index + self.all_layer_sizes[i], chunk_index +
                self.all_layer_sizes[i] + self.all_layer_sizes[i + 1]))
        for a in sector_before:
          for b in sector_after:
            self.all_possible_edges.append((a, b))
        chunk_index += self.all_layer_sizes[i]

    elif self.edge_policy_sample_mode == "independent_edges":  # check if right
      self.ssd_list = []
      chunk_index = 0

      self.all_possible_edges = []
      for i in range(len(self.all_layer_sizes) - 1):
        k = self.hidden_layer_edge_num[i]
        layer_possible_edges = []
        sector_before = list(
            range(chunk_index, chunk_index + self.all_layer_sizes[i]))
        sector_after = list(
            range(
                chunk_index + self.all_layer_sizes[i], chunk_index +
                self.all_layer_sizes[i] + self.all_layer_sizes[i + 1]))
        for a in sector_before:
          for b in sector_after:
            layer_possible_edges.append((a, b))
            self.all_possible_edges.append((a, b))
        chunk_index += self.all_layer_sizes[i]
        ssd_i = pg.sublist_of(
            k,
            candidates=layer_possible_edges,
            choices_sorted=False,
            choices_distinct=True)

        self.ssd_list.append(ssd_i)

    elif self.edge_policy_sample_mode == "residual_edges":
      self.all_possible_edges = []

      for i in range(len(self.all_layer_sizes) - 1):
        for j in range(i + 1, len(self.all_layer_sizes)):
          sector_before = list(
              range(
                  sum(self.all_layer_sizes[0:i]),
                  sum(self.all_layer_sizes[0:i + 1])))
          sector_after = list(
              range(
                  sum(self.all_layer_sizes[0:j]),
                  sum(self.all_layer_sizes[0:j + 1])))

          for a in sector_before:
            for b in sector_after:
              self.all_possible_edges.append((a, b))
Beispiel #2
0
  def make_search_space(self):
    if self.edge_policy_sample_mode == "aggregate_edges":
      total_number_k = sum(self.hidden_layer_edge_num)

      self.search_space = pg.sublist_of(
          total_number_k,
          candidates=self.all_possible_edges,
          choices_sorted=False,
          choices_distinct=True)

    elif self.edge_policy_sample_mode == "independent_edges":  # check if right
      self.search_space = pg.List(self.ssd_list)

    elif self.edge_policy_sample_mode == "residual_edges":
      total_number_k = sum(self.hidden_layer_edge_num)
      self.search_space = pg.sublist_of(
          total_number_k,
          candidates=self.all_possible_edges,
          choices_sorted=False,
          choices_distinct=True)

    self.template = pg.template(self.search_space)
Beispiel #3
0
  def make_search_space(self):
    """Creates both the edge and operation search space definitions."""
    self.make_all_possible_edges()
    self.edge_search_space = pg.sublist_of(
        self.num_edges,
        candidates=self.all_possible_edges,
        choices_sorted=False,
        choices_distinct=True)
    # Every node is allowed an operation over it, after matrix multiplication.
    self.op_search_space = pg.List(
        [pg.one_of(self.nonlinearity_ops) for i in range(self.total_nb_nodes)])

    self.search_space = pg.Dict(
        edge_search_space=self.edge_search_space,
        op_search_space=self.op_search_space)

    self.template = pg.template(self.search_space)