PyTorch torch.fix 関数
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.])
# 整数部分を取得する例
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 リファレンスマニュアル