divelab / DIG

A library for graph deep learning research
https://diveintographs.readthedocs.io/
GNU General Public License v3.0
1.82k stars 281 forks source link

Unsupervised Learning (MVRGL) #182

Open MarkSttc opened 1 year ago

MarkSttc commented 1 year ago

Thank you so much for the amazing work. This really help me a lot throughout my research period.

However, May I know how to train the model without using the eval method? I just want the trained model from contrastive lost only. and later will be visualized in the TSNE. Therefore, accuracy doesn't matter to me. Currently, I'm working with my own dataset for graph classification as downstream task.

Initially, I have tried using mvgrl.train() but seems like there is no learning progress and it gave me the error as well. Please find the attaches below for more clarification.

image

image image

ycremar commented 1 year ago

Hi @MarkSttc , thank you for your interest and question. You can definitely train encoders in contrastive manner for other tasks.

The simplest way is that you normally do the evaluation process. After the training and evaluation is finished, you can just take encoder_adj and encoder_diff to perform any other tasks since their parameters are already updated.

If you want to skip the evaluation, you can also do

list(mvgrl.train(encoder, dataloader, optimizer, epochs))
encoder_adj.eval()
encoder_diff.eval()
with torch.no_grad():
    embeds_adj = encoder_adj(data)
    embeds_diff = encoder_diff(data)