reciprocal_compression
Bases: reciprocal_expansion
The reciprocal data compression function.
It performs the reciprocal compression of the input vector, and returns the compression result. The class inherits from the reciprocal_expansion class, which inherits from the base data transformation class.
...
Notes
For input vector \(\mathbf{x} \in R^m\), its reciprocal compression will be $$ \begin{equation} \kappa(\mathbf{x}) = \frac{1}{\mathbf{x}} \in R^d \end{equation} $$ where \(d = m\).
By default, the input and output can also be processed with the optional pre- or post-processing functions in the reciprocal compression function.
Specifically, for very small positive and negative small values that are close to zero, the reciprocal compression function will replace them with very small numbers \(10^{-6}\) and \(-10^{-6}\), respectively. In the current implementation, the input values in the range \([0, 10^{-6}]\) are replaced with \(10^{-6}\), and values in the range \([-10^{-6}, 0)\) are replaced with \(-10^{-6}\).
Attributes:
Name | Type | Description |
---|---|---|
name |
str, default = 'reciprocal_compression'
|
Name of the compression function. |
Methods:
Name | Description |
---|---|
__init__ |
It performs the initialization of the compression function. |
calculate_D |
It calculates the compression space dimension d based on the input dimension parameter m. |
forward |
It implements the abstract forward method declared in the base compression class. |
Source code in tinybig/compression/basic_compression.py
__init__(name='reciprocal_compression', *args, **kwargs)
The initialization method of the reciprocal compression function.
It initializes a reciprocal compression object based on the input function name. This method will also call the initialization method of the base class as well.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
The name of the reciprocal compression function. |
'reciprocal_compression'
|
Returns:
Type | Description |
---|---|
transformation
|
The reciprocal compression function. |