Postprocessing Functions

Module: polygraphy.comparator

class PostprocessFunc[source]

Bases: object

Provides functions that can apply post-processing to IterationResult s.

static top_k(k=None, axis=None)[source]

Creates a function that applies a Top-K operation to a IterationResult. Top-K will return the indices of the k largest values in the array.

Parameters
  • k (Union[int, Tuple[int, int], Dict[str, int], Dict[str, Tuple[int, int]]]) – The number of indices to keep and optionally the axis on which to operate. If this exceeds the axis length, it will be clamped. This can be specified on a per-output basis by providing a dictionary. In that case, use an empty string (“”) as the key to specify default top-k value for outputs not explicitly listed. If no default is present, unspecified outputs will not be modified. Defaults to 10.

  • axis (int) – [Deprecated - specify axis in k parameter instead] The axis along which to apply the Top-K. Defaults to -1.

Returns

The top-k function.

Return type

Callable(IterationResult) -> IterationResult