From fd7ed457996b879cadf5b1e0e9e13774051adf08 Mon Sep 17 00:00:00 2001 From: wondergo2017 Date: Wed, 13 Apr 2022 15:53:46 +0800 Subject: [PATCH 1/2] fix nas device problem --- autogl/module/nas/algorithm/enas.py | 1 - autogl/module/nas/algorithm/gasso.py | 1 - autogl/module/nas/algorithm/rl.py | 2 -- autogl/module/nas/algorithm/spos.py | 1 - 4 files changed, 5 deletions(-) diff --git a/autogl/module/nas/algorithm/enas.py b/autogl/module/nas/algorithm/enas.py index 122ee2d..23bb1fe 100644 --- a/autogl/module/nas/algorithm/enas.py +++ b/autogl/module/nas/algorithm/enas.py @@ -82,7 +82,6 @@ class Enas(BaseNAS): device="auto", ): super().__init__(device) - self.device = device self.num_epochs = num_epochs self.log_frequency = log_frequency self.entropy_weight = entropy_weight diff --git a/autogl/module/nas/algorithm/gasso.py b/autogl/module/nas/algorithm/gasso.py index c3f5ba8..c445386 100644 --- a/autogl/module/nas/algorithm/gasso.py +++ b/autogl/module/nas/algorithm/gasso.py @@ -61,7 +61,6 @@ class Gasso(BaseNAS): device="auto", ): super().__init__(device=device) - self.device = device self.num_epochs = num_epochs self.warmup_epochs = warmup_epochs self.model_lr = model_lr diff --git a/autogl/module/nas/algorithm/rl.py b/autogl/module/nas/algorithm/rl.py index 95530a0..06ad6d8 100644 --- a/autogl/module/nas/algorithm/rl.py +++ b/autogl/module/nas/algorithm/rl.py @@ -265,7 +265,6 @@ class RL(BaseNAS): disable_progress=False, ): super().__init__(device) - self.device = device self.num_epochs = num_epochs self.log_frequency = log_frequency self.entropy_weight = entropy_weight @@ -447,7 +446,6 @@ class GraphNasRL(BaseNAS): hardware_metric_limit=None, ): super().__init__(device) - self.device = device self.num_epochs = num_epochs self.log_frequency = log_frequency self.entropy_weight = entropy_weight diff --git a/autogl/module/nas/algorithm/spos.py b/autogl/module/nas/algorithm/spos.py index 0e03fa6..5bcaf71 100644 --- a/autogl/module/nas/algorithm/spos.py +++ b/autogl/module/nas/algorithm/spos.py @@ -228,7 +228,6 @@ class Spos(BaseNAS): device="cuda", ): super().__init__(device) - self.device = device self.model_lr=5e-3 self.model_wd=5e-4 self.n_warmup = n_warmup From 921edf2cafb7312e150b618cab18e41aa745048b Mon Sep 17 00:00:00 2001 From: wondergo2017 Date: Wed, 13 Apr 2022 16:12:55 +0800 Subject: [PATCH 2/2] fix nas nclf backend --- autogl/module/nas/space/autoattend.py | 3 +++ test/nas/node_classification.py | 17 +++++------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/autogl/module/nas/space/autoattend.py b/autogl/module/nas/space/autoattend.py index 51d12eb..c0e6477 100644 --- a/autogl/module/nas/space/autoattend.py +++ b/autogl/module/nas/space/autoattend.py @@ -57,6 +57,9 @@ class AutoAttendNodeClassificationSpace(BaseSpace): ): super().__init__() + + from autogl.backend import DependentBackend;assert not DependentBackend.is_dgl(),"Now AutoAttend only support pyg" + self.layer_number = layer_number self.hidden_dim = hidden_dim self.input_dim = input_dim diff --git a/test/nas/node_classification.py b/test/nas/node_classification.py index 4b5e3c2..e28bbac 100644 --- a/test/nas/node_classification.py +++ b/test/nas/node_classification.py @@ -20,7 +20,7 @@ if DependentBackend.is_dgl(): elif DependentBackend.is_pyg(): from torch_geometric.datasets import Planetoid from autogl.module.model.pyg import BaseAutoModel - +from autogl.datasets import build_dataset_from_name import torch import torch.nn.functional as F from autogl.module.nas.space.single_path import SinglePathNodeClassificationSpace @@ -71,12 +71,13 @@ def test_model(model, data=None, check_children=False): if __name__ == "__main__": print("Testing backend: {}".format("dgl" if DependentBackend.is_dgl() else "pyg")) - if DependentBackend.is_dgl(): - dataset = CoraGraphDataset() + from autogl.datasets.utils.conversion._to_dgl_dataset import to_dgl_dataset as convert_dataset else: - dataset = Planetoid(os.path.expanduser("~/.cache-autogl"), "Cora") + from autogl.datasets.utils.conversion._to_pyg_dataset import to_pyg_dataset as convert_dataset + dataset = build_dataset_from_name('cora') + dataset = convert_dataset(dataset) data = dataset[0] di = bk_feat(data).shape[1] @@ -125,14 +126,6 @@ if __name__ == "__main__": model = algo.search(space, dataset, esti) test_model(model, data, True) - print("darts + graphnas ") - space = AutoAttendNodeClassificationSpace().cuda() - space.instantiate(input_dim=di, output_dim=do) - esti = OneShotEstimator() - algo = Darts(num_epochs=10) - model = algo.search(space, dataset, esti) - test_model(model, data, True) - print("Random search + graphnas ") space = GraphNasNodeClassificationSpace().cuda() space.instantiate(input_dim=di, output_dim=do)