diff --git a/recbole/model/general_recommender/lightgcn.py b/recbole/model/general_recommender/lightgcn.py index 898b87011..78844ce34 100644 --- a/recbole/model/general_recommender/lightgcn.py +++ b/recbole/model/general_recommender/lightgcn.py @@ -100,7 +100,7 @@ def get_norm_adj_mat(self): L = sp.coo_matrix(L) row = L.row col = L.col - i = torch.LongTensor([row, col]) + i = torch.LongTensor(np.array([row, col])) data = torch.FloatTensor(L.data) SparseL = torch.sparse.FloatTensor(i, data, torch.Size(L.shape)) return SparseL diff --git a/recbole/model/general_recommender/ncl.py b/recbole/model/general_recommender/ncl.py index 5006b4c7f..1c78c5fcd 100644 --- a/recbole/model/general_recommender/ncl.py +++ b/recbole/model/general_recommender/ncl.py @@ -121,7 +121,7 @@ def get_norm_adj_mat(self): L = sp.coo_matrix(L) row = L.row col = L.col - i = torch.LongTensor([row, col]) + i = torch.LongTensor(np.array([row, col])) data = torch.FloatTensor(L.data) SparseL = torch.sparse.FloatTensor(i, data, torch.Size(L.shape)) return SparseL diff --git a/recbole/model/general_recommender/ngcf.py b/recbole/model/general_recommender/ngcf.py index cb82d87da..0080f32eb 100644 --- a/recbole/model/general_recommender/ngcf.py +++ b/recbole/model/general_recommender/ngcf.py @@ -103,7 +103,7 @@ def get_norm_adj_mat(self): L = sp.coo_matrix(L) row = L.row col = L.col - i = torch.LongTensor([row, col]) + i = torch.LongTensor(np.array([row, col])) data = torch.FloatTensor(L.data) SparseL = torch.sparse.FloatTensor(i, data, torch.Size(L.shape)) return SparseL diff --git a/recbole/model/general_recommender/sgl.py b/recbole/model/general_recommender/sgl.py index d88aec04f..453fefc1c 100644 --- a/recbole/model/general_recommender/sgl.py +++ b/recbole/model/general_recommender/sgl.py @@ -156,7 +156,7 @@ def csr2tensor(self, matrix: sp.csr_matrix): """ matrix = matrix.tocoo() x = torch.sparse.FloatTensor( - torch.LongTensor([matrix.row.tolist(), matrix.col.tolist()]), + torch.LongTensor(np.array([matrix.row, matrix.col])), torch.FloatTensor(matrix.data.astype(np.float32)), matrix.shape ).to(self.device) return x