Spec-Zone.ru › PyTorch 2

torch.frexp

torch.frexp(input, *, out=None) -> (Tensor mantissa, Tensor exponent)

Разделяет input на мантиссу и экспоненту, так что input=мантисса×2экспонента\text{input} = \text{мантисса} \times 2^{\text{экспонента}}.

Диапазон мантиссы — открытый интервал (-1, 1).

Поддерживает входные данные типа float.

Параметры

input (Tensor) – входной тензор

Ключевые аргументы

out (tuple, опционально) – выходные тензоры

Пример:

>>> x = torch.arange(9.)
>>> mantissa, exponent = torch.frexp(x)
>>> mantissa
tensor([0.0000, 0.5000, 0.5000, 0.7500, 0.5000, 0.6250, 0.7500, 0.8750, 0.5000])
>>> exponent
tensor([0, 1, 2, 2, 3, 3, 3, 3, 4], dtype=torch.int32)
>>> torch.ldexp(mantissa, exponent)
tensor([0., 1., 2., 3., 4., 5., 6., 7., 8.])

© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/2.1/generated/torch.frexp.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API