[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-GraphSAINT--GraphSAINT":3,"tool-GraphSAINT--GraphSAINT":61},[4,18,28,37,45,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":24,"last_commit_at":25,"category_tags":26,"status":17},9989,"n8n","n8n-io\u002Fn8n","n8n 是一款面向技术团队的公平代码（fair-code）工作流自动化平台，旨在让用户在享受低代码快速构建便利的同时，保留编写自定义代码的灵活性。它主要解决了传统自动化工具要么过于封闭难以扩展、要么完全依赖手写代码效率低下的痛点，帮助用户轻松连接 400 多种应用与服务，实现复杂业务流程的自动化。\n\nn8n 特别适合开发者、工程师以及具备一定技术背景的业务人员使用。其核心亮点在于“按需编码”：既可以通过直观的可视化界面拖拽节点搭建流程，也能随时插入 JavaScript 或 Python 代码、调用 npm 包来处理复杂逻辑。此外，n8n 原生集成了基于 LangChain 的 AI 能力，支持用户利用自有数据和模型构建智能体工作流。在部署方面，n8n 提供极高的自由度，支持完全自托管以保障数据隐私和控制权，也提供云端服务选项。凭借活跃的社区生态和数百个现成模板，n8n 让构建强大且可控的自动化系统变得简单高效。",184740,2,"2026-04-19T23:22:26",[16,14,13,15,27],"插件",{"id":29,"name":30,"github_repo":31,"description_zh":32,"stars":33,"difficulty_score":10,"last_commit_at":34,"category_tags":35,"status":17},10095,"AutoGPT","Significant-Gravitas\u002FAutoGPT","AutoGPT 是一个旨在让每个人都能轻松使用和构建 AI 的强大平台，核心功能是帮助用户创建、部署和管理能够自动执行复杂任务的连续型 AI 智能体。它解决了传统 AI 应用中需要频繁人工干预、难以自动化长流程工作的痛点，让用户只需设定目标，AI 即可自主规划步骤、调用工具并持续运行直至完成任务。\n\n无论是开发者、研究人员，还是希望提升工作效率的普通用户，都能从 AutoGPT 中受益。开发者可利用其低代码界面快速定制专属智能体；研究人员能基于开源架构探索多智能体协作机制；而非技术背景用户也可直接选用预置的智能体模板，立即投入实际工作场景。\n\nAutoGPT 的技术亮点在于其模块化“积木式”工作流设计——用户通过连接功能块即可构建复杂逻辑，每个块负责单一动作，灵活且易于调试。同时，平台支持本地自托管与云端部署两种模式，兼顾数据隐私与使用便捷性。配合完善的文档和一键安装脚本，即使是初次接触的用户也能在几分钟内启动自己的第一个 AI 智能体。AutoGPT 正致力于降低 AI 应用门槛，让人人都能成为 AI 的创造者与受益者。",183572,"2026-04-20T04:47:55",[13,36,27,14,15],"语言模型",{"id":38,"name":39,"github_repo":40,"description_zh":41,"stars":42,"difficulty_score":10,"last_commit_at":43,"category_tags":44,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":46,"name":47,"github_repo":48,"description_zh":49,"stars":50,"difficulty_score":24,"last_commit_at":51,"category_tags":52,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",161147,"2026-04-19T23:31:47",[14,13,36],{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":24,"last_commit_at":59,"category_tags":60,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",109154,"2026-04-18T11:18:24",[14,15,13],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":64,"owner_name":72,"owner_avatar_url":73,"owner_bio":74,"owner_company":75,"owner_location":76,"owner_email":77,"owner_twitter":77,"owner_website":77,"owner_url":78,"languages":79,"stars":100,"forks":101,"last_commit_at":102,"license":103,"difficulty_score":104,"env_os":105,"env_gpu":106,"env_ram":105,"env_deps":107,"category_tags":119,"github_topics":121,"view_count":24,"oss_zip_url":77,"oss_zip_packed_at":77,"status":17,"created_at":129,"updated_at":130,"faqs":131,"releases":161},10008,"GraphSAINT\u002FGraphSAINT","GraphSAINT","[ICLR 2020; IPDPS 2019] Fast and accurate minibatch training for deep GNNs and large graphs (GraphSAINT: Graph Sampling Based Inductive Learning Method).","GraphSAINT 是一个专为大规模图数据设计的高效训练框架，旨在帮助开发者和研究人员轻松训练深度图神经网络（GNN）。传统方法在处理大型图时，常因逐层采样导致“邻居爆炸”问题，使得计算成本随网络深度呈指数级增长，难以在显存中运行。GraphSAINT 创新性地采用了“图采样”策略，即在每个训练批次中直接采样出一个完整的子图，而非在网络层内部进行节点筛选。这种方法不仅将计算复杂度从指数级降低为线性级，显著提升了训练效率，还通过独特的归一化技术和轻量级采样器，有效消除了采样偏差并保留了关键的结构信息，从而保证了模型的高准确率。此外，GraphSAINT 具有极佳的灵活性，能够无缝兼容大多数现有的 GNN 架构，并支持在分布式环境中高效扩展。无论是需要处理百万级节点图的算法工程师，还是致力于探索新型图模型的研究人员，GraphSAINT 都能提供一个稳定、可扩展且易于集成的解决方案，让大规模图学习变得更加简单可行。","\n# GraphSAINT: Graph \u003Cu>Sa\u003C\u002Fu>mpling Based \u003Cu>In\u003C\u002Fu>ductive Learning Me\u003Cu>t\u003C\u002Fu>hod\n\n\n[Hanqing Zeng](https:\u002F\u002Fsites.google.com\u002Fa\u002Fusc.edu\u002Fzengh\u002Fhome)\\*, [Hongkuan Zhou](https:\u002F\u002Ftedzhouhk.github.io\u002Fabout\u002F)\\*, [Ajitesh Srivastava](http:\u002F\u002Fwww-scf.usc.edu\u002F~ajiteshs\u002F), Rajgopal Kannan, [Viktor Prasanna](https:\u002F\u002Fsites.usc.edu\u002Fprasanna\u002F)\n\n**Contact**\n\n\nHanqing Zeng (zengh@usc.edu), Hongkuan Zhou (hongkuaz@usc.edu)\n\n\nFeel free to report bugs or tell us your suggestions!\n\n## Overview\n\nGraphSAINT is a general and flexible framework for training GNNs on large graphs. GraphSAINT highlights a novel minibatch method specifically optimized for data with complex relationships (i.e., graphs). The traditional way of training a GNN is: 1). Construct a GNN on the full training graph; 2). For each minibatch, pick some nodes at the output layer as the root node. Backtrack the inter-layer connections from the root node until reaching the input layer; 3). Forward and backward propagation based on the loss on the roots. The way GraphSAINT trains a GNN is: 1). For each minibatch, sample a small subgraph from the full training graph; 2). Construct a **complete** GNN on the small subgraph. No sampling is performed within GNN layers; 3). Forward and backward propagation based on the loss on the subgraph nodes.\n\n![GraphSAINT training algorithm](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FGraphSAINT_GraphSAINT_readme_911f7febda38.png)\n\nGraphSAINT performs \"*graph sampling*\" based training, whereas others perform \"*layer sampling*\" based training. Why does it matter to change the perspective of sampling? GraphSAINT achieves the following:\n\n**Accuracy**: We perform simple yet effective normalization to eliminate the bias introduced by graph sampling. In addition, since any sampling process incurs information loss due to dropped neighbors, we propose light-weight graph samplers to preserve important neighbors based on topological characteristics. In fact, graph sampling can also be understood as data augmentation or training regularization (e.g., we may see the edge sampling as a minibatch version of [DropEdge](https:\u002F\u002Farxiv.org\u002Fabs\u002F1907.10903)).\n\n**Efficiency**: While \"neighbor explosion\" is a headache for many layer sampling based methods, GraphSAINT provides a clean solution to it thanks to the graph sampling philosophy. As each GNN layer is complete and unsampled, the number of neighbors keeps constant no matter how deep we go. Computation cost per minibatch reduces from exponential to linear, w.r.t. GNN depth.\n\n**Flexibility**: Layer propagation on a minibatch subgraph of GraphSAINT is almost identical to that on the full graph. Therefore, most GNN architectures designed for the full graph can be seamlessly trained by GraphSAINT. On the other hand, some layer sampling algorithms only support limited number of GNN architectures. Take JK-net as an example: the jumping knowledge connection requires node samples in shallower layers as a superset of node samplers in the deeper layers --- minibatches of FastGCN and AS-GCN do not satisfy such condition.\n\n**Scalability**: GraphSAINT achieves scalability w.r.t. 1). *graph size*: our subgraph size does not need to grow proportionally with the training graphs size. So even if we are dealing with a million-node graph, the subgraphs can still easily fit in the GPU memory; 2). *model size*: by resolving \"neighbor explosion\", training cost scales linearly with GNN width and depth; and 3). *amount of parallel resources*: graph sampling is highly scalable by trivial task parallelism. In addition, resolving \"neighbor explosion\" also implies dramatic reduction in communication overhead, which is critical in distributed setting (see our IEEE\u002FIPDPS '19 or [hardware accelerator development](https:\u002F\u002Fdl.acm.org\u002Fdoi\u002Fabs\u002F10.1145\u002F3373087.3375312)).\n\n\n#### [News]: Check out our new work that generalizes subgraph sampling to both the training and inference: [shaDow-GNN](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002FshaDow_GNN) (NeurIPS'21)!\n\n## About This Repo\n\nThis repo contains source code of our two papers (ICLR '20 and IEEE\u002FIPDPS '19, see the [Citation](#Citation-&-Acknowledgement) Section).\n\nThe `.\u002Fgraphsaint` directory contains the Python implementation of the minibatch training algorithm in ICLR '20. We provide two implementations, one in Tensorflow and the other in PyTorch. The two versions follow the same algorithm. Note that all experiments in our paper are based on the Tensorflow implementation. New experiments on open graph benchmark are based on the PyTorch version. \n\n\nThe `.\u002Fipdps19_cpp` directory contains the C++ implementation of the parallel training techniques described in IEEE\u002FIPDPS '19 (see `.\u002Fipdps19_cpp\u002FREADME.md`). All the rest of this repository are for GraphSAINT in ICLR '20.\n\nThe GNN architectures supported by this repo:\n\n|  GNN arch  |  Tensorflow  |  PyTorch  |  C++  |\n| -------------: |:-------------:|:-----:|:----:|\n|GraphSAGE| :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |\n|GAT| :heavy_check_mark: | :heavy_check_mark: | |\n|JK-Net| :heavy_check_mark: | | |\n| GaAN | | :heavy_check_mark: | |\n|MixHop| :heavy_check_mark: | :heavy_check_mark: | |\n\nThe graph samplers supported by this repo:\n\n|  Sampler  |  Tensorflow  |  PyTorch  |  C++  |\n| -------------: |:-------------:|:-----:|:----:|\n|Node| :heavy_check_mark: | :heavy_check_mark: |  |\n|Edge| :heavy_check_mark: | :heavy_check_mark: | |\n|RW| :heavy_check_mark: | :heavy_check_mark: | |\n| MRW | :heavy_check_mark:| :heavy_check_mark: |:heavy_check_mark: | :heavy_check_mark:|\n|Full graph| :heavy_check_mark: | :heavy_check_mark: | |\n\nwhere\n* RW: Random walk sampler\n* MRW: Multi-dimensional random walk sampler\n* Full graph: always returns the full training graph. Meant to be a baseline. No real \"sampling\" is going on.\n\nYou can add your own samplers and GNN layers easily. See the [Customization](#Customization) section.\n\n## Results\n\n**New**: We are testing GraphSAINT on [Open Graph Benchmark](https:\u002F\u002Fogb.stanford.edu\u002F). Currently, we have results for the `ogbn-products` graph. Note that the `ogbn-products` accuracy on the leaderboard trained with other methods are mostly under the transductive setting. Our results are under inductive learning (which is harder).\n\nAll results in ICLR '20 can be reproduced by running the config in `.\u002Ftrain_config\u002F`. For example, `.\u002Ftrain_config\u002Ftable2\u002F*.yml` stores all the config for Table 2 of our paper. `.\u002Ftrain_config\u002Fexplore\u002F*,yml` stores all the config for deeper GNNs and various GNN architectures (GAT, JK, etc.). In addition, results related to OGB are trained by the config in `.\u002Ftrain_config\u002Fopen_graph_benchmark\u002F*.yml`.\n\n\nTest set F1-mic score summarized below.\n\n| Sampler | Depth|  GNN | PPI | PPI (large) | Flickr | Reddit | Yelp | Amazon | ogbn-products |\n|---:|:----:|:---:|:----:|:---:|:----:|:----:|:----:|:----:|:----:|\n| Node | 2 | SAGE | 0.960 |  | 0.507 | 0.962 | 0.641 | 0.782 | |\n| Edge | 2 | SAGE | 0.981 | | 0.510 | 0.966 | 0.653 | 0.807 | |\n| RW | 2 | SAGE | 0.981 | 0.941 | 0.511 | 0.966 | 0.653 | 0.815 | |\n| MRW | 2 | SAGE | 0.980 |  | 0.510 | 0.964 | 0.652 | 0.809 | |\n| RW | 5 | SAGE | | 0.995 | | | | | |\n| Edge | 4 | JK | | | | 0.970 | | | |\n| RW | 2 | GAT | | | 0.510 | 0.967 | 0.652 | 0.815 | |\n| RW | 2 | GaAN | | | 0.508 | 0.968 | 0.651 | | |\n| RW | 2 | MixHop | | | | 0.967 | | | |\n| Edge | 3 | GAT | | | |  | | | 0.8027\n\n\n\n\n\n\n## Dependencies\n\n\n* python >= 3.6.8\n* tensorflow >=1.12.0  \u002F pytorch >= 1.1.0\n* cython >=0.29.2\n* numpy >= 1.14.3\n* scipy >= 1.1.0\n* scikit-learn >= 0.19.1\n* pyyaml >= 3.12\n* g++ >= 5.4.0\n* openmp >= 4.0\n\n\n## Datasets\n\n\nAll datasets used in our papers are available for download:\n\n\n* PPI\n* PPI-large (a larger version of PPI)\n* Reddit\n* Flickr\n* Yelp\n* Amazon\n* ogbn-products\n* ... (more to be added)\n\nThey are available on [Google Drive link](https:\u002F\u002Fdrive.google.com\u002Fopen?id=1zycmmDES39zVlbVCYs88JTJ1Wm5FbfLz) (alternatively, [BaiduYun link (code: f1ao)](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1SOb0SiSAXavwAcNqkttwcg)). Rename the folder to `data` at the root directory.  The directory structure should be as below:\n\n\n```\nGraphSAINT\u002F\n│   README.md\n│   run_graphsaint.sh\n│   ...\n│\n└───graphsaint\u002F\n│   │   globals.py\n│   │   cython_sampler.pyx\n│   │   ...\n│   │\n│   └───tensorflow_version\u002F\n│   │   │    train.py\n│   │   │    model.py\n│   │   │    ...\n│   │\n│   └───pytorch_version\u002F\n│       │    train.py\n│       │    model.py\n│       │    ...\n│\n└───data\u002F\n│   └───ppi\u002F\n│   │   │    adj_train.npz\n│   │   │    adj_full.npz\n│   │   │    ...\n│   │\n│   └───reddit\u002F\n│   │   │    ...\n│   │\n│   └───...\n│\n```\n\n\nWe also have a script that converts datasets from our format to GraphSAGE format. To run the script,\n\n\n`python convert.py \u003Cdataset name>`\n\n\nFor example `python convert.py ppi` will convert dataset PPI and save new data in GraphSAGE format to `.\u002Fdata.ignore\u002Fppi\u002F`\n\n\n**New**: For data conversion from the OGB format to the GraphSAINT format, please use the script `.\u002Fdata\u002Fopen_graph_benchmark\u002Fogbn_converter.py`. Currently, this script can handle `ogbn-products` and `ogbn-arxiv`.\n\n\n\n## Cython Implemented Parallel Graph Sampler\n\n\nWe have a cython module which need compilation before training can start. Compile the module by running the following from the root directory:\n\n\n`python graphsaint\u002Fsetup.py build_ext --inplace`\n\n\n## Training Configuration\n\n\nThe hyperparameters needed in training can be set via the configuration file: `.\u002Ftrain_config\u002F\u003Cname>.yml`.\n\n\nThe configuration files to reproduce the Table 2 results are packed in `.\u002Ftrain_config\u002Ftable2\u002F`.\n\n\nFor detailed description of the configuration file format, please see `.\u002Ftrain_config\u002FREADME.md`\n\n\n## Run Training\n\n\nFirst of all, please compile cython samplers (see above).\n\n\nWe suggest looking through the available command line arguments defined in `.\u002Fgraphsaint\u002Fglobals.py` (shared by both the Tensorflow and PyTorch versions). By properly setting the flags, you can maximize CPU utilization in the sampling step (by telling the number of available cores), select the directory to place log files, and turn on \u002F off loggers (Tensorboard, Timeline, ...), etc.\n\n\n*NOTE*: For all methods compared in the paper (GraphSAINT, GCN, GraphSAGE, FastGCN, S-GCN, AS-GCN, ClusterGCN), sampling or clustering is **only** performed during training.\nTo obtain the validation \u002F test set accuracy, we run the full batch GNN on the full graph (training + validation + test nodes), and calculate F1 score only for the validation \u002F test nodes. See also issue #11.\n\n\n\n\nFor simplicity of implementation, during validation \u002F test set evaluation, we perform layer propagation using the full graph adjacency matrix. For Amazon or Yelp, this may cause memory issue for some GPUs. If an out-of-memory error occurs, please use the `--cpu_eval` flag to force the val \u002F test set evaluation to take place on CPU (the minibatch training will still be performed on GPU). See below for other Flags.\n\n\nTo run the code on CPU\n\n\n```\npython -m graphsaint.\u003Ctensorflow\u002Fpytorch>_version.train --data_prefix .\u002Fdata\u002F\u003Cdataset_name> --train_config \u003Cpath to train_config yml> --gpu -1\n```\n\n\nTo run the code on GPU\n\n\n```\npython -m graphsaint.\u003Ctensorflow\u002Fpytorch>_version.train --data_prefix .\u002Fdata\u002F\u003Cdataset_name> --train_config \u003Cpath to train_config yml> --gpu \u003CGPU number>\n```\n\n\nFor example `--gpu 0` will run on the first GPU. Also, use `--gpu \u003CGPU number> --cpu_eval` to make GPU perform the minibatch training and CPU to perform the validation \u002F test evaluation.\n\n\nWe have also implemented dual-GPU training to further speedup runtime. Simply add the flag `--dualGPU` and assign two GPUs using the `--gpu` flag. Currently this only works for GPUs supporting memory pooling and connected by NvLink.\n\n**New**: we have prepared specific scripts to train OGB graphs. See `.\u002Fgraphsaint\u002Fopen_graph_benchmark\u002F` for the scripts and instructions.\n\n\n## Customization\n\nBelow we describe how to customize this code base for your own research \u002F product.\n\n### How to Prepare Your Own Dataset?\n\nSuppose your full graph contains N nodes. Each node has C classes, and length-F initial attribute vector. If your train\u002Fval\u002Ftest split is a\u002Fb\u002Fc (i.e., a+b+c=1), then:\n\n`adj_full.npz`: a sparse matrix in CSR format, stored as a `scipy.sparse.csr_matrix`. The shape is N by N. Non-zeros in the matrix correspond to all the edges in the full graph. It doesn't matter if the two nodes connected by an edge are training, validation or test nodes. For unweighted graph, the non-zeros are all 1.\n\n`adj_train.npz`: a sparse matrix in CSR format, stored as a `scipy.sparse.csr_matrix`. The shape is also N by N. However, non-zeros in the matrix only correspond to edges connecting two training nodes. The graph sampler only picks nodes\u002Fedges from this `adj_train`, not `adj_full`. Therefore, neither the attribute information nor the structural information are revealed during training. Also, note that only aN rows and cols of `adj_train` contains non-zeros. See also issue #11. For unweighted graph, the non-zeros are all 1.\n\n`role.json`: a dictionary of three keys. Key `'tr'` corresponds to the list of all training node indices. Key `va` corresponds to the list of all validation node indices. Key `te` corresponds to the list of all test node indices. Note that in the raw data, nodes may have string-type ID. You would need to re-assign numerical ID (0 to N-1) to the nodes, so that you can index into the matrices of adj, features and class labels.\n\n`class_map.json`: a dictionary of length N. Each key is a node index, and each value is either a length C binary list (for multi-class classification) or an integer scalar (0 to C-1, for single-class classification).\n\n`feats.npy`: a `numpy` array of shape N by F. Row i corresponds to the attribute vector of node i.\n\n\n### How to Add Your Own Sampler?\n\nAll samplers are implemented as subclass of `GraphSampler` in `.\u002Fgraphsaint\u002Fgraph_samplers.py`. There are two ways to implement your sampler subclass:\n\n1) Implement in pure python. Overwrite the `par_sample` function of the super-class. We provide a basic example in the `NodeSamplingVanillaPython` class of `.\u002Fgraphsaint\u002Fgraph_samplers.py`.\n\t* Pros: Easy to implement\n\t* Cons: May have slow execution speed. It is non-trivial to parallelize a pure python function.\n2) Implement in cython. You need to add a subclass of the `Sampler` in `.\u002Fgraphsaint\u002Fcython_sampler.pyx`. In the subclass, you only need to overwrite the `__cinit__` and `sample` functions. The `sample` function defines the sequential behavior of the sampler. We automatically perform task-level parallelism by launching multiple samplers at the same time.\n\t* Pros: Fits in the parallel-execution framework. C++ level execution speed.\n\t* Cons: Hard to code\n\n### How to Support Your Own GNN Layer?\n\nAdd a layer in `.\u002Fgraphsaint\u002F\u003Ctensorflow or pytorch>_version\u002Flayers.py`. You would also need to do some minor update to `__init__` function of the `GraphSAINT` class in `.\u002Fgraphsaint\u002F\u003Ctensorflow or pytorch>_version\u002Fmodels.py`, so that the model knows how to lookup the correct class based on the keyword in the `yml` config.\n\n## Citation & Acknowledgement\n\nSupported by DARPA under FA8750-17-C-0086, NSF under CCF-1919289 and OAC-1911229.\n\nWe thank Matthias Fey for providing a [reference implementation](https:\u002F\u002Fpytorch-geometric.readthedocs.io\u002Fen\u002Flatest\u002Fmodules\u002Fdata.html#torch_geometric.data.GraphSAINTSampler) in the PyTorch Geometric library.\n\nWe thank the [OGB team](https:\u002F\u002Fogb.stanford.edu\u002F) for using GraphSAINT on large scale experiments.\n\n* ICLR 2020:\n\n```\n@inproceedings{graphsaint-iclr20,\ntitle={{GraphSAINT}: Graph Sampling Based Inductive Learning Method},\nauthor={Hanqing Zeng and Hongkuan Zhou and Ajitesh Srivastava and Rajgopal Kannan and Viktor Prasanna},\nbooktitle={International Conference on Learning Representations},\nyear={2020},\nurl={https:\u002F\u002Fopenreview.net\u002Fforum?id=BJe8pkHFwS}\n}\n```\n\n\n* IEEE\u002FIPDPS 2019:\n\n\n```\n@INPROCEEDINGS{graphsaint-ipdps19,\nauthor={Hanqing Zeng and Hongkuan Zhou and Ajitesh Srivastava and Rajgopal Kannan and Viktor Prasanna},\nbooktitle={2019 IEEE International Parallel and Distributed Processing Symposium (IPDPS)},\ntitle={Accurate, Efficient and Scalable Graph Embedding},\nyear={2019},\nmonth={May},\n}\n","# GraphSAINT：基于图采样的归纳学习方法\n\n\n[Hanqing Zeng](https:\u002F\u002Fsites.google.com\u002Fa\u002Fusc.edu\u002Fzengh\u002Fhome)\\*, [Hongkuan Zhou](https:\u002F\u002Ftedzhouhk.github.io\u002Fabout\u002F)\\*, [Ajitesh Srivastava](http:\u002F\u002Fwww-scf.usc.edu\u002F~ajiteshs\u002F), Rajgopal Kannan, [Viktor Prasanna](https:\u002F\u002Fsites.usc.edu\u002Fprasanna\u002F)\n\n**联系方式**\n\n\nHanqing Zeng (zengh@usc.edu), Hongkuan Zhou (hongkuaz@usc.edu)\n\n\n欢迎随时报告问题或提出建议！\n\n## 概述\n\nGraphSAINT 是一个通用且灵活的框架，用于在大规模图上训练 GNN。GraphSAINT 提出了一种新颖的 mini-batch 方法，专门针对具有复杂关系的数据（即图）进行了优化。传统的 GNN 训练方式是：1) 在完整的训练图上构建 GNN；2) 对于每个 mini-batch，选择输出层中的一些节点作为根节点，然后从根节点反向追踪层间连接，直到到达输入层；3) 基于根节点上的损失进行前向和反向传播。而 GraphSAINT 的训练方式是：1) 对于每个 mini-batch，从完整的训练图中采样一个小子图；2) 在这个小子图上构建一个**完整**的 GNN，GNN 层内不再进行采样；3) 基于子图节点上的损失进行前向和反向传播。\n\n![GraphSAINT 训练算法](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FGraphSAINT_GraphSAINT_readme_911f7febda38.png)\n\nGraphSAINT 采用的是“图采样”式的训练，而其他方法则是“层采样”式的训练。为什么改变采样的视角如此重要呢？GraphSAINT 能够实现以下几点：\n\n**准确性**：我们通过简单而有效的归一化操作，消除了图采样带来的偏差。此外，由于任何采样过程都会因为丢弃邻居而导致信息丢失，我们提出了轻量级的图采样器，能够根据拓扑特征保留重要的邻居。实际上，图采样也可以被理解为一种数据增强或训练正则化手段（例如，边采样可以看作是 [DropEdge](https:\u002F\u002Farxiv.org\u002Fabs\u002F1907.10903) 的 mini-batch 版本）。\n\n**效率**：对于许多基于层采样的方法来说，“邻居爆炸”是一个令人头疼的问题，而 GraphSAINT 则凭借其图采样的理念提供了一个干净的解决方案。由于每个 GNN 层都是完整的且未经过采样，无论网络深度如何，邻居的数量始终保持不变。因此，每批次的计算成本会随着 GNN 深度的增加从指数级降低到线性级。\n\n**灵活性**：GraphSAINT 中 mini-batch 子图上的层传播与在完整图上的传播几乎完全相同。因此，大多数为完整图设计的 GNN 架构都可以无缝地使用 GraphSAINT 进行训练。相比之下，一些层采样算法仅支持有限数量的 GNN 架构。以 JK-Net 为例，跳跃式知识连接要求浅层的节点样本必须是深层节点样本的超集——而 FastGCN 和 AS-GCN 的 mini-batch 格式并不满足这一条件。\n\n**可扩展性**：GraphSAINT 在以下三个方面实现了可扩展性：1) *图规模*：我们的子图大小无需随训练图规模成比例增长。因此，即使面对百万节点的图，子图仍然可以轻松容纳在 GPU 内存中；2) *模型规模*：通过解决“邻居爆炸”问题，训练成本与 GNN 的宽度和深度呈线性关系；3) *并行资源数量*：图采样可以通过简单的任务并行化实现高度可扩展。此外，解决“邻居爆炸”问题还意味着通信开销的大幅减少，这在分布式环境中尤为重要（参见我们发表在 IEEE\u002FIPDPS '19 上的文章，或 [硬件加速器开发](https:\u002F\u002Fdl.acm.org\u002Fdoi\u002Fabs\u002F10.1145\u002F3373087.3375312) 相关工作）。\n\n\n#### 【新闻】：请查看我们最新的工作，它将子图采样推广到了训练和推理两个阶段：[shaDow-GNN](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002FshaDow_GNN)（NeurIPS'21）！\n\n## 关于本仓库\n\n本仓库包含了我们两篇论文的源代码（ICLR '20 和 IEEE\u002FIPDPS '19，详见【引用与致谢】部分）。\n\n`.\u002Fgraphsaint` 目录包含 ICLR '20 论文中提出的 mini-batch 训练算法的 Python 实现。我们提供了两种实现版本，分别基于 Tensorflow 和 PyTorch。这两个版本遵循相同的算法。需要注意的是，我们论文中的所有实验均基于 Tensorflow 版本。而在公开图基准上的新实验则采用了 PyTorch 版本。\n\n\n`.\u002Fipdps19_cpp` 目录包含了 IEEE\u002FIPDPS '19 论文中描述的并行训练技术的 C++ 实现（详见 `.\u002Fipdps19_cpp\u002FREADME.md`）。本仓库的其余部分则专注于 ICLR '20 中的 GraphSAINT。\n\n本仓库支持的 GNN 架构如下：\n\n|  GNN 架构  |  Tensorflow  |  PyTorch  |  C++  |\n| -------------: |:-------------:|:-----:|:----:|\n|GraphSAGE| :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |\n|GAT| :heavy_check_mark: | :heavy_check_mark: | |\n|JK-Net| :heavy_check_mark: | | |\n| GaAN | | :heavy_check_mark: | |\n|MixHop| :heavy_check_mark: | :heavy_check_mark: | |\n\n本仓库支持的图采样器如下：\n\n|  采样器  |  Tensorflow  |  PyTorch  |  C++  |\n| -------------: |:-------------:|:-----:|:----:|\n|节点| :heavy_check_mark: | :heavy_check_mark: |  |\n|边| :heavy_check_mark: | :heavy_check_mark: | |\n|RW| :heavy_check_mark: | :heavy_check_mark: | |\n| MRW | :heavy_check_mark:| :heavy_check_mark: |:heavy_check_mark: | :heavy_check_mark:|\n|全图| :heavy_check_mark: | :heavy_check_mark: | |\n\n其中：\n* RW：随机游走采样器\n* MRW：多维随机游走采样器\n* 全图：始终返回完整的训练图，用作基线，实际上并未进行真正的采样。\n\n您可以轻松添加自己的采样器和 GNN 层。详情请参阅【自定义】部分。\n\n## 结果\n\n**新增**：我们正在 [Open Graph Benchmark](https:\u002F\u002Fogb.stanford.edu\u002F) 上测试 GraphSAINT。目前，我们已有 `ogbn-products` 图的数据结果。需要注意的是，排行榜上使用其他方法训练的 `ogbn-products` 准确率大多是在直推式设置下得出的。而我们的结果是在归纳式学习设置下得到的（归纳式学习难度更高）。\n\nICLR '20 中的所有结果都可以通过运行 `.\u002Ftrain_config\u002F` 中的配置文件来复现。例如，`.\u002Ftrain_config\u002Ftable2\u002F*.yml` 存储了我们论文中表 2 的所有配置文件。`.\u002Ftrain_config\u002Fexplore\u002F*,yml` 则存储了用于更深 GNN 和各种 GNN 架构（GAT、JK 等）的配置文件。此外，与 OGB 相关的结果是通过 `.\u002Ftrain_config\u002Fopen_graph_benchmark\u002F*.yml` 中的配置文件训练得到的。\n\n\n测试集 F1-mic 分数汇总如下。\n\n| 采样器 | 深度 | GNN | PPI | PPI (large) | Flickr | Reddit | Yelp | Amazon | ogbn-products |\n|---:|:----:|:---:|:----:|:---:|:----:|:----:|:----:|:----:|:----:|\n| Node | 2 | SAGE | 0.960 |  | 0.507 | 0.962 | 0.641 | 0.782 | |\n| Edge | 2 | SAGE | 0.981 | | 0.510 | 0.966 | 0.653 | 0.807 | |\n| RW | 2 | SAGE | 0.981 | 0.941 | 0.511 | 0.966 | 0.653 | 0.815 | |\n| MRW | 2 | SAGE | 0.980 |  | 0.510 | 0.964 | 0.652 | 0.809 | |\n| RW | 5 | SAGE | | 0.995 | | | | | |\n| Edge | 4 | JK | | | | 0.970 | | | |\n| RW | 2 | GAT | | | 0.510 | 0.967 | 0.652 | 0.815 | |\n| RW | 2 | GaAN | | | 0.508 | 0.968 | 0.651 | | |\n| RW | 2 | MixHop | | | | 0.967 | | | |\n| Edge | 3 | GAT | | | |  | | | 0.8027\n\n\n\n\n\n\n## 依赖项\n\n\n* python >= 3.6.8\n* tensorflow >=1.12.0  \u002F pytorch >= 1.1.0\n* cython >=0.29.2\n* numpy >= 1.14.3\n* scipy >= 1.1.0\n* scikit-learn >= 0.19.1\n* pyyaml >= 3.12\n* g++ >= 5.4.0\n* openmp >= 4.0\n\n\n## 数据集\n\n\n我们论文中使用的所有数据集均可下载：\n\n\n* PPI\n* PPI-large（PPI 的更大版本）\n* Reddit\n* Flickr\n* Yelp\n* Amazon\n* ogbn-products\n* ...（更多即将添加）\n\n这些数据集可通过 [Google Drive 链接](https:\u002F\u002Fdrive.google.com\u002Fopen?id=1zycmmDES39zVlbVCYs88JTJ1Wm5FbfLz) 下载（或者通过 [百度网盘链接（提取码：f1ao）](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1SOb0SiSAXavwAcNqkttwcg)）。请将下载的文件夹重命名为根目录下的 `data` 文件夹。目录结构应如下所示：\n\n\n```\nGraphSAINT\u002F\n│   README.md\n│   run_graphsaint.sh\n│   ...\n│\n└───graphsaint\u002F\n│   │   globals.py\n│   │   cython_sampler.pyx\n│   │   ...\n│   │\n│   └───tensorflow_version\u002F\n│   │   │    train.py\n│   │   │    model.py\n│   │   │    ...\n│   │\n│   └───pytorch_version\u002F\n│       │    train.py\n│       │    model.py\n│       │    ...\n│\n└───data\u002F\n│   └───ppi\u002F\n│   │   │    adj_train.npz\n│   │   │    adj_full.npz\n│   │   │    ...\n│   │\n│   └───reddit\u002F\n│   │   │    ...\n│   │\n│   └───...\n│\n```\n\n\n我们还提供了一个脚本，可以将我们的数据格式转换为 GraphSAGE 格式。要运行该脚本，\n\n\n`python convert.py \u003C数据集名称>`\n\n\n例如，`python convert.py ppi` 会将 PPI 数据集转换为 GraphSAGE 格式，并保存到 `.\u002Fdata.ignore\u002Fppi\u002F`。\n\n\n**新增**：对于从 OGB 格式到 GraphSAINT 格式的转换，请使用 `.\u002Fdata\u002Fopen_graph_benchmark\u002Fogbn_converter.py` 脚本。目前，该脚本可以处理 `ogbn-products` 和 `ogbn-arxiv`。\n\n\n## Cython 实现的并行图采样器\n\n\n我们有一个需要编译的 Cython 模块，才能开始训练。请在根目录下运行以下命令来编译该模块：\n\n\n`python graphsaint\u002Fsetup.py build_ext --inplace`\n\n\n## 训练配置\n\n\n训练所需的超参数可以通过配置文件设置：`.\u002Ftrain_config\u002F\u003Cname>.yml`。\n\n\n用于复现表 2 结果的配置文件已打包在 `.\u002Ftrain_config\u002Ftable2\u002F` 中。\n\n\n有关配置文件格式的详细说明，请参阅 `.\u002Ftrain_config\u002FREADME.md`。\n\n\n## 运行训练\n\n\n首先，请编译 Cython 采样器（见上文）。\n\n我们建议查看 `.\u002Fgraphsaint\u002Fglobals.py` 中定义的可用命令行参数（TensorFlow 和 PyTorch 版本共用）。通过正确设置这些标志，您可以最大化采样步骤中的 CPU 利用率（通过指定可用核心数量），选择日志文件的存放目录，并开启或关闭日志记录器（Tensorboard、Timeline 等）等。\n\n*注意*：对于论文中比较的所有方法（GraphSAINT、GCN、GraphSAGE、FastGCN、S-GCN、AS-GCN、ClusterGCN），采样或聚类**仅**在训练过程中进行。为了获得验证集\u002F测试集的准确率，我们会对整个图（包括训练、验证和测试节点）运行全批量 GNN，并仅针对验证\u002F测试节点计算 F1 分数。详情请参阅 issue #11。\n\n\n\n\n为简化实现，在验证\u002F测试集评估时，我们使用完整的图邻接矩阵进行层传播。对于 Amazon 或 Yelp 数据集，这可能会导致某些 GPU 内存不足的问题。如果出现内存不足错误，请使用 `--cpu_eval` 标志强制在 CPU 上进行验证\u002F测试集评估（而小批量训练仍将在 GPU 上进行）。其他标志说明如下。\n\n要在 CPU 上运行代码\n\n\n```\npython -m graphsaint.\u003Ctensorflow\u002Fpytorch>_version.train --data_prefix .\u002Fdata\u002F\u003C数据集名称> --train_config \u003Ctrain_config yml 路径> --gpu -1\n```\n\n\n要在 GPU 上运行代码\n\n\n```\npython -m graphsaint.\u003Ctensorflow\u002Fpytorch>_version.train --data_prefix .\u002Fdata\u002F\u003C数据集名称> --train_config \u003Ctrain_config yml 路径> --gpu \u003CGPU 编号>\n```\n\n\n例如，`--gpu 0` 表示在第一块 GPU 上运行。此外，还可以使用 `--gpu \u003CGPU 编号> --cpu_eval` 来让 GPU 执行小批量训练，而 CPU 执行验证\u002F测试评估。\n\n我们还实现了双 GPU 训练以进一步加快运行速度。只需添加 `--dualGPU` 标志，并使用 `--gpu` 标志指定两块 GPU 即可。目前，此功能仅适用于支持显存池化且通过 NvLink 连接的 GPU。\n\n**新增**：我们已准备了专门用于训练 OGB 图的脚本。相关脚本和说明请参阅 `.\u002Fgraphsaint\u002Fopen_graph_benchmark\u002F`。\n\n\n## 自定义\n\n以下我们将介绍如何根据您的研究或产品需求自定义此代码库。\n\n### 如何准备您自己的数据集？\n\n假设您的完整图包含 N 个节点。每个节点有 C 个类别，以及长度为 F 的初始属性向量。如果您的训练\u002F验证\u002F测试划分比例为 a\u002Fb\u002Fc（即 a+b+c=1），则：\n\n`adj_full.npz`：一个以 CSR 格式存储的稀疏矩阵，类型为 `scipy.sparse.csr_matrix`。其形状为 N×N。矩阵中的非零元素对应于完整图中的所有边。连接两节点的边是属于训练、验证还是测试节点并不重要。对于无权图，非零元素均为 1。\n\n`adj_train.npz`：一个以 CSR 格式存储的稀疏矩阵，类型为 `scipy.sparse.csr_matrix`。其形状同样为 N×N。然而，矩阵中的非零元素仅对应于连接两个训练节点的边。图采样器只会从这个 `adj_train` 中选取节点和边，而不会从 `adj_full` 中选取。因此，在训练过程中既不会泄露属性信息，也不会泄露结构信息。另外请注意，只有 `adj_train` 中 aN 行和 aN 列包含非零元素。参见问题 #11。对于无权图，非零元素均为 1。\n\n`role.json`：一个包含三个键的字典。键 `'tr'` 对应所有训练节点的索引列表，键 `'va'` 对应所有验证节点的索引列表，键 `'te'` 对应所有测试节点的索引列表。请注意，在原始数据中，节点可能具有字符串类型的 ID。您需要为节点重新分配数值 ID（0 至 N-1），以便能够通过索引访问邻接矩阵、特征矩阵和类别标签。\n\n`class_map.json`：一个长度为 N 的字典。每个键是节点的索引，每个值要么是一个长度为 C 的二进制列表（用于多分类问题），要么是一个整数标量（0 至 C-1，用于单分类问题）。\n\n`feats.npy`：一个形状为 N×F 的 `numpy` 数组。第 i 行对应节点 i 的属性向量。\n\n\n### 如何添加您自己的采样器？\n\n所有采样器都作为 `GraphSampler` 类的子类实现于 `.\u002Fgraphsaint\u002Fgraph_samplers.py` 文件中。您可以采用两种方式来实现自己的采样器子类：\n\n1) 使用纯 Python 实现。重写父类的 `par_sample` 函数。我们在 `.\u002Fgraphsaint\u002Fgraph_samplers.py` 文件中的 `NodeSamplingVanillaPython` 类中提供了一个基本示例。\n\t* 优点：易于实现\n\t* 缺点：执行速度可能较慢。将纯 Python 函数并行化并非易事。\n2) 使用 Cython 实现。您需要在 `.\u002Fgraphsaint\u002Fcython_sampler.pyx` 文件中添加一个 `Sampler` 类的子类。在该子类中，您只需重写 `__cinit__` 和 `sample` 函数。`sample` 函数定义了采样器的顺序行为。我们会自动通过同时启动多个采样器来实现任务级并行化。\n\t* 优点：可融入并行执行框架，执行速度接近 C++ 级别。\n\t* 缺点：编码难度较大。\n\n### 如何支持您自己的 GNN 层？\n\n在 `.\u002Fgraphsaint\u002F\u003Ctensorflow 或 pytorch>_version\u002Flayers.py` 文件中添加一层。此外，您还需要对 `.\u002Fgraphsaint\u002F\u003Ctensorflow 或 pytorch>_version\u002Fmodels.py` 文件中的 `GraphSAINT` 类的 `__init__` 方法进行一些小的更新，以便模型能够根据 YAML 配置文件中的关键字查找正确的类。\n\n## 引用与致谢\n\n本研究得到 DARPA FA8750-17-C-0086 项目、NSF CCF-1919289 和 OAC-1911229 项目的资助。\n\n我们感谢 Matthias Fey 在 PyTorch Geometric 库中提供的[参考实现](https:\u002F\u002Fpytorch-geometric.readthedocs.io\u002Fen\u002Flatest\u002Fmodules\u002Fdata.html#torch_geometric.data.GraphSAINTSampler)。\n\n我们感谢 [OGB 团队](https:\u002F\u002Fogb.stanford.edu\u002F)在大规模实验中使用 GraphSAINT。\n\n* ICLR 2020：\n\n```\n@inproceedings{graphsaint-iclr20,\ntitle={{GraphSAINT}: 基于图采样的归纳学习方法},\nauthor={Hanqing Zeng 和 Hongkuan Zhou 和 Ajitesh Srivastava 和 Rajgopal Kannan 和 Viktor Prasanna},\nbooktitle={国际表征学习会议},\nyear={2020},\nurl={https:\u002F\u002Fopenreview.net\u002Fforum?id=BJe8pkHFwS}\n}\n```\n\n\n* IEEE\u002FIPDPS 2019：\n\n\n```\n@INPROCEEDINGS{graphsaint-ipdps19,\nauthor={Hanqing Zeng 和 Hongkuan Zhou 和 Ajitesh Srivastava 和 Rajgopal Kannan 和 Viktor Prasanna},\nbooktitle={2019 年 IEEE 国际并行与分布式处理研讨会 (IPDPS)},\ntitle={准确、高效且可扩展的图嵌入},\nyear={2019},\nmonth={五月},\n}","# GraphSAINT 快速上手指南\n\nGraphSAINT 是一个基于**图采样**（Graph Sampling）的通用框架，专为在大规模图上训练图神经网络（GNN）而设计。与传统基于“层采样”的方法不同，GraphSAINT 通过对每个 mini-batch 采样一个完整的子图来构建 GNN，有效解决了深层网络中的“邻居爆炸”问题，显著提升了训练效率、可扩展性和模型灵活性。\n\n## 环境准备\n\n### 系统要求\n*   **操作系统**: Linux (推荐), macOS, Windows (需配置相应编译环境)\n*   **Python**: >= 3.6.8\n*   **编译器**: g++ >= 5.4.0 (需支持 OpenMP >= 4.0)\n\n### 前置依赖\n请确保已安装以下核心库（建议使用虚拟环境）：\n*   **深度学习框架**: TensorFlow >= 1.12.0 **或** PyTorch >= 1.1.0\n*   **科学计算**: NumPy >= 1.14.3, SciPy >= 1.1.0, Scikit-learn >= 0.19.1\n*   **其他工具**: Cython >= 0.29.2, PyYAML >= 3.12\n\n> **提示**: 国内用户可使用清华或阿里镜像源加速安装，例如：\n> `pip install -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple \u003Cpackage_name>`\n\n## 安装步骤\n\n### 1. 克隆代码库\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FGraphSAINT\u002FGraphSAINT.git\ncd GraphSAINT\n```\n\n### 2. 安装 Python 依赖\n```bash\npip install -r requirements.txt\n# 如果项目中没有 requirements.txt，请手动安装上述列出的依赖包\n```\n\n### 3. 编译 Cython 并行采样器\nGraphSAINT 使用 Cython 加速图采样过程，使用前必须编译该模块。在项目根目录执行：\n```bash\npython graphsaint\u002Fsetup.py build_ext --inplace\n```\n\n### 4. 准备数据集\n下载论文中使用的数据集（PPI, Reddit, Flickr, Yelp, Amazon, ogbn-products 等）。\n*   **下载地址**: [Google Drive](https:\u002F\u002Fdrive.google.com\u002Fopen?id=1zycmmDES39zVlbVCYs88JTJ1Wm5FbfLz) 或 [百度网盘 (提取码: f1ao)](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1SOb0SiSAXavwAcNqkttwcg)\n*   **目录结构**: 下载后解压，将文件夹重命名为 `data` 并放置于项目根目录下。最终结构应如下：\n    ```text\n    GraphSAINT\u002F\n    ├── data\u002F\n    │   ├── ppi\u002F\n    │   ├── reddit\u002F\n    │   └── ...\n    ├── graphsaint\u002F\n    └── ...\n    ```\n\n> **OGB 数据集转换**: 若使用 Open Graph Benchmark (OGB) 格式的数据，请使用脚本转换：\n> `python .\u002Fdata\u002Fopen_graph_benchmark\u002Fogbn_converter.py`\n\n## 基本使用\n\nGraphSAINT 通过 YAML 配置文件管理超参数。配置文件位于 `.\u002Ftrain_config\u002F` 目录下。\n\n### 1. 选择配置文件\n*   复现论文 Table 2 结果：使用 `.\u002Ftrain_config\u002Ftable2\u002F*.yml`\n*   探索深层网络或不同架构（如 GAT, JK-Net）：使用 `.\u002Ftrain_config\u002Fexplore\u002F*.yml`\n*   OGB 基准测试：使用 `.\u002Ftrain_config\u002Fopen_graph_benchmark\u002F*.yml`\n\n### 2. 运行训练\n\n#### 在 GPU 上运行\n指定数据集路径、配置文件路径及 GPU 编号：\n```bash\npython -m graphsaint.pytorch_version.train --data_prefix .\u002Fdata\u002Freddit --train_config .\u002Ftrain_config\u002Ftable2\u002Freddit_edge.yml --gpu 0\n```\n*(注：将 `pytorch_version` 替换为 `tensorflow_version` 可切换框架)*\n\n#### 在 CPU 上运行\n将 `--gpu` 参数设为 `-1`：\n```bash\npython -m graphsaint.pytorch_version.train --data_prefix .\u002Fdata\u002Freddit --train_config .\u002Ftrain_config\u002Ftable2\u002Freddit_edge.yml --gpu -1\n```\n\n#### 混合模式（GPU 训练 + CPU 评估）\n若在验证\u002F测试阶段遇到显存不足（OOM），可强制在 CPU 上进行评估：\n```bash\npython -m graphsaint.pytorch_version.train --data_prefix .\u002Fdata\u002Fyelp --train_config .\u002Ftrain_config\u002Ftable2\u002Fyelp_rw.yml --gpu 0 --cpu_eval\n```\n\n### 3. 自定义训练\n*   **修改超参数**: 直接编辑对应的 `.yml` 配置文件。\n*   **添加新采样器或模型**: 参考 `graphsaint` 目录下的现有实现，轻松扩展自定义的 GNN 层或图采样算法。","某大型电商平台的算法团队正试图构建一个深度图神经网络（GNN），以在包含数千万用户和商品交互关系的超大图上进行实时欺诈检测。\n\n### 没有 GraphSAINT 时\n- **显存爆炸导致训练中断**：随着 GNN 层数加深，传统“逐层采样”方法引发“邻居爆炸”效应，所需显存呈指数级增长，普通 GPU 根本无法加载模型。\n- **关键信息丢失影响精度**：为了强行适配显存限制，不得不大幅削减采样邻居数量，导致重要的欺诈关联路径被切断，模型误判率居高不下。\n- **架构兼容性差**：团队想尝试更先进的 JK-net 等复杂架构，但受限于原有采样逻辑对节点集合的严苛要求，无法顺利迁移和实验。\n- **分布式通信开销大**：在多卡并行训练时，由于每次反向传播涉及大量跨节点的稀疏数据交换，通信延迟成为主要瓶颈，训练效率极低。\n\n### 使用 GraphSAINT 后\n- **线性扩展解决显存难题**：GraphSAINT 采用“子图采样”策略，直接构建完整的小型子图进行训练，将计算成本从指数级降为线性，轻松在单张 GPU 上运行深层网络。\n- **偏差校正提升检测准确率**：通过特有的归一化机制消除采样偏差，并保留关键拓扑结构的邻居，使得模型在大幅压缩数据量的同时，欺诈识别精度反而显著提升。\n- **无缝支持多样模型架构**：由于子图上的传播逻辑与全图一致，团队可以零代码修改地直接套用 JK-net 等各种先进 GNN 变体，加速了算法迭代。\n- **高效并行降低通信负载**：子图独立性极强，不仅天然适合多卡任务并行，还大幅减少了分布式环境下的通信开销，使训练速度提升了数倍。\n\nGraphSAINT 通过革新性的子图采样范式，彻底解决了大规模图数据上深度学习的显存与效率瓶颈，让超大图上的高精度实时风控成为可能。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FGraphSAINT_GraphSAINT_45697573.png","Scalable GRL","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FGraphSAINT_42c6be7a.png","Goal: to improve the scalability of graph representation learning by algorithm and architecture innovations. ","University of Southern California","Los Angeles, USA",null,"https:\u002F\u002Fgithub.com\u002FGraphSAINT",[80,84,88,92,96],{"name":81,"color":82,"percentage":83},"Python","#3572A5",60.6,{"name":85,"color":86,"percentage":87},"C++","#f34b7d",26.7,{"name":89,"color":90,"percentage":91},"Cython","#fedf5b",11.7,{"name":93,"color":94,"percentage":95},"C","#555555",0.8,{"name":97,"color":98,"percentage":99},"Makefile","#427819",0.2,508,90,"2026-04-16T09:26:01","MIT",4,"未说明","训练可选 GPU（支持 --gpu 参数），验证\u002F测试若显存不足可强制使用 CPU（--cpu_eval）。双 GPU 加速需支持内存池化并通过 NvLink 连接。未指定具体型号、显存大小或 CUDA 版本。",{"notes":108,"python":109,"dependencies":110},"1. 使用前必须编译 Cython 模块：运行 'python graphsaint\u002Fsetup.py build_ext --inplace'。\n2. 数据集需手动下载并放置于根目录下的 'data' 文件夹中。\n3. 对于 Amazon 或 Yelp 等大图，若在验证\u002F测试阶段遇到显存溢出，请使用 '--cpu_eval' 标志将评估过程移至 CPU 执行。\n4. 提供 TensorFlow 和 PyTorch 两个版本的实现，论文实验主要基于 TensorFlow 版本。",">=3.6.8",[111,112,113,114,115,116,117,118],"tensorflow>=1.12.0 或 pytorch>=1.1.0","cython>=0.29.2","numpy>=1.14.3","scipy>=1.1.0","scikit-learn>=0.19.1","pyyaml>=3.12","g++>=5.4.0","openmp>=4.0",[14,120],"其他",[122,123,124,125,126,127,128],"gcn","graph-sampling","iclr","graphsage","jk-net","gat","ipdps","2026-03-27T02:49:30.150509","2026-04-20T16:46:06.539036",[132,137,142,146,151,156],{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},44950,"运行代码时出现 'DuplicateFlagError: The flag log_dir is defined twice' 错误怎么办？","这是由于 'log_dir' 标志被重复定义导致的（通常是因为 absl.logging 已定义了该标志）。维护者已推送修复，将标志名从 'log_dir' 重命名为其他名称以避免冲突。请拉取最新代码更新。如果问题仍然存在，可能需要保留之前的修改步骤并重新检查环境配置。","https:\u002F\u002Fgithub.com\u002FGraphSAINT\u002FGraphSAINT\u002Fissues\u002F2",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},44951,"GraphSAINT 在子图采样时如何处理连接采样节点与未采样节点的边（子图间边）？","在当前的子图训练过程中，如果节点 A 被采样而节点 B 未被采样，那么 A-B 这条边在当前子图中会被忽略。这样做是合理的，因为 mini-batch 训练的核心思想是基于采样的子图进行局部更新。虽然忽略了这些跨子图的边，但通过多次迭代和不同的采样策略（如随机游走或节点采样），模型最终仍能学习到全局结构信息。这种方法在保证计算效率的同时，通过无偏估计器确保了收敛性。","https:\u002F\u002Fgithub.com\u002FGraphSAINT\u002FGraphSAINT\u002Fissues\u002F21",{"id":143,"question_zh":144,"answer_zh":145,"source_url":141},44952,"GraphSAINT 与 Cluster-GCN 在时间和空间复杂度上有什么区别？","如果忽略预处理成本，且假设两者在相同大小的子图上操作并使用相同的 GNN 架构（例如 L 层 GraphSAGE-mean），那么每次梯度更新迭代的计算和空间复杂度是完全相同的。区别在于：1. 子图生成策略不同（Cluster-GCN 基于社区结构，GraphSAINT 基于随机采样）；2. 子图大小分布和收敛速率不同。因此，直接比较总训练时间是非平凡的，具体表现取决于数据集和超参数设置。详细实证证据可参考论文附录 D.2。",{"id":147,"question_zh":148,"answer_zh":149,"source_url":150},44953,"Amazon 数据集中部分节点没有标签（全为 0）且节点数量与论文描述不符，该如何处理？","这种情况是正常的，Amazon 图中存在大量低度节点，它们往往属于罕见类别从而没有标签。处理建议有两种：1. 添加一个人工类别（第 108 类），将所有无标签节点归入此类，保持图结构不变；2. 移除无标签节点。如果移除后产生孤立节点，无需进一步删除以保证连通性，因为对孤立节点应用 GNN 等价于应用 MLP，且可以通过添加自环让边采样器正常工作。移除无标签节点后，剩余节点数减少是符合预期的现象。","https:\u002F\u002Fgithub.com\u002FGraphSAINT\u002FGraphSAINT\u002Fissues\u002F18",{"id":152,"question_zh":153,"answer_zh":154,"source_url":155},44954,"GraphSAINT 使用的 Amazon 数据集原始特征是什么？与 Cluster-GCN 用的数据一样吗？","GraphSAINT 和 Cluster-GCN 使用的原始 Amazon 数据是不同的。GraphSAINT 的原始特征是长度为 100k 的稀疏 4-grams（4-gram 稀疏向量）。具体的数据集预处理流程可以参考项目中的 `.\u002Fdataset_details.md` 文档以获取详细信息。","https:\u002F\u002Fgithub.com\u002FGraphSAINT\u002FGraphSAINT\u002Fissues\u002F8",{"id":157,"question_zh":158,"answer_zh":159,"source_url":160},44955,"代码中的 Minibatch 是按节点顺序划分的吗？Minibatch 和 Subgraph 是同一个概念吗？","不完全是。在 GraphSAINT 中，一个 Minibatch 通常对应一个采样的 Subgraph。训练前会有一个预处理步骤：假设总共有 1000 个训练节点，采样器每次返回 100 个节点的子图，若参数 N=50，则预处理阶段会采样并存储 500 个子图（1000\u002F100 * 50）用于估计归一化系数。实际训练开始后，每个 Minibatch 会使用这些预采样好的子图之一进行训练，而不是简单地按节点顺序切分。Subgraph 是指具体的图结构切片，而 Minibatch 是指一次迭代中用于计算梯度的数据批次（在此框架下通常就是一个 Subgraph）。","https:\u002F\u002Fgithub.com\u002FGraphSAINT\u002FGraphSAINT\u002Fissues\u002F3",[]]