-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex-2_BenchmarkDataset.py
40 lines (31 loc) · 1.06 KB
/
ex-2_BenchmarkDataset.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 26 16:49:49 2019
@author: dipu
"""
import torch
from torch_geometric.datasets import TUDataset
dataset = TUDataset(root='tmp/ENZYMES', name='ENZYMES')
dataset.num_classes
dataset.num_node_features
print('Length of the dataset {} is {}'.format(dataset.name, len(dataset)))
#%%Acessing the each graph in the dataset
data = dataset[0]
#%% Suffling the dataset
dataset = dataset.shuffle()
#Or,
perm = torch.randperm(len(dataset))
dataset = dataset[perm]
#%% Cora dataset Example
from torch_geometric.datasets import Planetoid
dataset = Planetoid(root='tmp/Cora', name = 'Cora')
print('Length of the dataset {} is {}'.format(dataset.name, len(dataset)))
print('The number of classes in the dataset {} is {}'.format(dataset.name, dataset.num_classes))
print('The number of the node features is {}'.format(dataset.num_node_features))
## this data has a single and undirected citation graph
data = dataset[0]
print('datais \n',data)
data.train_mask.sum().item()
data.val_mask.sum().item()
data.test_mask.sum().item()