python – Pytorch:稀疏矩阵乘法

鉴于:

self.A = torch.autograd.Variable(random_sparse(n = dim)) 
self.w = torch.autograd.Variable(torch.Tensor(np.random.normal(0,1,(dim,dim))))

目标1:

torch.mm(self.A, self.w)

目标2:

torch.spmm(self.A, self.w)

结果1:

TypeError: Type torch.sparse.FloatTensor doesn't implement stateless method addmm

结果2:

AttributeError: 'module' object has no attribute 'spmm'

我的PyTorch版本是0.1.12_2 – 非常感谢可能的解决方案.

最佳答案 spmm已经从火炬模块移动到torch.sparse模块.有关官方文档,请查看此
link.在torch.sparse模块的文档开头还有一个警告:

This API is currently experimental and may change in the near future.

点赞