diff --git a/examples/mxnet/appnp/appnp.py b/examples/mxnet/appnp/appnp.py index a5c72a1d0576..e6d56e252088 100644 --- a/examples/mxnet/appnp/appnp.py +++ b/examples/mxnet/appnp/appnp.py @@ -93,7 +93,7 @@ def main(args): val_mask = g.ndata["val_mask"] test_mask = g.ndata["test_mask"] in_feats = features.shape[1] - n_classes = data.num_labels + n_classes = data.num_classes n_edges = data.graph.number_of_edges() print( """----Data statistics------' diff --git a/examples/mxnet/gat/train.py b/examples/mxnet/gat/train.py index 798855b34786..cd7d21897e3d 100644 --- a/examples/mxnet/gat/train.py +++ b/examples/mxnet/gat/train.py @@ -69,7 +69,7 @@ def main(args): test_mask = g.ndata["test_mask"] test_mask = mx.nd.array(np.nonzero(test_mask.asnumpy())[0], ctx=ctx) in_feats = features.shape[1] - n_classes = data.num_labels + n_classes = data.num_classes n_edges = data.graph.number_of_edges() g = dgl.remove_self_loop(g) diff --git a/examples/mxnet/gcn/gcn_concat.py b/examples/mxnet/gcn/gcn_concat.py index c714170bc7eb..92256c274043 100644 --- a/examples/mxnet/gcn/gcn_concat.py +++ b/examples/mxnet/gcn/gcn_concat.py @@ -94,7 +94,7 @@ def main(args): val_mask = g.ndata["val_mask"] test_mask = g.ndata["test_mask"] in_feats = features.shape[1] - n_classes = data.num_labels + n_classes = data.num_classes n_edges = data.graph.number_of_edges() print( """----Data statistics------' diff --git a/examples/mxnet/gcn/train.py b/examples/mxnet/gcn/train.py index 646ce25dea6e..8e5d6f42fd0d 100644 --- a/examples/mxnet/gcn/train.py +++ b/examples/mxnet/gcn/train.py @@ -46,7 +46,7 @@ def main(args): val_mask = g.ndata["val_mask"] test_mask = g.ndata["test_mask"] in_feats = features.shape[1] - n_classes = data.num_labels + n_classes = data.num_classes n_edges = data.graph.number_of_edges() print( """----Data statistics------' diff --git a/examples/mxnet/graphsage/main.py b/examples/mxnet/graphsage/main.py index 6446567df3ee..6ccdb3cd0e33 100644 --- a/examples/mxnet/graphsage/main.py +++ b/examples/mxnet/graphsage/main.py @@ -111,7 +111,7 @@ def main(args): val_mask = g.ndata["val_mask"] test_mask = g.ndata["test_mask"] in_feats = features.shape[1] - n_classes = data.num_labels + n_classes = data.num_classes n_edges = data.graph.number_of_edges() print( """----Data statistics------' diff --git a/examples/mxnet/monet/citation.py b/examples/mxnet/monet/citation.py index 53eaa34ed8fb..a90a7fd1a9a8 100644 --- a/examples/mxnet/monet/citation.py +++ b/examples/mxnet/monet/citation.py @@ -93,7 +93,7 @@ def main(args): val_mask = g.ndata["val_mask"] test_mask = g.ndata["test_mask"] in_feats = features.shape[1] - n_classes = data.num_labels + n_classes = data.num_classes n_edges = data.graph.number_of_edges() print( """----Data statistics------' diff --git a/examples/mxnet/sgc/sgc.py b/examples/mxnet/sgc/sgc.py index 791726cc1f50..c7134075018d 100644 --- a/examples/mxnet/sgc/sgc.py +++ b/examples/mxnet/sgc/sgc.py @@ -56,7 +56,7 @@ def main(args): val_mask = g.ndata["val_mask"] test_mask = g.ndata["test_mask"] in_feats = features.shape[1] - n_classes = data.num_labels + n_classes = data.num_classes n_edges = data.graph.number_of_edges() print( """----Data statistics------' diff --git a/examples/mxnet/tagcn/train.py b/examples/mxnet/tagcn/train.py index eaa49afdb7b3..76d2ee103599 100644 --- a/examples/mxnet/tagcn/train.py +++ b/examples/mxnet/tagcn/train.py @@ -48,7 +48,7 @@ def main(args): val_mask = g.ndata["val_mask"] test_mask = g.ndata["test_mask"] in_feats = features.shape[1] - n_classes = data.num_labels + n_classes = data.num_classes n_edges = data.graph.number_of_edges() print( """----Data statistics------' diff --git a/examples/pytorch/dimenet/qm9.py b/examples/pytorch/dimenet/qm9.py index 14649c5d87ca..ceec77c0130e 100644 --- a/examples/pytorch/dimenet/qm9.py +++ b/examples/pytorch/dimenet/qm9.py @@ -86,7 +86,7 @@ class QM9(QM9Dataset): Examples -------- >>> data = QM9Dataset(label_keys=['mu', 'gap'], cutoff=5.0) - >>> data.num_labels + >>> data.num_classes 2 >>> >>> # iterate over the dataset diff --git a/examples/pytorch/gat/train_ppi.py b/examples/pytorch/gat/train_ppi.py index dec51f96d25e..8cd340256c00 100644 --- a/examples/pytorch/gat/train_ppi.py +++ b/examples/pytorch/gat/train_ppi.py @@ -116,7 +116,7 @@ def train(train_dataloader, val_dataloader, device, model): # create GAT model in_size = features.shape[1] - out_size = train_dataset.num_labels + out_size = train_dataset.num_classes model = GAT(in_size, 256, out_size, heads=[4, 4, 6]).to(device) # model training diff --git a/examples/pytorch/geniepath/ppi.py b/examples/pytorch/geniepath/ppi.py index 41fb012a2532..19e20eeb016a 100644 --- a/examples/pytorch/geniepath/ppi.py +++ b/examples/pytorch/geniepath/ppi.py @@ -49,7 +49,7 @@ def main(args): else: device = "cpu" - num_classes = train_dataset.num_labels + num_classes = train_dataset.num_classes # Extract node features graph = train_dataset[0] diff --git a/examples/pytorch/sgc/sgc.py b/examples/pytorch/sgc/sgc.py index 1691ceed7067..9fca4829972d 100644 --- a/examples/pytorch/sgc/sgc.py +++ b/examples/pytorch/sgc/sgc.py @@ -59,7 +59,7 @@ def main(args): val_mask = g.ndata["val_mask"] test_mask = g.ndata["test_mask"] in_feats = features.shape[1] - n_classes = data.num_labels + n_classes = data.num_classes n_edges = g.num_edges() print( """----Data statistics------' diff --git a/examples/pytorch/sgc/sgc_reddit.py b/examples/pytorch/sgc/sgc_reddit.py index 85e50d74ffbf..6a9f83349628 100644 --- a/examples/pytorch/sgc/sgc_reddit.py +++ b/examples/pytorch/sgc/sgc_reddit.py @@ -51,7 +51,7 @@ def main(args): val_mask = g.ndata["val_mask"] test_mask = g.ndata["test_mask"] in_feats = features.shape[1] - n_classes = data.num_labels + n_classes = data.num_classes n_edges = g.num_edges() print( """----Data statistics------' diff --git a/examples/pytorch/sign/dataset.py b/examples/pytorch/sign/dataset.py index 8a5c92778d3d..128b5586b9ee 100644 --- a/examples/pytorch/sign/dataset.py +++ b/examples/pytorch/sign/dataset.py @@ -28,7 +28,7 @@ def load_dataset(name): data = CitationGraphDataset("cora") g = data[0] - n_classes = data.num_labels + n_classes = data.num_classes train_mask = g.ndata["train_mask"] val_mask = g.ndata["val_mask"] test_mask = g.ndata["test_mask"] diff --git a/examples/pytorch/tagcn/train.py b/examples/pytorch/tagcn/train.py index 9cd4ed0fa472..b6e5e3e7de66 100644 --- a/examples/pytorch/tagcn/train.py +++ b/examples/pytorch/tagcn/train.py @@ -38,7 +38,7 @@ def main(args): val_mask = g.ndata["val_mask"] test_mask = g.ndata["test_mask"] in_feats = features.shape[1] - n_classes = data.num_labels + n_classes = data.num_classes n_edges = g.num_edges() print( """----Data statistics------' diff --git a/examples/tensorflow/dgi/train.py b/examples/tensorflow/dgi/train.py index 4b2e7f3ea898..1d2e35b75a65 100644 --- a/examples/tensorflow/dgi/train.py +++ b/examples/tensorflow/dgi/train.py @@ -50,7 +50,7 @@ def main(args): val_mask = g.ndata["val_mask"] test_mask = g.ndata["test_mask"] in_feats = features.shape[1] - n_classes = data.num_labels + n_classes = data.num_classes n_edges = g.number_of_edges() # add self loop diff --git a/examples/tensorflow/gat/train.py b/examples/tensorflow/gat/train.py index f7559e894917..18ff5fbdb1d6 100644 --- a/examples/tensorflow/gat/train.py +++ b/examples/tensorflow/gat/train.py @@ -66,7 +66,7 @@ def main(args): val_mask = g.ndata["val_mask"] test_mask = g.ndata["test_mask"] num_feats = features.shape[1] - n_classes = data.num_labels + n_classes = data.num_classes n_edges = g.number_of_edges() print( """----Data statistics------' diff --git a/examples/tensorflow/gcn/gcn_builtin.py b/examples/tensorflow/gcn/gcn_builtin.py index e6b92b964290..3603895c30c0 100644 --- a/examples/tensorflow/gcn/gcn_builtin.py +++ b/examples/tensorflow/gcn/gcn_builtin.py @@ -114,7 +114,7 @@ def main(args): val_mask = g.ndata["val_mask"] test_mask = g.ndata["test_mask"] in_feats = features.shape[1] - n_classes = data.num_labels + n_classes = data.num_classes n_edges = data.graph.number_of_edges() print( """----Data statistics------' diff --git a/examples/tensorflow/gcn/gcn_mp.py b/examples/tensorflow/gcn/gcn_mp.py index 5796ab55ffcd..4deb7380668e 100644 --- a/examples/tensorflow/gcn/gcn_mp.py +++ b/examples/tensorflow/gcn/gcn_mp.py @@ -121,7 +121,7 @@ def main(args): val_mask = g.ndata["val_mask"] test_mask = g.ndata["test_mask"] in_feats = features.shape[1] - n_classes = data.num_labels + n_classes = data.num_classes n_edges = data.graph.number_of_edges() print( """----Data statistics------' diff --git a/examples/tensorflow/gcn/train.py b/examples/tensorflow/gcn/train.py index 35a48a00ab55..689637256934 100644 --- a/examples/tensorflow/gcn/train.py +++ b/examples/tensorflow/gcn/train.py @@ -43,7 +43,7 @@ def main(args): val_mask = g.ndata["val_mask"] test_mask = g.ndata["test_mask"] in_feats = features.shape[1] - n_classes = data.num_labels + n_classes = data.num_classes n_edges = g.number_of_edges() print( """----Data statistics------' diff --git a/python/dgl/data/ppi.py b/python/dgl/data/ppi.py index be4a16ef7e0b..71489ef3f21c 100644 --- a/python/dgl/data/ppi.py +++ b/python/dgl/data/ppi.py @@ -59,7 +59,7 @@ class PPIDataset(DGLBuiltinDataset): Examples -------- >>> dataset = PPIDataset(mode='valid') - >>> num_labels = dataset.num_labels + >>> num_classes = dataset.num_classes >>> for g in dataset: .... feat = g.ndata['feat'] .... label = g.ndata['label'] @@ -173,6 +173,10 @@ def load(self): def num_labels(self): return 121 + @property + def num_classes(self): + return 121 + def __len__(self): """Return number of samples in this dataset.""" return len(self.graphs) diff --git a/python/dgl/data/qm7b.py b/python/dgl/data/qm7b.py index 51382afd9ca2..117b552bfc25 100644 --- a/python/dgl/data/qm7b.py +++ b/python/dgl/data/qm7b.py @@ -141,6 +141,11 @@ def num_labels(self): """Number of prediction tasks.""" return 14 + @property + def num_classes(self): + """Number of prediction tasks.""" + return 14 + def __getitem__(self, idx): r"""Get graph and label by index diff --git a/python/dgl/data/qm9.py b/python/dgl/data/qm9.py index e91851bff847..635f1c66acf1 100644 --- a/python/dgl/data/qm9.py +++ b/python/dgl/data/qm9.py @@ -157,6 +157,16 @@ def num_labels(self): """ return self.label.shape[1] + @property + def num_classes(self): + r""" + Returns + -------- + int + Number of prediction tasks. + """ + return self.label.shape[1] + @property def num_tasks(self): r"""