naive_laplace_expansion
Bases: transformation
The naive laplace data expansion function.
It performs the naive laplace probabilistic expansion of the input vector, and returns the expansion result. The class inherits from the base expansion class (i.e., the transformation class in the module directory).
...
Notes
For input vector \(\mathbf{x} \in R^m\), its naive laplace probabilistic expansion can be represented as follows: $$ \begin{equation} \kappa(\mathbf{x} | \boldsymbol{\theta}) = \left[ \log P\left({\mathbf{x}} | \theta_1\right), \log P\left({\mathbf{x} } | \theta_2\right), \cdots, \log P\left({\mathbf{x} } | \theta_d\right) \right] \in {R}^D \end{equation} $$ where \(P\left({{x}} | \theta_d\right)\) denotes the probability density function of the laplace distribution with hyper-parameter \(\theta_d\), $$ \begin{equation} P\left(x | \theta_d\right) = P(x| \mu, b) = \frac{1}{2b} \exp^{\left(- \frac{|x-\mu|}{b} \right)}. \end{equation} $$
For naive laplace probabilistic expansion, its output expansion dimensions will be \(D = md\), where \(d\) denotes the number of provided distribution hyper-parameters.
By default, the input and output can also be processed with the optional pre- or post-processing functions in the gaussian rbf expansion function.
Attributes:
Name | Type | Description |
---|---|---|
name |
str, default = 'naive_laplace_expansion'
|
Name of the naive laplace expansion function. |
Methods:
Name | Description |
---|---|
__init__ |
It performs the initialization of the expansion function. |
calculate_D |
It calculates the expansion space dimension D based on the input dimension parameter m. |
forward |
It implements the abstract forward method declared in the base expansion class. |
Source code in tinybig/expansion/probabilistic_expansion.py
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 746 747 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 |
|
__init__(name='naive_laplace_expansion', *args, **kwargs)
The initialization method of the naive laplace probabilistic expansion function.
It initializes a naive laplace probabilistic expansion 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 naive laplace expansion function. |
'naive_laplace_expansion'
|
Returns:
Type | Description |
---|---|
transformation
|
The naive laplace probabilistic expansion function. |
Source code in tinybig/expansion/probabilistic_expansion.py
calculate_D(m)
The expansion dimension calculation method.
It calculates the intermediate expansion space dimension based on the input dimension parameter m. For the naive laplace probabilistic expansion function, the expansion space dimension will be $$ D = m d, $$ where \(d\) denotes the number of provided distribution hyper-parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
m
|
int
|
The dimension of the input space. |
required |
Returns:
Type | Description |
---|---|
int
|
The dimension of the expansion space. |
Source code in tinybig/expansion/probabilistic_expansion.py
forward(x, device='cpu', *args, **kwargs)
The forward method of the naive laplace probabilistic expansion function.
It performs the naive laplace probabilistic expansion of the input data and returns the expansion result as $$ \begin{equation} \kappa(\mathbf{x} | \boldsymbol{\theta}) = \left[ \log P\left({\mathbf{x}} | \theta_1\right), \log P\left({\mathbf{x} } | \theta_2\right), \cdots, \log P\left({\mathbf{x} } | \theta_d\right) \right] \in {R}^D \end{equation} $$
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
Tensor
|
The input data vector. |
required |
device
|
The device to perform the data expansion. |
'cpu'
|
Returns:
Type | Description |
---|---|
Tensor
|
The expanded data vector of the input. |