Skip to content

random_matrix_adaption_parameterized_interdependence

Bases: parameterized_interdependence

A parameterized interdependence function using random matrix adaptation.

Notes

Formally, given a parameter vector \(\mathbf{w} \in R^l\) of length \(l\), we can partition it into two vectors \(\lambda_1\) and \(\lambda_2\). These two vectors will define two diagonal matrices \(\Lambda_1 = diag( \lambda_1) \in R^{m \times m}\) and \(\Lambda_2 = diag(\lambda_2) \in R^{r \times r}\).

These two sub-matrices will fabricate a parameter matrix of shape \(m \times m'\) as follows:

\[
    \begin{equation}
    \xi(\mathbf{w}) =  \Lambda_1 \mathbf{A} \Lambda_1 \mathbf{B}^\top \in R^{m \times m'},
    \end{equation}
\]

where matrices \(\mathbf{A} \in R^{m \times r}\) and \(\mathbf{B} \in R^{m' \times r}\) are randomly sampled from the Gaussian distribution \(\mathcal{N}(\mathbf{0}, \mathbf{I})\). The required length of vector \(\mathbf{w}\) is \(l_{\xi} = m + r\).

Attributes:

Name Type Description
r int

Rank of the random matrix approximation.

Methods:

Name Description
__init__

Initializes the random matrix adaptation parameterized interdependence function.

Source code in tinybig/interdependence/parameterized_interdependence.py
class random_matrix_adaption_parameterized_interdependence(parameterized_interdependence):
    r"""
        A parameterized interdependence function using random matrix adaptation.

        Notes
        ----------

        Formally, given a parameter vector $\mathbf{w} \in R^l$ of length $l$, we can partition it into two vectors $\lambda_1$ and $\lambda_2$.
        These two vectors will define two diagonal matrices $\Lambda_1 = diag( \lambda_1) \in R^{m \times m}$ and $\Lambda_2 = diag(\lambda_2) \in R^{r \times r}$.

        These two sub-matrices will fabricate a parameter matrix of shape $m \times m'$ as follows:

        $$
            \begin{equation}
            \xi(\mathbf{w}) =  \Lambda_1 \mathbf{A} \Lambda_1 \mathbf{B}^\top \in R^{m \times m'},
            \end{equation}
        $$

        where matrices $\mathbf{A} \in R^{m \times r}$ and $\mathbf{B} \in R^{m' \times r}$ are randomly sampled from the Gaussian distribution $\mathcal{N}(\mathbf{0}, \mathbf{I})$.
        The required length of vector $\mathbf{w}$ is $l_{\xi} = m + r$.


        Attributes
        ----------
        r : int
            Rank of the random matrix approximation.

        Methods
        -------
        __init__(...)
            Initializes the random matrix adaptation parameterized interdependence function.
    """
    def __init__(self, r: int = 2, name: str = 'random_matrix_adaption_parameterized_interdependence', *args, **kwargs):
        """
            Initializes the random matrix adaptation parameterized interdependence function.

            Parameters
            ----------
            r : int, optional
                Rank of the random matrix approximation. Defaults to 2.
            name : str, optional
                Name of the interdependence function. Defaults to 'random_matrix_adaption_parameterized_interdependence'.
            *args : tuple
                Additional positional arguments for the parent class.
            **kwargs : dict
                Additional keyword arguments for the parent class.
        """
        super().__init__(name=name, *args, **kwargs)
        self.r = r
        self.parameter_fabrication = random_matrix_adaption_reconciliation(r=self.r)

__init__(r=2, name='random_matrix_adaption_parameterized_interdependence', *args, **kwargs)

Initializes the random matrix adaptation parameterized interdependence function.

Parameters:

Name Type Description Default
r int

Rank of the random matrix approximation. Defaults to 2.

2
name str

Name of the interdependence function. Defaults to 'random_matrix_adaption_parameterized_interdependence'.

'random_matrix_adaption_parameterized_interdependence'
*args tuple

Additional positional arguments for the parent class.

()
**kwargs dict

Additional keyword arguments for the parent class.

{}
Source code in tinybig/interdependence/parameterized_interdependence.py
def __init__(self, r: int = 2, name: str = 'random_matrix_adaption_parameterized_interdependence', *args, **kwargs):
    """
        Initializes the random matrix adaptation parameterized interdependence function.

        Parameters
        ----------
        r : int, optional
            Rank of the random matrix approximation. Defaults to 2.
        name : str, optional
            Name of the interdependence function. Defaults to 'random_matrix_adaption_parameterized_interdependence'.
        *args : tuple
            Additional positional arguments for the parent class.
        **kwargs : dict
            Additional keyword arguments for the parent class.
    """
    super().__init__(name=name, *args, **kwargs)
    self.r = r
    self.parameter_fabrication = random_matrix_adaption_reconciliation(r=self.r)