TUTORIALAI 与数据科学FETCHED

PyTorch torch.dot 函数

PyTorch torch.dot 函数 Pytorch torch 参考手册 torch.dot 是 PyTorch 中用于计算两个向量点积的函数。 函数定义 torch.dot(input, other, out) 使用示例 实例 [mycode4 type='python'] import torch a = torch.tensor([1, 2, 3]) b = torch.tensor..

更新于 2026/7/16

教程详情页默认 noindex。

PyTorch torch.dot 函数


Pytorch torch 参考手册 Pytorch torch 参考手册

torch.dot 是 PyTorch 中用于计算两个向量点积的函数。

函数定义

torch.dot(input, other, out)

使用示例

实例

import torch

a = torch.tensor([1, 2, 3])
b = torch.tensor([4, 5, 6])

# 点积: 1*4 + 2*5 + 3*6 = 32
result = torch.dot(a, b)

print(result)

输出结果为:

tensor(32)

Pytorch torch 参考手册 Pytorch torch 参考手册