Skip to content

naive_uniform_probabilistic_compression

Bases: naive_probabilistic_compression

A uniform probabilistic compression class.

This class samples features using a uniform distribution between specified lower and upper bounds.

Methods:

Name Description
__init__

Initializes the uniform probabilistic compression function.

Parameters:

Name Type Description Default
name str

Name of the transformation. Defaults to 'naive_uniform_probabilistic_compression'.

'naive_normal_probabilistic_compression'
low float

Lower bound of the uniform distribution. Defaults to 0.0.

0.0
high float

Upper bound of the uniform distribution. Defaults to 1.0.

1.0
require_normalization bool

If True, normalizes the input tensor before sampling. Defaults to True.

True
Source code in tinybig/compression/probabilistic_compression.py
class naive_uniform_probabilistic_compression(naive_probabilistic_compression):
    """
        A uniform probabilistic compression class.

        This class samples features using a uniform distribution between specified lower and upper bounds.

        Methods
        -------
        __init__(name='naive_uniform_probabilistic_compression', low=0.0, high=1.0, ...)
            Initializes the uniform probabilistic compression function.

        Parameters
        ----------
        name : str, optional
            Name of the transformation. Defaults to 'naive_uniform_probabilistic_compression'.
        low : float, optional
            Lower bound of the uniform distribution. Defaults to 0.0.
        high : float, optional
            Upper bound of the uniform distribution. Defaults to 1.0.
        require_normalization : bool, optional
            If True, normalizes the input tensor before sampling. Defaults to True.
    """
    def __init__(self, name: str = 'naive_normal_probabilistic_compression', low: float = 0.0, high: float = 1.0, require_normalization: bool = True, *args, **kwargs):
        """
            Initializes the uniform probabilistic compression function.

            Parameters
            ----------
            name : str, optional
                Name of the transformation. Defaults to 'naive_uniform_probabilistic_compression'.
            low : float, optional
                Lower bound of the uniform distribution. Defaults to 0.0.
            high : float, optional
                Upper bound of the uniform distribution. Defaults to 1.0.
            require_normalization : bool, optional
                If True, normalizes the input tensor before sampling. Defaults to True.
        """
        distribution_function = torch.distributions.uniform.Uniform(low=low, high=high)
        super().__init__(name=name, distribution_function=distribution_function, require_normalization=True, *args, **kwargs)

__init__(name='naive_normal_probabilistic_compression', low=0.0, high=1.0, require_normalization=True, *args, **kwargs)

Initializes the uniform probabilistic compression function.

Parameters:

Name Type Description Default
name str

Name of the transformation. Defaults to 'naive_uniform_probabilistic_compression'.

'naive_normal_probabilistic_compression'
low float

Lower bound of the uniform distribution. Defaults to 0.0.

0.0
high float

Upper bound of the uniform distribution. Defaults to 1.0.

1.0
require_normalization bool

If True, normalizes the input tensor before sampling. Defaults to True.

True
Source code in tinybig/compression/probabilistic_compression.py
def __init__(self, name: str = 'naive_normal_probabilistic_compression', low: float = 0.0, high: float = 1.0, require_normalization: bool = True, *args, **kwargs):
    """
        Initializes the uniform probabilistic compression function.

        Parameters
        ----------
        name : str, optional
            Name of the transformation. Defaults to 'naive_uniform_probabilistic_compression'.
        low : float, optional
            Lower bound of the uniform distribution. Defaults to 0.0.
        high : float, optional
            Upper bound of the uniform distribution. Defaults to 1.0.
        require_normalization : bool, optional
            If True, normalizes the input tensor before sampling. Defaults to True.
    """
    distribution_function = torch.distributions.uniform.Uniform(low=low, high=high)
    super().__init__(name=name, distribution_function=distribution_function, require_normalization=True, *args, **kwargs)