Skip to content

naive_laplace_probabilistic_compression

Bases: naive_probabilistic_compression

A Laplace probabilistic compression class.

This class samples features using a Laplace distribution with a specified location (mean) and scale (spread).

Methods:

Name Description
__init__

Initializes the Laplace probabilistic compression function.

Parameters:

Name Type Description Default
name str

Name of the transformation. Defaults to 'naive_laplace_probabilistic_compression'.

'naive_laplace_probabilistic_compression'
loc float

Location parameter of the Laplace distribution (mean). Defaults to 0.0.

0.0
scale float

Scale parameter of the Laplace distribution (spread). Defaults to 1.0.

1.0
Source code in tinybig/compression/probabilistic_compression.py
class naive_laplace_probabilistic_compression(naive_probabilistic_compression):
    """
        A Laplace probabilistic compression class.

        This class samples features using a Laplace distribution with a specified location (mean) and scale (spread).

        Methods
        -------
        __init__(name='naive_laplace_probabilistic_compression', loc=0.0, scale=1.0, ...)
            Initializes the Laplace probabilistic compression function.

        Parameters
        ----------
        name : str, optional
            Name of the transformation. Defaults to 'naive_laplace_probabilistic_compression'.
        loc : float, optional
            Location parameter of the Laplace distribution (mean). Defaults to 0.0.
        scale : float, optional
            Scale parameter of the Laplace distribution (spread). Defaults to 1.0.
    """
    def __init__(self, name: str = 'naive_laplace_probabilistic_compression', loc: float = 0.0, scale: float = 1.0, *args, **kwargs):
        """
            Initializes the Laplace probabilistic compression function.

            Parameters
            ----------
            name : str, optional
                Name of the transformation. Defaults to 'naive_laplace_probabilistic_compression'.
            loc : float, optional
                Location parameter of the Laplace distribution (mean). Defaults to 0.0.
            scale : float, optional
                Scale parameter of the Laplace distribution (spread). Defaults to 1.0.
        """
        distribution_function = torch.distributions.laplace.Laplace(torch.tensor([loc]), torch.tensor([scale]))
        super().__init__(name=name, distribution_function=distribution_function, *args, **kwargs)

__init__(name='naive_laplace_probabilistic_compression', loc=0.0, scale=1.0, *args, **kwargs)

Initializes the Laplace probabilistic compression function.

Parameters:

Name Type Description Default
name str

Name of the transformation. Defaults to 'naive_laplace_probabilistic_compression'.

'naive_laplace_probabilistic_compression'
loc float

Location parameter of the Laplace distribution (mean). Defaults to 0.0.

0.0
scale float

Scale parameter of the Laplace distribution (spread). Defaults to 1.0.

1.0
Source code in tinybig/compression/probabilistic_compression.py
def __init__(self, name: str = 'naive_laplace_probabilistic_compression', loc: float = 0.0, scale: float = 1.0, *args, **kwargs):
    """
        Initializes the Laplace probabilistic compression function.

        Parameters
        ----------
        name : str, optional
            Name of the transformation. Defaults to 'naive_laplace_probabilistic_compression'.
        loc : float, optional
            Location parameter of the Laplace distribution (mean). Defaults to 0.0.
        scale : float, optional
            Scale parameter of the Laplace distribution (spread). Defaults to 1.0.
    """
    distribution_function = torch.distributions.laplace.Laplace(torch.tensor([loc]), torch.tensor([scale]))
    super().__init__(name=name, distribution_function=distribution_function, *args, **kwargs)