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.

README.md 7.9 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. # Contents
  2. - [GCN Description](#gcn-description)
  3. - [Model Architecture](#model-architecture)
  4. - [Dataset](#dataset)
  5. - [Environment Requirements](#environment-requirements)
  6. - [Quick Start](#quick-start)
  7. - [Script Description](#script-description)
  8. - [Script and Sample Code](#script-and-sample-code)
  9. - [Script Parameters](#script-parameters)
  10. - [Training, Evaluation, Test Process](#training-evaluation-test-process)
  11. - [Model Description](#model-description)
  12. - [Performance](#performance)
  13. - [Description of Random Situation](#description-of-random-situation)
  14. - [ModelZoo Homepage](#modelzoo-homepage)
  15. # [GCN Description](#contents)
  16. GCN(Graph Convolutional Networks) was proposed in 2016 and designed to do semi-supervised learning on graph-structured data. A scalable approach based on an efficient variant of convolutional neural networks which operate directly on graphs was presented. The model scales linearly in the number of graph edges and learns hidden layer representations that encode both local graph structure and features of nodes.
  17. [Paper](https://arxiv.org/abs/1609.02907): Thomas N. Kipf, Max Welling. 2016. Semi-Supervised Classification with Graph Convolutional Networks. In ICLR 2016.
  18. # [Model Architecture](#contents)
  19. GCN contains two graph convolution layers. Each layer takes nodes features and adjacency matrix as input, nodes' features are then updated by aggregating neighbours' features.
  20. # [Dataset](#contents)
  21. | Dataset | Type | Nodes | Edges | Classes | Features | Label rate |
  22. | ------- | ---------------: |-----: | ----: | ------: |--------: | ---------: |
  23. | Cora | Citation network | 2708 | 5429 | 7 | 1433 | 0.052 |
  24. | Citeseer| Citation network | 3327 | 4732 | 6 | 3703 | 0.036 |
  25. # [Environment Requirements](#contents)
  26. - Hardware(Ascend)
  27. - Prepare hardware environment with Ascend processor. If you want to try Ascend , please send the [application form](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/file/other/Ascend%20Model%20Zoo%E4%BD%93%E9%AA%8C%E8%B5%84%E6%BA%90%E7%94%B3%E8%AF%B7%E8%A1%A8.docx) to ascend@huawei.com. Once approved, you can get the resources.
  28. - Framework
  29. - [MindSpore](https://gitee.com/mindspore/mindspore)
  30. - For more information, please check the resources below:
  31. - [MindSpore Tutorials](https://www.mindspore.cn/tutorial/training/en/master/index.html)
  32. - [MindSpore Python API](https://www.mindspore.cn/doc/api_python/en/master/index.html)
  33. # [Quick Start](#contents)
  34. - Install [MindSpore](https://www.mindspore.cn/install/en).
  35. - Download the dataset Cora or Citeseer provided by /kimiyoung/planetoid from github.
  36. - Place the dataset to any path you want, the folder should include files as follows(we use Cora dataset as an example):
  37. ```
  38. .
  39. └─data
  40. ├─ind.cora.allx
  41. ├─ind.cora.ally
  42. ├─ind.cora.graph
  43. ├─ind.cora.test.index
  44. ├─ind.cora.tx
  45. ├─ind.cora.ty
  46. ├─ind.cora.x
  47. └─ind.cora.y
  48. ```
  49. - Generate dataset in mindrecord format for cora or citeseer.
  50. ####Usage
  51. ```buildoutcfg
  52. cd ./scripts
  53. # SRC_PATH is the dataset file path you downloaded, DATASET_NAME is cora or citeseer
  54. sh run_process_data.sh [SRC_PATH] [DATASET_NAME]
  55. ```
  56. ####Launch
  57. ```
  58. #Generate dataset in mindrecord format for cora
  59. sh run_process_data.sh ./data cora
  60. #Generate dataset in mindrecord format for citeseer
  61. sh run_process_data.sh ./data citeseer
  62. ```
  63. # [Script Description](#contents)
  64. ## [Script and Sample Code](#contents)
  65. ```shell
  66. .
  67. └─gcn
  68. ├─README.md
  69. ├─scripts
  70. | ├─run_process_data.sh # Generate dataset in mindrecord format
  71. | └─run_train.sh # Launch training, now only Ascend backend is supported.
  72. |
  73. ├─src
  74. | ├─config.py # Parameter configuration
  75. | ├─dataset.py # Data preprocessin
  76. | ├─gcn.py # GCN backbone
  77. | └─metrics.py # Loss and accuracy
  78. |
  79. └─train.py # Train net, evaluation is performed after every training epoch. After the verification result converges, the training stops, then testing is performed.
  80. ```
  81. ## [Script Parameters](#contents)
  82. Parameters for training can be set in config.py.
  83. ```
  84. "learning_rate": 0.01, # Learning rate
  85. "epochs": 200, # Epoch sizes for training
  86. "hidden1": 16, # Hidden size for the first graph convolution layer
  87. "dropout": 0.5, # Dropout ratio for the first graph convolution layer
  88. "weight_decay": 5e-4, # Weight decay for the parameter of the first graph convolution layer
  89. "early_stopping": 10, # Tolerance for early stopping
  90. ```
  91. ## [Training, Evaluation, Test Process](#contents)
  92. #### Usage
  93. ```
  94. # run train with cora or citeseer dataset, DATASET_NAME is cora or citeseer
  95. sh run_train.sh [DATASET_NAME]
  96. ```
  97. #### Launch
  98. ```bash
  99. sh run_train.sh cora
  100. ```
  101. #### Result
  102. Training result will be stored in the scripts path, whose folder name begins with "train". You can find the result like the followings in log.
  103. ```
  104. Epoch: 0001 train_loss= 1.95373 train_acc= 0.09286 val_loss= 1.95075 val_acc= 0.20200 time= 7.25737
  105. Epoch: 0002 train_loss= 1.94812 train_acc= 0.32857 val_loss= 1.94717 val_acc= 0.34000 time= 0.00438
  106. Epoch: 0003 train_loss= 1.94249 train_acc= 0.47857 val_loss= 1.94337 val_acc= 0.43000 time= 0.00428
  107. Epoch: 0004 train_loss= 1.93550 train_acc= 0.55000 val_loss= 1.93957 val_acc= 0.46400 time= 0.00421
  108. Epoch: 0005 train_loss= 1.92617 train_acc= 0.67143 val_loss= 1.93558 val_acc= 0.45400 time= 0.00430
  109. ...
  110. Epoch: 0196 train_loss= 0.60326 train_acc= 0.97857 val_loss= 1.05155 val_acc= 0.78200 time= 0.00418
  111. Epoch: 0197 train_loss= 0.60377 train_acc= 0.97143 val_loss= 1.04940 val_acc= 0.78000 time= 0.00418
  112. Epoch: 0198 train_loss= 0.60680 train_acc= 0.95000 val_loss= 1.04847 val_acc= 0.78000 time= 0.00414
  113. Epoch: 0199 train_loss= 0.61920 train_acc= 0.96429 val_loss= 1.04797 val_acc= 0.78400 time= 0.00413
  114. Epoch: 0200 train_loss= 0.57948 train_acc= 0.96429 val_loss= 1.04753 val_acc= 0.78600 time= 0.00415
  115. Optimization Finished!
  116. Test set results: cost= 1.00983 accuracy= 0.81300 time= 0.39083
  117. ...
  118. ```
  119. # [Model Description](#contents)
  120. ## [Performance](#contents)
  121. | Parameters | GCN |
  122. | -------------------------- | -------------------------------------------------------------- |
  123. | Resource | Ascend 910 |
  124. | uploaded Date | 06/09/2020 (month/day/year) |
  125. | MindSpore Version | 0.5.0-beta |
  126. | Dataset | Cora/Citeseer |
  127. | Training Parameters | epoch=200 |
  128. | Optimizer | Adam |
  129. | Loss Function | Softmax Cross Entropy |
  130. | Accuracy | 81.5/70.3 |
  131. | Parameters (B) | 92160/59344 |
  132. | Scripts | https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/gnn/gcn |
  133. # [Description of Random Situation](#contents)
  134. There are two random situations:
  135. - Seed is set in train.py according to input argument --seed.
  136. - Dropout operations.
  137. Some seeds have already been set in train.py to avoid the randomness of weight initialization. If you want to disable dropout, please set the corresponding dropout_prob parameter to 0 in src/config.py.
  138. # [ModelZoo Homepage](#contents)
  139. Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).