BAShapeDataset
- class dgl.data.BAShapeDataset(num_base_nodes=300, num_base_edges_per_node=5, num_motifs=80, perturb_ratio=0.01, seed=None, raw_dir=None, force_reload=False, verbose=True, transform=None)[source]
Bases:
DGLBuiltinDataset
BA-SHAPES数据集来自GNNExplainer: 生成图神经网络的解释
这是一个用于节点分类的合成数据集。它是通过按顺序执行以下步骤生成的。
构建一个基础的Barabási–Albert (BA) 图。
构建一组五节点房屋结构的网络模体。
将图案附加到基础图的随机选择的节点上。
通过添加随机边来扰动图。
节点被分配到4个类别。标签为0的节点属于基础BA图。标签为1、2、3的节点分别位于房屋的中间、底部或顶部。
为所有节点生成常量特征,其值为1。
- Parameters:
num_base_nodes (int, optional) – 基础BA图中的节点数量。默认值:300
num_base_edges_per_node (int, 可选) – 在构建基础BA图时,从新节点连接到现有节点的边数。默认值:5
num_motifs (int, optional) – 使用的房屋结构网络主题的数量。默认值:80
perturb_ratio (float, optional) – 在扰动中添加的随机边数除以原始图中的边数。默认值:0.01
seed (整数, random_state, 或 None, 可选) – 随机数生成状态的指示器。默认值:None
raw_dir (str, optional) – Raw file directory to store the processed data. Default: ~/.dgl/
force_reload (bool, optional) – 是否总是从头生成数据,而不是加载缓存版本。 默认值: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 BAShapeDataset >>> dataset = BAShapeDataset() >>> dataset.num_classes 4 >>> g = dataset[0] >>> label = g.ndata['label'] >>> feat = g.ndata['feat']