map_range

torchhd.map_range(input: Tensor, in_min: float, in_max: float, out_min: float, out_max: float) Tensor[来源]

将输入的实数值范围映射到输出的实数值范围。

注意

超出最小-最大范围的输入值不会被限制。

Parameters:
  • 输入 (张量) – 要映射的值

  • in_min (float) – 输入范围的最小值

  • in_max (float) – 输入范围的最大值

  • out_min (float) – 输出范围的最小值

  • out_max (float) – 输出范围的最大值

Shapes:
  • 输入: \((*)\)

  • 输出: \((*)\)

示例:

>>> x = torch.rand(2, 3)
>>> x
tensor([[0.2211, 0.1291, 0.3081],
        [0.7654, 0.2155, 0.4381]])
>>> functional.map_range(x, 0, 1, -10, 10)
tensor([[-5.5781, -7.4176, -3.8374],
        [ 5.3082, -5.6906, -1.2383]])