Beispiel #1
0
    def build_model(self):
        self.args.share_param = False
        self.with_retrain = True
        self.args.shared_initial_step = 0
        if self.args.search_mode == "macro":
            # generate model description in macro way (generate entire network description)
            from graphnas.search_space import MacroSearchSpace
            search_space_cls = MacroSearchSpace()
            self.search_space = search_space_cls.get_search_space()
            # layers_of_child_model is 2
            self.action_list = search_space_cls.generate_action_list(
                self.args.layers_of_child_model)
            # build RNN controller
            from graphnas.graphnas_controller import SimpleNASController
            self.controller = SimpleNASController(
                self.args,
                action_list=self.action_list,
                search_space=self.search_space,
                cuda=self.args.cuda)

            if self.args.dataset in ["cora", "citeseer", "pubmed"]:
                # implements based on dgl
                self.submodel_manager = CitationGNNManager(self.args)
            if self.args.dataset in ["Cora", "Citeseer", "Pubmed"]:
                # implements based on pyg
                self.submodel_manager = GeoCitationManager(self.args)

        if self.args.search_mode == "micro":
            self.args.format = "micro"
            self.args.predict_hyper = True
            if not hasattr(self.args, "num_of_cell"):
                self.args.num_of_cell = 2
            from graphnas_variants.micro_graphnas.micro_search_space import IncrementSearchSpace
            search_space_cls = IncrementSearchSpace()
            search_space = search_space_cls.get_search_space()
            from graphnas.graphnas_controller import SimpleNASController
            from graphnas_variants.micro_graphnas.micro_model_manager import MicroCitationManager
            self.submodel_manager = MicroCitationManager(self.args)
            self.search_space = search_space
            action_list = search_space_cls.generate_action_list(
                cell=self.args.num_of_cell)
            if hasattr(self.args, "predict_hyper") and self.args.predict_hyper:
                self.action_list = action_list + [
                    "learning_rate", "dropout", "weight_decay", "hidden_unit"
                ]
            else:
                self.action_list = action_list
            self.controller = SimpleNASController(
                self.args,
                action_list=self.action_list,
                search_space=self.search_space,
                cuda=self.args.cuda)
            if self.cuda:
                self.controller.cuda()

        if self.cuda:
            self.controller.cuda()
Beispiel #2
0
def eval(chromosome):
    args = build_args()

    dataset_list = ["Citeseer", "Pubmed", "cora"]
    base_list = [
        "pyg",
        "pyg",
        "dgl",
    ]
    for dataset, actions, base in zip(dataset_list, chromosome, base_list):
        # if dataset == "cora":
        #     continue
        args.dataset = dataset
        if base == "dgl":
            manager = CitationGNNManager(args)
        else:
            manager = GeoCitationManager(args)
        val_acc, test_acc = manager.evaluate(actions)
        print(test_acc)
        print("_" * 80)
        return test_acc
Beispiel #3
0
 def build_model(self):
     if self.args.search_mode == "macro":
         search_space_cls = MacroSearchSpace()
         self.search_space = search_space_cls.get_search_space()
         self.action_list = search_space_cls.generate_action_list(
             self.args.layers_of_child_model)
         # build RNN controller
         if self.args.dataset in ["cora", "citeseer", "pubmed"]:
             # implements based on dgl
             self.submodel_manager = CitationGNNManager(self.args)
         if self.args.dataset in ["Cora", "Citeseer", "Pubmed",
                                  "CS", "Physics", "Computers", "Photo"]:
             # implements based on pyg
             self.submodel_manager = GeoCitationManager(self.args)
     print("Search space:")
     print(self.search_space)
     print("Generated Action List: ")
     print(self.action_list)
Beispiel #4
0
 def build_model(self):
     if self.args.search_mode == "macro":
         # generate model description in macro way
         # (generate entire network description)
         search_space_cls = MacroSearchSpace()
         self.search_space = search_space_cls.get_search_space()
         self.action_list = search_space_cls.generate_action_list(
             self.args.layers_of_child_model)
         # build RNN controller
         if self.args.dataset in ["cora", "citeseer", "pubmed"]:
             # implements based on dgl
             self.submodel_manager = CitationGNNManager(self.args)
         if self.args.dataset in [
                 "Cora", "Citeseer", "Pubmed", "CS", "Physics", "Computers",
                 "Photo"
         ]:
             # implements based on pyg
             self.submodel_manager = GeoCitationManager(self.args)
     if self.args.search_mode == "micro":
         self.args.format = "micro"
         self.args.predict_hyper = True
         if not hasattr(self.args, "num_of_cell"):
             self.args.num_of_cell = 2
         search_space_cls = IncrementSearchSpace()
         search_space = search_space_cls.get_search_space()
         self.submodel_manager = MicroCitationManager(self.args)
         self.search_space = search_space
         action_list = search_space_cls.generate_action_list(
             cell=self.args.num_of_cell)
         if hasattr(self.args, "predict_hyper") and self.args.predict_hyper:
             self.action_list = action_list + [
                 "learning_rate", "dropout", "weight_decay", "hidden_unit"
             ]
         else:
             self.action_list = action_list
     print("Search space:")
     print(self.search_space)
     print("Generated Action List: ")
     print(self.action_list)
Beispiel #5
0
if __name__ == "__main__":
    args = build_args()

    gnn_list = [
        ['gat', 'sum', 'linear', 4, 128, 'linear', 'sum', 'elu', 8, 6],
        ['gcn', 'sum', 'tanh', 6, 64, 'cos', 'sum', 'tanh', 6, 3],
        ['const', 'sum', 'relu6', 2, 128, 'gat', 'sum', 'linear', 2, 7],
    ]
    dataset_list = ["Citeseer", "Pubmed", "cora"]
    base_list = [
        "pyg",
        "pyg",
        "dgl",
    ]
    for dataset, actions, base in zip(dataset_list, gnn_list, base_list):
        # if dataset == "cora":
        #     continue
        args.dataset = dataset
        if base == "dgl":
            manager = CitationGNNManager(args)
        else:
            manager = GeoCitationManager(args)
        test_scores_list = []
        for i in range(100):
            val_acc, test_acc = manager.evaluate(actions)
            test_scores_list.append(test_acc)
        print("_" * 80)
        test_scores_list.sort()
        print(dataset, np.mean(test_scores_list[5:-5]),
              np.std(test_scores_list[5:-5]))