Skip to content

identity_remainder

Bases: remainder

The identity remainder function.

It calculates the identity remainder, and returns input data as the remainders. This class inherits from the base remainder class (i.e., the remainder class in the module directory).

...

Notes

The identity remainder function \(\pi: {R}^m \to {R}^n\) just projects all inputs to the inputs themselves, i.e., $$ \begin{equation} \pi(\mathbf{x}) = \mathbf{x} \in {R}^n, \end{equation} $$ where the input and output dimensions need to be equal, i.e., \(m = n\).

By default, the remainder term will also be processed with the optional activation functions.

Attributes:

Name Type Description
name str, default = 'identity_remainder'

Name of the identity remainder function.

Methods:

Name Description
__init__

It initializes the identity remainder function.

forward

It implements the abstract forward method declared in the base remainder class.

Source code in tinybig/remainder/basic_remainder.py
class identity_remainder(remainder):
    r"""
    The identity remainder function.

    It calculates the identity remainder, and returns input data as the remainders.
    This class inherits from the base remainder class (i.e., the remainder class in the module directory).

    ...

    Notes
    ----------
    The identity remainder function $\pi: {R}^m \to {R}^n$ just projects all inputs to the inputs themselves, i.e.,
    $$
        \begin{equation}
            \pi(\mathbf{x}) = \mathbf{x} \in {R}^n,
        \end{equation}
    $$
    where the input and output dimensions need to be equal, i.e., $m = n$.

    By default, the remainder term will also be processed with the optional activation functions.

    Attributes
    ----------
    name: str, default = 'identity_remainder'
        Name of the identity remainder function.

    Methods
    ----------
    __init__
        It initializes the identity remainder function.

    forward
        It implements the abstract forward method declared in the base remainder class.
    """
    def __init__(self, name='identity_remainder', *args, **kwargs):
        """
        The initialization method of the identity remainder function.

        It initializes an identity remainder function object.
        This method will also call the initialization method of the base class as well.

        Parameters
        ----------
        name: str, default = 'identity_remainder'
            Name of the identity remainder function.

        Returns
        ----------
        remainder
            The identity remainder function object.
        """
        super().__init__(name=name, *args, **kwargs)

    def forward(self, x: torch.Tensor, device='cpu', *args, **kwargs):
        r"""
       The forward method of the identity remainder function.

       The identity remainder function $\pi: {R}^m \to {R}^n$ just projects all inputs to the inputs themselves, i.e.,
        $$
            \begin{equation}
                \pi(\mathbf{x}) = \mathbf{x} \in {R}^n,
            \end{equation}
        $$
        where the input and output dimensions need to be equal, i.e., $m = n$.

        By default, the remainder term will also be processed with the optional activation functions.

        Parameters
        ----------
        x: torch.Tensor
            The input data vector.
        device: str, default = 'cpu'
            Device to calculate the remainder function.

        Returns
        ----------
        torch.Tensor
            The remainder term of length $n$.
        """
        return self.activation(x=x, device=device)

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

The initialization method of the identity remainder function.

It initializes an identity remainder function object. This method will also call the initialization method of the base class as well.

Parameters:

Name Type Description Default
name

Name of the identity remainder function.

'identity_remainder'

Returns:

Type Description
remainder

The identity remainder function object.

Source code in tinybig/remainder/basic_remainder.py
def __init__(self, name='identity_remainder', *args, **kwargs):
    """
    The initialization method of the identity remainder function.

    It initializes an identity remainder function object.
    This method will also call the initialization method of the base class as well.

    Parameters
    ----------
    name: str, default = 'identity_remainder'
        Name of the identity remainder function.

    Returns
    ----------
    remainder
        The identity remainder function object.
    """
    super().__init__(name=name, *args, **kwargs)

forward(x, device='cpu', *args, **kwargs)

The forward method of the identity remainder function.

The identity remainder function \(\pi: {R}^m \to {R}^n\) just projects all inputs to the inputs themselves, i.e., $$ \begin{equation} \pi(\mathbf{x}) = \mathbf{x} \in {R}^n, \end{equation} $$ where the input and output dimensions need to be equal, i.e., \(m = n\).

By default, the remainder term will also be processed with the optional activation functions.

Parameters

x: torch.Tensor The input data vector. device: str, default = 'cpu' Device to calculate the remainder function.

Returns

torch.Tensor The remainder term of length \(n\).

Source code in tinybig/remainder/basic_remainder.py
def forward(self, x: torch.Tensor, device='cpu', *args, **kwargs):
    r"""
   The forward method of the identity remainder function.

   The identity remainder function $\pi: {R}^m \to {R}^n$ just projects all inputs to the inputs themselves, i.e.,
    $$
        \begin{equation}
            \pi(\mathbf{x}) = \mathbf{x} \in {R}^n,
        \end{equation}
    $$
    where the input and output dimensions need to be equal, i.e., $m = n$.

    By default, the remainder term will also be processed with the optional activation functions.

    Parameters
    ----------
    x: torch.Tensor
        The input data vector.
    device: str, default = 'cpu'
        Device to calculate the remainder function.

    Returns
    ----------
    torch.Tensor
        The remainder term of length $n$.
    """
    return self.activation(x=x, device=device)