Implementation of kernels on the edge space of graphs or simplicial complexes#139
Conversation
stoprightthere
left a comment
There was a problem hiding this comment.
Hi @cookbook-ms this looks cool! I've only had a brief skim over the code and left a couple of minor comments. Didn't check the maths though.
|
Sorry for the late updates. In this update, we have the following changes:
Please have a look at your convenience. Thanks :) |
|
Thanks a lot, Maosheng! I plan to take a look in a week or two, after the deadline streak has passed. |
|
Hi @cookbook-ms, Thank you so much for implementing the Hodge compositional kernel! I remember in the past we discussed a somewhat different design, which can hopefully relief the confusion of edges being implicitly oriented and which could better fit into the existing structure of the library. Please tell me if you would be willing to implement (perhaps some parts of) this proposal. What you won't do, I'll get around to doing myself in some time. I'm copying a proposal from one of my old emails below. Well, rather a somewhat more detailed version of it.
In addition to the above classes, add a documentation page for theory of Hodge-compositional kernels on graphs/simplicial complexes. Feel free to ping me if you want to discuss this more. |
|
Hi Slava, please check my reply per item.
'MaternKarhunenLoeveKernel_HodgeCompositionEdge' should be implemented as discussed already, which takes three sets of parameters as inputs.
I planned to do that after you pass the above.
|
|
I see. I want to finish #149 asap, so, if that's okay, I'll take another look after you do
|
Now it samples random edges returning both the edges as pairs of nodes, also their indices. But it is much easier to use indices of edges to obtain the eigenvectors at the corresponding locations, thus computing the kernels. For this, I included a method to obtain the indices of given input edges. |
vabor112
left a comment
There was a problem hiding this comment.
Some random comments. Also, don't forget to run make lint and make test before pushing.
- New abstract class HodgeDiscreteSpectrumSpace, a subclass of DiscreteSpectrumSpace. Its methods have an additional parameter `type`, which can be one of "harmonic", "curl", "gradient". This allows getting (repeated) eigenvalues and eigenfunctions only for the respective type of the Hodge decomposition. - MaternKarhunenLoeveKernel can now directly accept `eigenvalues_laplacian` and `eigenfunctions` as parameters. This is useful for the new MaternHodgeCompositionalKernel. - New MaternHodgeCompositionalKernel, a class is similar to MaternKarhunenLoeveKernel, but providing a more expressive family of kernels on the spaces where Hodge decomposition is available. - DeterministicFeatureMapCompact and RandomPhaseFeatureMapCompact don't construct and store a kernel anymore. For this, the method `_spectrum` of MaternKarhunenLoeveKernel, now called just `spectrum`, has become static. Also, the `normalize` parameter of feature maps is now True by default.
…angles in GraphEdges
aterenin
left a comment
There was a problem hiding this comment.
I had a full read-over the code and ran the notebook. Largely LGTM, except there are a few places in GraphEdges.ipynb where I would suggest a small number of changes. This is mostly:
- A missing random seed in one of the calls.
- A few places where certain package design choices are pointed out to the user, for instance handling
outputscale, but no link to additional documentation is provided. I suggest providing links so that a user who is only interested in graph edge functionality can easily find what they need.
Otherwise LGTM!
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "type_reference = np.random.RandomState()\n", |
There was a problem hiding this comment.
This should have a random seed.
There was a problem hiding this comment.
This RandomState is only used to tell GraphEdges.from_adjacency which backend to use for internal computations. It's never actually used for random number generation, thus there's no need to set a seed. I changed the line to
type_reference = np.random.RandomState() # defines the backend, never used for random number generationHopefully, this makes things more clear.
There was a problem hiding this comment.
Why is the exact same line used later with seeds inputted?
There was a problem hiding this comment.
Other RandomState-s are actually used for random number generation. Where this is the case, the variable is called key rather than type_reference, as in
key = np.random.RandomState(1234)in contrast to
type_reference = np.random.RandomState() # defines the backend, never used for random number generation| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "Now, if we visualize the space, it will look like this:" |
There was a problem hiding this comment.
Draw attention to difference from previous figure - that there is one less triangle.
| "The next line initializes the dictionary of kernel parameters `params` with some default values.\n", | ||
| "\n", | ||
| "**Note:** our kernels do not provide the outputscale/variance parameter frequently used in Gaussian processes.\n", | ||
| "However, it is usually trivial to add it by multiplying the kernel by an (optimizable) constant." |
There was a problem hiding this comment.
Add a link to somewhere which shows an example doing this - otherwise someone who is interested only in the graph part may not find it.
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "We start by sampling `3` (uniformly) random points on our graph.\n", |
There was a problem hiding this comment.
Visualizing where these edges are would help.
This pull requests an implementation of kernels on the Edge space of a graph or a simplicial 2-complex.
I implemented the following:
geometric_kernels/spaces/graph_edge.py, which allows backends based on numpy, pytorch and jax.Note that: