reverse_bessel_expansion
Bases: transformation
The reverse bessel expansion function.
Applies reverse Bessel polynomial expansion to input data.
Notes
Formally, the reverse Bessel polynomials are an orthogonal sequence of polynomials with the following closed-form representation:
\[ \begin{equation} R_n(x) = x^n B_n \left( \frac{1}{x} \right) = \sum_{k=0}^n \frac{(n+k)!}{(n-k)! k!} \frac{x^{n-k}}{2^k} . \end{equation} \]
The reverse Bessel polynomials can be recursively defined as follows:
Base cases \(n=0\) and \(n=1\):
\[ \begin{equation} R_0(x) = 1 \text{, and } R_1(x) = x + 1. \end{equation} \]
High-order cases with degree \(n \ge 2\):
\[ \begin{equation} R_n(x) = (2n - 1) R_{n-1}(x) + x^2 R_{n-2}(x) \end{equation} \]
The reverse Bessel polynomials can be used to define the data expansion functions as follows:
\[ \begin{equation} \kappa(\mathbf{x} | d) = \left[ R_1(\mathbf{x}), R_2(\mathbf{x}), \cdots, R_d(\mathbf{x}) \right] \in R^D, \end{equation} \]
where the output dimension \(D = md\).
Attributes:
Name | Type | Description |
---|---|---|
d |
int
|
The degree of reverse Bessel polynomial expansion. |
Methods:
Name | Description |
---|---|
calculate_D |
Calculates the output dimension after expansion. |
forward |
Performs reverse Bessel polynomial expansion on the input tensor. |
Source code in tinybig/expansion/orthogonal_polynomial_expansion.py
748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 |
|
__init__(name='reverse_bessel_polynomial_expansion', d=2, *args, **kwargs)
Initializes the reverse Bessel polynomial expansion transformation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the transformation. Defaults to 'reverse_bessel_polynomial_expansion'. |
'reverse_bessel_polynomial_expansion'
|
d
|
int
|
The maximum order of reverse Bessel polynomials for expansion. Defaults to 2. |
2
|
*args
|
tuple
|
Additional positional arguments. |
()
|
**kwargs
|
dict
|
Additional keyword arguments. |
{}
|
Source code in tinybig/expansion/orthogonal_polynomial_expansion.py
calculate_D(m)
Calculates the output dimension after reverse Bessel polynomial expansion.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
m
|
int
|
Input dimension. |
required |
Returns:
Type | Description |
---|---|
int
|
Output dimension after expansion. |
Source code in tinybig/expansion/orthogonal_polynomial_expansion.py
forward(x, device='cpu', *args, **kwargs)
Performs reverse Bessel polynomial expansion on the input tensor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
Tensor
|
Input tensor of shape |
required |
device
|
str
|
Device for computation ('cpu', 'cuda'). Defaults to 'cpu'. |
'cpu'
|
*args
|
tuple
|
Additional positional arguments. |
()
|
**kwargs
|
dict
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Tensor
|
Expanded tensor of shape |
Raises:
Type | Description |
---|---|
AssertionError
|
If the output tensor shape does not match the expected dimensions. |