snap-stanford / neural-subgraph-learning-GNN

329 stars 64 forks source link

Accessing Embedded Space & Decoder Inquiry #20

Closed jessxphil closed 3 years ago

jessxphil commented 3 years ago

Thank you in advance for your help!

I don't want to use up too much of your time so I'll try to write a few concise questions.

  1. I ran the 'Train' code but the preloaded model didn't update according to the new weights/bias from my personal data. How can I make sure I'm training the model according to my data?

  2. I'm looking to extract the embedded space to use as input features for another model. Just to confirm, is that embedded space stored in the 'pred' variable from the Train.py? [Note: pred = model(emb_as, emb_bs) #Line 131 or pred = pred.argmax(dim=-1) #Line 148]

ALSO There's another embedded space variable from the Analyze_Embedding.pybd. [Note: embs = model.emb_model(batch).detach().cpu().numpy() #Line 79]

  1. Can I use the 'Decoder' on the extracted embedded space to retrieve my graph data?
qema commented 3 years ago

Thanks for your interest!

  1. See the experimental branch (https://github.com/snap-stanford/neural-subgraph-learning-GNN/issues/16#issuecomment-860029505) and the suggested workaround in that thread for a way to train on custom datasets while making use of node features.
  2. To get a graph's embedding, use embs = model.emb_model(batch).detach().cpu().numpy(). See https://github.com/snap-stanford/neural-subgraph-learning-GNN/blob/4d074cbc0fa9d81defef746302e62b1b9a97791d/subgraph_matching/alignment.py#L54 for an example.
  3. The subgraph mining component only finds frequent graphs that are contained in a given region of the embedding space; in general it's quite tricky to decode from an arbitrary point in the embedding space back to a graph, since most points in the space might not exactly correspond to any graph. If possible, it's usually best to maintain both a graph and its embedding together.
jessxphil commented 3 years ago

Thank you for the clear explanation! I really appreciate your help!