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

Randomness in Laplacian Eigenmaps Embeddings #122

Closed
wendywangwwt opened this issue Dec 19, 2022 · 2 comments
Closed

Randomness in Laplacian Eigenmaps Embeddings #122

wendywangwwt opened this issue Dec 19, 2022 · 2 comments

Comments

@wendywangwwt
Copy link

Hi! I'm using Laplacian Eigenmaps and noticed that the resulting embeddings are not always the same, even though I have explicitly set the seed:

model = LaplacianEigenmaps(dimensions=3,seed=0)

Running the same algorithm in the same python session for multiple times yields different embeddings each time. Here is a minimal reproducible example:

import networkx as nx
g_undirected = nx.newman_watts_strogatz_graph(1000, 20, 0.05, seed=1)

from karateclub.node_embedding.neighbourhood import LaplacianEigenmaps
import numpy as np

for _ in range(5):
    model = LaplacianEigenmaps(dimensions=3,seed=0)
    model.fit(g_undirected)
    node_emb_le = model.get_embedding()
    print(np.sum(node_emb_le))

It yields the following summed value of the embeddings for me:

31.647046936812927
-31.647046936812888
31.64704693681287
-31.690999529775908
-31.581837545720354

How can I control the randomness so that every time the resulting embeddings are exactly the same, even if I run the algorithm for arbitrary times in the same python session?

@benedekrozemberczki
Copy link
Owner

Can you also seed numpy?

@benedekrozemberczki
Copy link
Owner

Sorry, could you please reply @wendywangwwt ? Closing for now.

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

No branches or pull requests

2 participants