Skip to content

Commit e4fe9fe

Browse files
authored
Merge pull request #29 from jajupmochi/v0.2
V0.2
2 parents 068b57a + 5eea854 commit e4fe9fe

23 files changed

+3609
-3281
lines changed

CHANGELOG.md

Whitespace-only changes.

Problems.md

Lines changed: 4 additions & 2 deletions
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

@@ -10,12 +10,14 @@ Update your `control` package.
1010

1111
### Intel MKL FATAL ERROR: Cannot load libmkl_avx2.so or libmkl_def.so.
1212

13-
The Intel Math Kernel Library (MKL) is missing or not properly set. I assume the MKL is required by `control` module.
13+
The Intel Math Kernel Library (MKL) is missing or not properly set. I assume MKL is required by the `control` module.
1414

1515
Install MKL. Then add the following to your path:
1616

1717
```
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: 15 additions & 15 deletions
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

@@ -131,6 +131,20 @@ A comparison of performances of graph kernels on benchmark datasets can be found
131131

132132
Fork the library and open a pull request! Make your own contribute to the community!
133133

134+
## Authors
135+
136+
* [Linlin Jia](https://jajupmochi.github.io/), LITIS, INSA Rouen Normandie
137+
* [Benoit Gaüzère](http://pagesperso.litislab.fr/~bgauzere/#contact_en), LITIS, INSA Rouen Normandie
138+
* [Paul Honeine](http://honeine.fr/paul/Welcome.html), LITIS, Université de Rouen Normandie
139+
140+
## Citation
141+
142+
Still waiting...
143+
144+
## Acknowledgments
145+
146+
This research was supported by CSC (China Scholarship Council) and the French national research agency (ANR) under the grant APi (ANR-18-CE23-0014). The authors would like to thank the CRIANN (Le Centre Régional Informatique et d’Applications Numériques de Normandie) for providing computational resources.
147+
134148
## References
135149
[1] Thomas Gärtner, Peter Flach, and Stefan Wrobel. On graph kernels: Hardness results and efficient alternatives. Learning Theory and Kernel Machines, pages 129–143, 2003.
136150

@@ -153,17 +167,3 @@ Fork the library and open a pull request! Make your own contribute to the commun
153167
[10] Gaüzere, B., Brun, L., Villemin, D., 2012. Two new graphs kernels in chemoinformatics. Pattern Recognition Letters 33, 2038–2047.
154168

155169
[11] Shervashidze, N., Schweitzer, P., Leeuwen, E.J.v., Mehlhorn, K., Borgwardt, K.M., 2011. Weisfeiler-lehman graph kernels. Journal of Machine Learning Research 12, 2539–2561.
156-
157-
## Authors
158-
159-
* [Linlin Jia](https://jajupmochi.github.io/), LITIS, INSA Rouen Normandie
160-
* [Benoit Gaüzère](http://pagesperso.litislab.fr/~bgauzere/#contact_en), LITIS, INSA Rouen Normandie
161-
* [Paul Honeine](http://honeine.fr/paul/Welcome.html), LITIS, Université de Rouen Normandie
162-
163-
## Citation
164-
165-
Still waiting...
166-
167-
## Acknowledgments
168-
169-
This research was supported by CSC (China Scholarship Council) and the French national research agency (ANR) under the grant APi (ANR-18-CE23-0014). The authors would like to thank the CRIANN (Le Centre Régional Informatique et d’Applications Numériques de Normandie) for providing computational resources.

gklearn/experiments/papers/PRL_2020/runtimes_28cores.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,12 @@
1010
import logging
1111

1212

13-
# def get_graphs(ds_name):
14-
# from gklearn.utils.graph_synthesizer import GraphSynthesizer
15-
# gsyzer = GraphSynthesizer()
16-
# graphs = gsyzer.unified_graphs(num_graphs=100, num_nodes=num_nodes, num_edges=int(num_nodes*2), num_node_labels=0, num_edge_labels=0, seed=None, directed=False)
17-
# return graphs
18-
19-
20-
def xp_runtimes_of_all_7cores():
13+
def xp_runtimes_of_all_28cores():
2114

2215
# Run and save.
2316
import pickle
2417
import os
25-
save_dir = 'outputs/runtimes_of_all_7cores/'
18+
save_dir = 'outputs/runtimes_of_all_28cores/'
2619
if not os.path.exists(save_dir):
2720
os.makedirs(save_dir)
2821

@@ -41,16 +34,16 @@ def xp_runtimes_of_all_7cores():
4134
graphs, _ = load_predefined_dataset(ds_name)
4235

4336
# Compute Gram matrix.
37+
run_time = 'error'
4438
try:
4539
gram_matrix, run_time = compute_graph_kernel(graphs, kernel_name, n_jobs=28)
46-
run_times[kernel_name].append(run_time)
4740
except Exception as exp:
48-
run_times[kernel_name].append('error')
4941
print('An exception occured when running this experiment:')
5042
LOG_FILENAME = save_dir + 'error.txt'
5143
logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG)
5244
logging.exception('')
5345
print(repr(exp))
46+
run_times[kernel_name].append(run_time)
5447

5548
pickle.dump(run_time, open(save_dir + 'run_time.' + kernel_name + '.' + ds_name + '.pkl', 'wb'))
5649

@@ -61,4 +54,4 @@ def xp_runtimes_of_all_7cores():
6154

6255

6356
if __name__ == '__main__':
64-
xp_runtimes_of_all_7cores()
57+
xp_runtimes_of_all_28cores()
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/synthesized_graphs_N.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ def xp_synthesied_graphs_dataset_size():
4141

4242
sub_graphs = [g.copy() for g in graphs[0:num_graphs]]
4343

44+
run_time = 'error'
4445
try:
4546
gram_matrix, run_time = compute_graph_kernel(sub_graphs, kernel_name, n_jobs=1)
46-
run_times[kernel_name].append(run_time)
4747
except Exception as exp:
48-
run_times[kernel_name].append('error')
4948
print('An exception occured when running this experiment:')
5049
LOG_FILENAME = save_dir + 'error.txt'
5150
logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG)
5251
logging.exception('')
5352
print(repr(exp))
53+
run_times[kernel_name].append(run_time)
5454

5555
pickle.dump(run_time, open(save_dir + 'run_time.' + kernel_name + '.' + str(num_graphs) + '.pkl', 'wb'))
5656

gklearn/experiments/papers/PRL_2020/synthesized_graphs_degrees.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ def xp_synthesied_graphs_degrees():
4040
graphs = generate_graphs(degree)
4141

4242
# Compute Gram matrix.
43+
run_time = 'error'
4344
try:
4445
gram_matrix, run_time = compute_graph_kernel(graphs, kernel_name, n_jobs=1)
45-
run_times[kernel_name].append(run_time)
4646
except Exception as exp:
47-
run_times[kernel_name].append('error')
4847
print('An exception occured when running this experiment:')
4948
LOG_FILENAME = save_dir + 'error.txt'
5049
logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG)
5150
logging.exception('')
5251
print(repr(exp))
52+
run_times[kernel_name].append(run_time)
5353

5454
pickle.dump(run_time, open(save_dir + 'run_time.' + kernel_name + '.' + str(degree) + '.pkl', 'wb'))
5555

gklearn/experiments/papers/PRL_2020/synthesized_graphs_num_el.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ def xp_synthesied_graphs_num_edge_label_alphabet():
4040
graphs = generate_graphs(num_el_alp)
4141

4242
# Compute Gram matrix.
43+
run_time = 'error'
4344
try:
4445
gram_matrix, run_time = compute_graph_kernel(graphs, kernel_name, n_jobs=1)
45-
run_times[kernel_name].append(run_time)
4646
except Exception as exp:
47-
run_times[kernel_name].append('error')
4847
print('An exception occured when running this experiment:')
4948
LOG_FILENAME = save_dir + 'error.txt'
5049
logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG)
5150
logging.exception('')
5251
print(repr(exp))
52+
run_times[kernel_name].append(run_time)
5353

5454
pickle.dump(run_time, open(save_dir + 'run_time.' + kernel_name + '.' + str(num_el_alp) + '.pkl', 'wb'))
5555

gklearn/experiments/papers/PRL_2020/synthesized_graphs_num_nl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,17 @@ def xp_synthesied_graphs_num_node_label_alphabet():
4040
graphs = generate_graphs(num_nl_alp)
4141

4242
# Compute Gram matrix.
43+
run_time = 'error'
4344
try:
4445
gram_matrix, run_time = compute_graph_kernel(graphs, kernel_name, n_jobs=1)
45-
run_times[kernel_name].append(run_time)
4646
except Exception as exp:
4747
run_times[kernel_name].append('error')
4848
print('An exception occured when running this experiment:')
4949
LOG_FILENAME = save_dir + 'error.txt'
5050
logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG)
5151
logging.exception('')
5252
print(repr(exp))
53+
run_times[kernel_name].append(run_time)
5354

5455
pickle.dump(run_time, open(save_dir + 'run_time.' + kernel_name + '.' + str(num_nl_alp) + '.pkl', 'wb'))
5556

gklearn/experiments/papers/PRL_2020/synthesized_graphs_num_nodes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,17 @@ def xp_synthesied_graphs_num_nodes():
4040
graphs = generate_graphs(num_nodes)
4141

4242
# Compute Gram matrix.
43+
run_time = 'error'
4344
try:
4445
gram_matrix, run_time = compute_graph_kernel(graphs, kernel_name, n_jobs=1)
45-
run_times[kernel_name].append(run_time)
4646
except Exception as exp:
4747
run_times[kernel_name].append('error')
4848
print('An exception occured when running this experiment:')
4949
LOG_FILENAME = save_dir + 'error.txt'
5050
logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG)
5151
logging.exception('')
5252
print(repr(exp))
53+
run_times[kernel_name].append(run_time)
5354

5455
pickle.dump(run_time, open(save_dir + 'run_time.' + kernel_name + '.' + str(num_nodes) + '.pkl', 'wb'))
5556

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)