dataset[0].nodes.data['test_mask']].numpy() accs = [] model_hp, decoder_hp = get_encoder_decoder_hp(args.model) for seed in tqdm(range(args.repeat)): solver = AutoNodeClassifier( feature_module=None, graph_models=(args.model, ), ensemble_module=None, max_evals=1, hpo_module='random', trainer_hp_space=fixed( **{ "max_epoch": args.epoch, "early_stopping_round": args.epoch + 1, "lr": args.lr, "weight_decay": args.weight_decay, }), model_hp_spaces=[{ "encoder": fixed(**model_hp), "decoder": fixed(**decoder_hp) }]) solver.fit(dataset, evaluation_method=['acc'], seed=seed) output = solver.predict(dataset) acc = (output == label).astype('float').mean() accs.append(acc) print('{:.4f} ~ {:.4f}'.format(np.mean(accs), np.std(accs)))
dataset[0].nodes.data['test_mask']].numpy() accs = [] model_hp, decoder_hp = get_encoder_decoder_hp(args.model, decoupled=True) for seed in tqdm(range(args.repeat)): solver = AutoNodeClassifier( feature_module='NormalizeFeatures', graph_models=(args.model, ), ensemble_module=None, max_evals=1, hpo_module='random', trainer_hp_space=fixed( **{ "max_epoch": args.epoch, "early_stopping_round": args.epoch + 1, "lr": args.lr, "weight_decay": args.weight_decay, }), model_hp_spaces=[{ "encoder": fixed(**model_hp), "decoder": fixed(**decoder_hp) }]) solver.fit(dataset, seed=seed) output = solver.predict(dataset) acc = (output == label).astype('float').mean() accs.append(acc) print('{:.4f} ~ {:.4f}'.format(np.mean(accs), np.std(accs)))
import os os.environ["AUTOGL_BACKEND"] = "dgl" from autogl.datasets import build_dataset_from_name from autogl.solver import AutoNodeClassifier from autogl.module.train import NodeClassificationFullTrainer from autogl.backend import DependentBackend key = "y" if DependentBackend.is_pyg() else "label" cora = build_dataset_from_name("cora") solver = AutoNodeClassifier(graph_models=("gin", ), default_trainer=NodeClassificationFullTrainer( decoder=None, init=False, max_epoch=200, early_stopping_round=201, lr=0.01, weight_decay=0.0, ), hpo_module=None, device="auto") solver.fit(cora, evaluation_method=["acc"]) result = solver.predict(cora) print((result == cora[0].nodes.data[key][ cora[0].nodes.data["test_mask"]].cpu().numpy()).astype('float').mean())
import autogl from autogl.datasets import build_dataset_from_name cora_dataset = build_dataset_from_name('cora', path='/home/qinyj/AGL/') import torch device = torch.device('cuda:5' if torch.cuda.is_available() else 'cpu') #device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') from autogl.solver import AutoNodeClassifier solver = AutoNodeClassifier(feature_module='deepgl', graph_models=['gcn', 'gat'], hpo_module='anneal', ensemble_module='voting', device=device) solver.fit(cora_dataset, time_limit=3600) solver.get_leaderboard().show() from autogl.module.train import Acc predicted = solver.predict_proba() print( 'Test accuracy: ', Acc.evaluate( predicted, cora_dataset.data.y[cora_dataset.data.test_mask].cpu().numpy()))