You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

quickstart.py 769 B

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324
  1. import autogl
  2. from autogl.datasets import build_dataset_from_name
  3. cora_dataset = build_dataset_from_name('cora', path = '/home/AGL/')
  4. import torch
  5. device = torch.device('cuda:5' if torch.cuda.is_available() else 'cpu')
  6. #device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
  7. from autogl.solver import AutoNodeClassifier
  8. solver = AutoNodeClassifier(
  9. feature_module='deepgl',
  10. graph_models=['gcn', 'gat'],
  11. hpo_module='anneal',
  12. ensemble_module='voting',
  13. device=device
  14. )
  15. solver.fit(cora_dataset, time_limit=3600)
  16. solver.get_leaderboard().show()
  17. from autogl.module.train import Acc
  18. predicted = solver.predict_proba()
  19. print('Test accuracy: ', Acc.evaluate(predicted,
  20. cora_dataset.data.y[cora_dataset.data.test_mask].cpu().numpy()))