Browse Source

New translations weisfeilerLehmanKernel.py (Chinese Simplified)

l10n_v0.2.x
linlin 4 years ago
parent
commit
07f25abf73
1 changed files with 17 additions and 17 deletions
  1. +17
    -17
      lang/zh/gklearn/kernels/weisfeilerLehmanKernel.py

+ 17
- 17
lang/zh/gklearn/kernels/weisfeilerLehmanKernel.py View File

@@ -32,15 +32,15 @@ def weisfeilerlehmankernel(*args,
n_jobs=None, n_jobs=None,
chunksize=None, chunksize=None,
verbose=True): verbose=True):
"""Calculate Weisfeiler-Lehman kernels between graphs.
"""Compute Weisfeiler-Lehman kernels between graphs.
Parameters Parameters
---------- ----------
Gn : List of NetworkX graph Gn : List of NetworkX graph
List of graphs between which the kernels are calculated.
List of graphs between which the kernels are computed.
G1, G2 : NetworkX graphs G1, G2 : NetworkX graphs
Two graphs between which the kernel is calculated.
Two graphs between which the kernel is computed.


node_label : string node_label : string
Node attribute used as label. The default node label is atom. Node attribute used as label. The default node label is atom.
@@ -115,12 +115,12 @@ def weisfeilerlehmankernel(*args,




def _wl_kernel_do(Gn, node_label, edge_label, height, parallel, n_jobs, chunksize, verbose): def _wl_kernel_do(Gn, node_label, edge_label, height, parallel, n_jobs, chunksize, verbose):
"""Calculate Weisfeiler-Lehman kernels between graphs.
"""Compute Weisfeiler-Lehman kernels between graphs.


Parameters Parameters
---------- ----------
Gn : List of NetworkX graph Gn : List of NetworkX graph
List of graphs between which the kernels are calculated.
List of graphs between which the kernels are computed.
node_label : string node_label : string
node attribute used as label. node attribute used as label.
edge_label : string edge_label : string
@@ -146,7 +146,7 @@ def _wl_kernel_do(Gn, node_label, edge_label, height, parallel, n_jobs, chunksiz
# number of occurence of each label in G # number of occurence of each label in G
all_num_of_each_label.append(dict(Counter(labels_ori))) all_num_of_each_label.append(dict(Counter(labels_ori)))


# calculate subtree kernel with the 0th iteration and add it to the final kernel
# Compute subtree kernel with the 0th iteration and add it to the final kernel
compute_kernel_matrix(Kmatrix, all_num_of_each_label, Gn, parallel, n_jobs, chunksize, False) compute_kernel_matrix(Kmatrix, all_num_of_each_label, Gn, parallel, n_jobs, chunksize, False)


# iterate each height # iterate each height
@@ -255,7 +255,7 @@ def _wl_kernel_do(Gn, node_label, edge_label, height, parallel, n_jobs, chunksiz
# all_labels_ori.update(labels_comp) # all_labels_ori.update(labels_comp)
all_num_of_each_label.append(dict(Counter(labels_comp))) all_num_of_each_label.append(dict(Counter(labels_comp)))


# calculate subtree kernel with h iterations and add it to the final kernel
# Compute subtree kernel with h iterations and add it to the final kernel
compute_kernel_matrix(Kmatrix, all_num_of_each_label, Gn, parallel, n_jobs, chunksize, False) compute_kernel_matrix(Kmatrix, all_num_of_each_label, Gn, parallel, n_jobs, chunksize, False)


return Kmatrix return Kmatrix
@@ -316,7 +316,7 @@ def compute_kernel_matrix(Kmatrix, all_num_of_each_label, Gn, parallel, n_jobs,
do_partial = partial(wrapper_compute_subtree_kernel, Kmatrix) do_partial = partial(wrapper_compute_subtree_kernel, Kmatrix)
parallel_gm(do_partial, Kmatrix, Gn, init_worker=init_worker, parallel_gm(do_partial, Kmatrix, Gn, init_worker=init_worker,
glbv=(all_num_of_each_label,), n_jobs=n_jobs, chunksize=chunksize, verbose=verbose) glbv=(all_num_of_each_label,), n_jobs=n_jobs, chunksize=chunksize, verbose=verbose)
elif parallel == None:
elif parallel is None:
for i in range(len(Kmatrix)): for i in range(len(Kmatrix)):
for j in range(i, len(Kmatrix)): for j in range(i, len(Kmatrix)):
Kmatrix[i][j] = compute_subtree_kernel(all_num_of_each_label[i], Kmatrix[i][j] = compute_subtree_kernel(all_num_of_each_label[i],
@@ -345,12 +345,12 @@ def wrapper_compute_subtree_kernel(Kmatrix, itr):


def _wl_spkernel_do(Gn, node_label, edge_label, height): def _wl_spkernel_do(Gn, node_label, edge_label, height):
"""Calculate Weisfeiler-Lehman shortest path kernels between graphs.
"""Compute Weisfeiler-Lehman shortest path kernels between graphs.
Parameters Parameters
---------- ----------
Gn : List of NetworkX graph Gn : List of NetworkX graph
List of graphs between which the kernels are calculated.
List of graphs between which the kernels are computed.
node_label : string node_label : string
node attribute used as label. node attribute used as label.
edge_label : string edge_label : string
@@ -413,7 +413,7 @@ def _wl_spkernel_do(Gn, node_label, edge_label, height):
for node in G.nodes(data = True): for node in G.nodes(data = True):
node[1][node_label] = set_compressed[set_multisets[node[0]]] node[1][node_label] = set_compressed[set_multisets[node[0]]]
# calculate subtree kernel with h iterations and add it to the final kernel
# Compute subtree kernel with h iterations and add it to the final kernel
for i in range(0, len(Gn)): for i in range(0, len(Gn)):
for j in range(i, len(Gn)): for j in range(i, len(Gn)):
for e1 in Gn[i].edges(data = True): for e1 in Gn[i].edges(data = True):
@@ -427,12 +427,12 @@ def _wl_spkernel_do(Gn, node_label, edge_label, height):




def _wl_edgekernel_do(Gn, node_label, edge_label, height): def _wl_edgekernel_do(Gn, node_label, edge_label, height):
"""Calculate Weisfeiler-Lehman edge kernels between graphs.
"""Compute Weisfeiler-Lehman edge kernels between graphs.
Parameters Parameters
---------- ----------
Gn : List of NetworkX graph Gn : List of NetworkX graph
List of graphs between which the kernels are calculated.
List of graphs between which the kernels are computed.
node_label : string node_label : string
node attribute used as label. node attribute used as label.
edge_label : string edge_label : string
@@ -491,7 +491,7 @@ def _wl_edgekernel_do(Gn, node_label, edge_label, height):
for node in G.nodes(data = True): for node in G.nodes(data = True):
node[1][node_label] = set_compressed[set_multisets[node[0]]] node[1][node_label] = set_compressed[set_multisets[node[0]]]
# calculate subtree kernel with h iterations and add it to the final kernel
# Compute subtree kernel with h iterations and add it to the final kernel
for i in range(0, len(Gn)): for i in range(0, len(Gn)):
for j in range(i, len(Gn)): for j in range(i, len(Gn)):
for e1 in Gn[i].edges(data = True): for e1 in Gn[i].edges(data = True):
@@ -504,12 +504,12 @@ def _wl_edgekernel_do(Gn, node_label, edge_label, height):




def _wl_userkernel_do(Gn, node_label, edge_label, height, base_kernel): def _wl_userkernel_do(Gn, node_label, edge_label, height, base_kernel):
"""Calculate Weisfeiler-Lehman kernels based on user-defined kernel between graphs.
"""Compute Weisfeiler-Lehman kernels based on user-defined kernel between graphs.
Parameters Parameters
---------- ----------
Gn : List of NetworkX graph Gn : List of NetworkX graph
List of graphs between which the kernels are calculated.
List of graphs between which the kernels are computed.
node_label : string node_label : string
node attribute used as label. node attribute used as label.
edge_label : string edge_label : string
@@ -564,7 +564,7 @@ def _wl_userkernel_do(Gn, node_label, edge_label, height, base_kernel):
for node in G.nodes(data = True): for node in G.nodes(data = True):
node[1][node_label] = set_compressed[set_multisets[node[0]]] node[1][node_label] = set_compressed[set_multisets[node[0]]]
# calculate kernel with h iterations and add it to the final kernel
# Compute kernel with h iterations and add it to the final kernel
Kmatrix += base_kernel(Gn, node_label, edge_label) Kmatrix += base_kernel(Gn, node_label, edge_label)
return Kmatrix return Kmatrix

Loading…
Cancel
Save