示例#1
0
    def sample(self, with_loose_ends, upscale=True):
        if with_loose_ends:
            adjacency_matrix_sample = self._sample_adjacency_matrix_with_loose_ends(
            )
        else:
            adjacency_matrix_sample = self._sample_adjacency_matrix_without_loose_ends(
                adjacency_matrix=np.zeros([
                    self.num_intermediate_nodes + 2,
                    self.num_intermediate_nodes + 2
                ]),
                node=self.num_intermediate_nodes + 1)
            assert self._check_validity_of_adjacency_matrix(
                adjacency_matrix_sample), 'Incorrect graph'

        if upscale and self.search_space_number in [1, 2]:
            adjacency_matrix_sample = upscale_to_nasbench_format(
                adjacency_matrix_sample)
        return adjacency_matrix_sample, random.choices(
            PRIMITIVES, k=self.num_intermediate_nodes)
示例#2
0
 def generate_adjacency_matrix_without_loose_ends(self):
     for adjacency_matrix in self._generate_adjacency_matrix(adjacency_matrix=np.zeros([6, 6]),
                                                             node=OUTPUT_NODE - 1):
         yield upscale_to_nasbench_format(adjacency_matrix)
示例#3
0
 def create_nasbench_adjacency_matrix_with_loose_ends(self, parents):
     return upscale_to_nasbench_format(self._create_adjacency_matrix_with_loose_ends(parents))
示例#4
0
 def create_nasbench_adjacency_matrix(self, parents, **kwargs):
     adjacency_matrix = self._create_adjacency_matrix(parents, adjacency_matrix=np.zeros([6, 6]),
                                                      node=OUTPUT_NODE - 1)
     # Create nasbench compatible adjacency matrix
     return upscale_to_nasbench_format(adjacency_matrix)