kkteru / r-gcn

PyToch implementation of R-GCN model for node classification and link prediction
40 stars 2 forks source link

error in DataSampler.py #1

Open liuqk3 opened 5 years ago

liuqk3 commented 5 years ago

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 ?

kkteru commented 5 years ago

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.

liuqk3 commented 5 years ago

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

kkteru commented 5 years ago

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

liuqk3 commented 5 years ago

@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 ?