clip_to_normalised#

clip_to_normalised(weights, epsilon=3e-05, very_small_subtract=1e-05)[source]#

If the sum of the weights are not exactly 1, then decrease the largest member to make the same sum 1 precise.

Parameters:
  • weights (Dict[int, float]) –

    Weights where the sum is almost 1.

    A dict of pair id -> weight mappings.

  • epsilon – We check that our floating point sum is within this value.

  • very_small_subtract – Use this value to substract so we never go above 1, always under.

Returns:

A dict of pair id -> fixed weight mappings.

New weights where the largest weight have been clipped to make exactly 1

Return type:

Dict[int, float]