PyTorch torch.fix 関数

PyTorch torch.fix 関数


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

torch.fixは PyTorch で要素ごとに整数部分(0 に向かって丸める)を取得する関数です。

関数定義

torch.fix(input, *, out=None)

使用例

例

import torch

# 整数部分を取得する例
x = torch.tensor([-1.5, -0.5, 0.5, 1.5, 2.7])
result = torch.fix(x)
print(result)  # tensor([-1., -0., 0., 1., 2.])

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

その他の拡張