Skip to content

Commit 5303897

Browse files
committed
Add exps.
1 parent 0eef570 commit 5303897

File tree

4 files changed

+68
-3
lines changed

4 files changed

+68
-3
lines changed

Problems.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# About graph kenrels.
22

3-
## (Random walk) Sylvester equation kernel.
3+
## (Random walk) Sylvester equation kernel.
44

55
### ImportError: cannot import name 'frange' from 'matplotlib.mlab'
66

@@ -18,4 +18,6 @@ Install MKL. Then add the following to your path:
1818
export PATH=/opt/intel/bin:$PATH
1919
2020
export LD_LIBRARY_PATH=/opt/intel/lib/intel64:/opt/intel/mkl/lib/intel64:$LD_LIBRARY_PATH
21+
22+
export LD_PRELOAD=/opt/intel/mkl/lib/intel64/libmkl_def.so:/opt/intel/mkl/lib/intel64/libmkl_avx2.so:/opt/intel/mkl/lib/intel64/libmkl_core.so:/opt/intel/mkl/lib/intel64/libmkl_intel_lp64.so:/opt/intel/mkl/lib/intel64/libmkl_intel_thread.so:/opt/intel/lib/intel64_lin/libiomp5.so
2123
```

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Check [`notebooks`](https://github.com/jajupmochi/graphkit-learn/tree/master/not
6060

6161
The docs of the library can be found [here](https://graphkit-learn.readthedocs.io/en/master/?badge=master).
6262

63-
## Main contents
63+
## Main contents
6464

6565
### 1 List of graph kernels
6666

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
Created on Mon Sep 21 10:34:26 2020
5+
6+
@author: ljia
7+
"""
8+
from utils import Graph_Kernel_List, Dataset_List, compute_graph_kernel
9+
from gklearn.utils.graphdataset import load_predefined_dataset
10+
import logging
11+
12+
13+
def xp_runtimes_diff_chunksizes():
14+
15+
# Run and save.
16+
import pickle
17+
import os
18+
save_dir = 'outputs/runtimes_diff_chunksizes/'
19+
if not os.path.exists(save_dir):
20+
os.makedirs(save_dir)
21+
22+
run_times = {}
23+
24+
for kernel_name in Graph_Kernel_List:
25+
print()
26+
print('Kernel:', kernel_name)
27+
28+
run_times[kernel_name] = []
29+
for ds_name in Dataset_List:
30+
print()
31+
print('Dataset:', ds_name)
32+
33+
run_times[kernel_name].append([])
34+
for chunksize in [1, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000]:
35+
print()
36+
print('Chunksize:', chunksize)
37+
38+
# get graphs.
39+
graphs, _ = load_predefined_dataset(ds_name)
40+
41+
# Compute Gram matrix.
42+
run_time = 'error'
43+
try:
44+
gram_matrix, run_time = compute_graph_kernel(graphs, kernel_name, chunksize=chunksize)
45+
except Exception as exp:
46+
print('An exception occured when running this experiment:')
47+
LOG_FILENAME = save_dir + 'error.txt'
48+
logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG)
49+
logging.exception('')
50+
print(repr(exp))
51+
run_times[kernel_name][-1].append(run_time)
52+
53+
pickle.dump(run_time, open(save_dir + 'run_time.' + kernel_name + '.' + ds_name + '.' + str(chunksize) + '.pkl', 'wb'))
54+
55+
# Save all.
56+
pickle.dump(run_times, open(save_dir + 'run_times.pkl', 'wb'))
57+
58+
return
59+
60+
61+
if __name__ == '__main__':
62+
xp_runtimes_diff_chunksizes()

gklearn/experiments/papers/PRL_2020/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
Dataset_List = ['Alkane', 'Acyclic', 'MAO', 'PAH', 'MUTAG', 'Letter-med', 'ENZYMES', 'AIDS', 'NCI1', 'NCI109', 'DD']
2828

2929

30-
def compute_graph_kernel(graphs, kernel_name, n_jobs=multiprocessing.cpu_count()):
30+
def compute_graph_kernel(graphs, kernel_name, n_jobs=multiprocessing.cpu_count(), chunksize=None):
3131

3232
if kernel_name == 'CommonWalk':
3333
from gklearn.kernels.commonWalkKernel import commonwalkkernel
@@ -105,6 +105,7 @@ def compute_graph_kernel(graphs, kernel_name, n_jobs=multiprocessing.cpu_count()
105105

106106
# params['parallel'] = None
107107
params['n_jobs'] = n_jobs
108+
params['chunksize'] = chunksize
108109
params['verbose'] = True
109110
results = estimator(graphs, **params)
110111

0 commit comments

Comments
 (0)