Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/graphwave chebyshev #920

Merged
merged 89 commits into from
Feb 25, 2020
Merged

Conversation

kieranricardo
Copy link
Contributor

@kieranricardo kieranricardo commented Feb 23, 2020

This PR adds unit tests and Chebyshev polynomials for GraphWave, and removes the experimental tag from GraphWave.

Chebyshev polynomials are used approximate spectral graph filtering for GraphWave instead of calculating all the eigenvalues explicitly. This decreases the computational complexity from O(N^3) to O(kEn) where:

  • N is the number of nodes
  • k is the order of the Chebyshev polynomial
  • E is the number of edges in the graph
  • n is the number of nodes to calculate embeddings for (length of node_ids passed to generator.flow in this case

Reviewer checklist:

  • unit tests are correctly implemented
  • code is adequately covered by unit tests
  • Chebyshev approximation is correctly implemented (this is tested in test_chebyshev by comparing the approximation to the exact value)

kieranricardo and others added 30 commits February 6, 2020 11:23
- refactored embedding calculation
- added `scales="auto"` option
# Conflicts:
#	stellargraph/mapper/__init__.py
Co-Authored-By: Huon Wilson <Huon.Wilson@data61.csiro.au>
(num_scales, num_nodes) tensor of the wavelets for each scale for the specified node.
"""

def y(vector):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename function "y" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.

Copy link
Member

@huonw huonw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

CHANGELOG.md Outdated Show resolved Hide resolved
stellargraph/core/validation.py Outdated Show resolved Hide resolved
"""
Args:
G (StellarGraph): the StellarGraph object.
scales (iterable of floats): the wavelet scales to use. Smaller values embed smaller scale structural
features, and larger values embed larger structural features.
deg: the degree of the Chebyshev polynomial to use. Higher degrees yield more accurate results but at a
higher computational cost. The default value of `20` is accurate enough for most applications.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could note it, so that users (and us) can remember where the assertion comes from:

Suggested change
higher computational cost. The default value of `20` is accurate enough for most applications.
higher computational cost. According to [1], the default value of `20` is accurate enough for most applications.

With a citation somewhere in this doc string:

[1] D. I. Shuman, P. Vandergheynst, and P. Frossard, “Chebyshev Polynomial Approximation for Distributed Signal Processing,” https://arxiv.org/abs/1105.1891

stellargraph/mapper/graphwave_generator.py Show resolved Hide resolved
cheby_polys.append(cheby_poly)

cheby_polys = K.squeeze(tf.stack(cheby_polys, axis=0), axis=-1)
return tf.matmul(coeffs, cheby_polys)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to note, because it's different to the paper we're using for reference.

Copy link
Member

@huonw huonw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a few very tiny things, and then I think it's good.

Also, it's a bit buried now, but I replied to #920 (comment) .

min_val: the minimum value that `x` can attain
min_val: the maximum value that `x` can attain
"""
if min_val == -np.inf:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be very slightly better for this to be inside the if x < min_val or ...: branch, so that we don't waste time doing these checks or string formatting if x is valid.

CHANGELOG.md Outdated Show resolved Hide resolved
stellargraph/mapper/graphwave_generator.py Outdated Show resolved Hide resolved
kieranricardo and others added 3 commits February 25, 2020 16:54
Co-Authored-By: Huon Wilson <Huon.Wilson@data61.csiro.au>
Co-Authored-By: Huon Wilson <Huon.Wilson@data61.csiro.au>
Copy link
Member

@huonw huonw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, other than the merge conflict from #879.

@kieranricardo kieranricardo merged commit 7f9f45d into develop Feb 25, 2020
@kieranricardo kieranricardo deleted the feature/graphwave-chebyshev branch February 25, 2020 06:38
@huonw huonw mentioned this pull request Feb 28, 2020
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants