Browse Source

Fix a bug in the WL kernel class.

v0.2.x
jajupmochi 4 years ago
parent
commit
2a065f4fb6
2 changed files with 5 additions and 4 deletions
  1. +3
    -3
      gklearn/kernels/weisfeiler_lehman.py
  2. +2
    -1
      gklearn/tests/test_graph_kernels.py

+ 3
- 3
gklearn/kernels/weisfeiler_lehman.py View File

@@ -153,7 +153,7 @@ class WeisfeilerLehman(GraphKernel): # @todo: total parallelization and sp, edge
all_num_of_each_label.append(dict(Counter(labels_ori)))
# Compute subtree kernel with the 0th iteration and add it to the final kernel.
self._compute_gram_matrix(gram_matrix, all_num_of_each_label, Gn)
self._compute_gram_itr(gram_matrix, all_num_of_each_label, Gn)
# iterate each height
for h in range(1, self._height + 1):
@@ -199,12 +199,12 @@ class WeisfeilerLehman(GraphKernel): # @todo: total parallelization and sp, edge
all_num_of_each_label.append(dict(Counter(labels_comp)))
# Compute subtree kernel with h iterations and add it to the final kernel
self._compute_gram_matrix(gram_matrix, all_num_of_each_label, Gn)
self._compute_gram_itr(gram_matrix, all_num_of_each_label, Gn)
return gram_matrix

def _compute_gram_matrix(self, gram_matrix, all_num_of_each_label, Gn):
def _compute_gram_itr(self, gram_matrix, all_num_of_each_label, Gn):
"""Compute Gram matrix using the base kernel.
"""
if self._parallel == 'imap_unordered':


+ 2
- 1
gklearn/tests/test_graph_kernels.py View File

@@ -434,7 +434,8 @@ def test_WLSubtree(ds_name, parallel):

if __name__ == "__main__":
# test_spkernel('Alkane', 'imap_unordered')
test_StructuralSP('Fingerprint_edge', 'imap_unordered')
# test_StructuralSP('Fingerprint_edge', 'imap_unordered')
test_WLSubtree('Acyclic', 'imap_unordered')
# test_RandomWalk('Acyclic', 'sylvester', None, 'imap_unordered')
# test_RandomWalk('Acyclic', 'conjugate', None, 'imap_unordered')
# test_RandomWalk('Acyclic', 'fp', None, None)

Loading…
Cancel
Save