r-gcn
r-gcn copied to clipboard
error in DataSampler.py
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 ?
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.
Thanks for your reply. I run this code with PyTorch 0.4.1. Maybe an update of PyTorch can fix this.
No problem. Let me know if it doesn't.
@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 ?