{"id":19979289,"url":"https://github.com/edisonleeeee/spikenet","last_synced_at":"2025-05-04T04:32:48.041Z","repository":{"id":109814618,"uuid":"529256038","full_name":"EdisonLeeeee/SpikeNet","owner":"EdisonLeeeee","description":"[AAAI23] Scaling Up Dynamic Graph Representation Learning via Spiking Neural Networks","archived":false,"fork":false,"pushed_at":"2023-09-27T09:42:24.000Z","size":1004,"stargazers_count":33,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2023-09-27T19:52:09.362Z","etag":null,"topics":["dynamic-graphs","graph-neural-networks","spiking-neural-networks","temporal-graph-networks"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2208.10364","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EdisonLeeeee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-08-26T12:51:13.000Z","updated_at":"2023-09-23T08:12:28.000Z","dependencies_parsed_at":"2023-09-27T15:39:53.266Z","dependency_job_id":null,"html_url":"https://github.com/EdisonLeeeee/SpikeNet","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EdisonLeeeee%2FSpikeNet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EdisonLeeeee%2FSpikeNet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EdisonLeeeee%2FSpikeNet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EdisonLeeeee%2FSpikeNet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EdisonLeeeee","download_url":"https://codeload.github.com/EdisonLeeeee/SpikeNet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224385195,"owners_count":17302442,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dynamic-graphs","graph-neural-networks","spiking-neural-networks","temporal-graph-networks"],"created_at":"2024-11-13T03:37:25.334Z","updated_at":"2024-11-13T03:37:25.908Z","avatar_url":"https://github.com/EdisonLeeeee.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SpikeNet\n\u003e [**Scaling Up Dynamic Graph Representation Learning via Spiking Neural Networks**](https://arxiv.org/abs/2208.10364) (AAAI 2023)\n\u003e\n\u003e Jintang Li, Zhouxin Yu, Zulun Zhu, Liang Chen, Qi Yu, Zibin Zheng, Sheng Tian, Ruofan Wu, Changhua Meng    \n\n**This repository is an official PyTorch implementation of SpikeNet.**\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"figs/spikenet.png\"/\u003e\n\u003c/div\u003e\u003cbr/\u003e\n\n\n# Abstract\nRecent years have seen a surge in research on dynamic graph representation learning, which aims to model temporal graphs that are dynamic and evolving constantly over time. However, current work typically models graph dynamics with recurrent neural networks (RNNs), making them suffer seriously from computation and memory overheads on large temporal graphs. So far, scalability of dynamic graph representation learning on large temporal graphs remains one of the major challenges. In this paper, we present a scalable framework, namely SpikeNet, to efficiently capture the temporal and structural patterns of temporal graphs. We explore a new direction in that we can capture the evolving dynamics of temporal graphs with spiking neural networks (SNNs) instead of RNNs. As a low-power alternative to RNNs, SNNs explicitly model graph dynamics as spike trains of neuron populations and enable spike-based propagation in an efficient way. Experiments on three large real-world temporal graph datasets demonstrate that SpikeNet outperforms strong baselines on the temporal node classification task with lower computational costs. Particularly, SpikeNet generalizes to a large temporal graph (2M nodes and 13M edges) with significantly fewer parameters and computation overheads.\n\n# Dataset\n## Overview\n|             | DBLP    | Tmall     | Patent     |\n| ----------- | ------- | --------- | ---------- |\n| #nodes      | 28,085  | 577,314   | 2,738,012 |\n| #edges      | 236,894 | 4,807,545 | 13,960,811 |\n| #time steps | 27      | 186       | 25         |\n| #classes    | 10      | 5         | 6          |\n\n## Download datasets\n+ DBLP\n+ Tmall\n+ Patent\n  \nAll dataset can be found at [Dropbox](https://www.dropbox.com/sh/palzyh5box1uc1v/AACSLHB7PChT-ruN-rksZTCYa?dl=0). \nYou can download the datasets and put them in the folder `data/`, e.g., `data/dblp`.\n\n## (Optional) Re-generate node features via DeepWalk\nSince these datasets have no associated node features, we have generated node features via unsupervised DeepWalk method (saved as `.npy` format). \nYou can find them at [Dropbox](https://www.dropbox.com/sh/palzyh5box1uc1v/AACSLHB7PChT-ruN-rksZTCYa?dl=0) as well. \nOnly `dblp.npy` is uploaded due to size limit of Dropbox. \n\n(Update) The generated node features for Tmall and Patent datasets have been shared through Aliyun Drive, and the link is as follows: https://www.aliyundrive.com/s/LH9qa9XZmXa. \n\nNote: Since Aliyun Drive does not support direct sharing of npy files, you will need to manually change the file extension `.txt` to `.npy` after downloading. \n\n\nWe also provide the script to generate the node features. Alternatively, you can generate them on your end (this will take about minutes to hours):\n\n```bash\npython generate_feature.py --dataset dblp\npython generate_feature.py --dataset tmall --normalize\npython generate_feature.py --dataset patent --normalize\n```\n\n## Overall file structure\n```bash\nSpikeNet\n├── data\n│   ├── dblp\n│   │   ├── dblp.npy\n│   │   ├── dblp.txt\n│   │   └── node2label.txt\n│   ├── tmall\n│   │   ├── tmall.npy\n│   │   └── tmall.txt\n│   │   ├── node2label.txt\n│   ├── patent\n│   │   ├── patent_edges.json\n│   │   ├── patent_nodes.json\n│   │   └── patent.npy\n├── figs\n│   └── spikenet.png\n├── spikenet\n│   ├── dataset.py\n│   ├── deepwalk.py\n│   ├── layers.py\n│   ├── neuron.py\n│   ├── sample_neighber.cpp\n│   └── utils.py\n├── generate_feature.py\n├── main.py\n├── main_static.py\n├── README.md\n├── setup.py\n```\n# Requirements\n\n```\ntqdm==4.59.0\nscipy==1.5.2\ntexttable==1.6.2\ntorch==1.9.0\nnumpy==1.22.4\nnumba==0.56.4\nscikit_learn==1.0\ntorch_cluster (optional, only for random walk sampler)\n```\nIn fact, the version of these packages does not have to be consistent to ours. For example, Pytorch 1.6~-1.12 should also work.\n\n\n\n# Usage\n\n## Build neighborhood sampler\n```bash\npython setup.py install\n```\n\n## Run SpikeNet\n\n```bash\n# DBLP\npython main.py --dataset dblp --hids 128 10 --batch_size 1024 --p 0.5 --train_size 0.4\npython main.py --dataset dblp --hids 128 10 --batch_size 1024 --p 0.5 --train_size 0.6\npython main.py --dataset dblp --hids 128 10 --batch_size 1024 --p 0.5 --train_size 0.8\n\n# Tmall\npython main.py --dataset tmall --hids 512 10 --batch_size 1024 --p 1.0 --train_size 0.4\npython main.py --dataset tmall --hids 512 10 --batch_size 1024 --p 1.0 --train_size 0.6\npython main.py --dataset tmall --hids 512 10 --batch_size 1024 --p 1.0 --train_size 0.8\n\n# Patent\npython main.py --dataset patent --hids 512 10 --batch_size 2048 --p 1.0 --train_size 0.4\npython main.py --dataset patent --hids 512 10 --batch_size 2048 --p 1.0 --train_size 0.6\npython main.py --dataset patent --hids 512 10 --batch_size 2048 --p 0.5 --train_size 0.8\n```\n\n\n# On the extention to stastic graphs\nActually, SpikeNet is not only applicaple for temporal graphs, it is also straightforward to extend to stastic graphs by defining a time step hyperparameter $T$ manually.\nIn this way, the sampled subgraph at each time step naturally form graph snapshot. We can use SpikeNet to capture the *evolving* dynamics of sampled subgraphs.\nDue to space limit, we did not discuss this part in our paper. However, we believe this is indeed necessary to show the effectiveness of our work.\n\n\nWe provide a simple example for the usage on stastic graphs datasets `Flickr` and `Reddit` (be sure you have PyTorch Geometric installed):\n\n```bash\n# Flickr\npython main_static.py --dataset flickr --surrogate super\n\n# Reddit\npython main_static.py --dataset reddit --surrogate super\n```\n\nWe report Micro-F1 score and the results are as follows:\n\n| Method     | Flickr      | Reddit      |\n| ---------- | ----------- | ----------- |\n| GCN        | 0.492±0.003 | 0.933±0.000 |\n| GraphSAGE  | 0.501±0.013 | 0.953±0.001 |\n| FastGCN    | 0.504±0.001 | 0.924±0.001 |\n| S-GCN      | 0.482±0.003 | 0.964±0.001 |\n| AS-GCN     | 0.504±0.002 | 0.958±0.001 |\n| ClusterGCN | 0.481±0.005 | 0.954±0.001 |\n| GraphSAINT | 0.511±0.001 | 0.966±0.001 |\n| SpikeNet   | 0.515±0.003 | 0.953±0.001 |\n\n# Reference\n```bibtex\n@inproceedings{li2023scaling,\n  author    = {Jintang Li and\n               Zhouxin Yu and\n               Zulun Zhu and\n               Liang Chen and\n               Qi Yu and\n               Zibin Zheng and\n               Sheng Tian and\n               Ruofan Wu and\n               Changhua Meng},\n  title     = {Scaling Up Dynamic Graph Representation Learning via Spiking Neural\n               Networks},\n  booktitle = {{AAAI}},\n  pages     = {8588--8596},\n  publisher = {{AAAI} Press},\n  year      = {2023}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedisonleeeee%2Fspikenet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedisonleeeee%2Fspikenet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedisonleeeee%2Fspikenet/lists"}