Skip to content

harr_wavelet

Bases: discrete_wavelet

Haar wavelet implementation.

This wavelet is piecewise constant with values 1 or -1 over specific intervals.

Source code in tinybig/koala/signal_processing/wavelet.py
class harr_wavelet(discrete_wavelet):
    """
    Haar wavelet implementation.

    This wavelet is piecewise constant with values 1 or -1 over specific intervals.
    """
    def __init__(self, name: str = 'harr_wavelet', *args, **kwargs):
        """
        Initialize the Haar wavelet.

        Parameters
        ----------
        name : str, optional
            Name of the wavelet. Default is 'harr_wavelet'.
        *args, **kwargs
            Additional parameters.
        """
        super().__init__(name=name, *args, **kwargs)

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

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

        Returns
        -------
        torch.Tensor
            Wavelet values for the input.
        """
        result = torch.zeros_like(tau)
        result[(tau >= 0) & (tau < 0.5)] = 1
        result[(tau >= 0.5) & (tau < 1)] = -1
        return result

__init__(name='harr_wavelet', *args, **kwargs)

Initialize the Haar wavelet.

Parameters:

Name Type Description Default
name str

Name of the wavelet. Default is 'harr_wavelet'.

'harr_wavelet'
*args

Additional parameters.

()
**kwargs

Additional parameters.

()
Source code in tinybig/koala/signal_processing/wavelet.py
def __init__(self, name: str = 'harr_wavelet', *args, **kwargs):
    """
    Initialize the Haar wavelet.

    Parameters
    ----------
    name : str, optional
        Name of the wavelet. Default is 'harr_wavelet'.
    *args, **kwargs
        Additional parameters.
    """
    super().__init__(name=name, *args, **kwargs)

psi(tau)

Define the Haar 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 Haar wavelet function.

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

    Returns
    -------
    torch.Tensor
        Wavelet values for the input.
    """
    result = torch.zeros_like(tau)
    result[(tau >= 0) & (tau < 0.5)] = 1
    result[(tau >= 0.5) & (tau < 1)] = -1
    return result