r-gcn icon indicating copy to clipboard operation
r-gcn copied to clipboard

error in DataSampler.py

Open liuqk3 opened this issue 5 years ago • 4 comments

There is an error: idx = torch.LongTensor([A.tocoo().row, A.tocoo().col]) RuntimeError: sizes must be non-negative

in the following function.

def get_torch_sparse_matrix(A, dev):
    '''
    A : list of sparse adjacency matrices
    '''
    idx = torch.LongTensor([A.tocoo().row, A.tocoo().col])
    dat = torch.FloatTensor(A.tocoo().data)
return torch.sparse.FloatTensor(idx, dat, torch.Size([A.shape[0], A.shape[1]])).to(device=dev)

can you fix it ?

liuqk3 avatar Mar 28 '19 11:03 liuqk3

Could you tell me on which dataset you are getting this error? And possibly a way for me to reproduce this?

Note that I have developed this for pytorch version 1.0.0. In the older versions, a zero in size of a tensor throws this error. While this should not ideally be happening at all, maybe check the argument A for this.

kkteru avatar Mar 28 '19 20:03 kkteru

Thanks for your reply. I run this code with PyTorch 0.4.1. Maybe an update of PyTorch can fix this.

liuqk3 avatar Mar 29 '19 02:03 liuqk3

No problem. Let me know if it doesn't.

kkteru avatar Mar 29 '19 04:03 kkteru

@tesseract28
Now the code can run successfully. I trained the model for 30 epochs, and the other settings remain unchanged. However, the performance is:

hit@10: 0.08404182546662758,
mr: 2165.282761653474
mrr: 0.07395832514849997

Can you tell me how you trained your model ?

liuqk3 avatar Mar 29 '19 11:03 liuqk3