ChandlerBang / GCond

[ICLR'22] [KDD'22] [IJCAI'24] Implementation of "Graph Condensation for Graph Neural Networks"
https://www.cs.emory.edu/~wjin30/files/GCond.pdf
109 stars 15 forks source link

Runtime error:expect scalar type Long but found Int #1

Closed HunterLep closed 1 year ago

HunterLep commented 1 year ago

I've been trying reproducing the performance of your paper and this runtime error keeps popping up.After a brief look,I think Line 183 in utils.py should turn "batch" into a LongTensor type.I managed to fix this problem and reproduced the performance.I wonder if you could check if I'm right so that I can move on to other issues.

ChandlerBang commented 1 year ago

Hi! Thanks for the comment.

In line 183, batch = np.random.permutation(self.class_dict2[c])[:num]; it takes first num samples from the c-th class. I feel it should not throw such an error and I am interested in what command you used.

HunterLep commented 1 year ago

Hi!

Thanks for your reply.

I used the command in your readme python train_gcond_transduct.py --dataset cora --nlayers=2 --lr_feat=1e-4 --gpu_id=0 --lr_adj=1e-4 --r=0.5

Here's the full error message,just for your information;

Traceback (most recent call last):

  File "train_gcond_transduct.py", line 57, in <module>

    agent.train()

  File "F:\GCond-main\gcond_agent_transduct.py", line 198, in train

    c, adj, transductive=True, args=args)

  File "F:\GCond-main\utils.py", line 185, in retrieve_class_sampler

    out = self.samplers[c].sample(batch)

  File "D:\Anaconda\envs\gcond\lib\site-packages\torch_geometric\data\sampler.py", line 151, in sample

    adj_t, n_id = self.adj_t.sample_adj(n_id, size, replace=False)

  File "D:\Anaconda\envs\gcond\lib\site-packages\torch_sparse\sample.py", line 31, in sample_adj

    rowptr, col, subset, num_neighbors, replace)

RuntimeError: expected scalar type Long but found Int

I made a change in line 183 with "batch" just to see if it would make any difference and it did.

ChandlerBang commented 1 year ago

I just tried running the command and it worked fine to me. I guess it is due to the version of PyG (mine is for linux). But I'm glad that you figured out a solution.

HunterLep commented 1 year ago

That makes sense.I'm using the windows version of PyG.Anyway thanks for your time.