PyTorch torch.dot 関数


Pytorch torch 参考手册Pytorch torch リファレンスマニュアル

torch.dotPyTorch において2つのベクトルのドット積を計算する関数です。

関数定義

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 リファレンスマニュアル

その他の拡張