Skip to content

Testing graph2vec with similarity of inferred embeddings. #163

Open
@nikosandriotis

Description

@nikosandriotis

Since there is no way of printing the loss function to understand why I am not getting expected results, I wanted to open this issue.

I am training graph2vec with 4000 random erdos_renyi graphs:

Graph2Vec generic example

graphs = []

Define ranges for n and p

n_range = range(400, 800, 50) # n from 400 to 800 in steps of 50
p_range = [round(p, 2) for p in list([i/100 for i in range(30, 71, 10)])] # p from 0.3 to 0.7

Create graphs

for _ in range(4000):
n = random.choice(n_range)
p = random.choice(p_range)
G = nx.erdos_renyi_graph(n, p)
graphs.append(G)

And training:

model = Graph2Vec(dimensions=1024, epochs=200)

Train the model

model.fit(graphs)

Save the full pipeline

os.makedirs("saved_model", exist_ok=True)
joblib.dump(model, "saved_model/graph2vec_diverseplus_pipeline_1024_200epochs_narrow.pkl")

similarity of generated embeddings

Then I am using the trained model to infer embeddings for 2 sets of similar structure graphs:

new_graphs_1 = [nx.erdos_renyi_graph(500, 0.6) for _ in range(10)]
new_graphs_2 = [nx.erdos_renyi_graph(500, 0.6) for _ in range(10)]

new_embeddings_1 = model.infer(new_graphs_1)
new_embeddings_2 = model.infer(new_graphs_2)

Shouldn't the similarity be very close of these 2 embeddings? Instead I get values of 0.6 similarity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions