PyTorch torch.sgn 関数


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

torch.sgnPyTorch において要素ごとに符号ベクトルを返す関数です。複素数に対しては単位複素数を返します。

関数定義

torch.sgn(input, out=None)

使用例

実例

import torch

# 要素ごとに符号ベクトルを返す
x = torch.tensor([-2.0, 0.0, 3.0])
result = torch.sgn(x)
print(result)

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

その他の拡張