-
Notifications
You must be signed in to change notification settings - Fork 4
/
datasets.py
48 lines (41 loc) · 1.75 KB
/
datasets.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
41
42
43
44
45
46
47
import numpy as np
import pickle
def load(name, split):
data = np.load(f'./data/{name}/{split}.npz')
dist_mask = np.load(f'./data/{name}/{split}_dist_mask.npy')
dataset = {
'x': data['x'],
'y': data['y'],
'dist_mask': dist_mask,
'node_mask': data['node_mask']
}
return dataset
def load_sbm(name):
assert(name in ['PATTERN', 'CLUSTER'])
train_set = load(name, split='train')
val_set = load(name, split='val')
test_set = load(name, split='test')
return train_set, val_set, test_set
def load_superpixel(name):
assert(name in ['MNIST', 'CIFAR10'])
train_set = load(name, split='train')
val_set = load(name, split='val')
test_set = load(name, split='test')
return train_set, val_set, test_set
def load_zinc():
train_set = load(f'ZINC/subset', split='train')
train_set['edge_attr'] = np.load(f'./data/ZINC/subset/train_edge_attr.npy')
val_set = load(f'ZINC/subset', split='val')
val_set['edge_attr'] = np.load(f'./data/ZINC/subset/val_edge_attr.npy')
test_set = load(f'ZINC/subset', split='test')
test_set['edge_attr'] = np.load(f'./data/ZINC/subset/test_edge_attr.npy')
return train_set, val_set, test_set
def load_peptides(name):
assert(name in ['peptides-struct', 'peptides-func'])
train_xy = np.load(f'./data/{name}/train.npz')
train_dist_mask = pickle.load(open(f'./data/{name}/train_dist_mask.pkl', 'rb'))
val_xy = np.load(f'./data/{name}/val.npz')
val_dist_mask = pickle.load(open(f'./data/{name}/val_dist_mask.pkl', 'rb'))
test_xy = np.load(f'./data/{name}/test.npz')
test_dist_mask = pickle.load(open(f'./data/{name}/test_dist_mask.pkl', 'rb'))
return (train_xy, train_dist_mask), (val_xy, val_dist_mask), (test_xy, test_dist_mask)