PyTorch torch.sgn 関数
torch.sgnPyTorch において要素ごとに符号ベクトルを返す関数です。複素数に対しては単位複素数を返します。
関数定義
torch.sgn(input, out=None)
使用例
実例
import torch
# 要素ごとに符号ベクトルを返す
x = torch.tensor([-2.0, 0.0, 3.0])
result = torch.sgn(x)
print(result)
# 要素ごとに符号ベクトルを返す
x = torch.tensor([-2.0, 0.0, 3.0])
result = torch.sgn(x)
print(result)
その他の拡張
Pytorch torch リファレンスマニュアル