BA社区数据集
- class dgl.data.BACommunityDataset(num_base_nodes=300, num_base_edges_per_node=4, num_motifs=80, perturb_ratio=0.01, num_inter_edges=350, seed=None, raw_dir=None, force_reload=False, verbose=True, transform=None)[source]
Bases:
DGLBuiltinDataset
BA-COMMUNITY 数据集来自 GNNExplainer: 生成图神经网络的解释
这是一个用于节点分类的合成数据集。它是通过按顺序执行以下步骤生成的。
构建一个基础的Barabási–Albert (BA) 图。
构建一组五节点房屋结构的网络模体。
将图案附加到基础图的随机选择的节点上。
通过添加随机边来扰动图。
节点被分配到4个类别。标签为0的节点属于基础BA图。标签为1、2、3的节点分别位于房屋的中间、底部或顶部。
生成长度为10的正态分布特征
重复上述步骤生成另一个图。其节点被分配到类别4、5、6、7。其节点特征是用不同的正态分布生成的。
通过随机添加边来连接这两个图。
- Parameters:
num_base_nodes (int, optional) – 每个基础BA图中的节点数。默认值:300
num_base_edges_per_node (int, optional) – 在构建基础BA图时,从新节点连接到现有节点的边数。默认值:4
num_motifs (int, optional) – 用于构建每个图的房屋结构网络主题的数量。默认值:80
perturb_ratio (float, optional) – 在扰动中添加到图中的随机边数除以原始边数。默认值:0.01
num_inter_edges (int, optional) – 在两个图之间添加的随机边的数量。默认值:350
seed (integer, random_state, or None, optional) – Indicator of random number generation state. Default: None
raw_dir (str, optional) – Raw file directory to store the processed data. Default: ~/.dgl/
force_reload (bool, optional) – Whether to always generate the data from scratch rather than load a cached version. Default: False
verbose (bool, optional) – Whether to print progress information. Default: True
transform (callable, optional) – A transform that takes in a
DGLGraph
object and returns a transformed version. TheDGLGraph
object will be transformed before every access. Default: None
示例
>>> from dgl.data import BACommunityDataset >>> dataset = BACommunityDataset() >>> dataset.num_classes 8 >>> g = dataset[0] >>> label = g.ndata['label'] >>> feat = g.ndata['feat']