values =X_train.data
indices = np.vstack((X_train.row, X_train.col))
i = torch.LongTensor(indices)
v = torch.FloatTensor(values)
shape = X_train.shape
X_train=torch.sparse.FloatTensor(i, v, torch.Size(shape))
注:
转换为scipy.sparse:.tocoo()
即可
2024-03-01 09:29:52
values =X_train.data
indices = np.vstack((X_train.row, X_train.col))
i = torch.LongTensor(indices)
v = torch.FloatTensor(values)
shape = X_train.shape
X_train=torch.sparse.FloatTensor(i, v, torch.Size(shape))
注:
转换为scipy.sparse:.tocoo()
即可