Skip to content

naive_gamma_probabilistic_compression

Bases: naive_probabilistic_compression

A Gamma probabilistic compression class.

This class samples features using a Gamma distribution with specified concentration (alpha) and rate (beta).

Methods:

Name Description
__init__

Initializes the Gamma probabilistic compression function.

Parameters:

Name Type Description Default
name str

Name of the transformation. Defaults to 'naive_gamma_probabilistic_compression'.

'naive_gamma_probabilistic_compression'
concentration float

Concentration parameter (alpha) of the Gamma distribution. Defaults to 1.0.

1.0
rate float

Rate parameter (beta) of the Gamma 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_gamma_probabilistic_compression(naive_probabilistic_compression):
    """
        A Gamma probabilistic compression class.

        This class samples features using a Gamma distribution with specified concentration (alpha) and rate (beta).

        Methods
        -------
        __init__(name='naive_gamma_probabilistic_compression', concentration=1.0, rate=1.0, ...)
            Initializes the Gamma probabilistic compression function.

        Parameters
        ----------
        name : str, optional
            Name of the transformation. Defaults to 'naive_gamma_probabilistic_compression'.
        concentration : float, optional
            Concentration parameter (alpha) of the Gamma distribution. Defaults to 1.0.
        rate : float, optional
            Rate parameter (beta) of the Gamma 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_gamma_probabilistic_compression', concentration: float = 1.0, rate: float = 1.0, require_normalization: bool = True, *args, **kwargs):
        """
            Initializes the Gamma probabilistic compression function.

            Parameters
            ----------
            name : str, optional
                Name of the transformation. Defaults to 'naive_gamma_probabilistic_compression'.
            concentration : float, optional
                Concentration parameter (alpha) of the Gamma distribution. Defaults to 1.0.
            rate : float, optional
                Rate parameter (beta) of the Gamma distribution. Defaults to 1.0.
            require_normalization : bool, optional
                If True, normalizes the input tensor before sampling. Defaults to True.
        """
        distribution_function = torch.distributions.gamma.Gamma(torch.tensor([concentration]), torch.tensor([rate]))
        super().__init__(name=name, distribution_function=distribution_function, require_normalization=True, *args, **kwargs)

__init__(name='naive_gamma_probabilistic_compression', concentration=1.0, rate=1.0, require_normalization=True, *args, **kwargs)

Initializes the Gamma probabilistic compression function.

Parameters:

Name Type Description Default
name str

Name of the transformation. Defaults to 'naive_gamma_probabilistic_compression'.

'naive_gamma_probabilistic_compression'
concentration float

Concentration parameter (alpha) of the Gamma distribution. Defaults to 1.0.

1.0
rate float

Rate parameter (beta) of the Gamma 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_gamma_probabilistic_compression', concentration: float = 1.0, rate: float = 1.0, require_normalization: bool = True, *args, **kwargs):
    """
        Initializes the Gamma probabilistic compression function.

        Parameters
        ----------
        name : str, optional
            Name of the transformation. Defaults to 'naive_gamma_probabilistic_compression'.
        concentration : float, optional
            Concentration parameter (alpha) of the Gamma distribution. Defaults to 1.0.
        rate : float, optional
            Rate parameter (beta) of the Gamma distribution. Defaults to 1.0.
        require_normalization : bool, optional
            If True, normalizes the input tensor before sampling. Defaults to True.
    """
    distribution_function = torch.distributions.gamma.Gamma(torch.tensor([concentration]), torch.tensor([rate]))
    super().__init__(name=name, distribution_function=distribution_function, require_normalization=True, *args, **kwargs)