PyTorch torch.is_floating_point 関数


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

torch.is_floating_pointPyTorch において、テンソルのデータ型が浮動小数点型かどうかを確認するための関数です。

関数定義

torch.is_floating_point(input)

使用例

実例

import torch

# 浮動小数点数テンソル
x = torch.tensor([1.0, 2.0, 3.0])
print("浮動小数点数:", torch.is_floating_point(x))

# 整数テンソル
y = torch.tensor([1, 2, 3])
print("整数:", torch.is_floating_point(y))

出力結果は次のとおりです:

浮点数: True
整数: False

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

その他の拡張