ZINCDataset

class dgl.data.ZINCDataset(mode='train', raw_dir=None, force_reload=False, verbose=False, transform=None)[source]

Bases: DGLBuiltinDataset

用于图回归任务的ZINC数据集。

使用了ZINC分子图数据集(250K)的一个子集(12K)来回归一个称为受限溶解度的分子属性。对于每个分子图,节点特征是重原子的类型,边特征是键的类型。每个图包含9-37个节点和16-84条边。

Reference https://arxiv.org/pdf/2003.00982.pdf

统计:

训练样本:10,000 验证样本:1,000 测试样本:1,000 平均节点数:23.16 平均边数:39.83 原子类型数:28 键类型数:4

Parameters:
  • mode (str, optional) – 应从[“train”, “valid”, “test”]中选择 默认值: “train”.

  • raw_dir (str) – 用于下载/包含输入数据目录的原始文件目录。 默认值:“~/.dgl/”。

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

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

  • 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_atom_types

原子类型的数量。

Type:

int

num_bond_types

债券类型的数量。

Type:

int

示例

>>> from dgl.data import ZINCDataset
>>> training_set = ZINCDataset(mode="train")
>>> training_set.num_atom_types
28
>>> len(training_set)
10000
>>> graph, label = training_set[0]
>>> graph
Graph(num_nodes=29, num_edges=64,
    ndata_schemes={'feat': Scheme(shape=(), dtype=torch.int64)}
    edata_schemes={'feat': Scheme(shape=(), dtype=torch.int64)})
__getitem__(idx)[source]

通过索引获取一个示例。

Parameters:

idx (int) – The sample index.

Returns:

  • dgl.DGLGraph – 每个图包含:

    • ndata['feat']: 重原子类型作为节点特征

    • edata['feat']: 键类型作为边特征

  • Tensor – 约束溶解度作为图标签

__len__()[source]

数据集中的示例数量。