index_to_value

torchhd.index_to_value(input: LongTensor, index_length: int, out_min: float, out_max: float) FloatTensor[source]

Maps the input index range to a real value range.

Note

Input values greater or equal to index_length are not clamped.

Parameters:
  • input (torch.LongTensor) – The values to map

  • index_length (int) – The length of the input index, i.e., one more than the maximum index

  • out_min (float) – the minimum value of the output range

  • out_max (float) – the maximum value of the output range

Shapes:
  • Input: \((*)\)

  • Output: \((*)\)

Examples:

>>> x = torch.randint(0, 10, (2, 3))
>>> x
tensor([[3, 0, 3],
        [2, 5, 5]])
>>> functional.index_to_value(x, 10, 0, 1)
tensor([[0.3333, 0.0000, 0.3333],
        [0.2222, 0.5556, 0.5556]])