bessel_expansion
Bases: transformation
The bessel expansion function.
Applies Bessel polynomial expansion to input data.
Notes
Formally, the Bessel polynomials are an orthogonal sequence of polynomials with the following closed-form representation:
\[ \begin{equation} B_n(x) = \sum_{k=0}^n \frac{(n+k)!}{(n-k)! k!} \left( \frac{x}{2}\right)^k. \end{equation} \]
The Bessel polynomials can be recursively defined as follows:
Base cases \(n=0\) and \(n=1\):
\[ \begin{equation} B_0(x) = 1 \text{, and } B_1(x) = x + 1. \end{equation} \]
High-order cases with degree \(n \ge 2\):
\[ \begin{equation} B_n(x) = (2n - 1) x B_{n-1}(x) + B_{n-2}(x). \end{equation} \]
The Bessel polynomials can be used to define the data expansion functions as follows:
\[ \begin{equation} \kappa(\mathbf{x} | d) = \left[ B_1(\mathbf{x}), B_2(\mathbf{x}), \cdots, B_d(\mathbf{x}) \right] \in R^D, \end{equation} \]
where the output dimension \(D = md\).
Attributes:
Name | Type | Description |
---|---|---|
d |
int
|
The degree of Bessel polynomial expansion. |
Methods:
Name | Description |
---|---|
calculate_D |
Calculates the output dimension after expansion. |
forward |
Performs Bessel polynomial expansion on the input tensor. |
Source code in tinybig/expansion/orthogonal_polynomial_expansion.py
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 |
|
__init__(name='bessel_polynomial_expansion', d=2, *args, **kwargs)
Initializes the Bessel polynomial expansion transformation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the transformation. Defaults to 'bessel_polynomial_expansion'. |
'bessel_polynomial_expansion'
|
d
|
int
|
The maximum order of 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 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 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. |