PyTorch torch.cos 関数
torch.cosは PyTorch で要素ごとのコサインを計算するための関数です。
関数定義
torch.cos(input, out=None)
使用例
実例
import torch
x = torch.tensor([0, torch.pi/2, torch.pi, 3*torch.pi/2])
print(torch.cos(x))
x = torch.tensor([0, torch.pi/2, torch.pi, 3*torch.pi/2])
print(torch.cos(x))
出力結果は次のとおりです:
tensor([ 1.0000e+00, -8.7423e-08, -1.0000e+00, -8.7423e-08])
その他の拡張
Pytorch torch リファレンスマニュアル