Shirley-Ying / SNPM

AAAI 23
MIT License
14 stars 4 forks source link

RuntimeError #3

Open kayjayk opened 8 months ago

kayjayk commented 8 months ago

@Shirley-YFY Hello, My name is kijun. I read your paper interesting. And thank you for releasing the relevant code. I found an error while running the code as you mentioned in README.

when I run the train_copy.py in the 6th, I got an error like below.

parse with gowalla default settings
use device: cuda:0
log_file: data/Thu Feb 22 08:44:07 2024.txt
loc_temporal_file: data/coo_loc2loc_6_3_nowaste.npz
interact_file: KGE/gowalla_scheme2_transe_user-loc_100.pkl
1.0
1.0
W in AXW: False
GCN in user: False
spatial graph: False
Active POI number:106994
Active User number:7768
Total Checkins number:1823598
Split.TRAIN load 7768 users with max_seq_count 72 batches: 345
Split.TEST load 7768 users with max_seq_count 18 batches: 76
Training:   0%|                                                                                           | 0/2400 [00:00<?, ?it/s]Traceback (most recent call last):
  File "/home/jovyan/train_copy.py", line 110, in <module>
    loss = model_pre(x,y)
  File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/jovyan/network_dgraph.py", line 204, in forward
    vec_output=self.vec_embedding_layer1(self.vecs_use)
  File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/linear.py", line 114, in forward
    return F.linear(input, self.weight, self.bias)
RuntimeError: mat1 and mat2 shapes cannot be multiplied (106994x3 and 20x20)

Would you please help me to solve this?

Shirley-Ying commented 8 months ago

I think you might have made some changes to the source code that led to the error. I suggest you use debug mode to check the dimension of self.vecs_use in the line vec_output=self.vec_embedding_layer1(self.vecs_use). In the original code, the dimension of self.vecs_use should not be "106994 x 3" as mentioned in the error message you provided. My guess is that during the feature vector stage, you might have kept only three feature vectors, resulting in each poi point's feature representation in WORK/vecs_use.npy being only 3-dimensional.

Due to various reasons, the source code of this project has not been well organized. Therefore, modifying parameters in earlier steps may lead to subsequent processes encountering dimension mismatches. Alternatively, I suspect you might be using a different dataset. During the feature value filtering stage, it seems that twenty valid feature values (>1e-5) weren't successfully retained.

This process occurs in line 126 of the spectral_clustering.py file, specifically at the condition while (vals[j]) < 1e-5:. You can verify this by checking the number of elements contained in the subsequent index.

Good luck to you.