CoraFullDataset

class dgl.data.CoraFullDataset(raw_dir=None, force_reload=False, verbose=False, transform=None)[source]

Bases: GNNBenchmarkDataset

用于节点分类任务的CORA-Full数据集。

扩展的Cora数据集。节点代表论文,边代表引用。

Reference: https://github.com/shchur/gnn-benchmark#datasets

统计:

  • 节点数:19,793

  • 边数:126,842(请注意,原始数据集有65,311条边,但DGL添加了反向边并去除了重复边,因此数量不同)

  • 班级数量:70

  • 节点特征大小:8,710

Parameters:
  • raw_dir (str) – Raw file directory to download/contains the input data directory. Default: ~/.dgl/

  • force_reload (bool) – Whether to reload the dataset. Default: False

  • verbose (bool) – Whether to print out progress information. Default: True.

  • transform (callable, optional) – A transform that takes in a DGLGraph object and returns a transformed version. The DGLGraph object will be transformed before every access.

num_classes

每个节点的类别数量。

Type:

int

示例

>>> data = CoraFullDataset()
>>> g = data[0]
>>> num_class = data.num_classes
>>> feat = g.ndata['feat']  # get node feature
>>> label = g.ndata['label']  # get node labels
__getitem__(idx)

通过索引获取图表

Parameters:

idx (int) – Item index

Returns:

The graph contains:

  • ndata['feat']: node features

  • ndata['label']: node labels

Return type:

dgl.DGLGraph

__len__()

数据集中的图表数量