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)
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()
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() 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 pyg self.submodel_manager = GeoCitationManager(self.args) if self.cuda: self.controller.cuda()
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)
def fitness_func(solution, solution_idx): args = build_args() if args.cuda and not torch.cuda.is_available(): # cuda is not available args.cuda = False torch.manual_seed(args.random_seed) if args.cuda: torch.cuda.manual_seed(args.random_seed) utils.makedirs(args.dataset) global trnr search_space = MacroSearchSpace().search_space gnn = [] gnn.append(search_space['attention_type'][int(solution[0])]) gnn.append(search_space['aggregator_type'][int(solution[1])]) gnn.append(search_space['activate_function'][int(solution[2])]) gnn.append(int(solution[3])) gnn.append(int(solution[4])) gnn.append(search_space['attention_type'][int(solution[5])]) gnn.append(search_space['aggregator_type'][int(solution[6])]) gnn.append(search_space['activate_function'][int(solution[7])]) gnn.append(int(solution[8])) gnn.append(6) fitness = trnr.genetic_get_reward(gnn)[1] return fitness