我写了一个基于循环和基于单和的矩阵乘法代码,我想执行。你能帮我检查它的正确性吗??
`
w = torch.randn((10,32,32))
x = torch.randn((3,32,32))
x_c = x.clone()
z = torch.zeros(x.shape)
for i in range(x.shape[0]):
dummy_x = torch.zeros((x.shape[1],w.shape[2]))
for j in range(w.shape[0]):
dummy_x += torch.matmul(x[i],w[j])
z[i]=dummy_x
result = torch.einsum("ijk,lkm->ijm",x_c,w)
# result = torch.einsum("iljm->ijm",result)
torch.eq(result,z)
字符串
我尝试了上面的代码,并使用torch.eq检查了是否相等,但答案是false
1条答案
按热度按时间deyfvvtc1#
字符串