Shen-Lab / GraphCL

[NeurIPS 2020] "Graph Contrastive Learning with Augmentations" by Yuning You, Tianlong Chen, Yongduo Sui, Ting Chen, Zhangyang Wang, Yang Shen
MIT License
547 stars 103 forks source link

Bugs report for unsupervised_TU #8

Closed ha-lins closed 3 years ago

ha-lins commented 3 years ago

Hi @yyou1996,

When I ran the unsupervised experiments for Biochemical Molecules datasets, I met the bug of size mismatch as follows:

python gsimclr.py --DS MUTAG --lr 0.01 --local --num-gc-layers 3 --aug dnodes --seed 0
188 7

lr: 0.01 num_features: 7 hidden_dim: 32 num_gc_layers: 3

Traceback (most recent call last): File "gsimclr.py", line 190, in emb, y = model.encoder.get_embeddings(dataloader_eval) File "/data3/linshuai/GraphCL/unsupervised_TU/gin.py", line 87, in getembeddings x, = self.forward(x, edge_index, batch) File "/data3/linshuai/GraphCL/unsupervised_TU/gin.py", line 61, in forward x = F.relu(self.convs[i](x, edge_index)) File "/data/linshuai/anaconda3/envs/mvgrl/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, kwargs) File "/data/linshuai/anaconda3/envs/mvgrl/lib/python3.6/site-packages/torch_geometric/nn/conv/gin_conv.py", line 69, in forward return self.nn(out) File "/data/linshuai/anaconda3/envs/mvgrl/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, *kwargs) File "/data/linshuai/anaconda3/envs/mvgrl/lib/python3.6/site-packages/torch/nn/modules/container.py", line 100, in forward input = module(input) File "/data/linshuai/anaconda3/envs/mvgrl/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(input, kwargs) File "/data/linshuai/anaconda3/envs/mvgrl/lib/python3.6/site-packages/torch/nn/modules/linear.py", line 87, in forward return F.linear(input, self.weight, self.bias) File "/data/linshuai/anaconda3/envs/mvgrl/lib/python3.6/site-packages/torch/nn/functional.py", line 1370, in linear ret = torch.addmm(bias, input, weight.t()) RuntimeError: size mismatch, m1: [2258 x 1], m2: [7 x 32] at /pytorch/aten/src/THC/generic/THCTensorMathBlas.cu:290

It seems that the aug is 'none' here in the testing and thus the second dim of data_aug.x was set to 1. So I removed this line and the bug was gone.

What's your opinion about the issue and solution? Thanks in advance!

yyou1996 commented 3 years ago

Hi @ha-lins,

Thanks for your question. In evaluation data_aug should not be called since get_embeddings function only operate on data of the returned data, data_aug from data_loader (see https://github.com/Shen-Lab/GraphCL/blob/4ca7742ea6a3411357c2e5da4dcfdbfab581d5f8/unsupervised_TU/gin.py#L71 in get_embeddings function), thus the operation in https://github.com/Shen-Lab/GraphCL/blob/master/unsupervised_TU/aug.py#L247 should not affect. Did you check the operated object in get_embeddings function?

ha-lins commented 3 years ago

Yes, thanks for your response!

It works well now and the problem was from my incorrect modification.