Skip to content

enums

pytorch_lattice.enums

Enum Classes for PyTorch Lattice.

CategoricalCalibratorInit

Bases: _Enum

Type of kernel initialization to use for CategoricalCalibrator.

  • UNIFORM: initialize the kernel with uniformly distributed values. The sample range will be [output_min, output_max] if both are provided.
  • CONSTANT: initialize the kernel with a constant value for all categories. This value will be (output_min + output_max) / 2 if both are provided.
Source code in pytorch_lattice/enums.py
class CategoricalCalibratorInit(_Enum):
    """Type of kernel initialization to use for CategoricalCalibrator.

    - UNIFORM: initialize the kernel with uniformly distributed values. The sample range
        will be [`output_min`, `output_max`] if both are provided.
    - CONSTANT: initialize the kernel with a constant value for all categories. This
        value will be `(output_min + output_max) / 2` if both are provided.
    """

    UNIFORM = "uniform"
    CONSTANT = "constant"

InputKeypointsInit

Bases: _Enum

Type of initialization to use for NumericalCalibrator input keypoints.

  • QUANTILES: initialize the input keypoints such that each segment will see the same number of examples.
  • UNIFORM: initialize the input keypoints uniformly spaced in the feature range.
Source code in pytorch_lattice/enums.py
class InputKeypointsInit(_Enum):
    """Type of initialization to use for NumericalCalibrator input keypoints.

    - QUANTILES: initialize the input keypoints such that each segment will see the same
        number of examples.
    - UNIFORM: initialize the input keypoints uniformly spaced in the feature range.
    """

    QUANTILES = "quantiles"
    UNIFORM = "uniform"

InputKeypointsType

Bases: _Enum

The type of input keypoints to use.

  • FIXED: the input keypoints will be fixed during initialization.
  • LEARNED: the interior keypoints will learn through training to best fit the piecewise linear function.
Source code in pytorch_lattice/enums.py
class InputKeypointsType(_Enum):
    """The type of input keypoints to use.

    - FIXED: the input keypoints will be fixed during initialization.
    - LEARNED: the interior keypoints will learn through training to best fit the
        piecewise linear function.
    """

    FIXED = "fixed"
    LEARNED = "learned"

Interpolation

Bases: _Enum

Enum for interpolation method of lattice.

  • HYPERCUBE: n-dimensional hypercube surrounding input point(s).
  • SIMPLEX: uses only one of the n! simplices in the n-dim hypercube.
Source code in pytorch_lattice/enums.py
class Interpolation(_Enum):
    """Enum for interpolation method of lattice.

    - HYPERCUBE: n-dimensional hypercube surrounding input point(s).
    - SIMPLEX: uses only one of the n! simplices in the n-dim hypercube.
    """

    HYPERCUBE = "hypercube"
    SIMPLEX = "simplex"

LatticeInit

Bases: _Enum

Type of kernel initialization to use for CategoricalCalibrator.

  • LINEAR: initialize the kernel with weights represented by a linear function, conforming to monotonicity and unimodality constraints.
  • RANDOM_MONOTONIC: initialize the kernel with a uniformly random sampled lattice layer weight tensor, conforming to monotonicity and unimodality constraints.
Source code in pytorch_lattice/enums.py
class LatticeInit(_Enum):
    """Type of kernel initialization to use for CategoricalCalibrator.

    - LINEAR: initialize the kernel with weights represented by a linear function,
        conforming to monotonicity and unimodality constraints.
    - RANDOM_MONOTONIC: initialize the kernel with a uniformly random sampled
        lattice layer weight tensor, conforming to monotonicity and unimodality
        constraints.
    """

    LINEAR = "linear"
    RANDOM_MONOTONIC = "random_monotonic"

Monotonicity

Bases: _Enum

Type of monotonicity constraint.

  • INCREASING: increasing monotonicity i.e. increasing input increases output.
  • DECREASING: decreasing monotonicity i.e. increasing input decreases output.
Source code in pytorch_lattice/enums.py
class Monotonicity(_Enum):
    """Type of monotonicity constraint.

    - INCREASING: increasing monotonicity i.e. increasing input increases output.
    - DECREASING: decreasing monotonicity i.e. increasing input decreases output.
    """

    INCREASING = "increasing"
    DECREASING = "decreasing"

NumericalCalibratorInit

Bases: _Enum

Type of kernel initialization to use for NumericalCalibrator.

  • EQUAL_HEIGHTS: initialize the kernel such that all segments have the same height.
  • EQUAL_SLOPES: initialize the kernel such that all segments have the same slope.
Source code in pytorch_lattice/enums.py
class NumericalCalibratorInit(_Enum):
    """Type of kernel initialization to use for NumericalCalibrator.

    - EQUAL_HEIGHTS: initialize the kernel such that all segments have the same height.
    - EQUAL_SLOPES: initialize the kernel such that all segments have the same slope.
    """

    EQUAL_HEIGHTS = "equal_heights"
    EQUAL_SLOPES = "equal_slopes"