Commit 26d685d3 authored by Carl Poelking's avatar Carl Poelking
Browse files

Graph-kernel function factory.

parent 556d4e7c
......@@ -627,8 +627,11 @@ class ParticleGraph(object):
types_global=options_descriptor['type_list'])
ix = adaptor.adapt(spectrum)
dim = ix.shape[1]
assert ix.shape[0] == n_atoms
P = ix
if options_soap.get('kernel.adaptor') in [ 'global-generic', 'global-specific' ]:
pass
else:
assert P.shape[0] == n_atoms
elif descriptor_type == 'soap-quippy':
atoms_quippy = datasets.gdb.convert_ase2quippy_atomslist([atoms])[0]
# Read options
......@@ -671,7 +674,10 @@ class ParticleGraph(object):
#print z, z_idx
P = np.array(ix)
dim = P.shape[1]
assert P.shape[0] == n_atoms
if options_soap.get('kernel.adaptor') in [ 'global-generic', 'global-specific' ]:
pass
else:
assert P.shape[0] == n_atoms
#print P.dot(P.T)
elif descriptor_type == 'npy_load':
folder = options_descriptor["folder"]
......
......@@ -3,6 +3,22 @@ import numpy.linalg as la
import soap
import permanent as perm
import kernel as kern
import lagraph
def compare_graphs_average(g1, g2, options):
P1 = g1.P
P1_avg = np.average(g1.P, axis=0)
P1_avg = P1_avg / np.dot(P1_avg, P1_avg)**0.5
P2 = g2.P
P2_avg = np.average(g2.P, axis=0)
P2_avg = P2_avg / np.dot(P2_avg, P2_avg)**0.5
print P1.shape, P2.shape, P1_avg.shape, P2_avg.shape
return np.dot(P1_avg, P2_avg)
def compare_graphs_global(g1, g2, options):
assert g1.P.shape[0] == 1 # Global descriptor computed?
assert g2.P.shape[0] == 1 # Global descriptor computed?
return np.dot(g1.P[0], g2.P[0])
def compare_graphs_rematch(g1, g2, options):
if options['graph']['hierarchical']:
......@@ -134,3 +150,10 @@ def optimize_rematch(graphs, options, write_out=False, log=None, verbose=False):
options['lamatch']['gamma'] = merits[-1][0]
return
GraphKernelFactory = {
'rematch' : compare_graphs_rematch,
'average': compare_graphs_average,
'global': compare_graphs_global,
'laplacian': lagraph.compare_graphs_laplacian_kernelized
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment