xiaoqing-ing

一、点积

概念:相同位置的按元素乘积的和,可以通过dot()函数调用

y = torch.ones(4, dtype=torch.float32)
print(y)
print(x)

# 点积:相同位置的按元素乘积的和
print(torch.dot(x, y))

# 可以通过执行元素乘法,然后进行求和来表示两个向量的点积
print(x*y)
print((x*y).sum())

#输出结果

tensor([1., 1., 1., 1.])
tensor([0., 1., 2., 3.])
tensor(6.)
tensor([0., 1., 2., 3.])
tensor(6.)

  

二、矩阵-向量积

1、调用mv函数求矩阵向量积

2、矩阵向量积 

分类:

技术点:

相关文章: