torch.spmm矩阵乘法
Example:
import torch
indices = torch.tensor([[0,1],
[0,1]])
values = torch.tensor([2,3])
shape = torch.Size((2,2))
s = torch.sparse.FloatTensor(indices,values,shape)
print(s)
d = torch.tensor([[1,2],
[3,4]])
print(d)
print(torch.spmm(s,d))
"""
tensor(indices=tensor([[0, 1],
[0, 1]]),
values=tensor([2, 3]),
size=(2, 2), nnz=2, layout=torch.sparse_coo)
tensor([[1, 2],
[3, 4]])
tensor([[ 2, 4],
[ 9, 12]])
"""
因上求缘,果上努力~~~~ 作者:图神经网络,转载请注明原文链接:https://www.cnblogs.com/BlairGrowing/p/16010041.html