Skip to content

dog_wavelet

Bases: discrete_wavelet

Difference of Gaussians (DoG) wavelet implementation.

Source code in tinybig/koala/signal_processing/wavelet.py
class dog_wavelet(discrete_wavelet):
    """
    Difference of Gaussians (DoG) wavelet implementation.
    """
    def __init__(self, sigma_1: float = 1.0, sigma_2: float = 2.0, name: str = 'difference_of_Gaussians_wavelet', *args, **kwargs):
        """
        Initialize the DoG wavelet.

        Parameters
        ----------
        sigma_1 : float, optional
            Standard deviation of the first Gaussian. Must be >= 0. Default is 1.0.
        sigma_2 : float, optional
            Standard deviation of the second Gaussian. Must be >= 0. Default is 2.0.
        name : str, optional
            Name of the wavelet. Default is 'difference_of_Gaussians_wavelet'.
        *args, **kwargs
            Additional parameters.
        """
        super().__init__(name=name, *args, **kwargs)
        if sigma_1 < 0.0 or sigma_2 < 0.0:
            raise ValueError('sigma_1 and sigma_2 must be >= 0.')
        self.sigma_1 = sigma_1
        self.sigma_2 = sigma_2

    def psi(self, tau: torch.Tensor):
        """
        Define the DoG wavelet function.

        Parameters
        ----------
        tau : torch.Tensor
            Transformed input values.

        Returns
        -------
        torch.Tensor
            Wavelet values for the input.
        """
        gauss1 = torch.exp(-0.5 * (tau / self.sigma_1) ** 2) / (math.sqrt(2 * torch.pi * self.sigma_1 ** 2))
        gauss2 = torch.exp(-0.5 * (tau / self.sigma_2) ** 2) / (math.sqrt(2 * torch.pi * self.sigma_2 ** 2))
        return gauss1 - gauss2

__init__(sigma_1=1.0, sigma_2=2.0, name='difference_of_Gaussians_wavelet', *args, **kwargs)

Initialize the DoG wavelet.

Parameters:

Name Type Description Default
sigma_1 float

Standard deviation of the first Gaussian. Must be >= 0. Default is 1.0.

1.0
sigma_2 float

Standard deviation of the second Gaussian. Must be >= 0. Default is 2.0.

2.0
name str

Name of the wavelet. Default is 'difference_of_Gaussians_wavelet'.

'difference_of_Gaussians_wavelet'
*args

Additional parameters.

()
**kwargs

Additional parameters.

()
Source code in tinybig/koala/signal_processing/wavelet.py
def __init__(self, sigma_1: float = 1.0, sigma_2: float = 2.0, name: str = 'difference_of_Gaussians_wavelet', *args, **kwargs):
    """
    Initialize the DoG wavelet.

    Parameters
    ----------
    sigma_1 : float, optional
        Standard deviation of the first Gaussian. Must be >= 0. Default is 1.0.
    sigma_2 : float, optional
        Standard deviation of the second Gaussian. Must be >= 0. Default is 2.0.
    name : str, optional
        Name of the wavelet. Default is 'difference_of_Gaussians_wavelet'.
    *args, **kwargs
        Additional parameters.
    """
    super().__init__(name=name, *args, **kwargs)
    if sigma_1 < 0.0 or sigma_2 < 0.0:
        raise ValueError('sigma_1 and sigma_2 must be >= 0.')
    self.sigma_1 = sigma_1
    self.sigma_2 = sigma_2

psi(tau)

Define the DoG wavelet function.

Parameters:

Name Type Description Default
tau Tensor

Transformed input values.

required

Returns:

Type Description
Tensor

Wavelet values for the input.

Source code in tinybig/koala/signal_processing/wavelet.py
def psi(self, tau: torch.Tensor):
    """
    Define the DoG wavelet function.

    Parameters
    ----------
    tau : torch.Tensor
        Transformed input values.

    Returns
    -------
    torch.Tensor
        Wavelet values for the input.
    """
    gauss1 = torch.exp(-0.5 * (tau / self.sigma_1) ** 2) / (math.sqrt(2 * torch.pi * self.sigma_1 ** 2))
    gauss2 = torch.exp(-0.5 * (tau / self.sigma_2) ** 2) / (math.sqrt(2 * torch.pi * self.sigma_2 ** 2))
    return gauss1 - gauss2