hyperbolic_expansion
Bases: transformation
The hyperbolic data expansion function.
It performs the hyperbolic 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 hyperbolic expansion can be represented as follows: $$ \begin{equation} \kappa (\mathbf{x}) = \left[ \cosh(\mathbf{x}), \sinh(\mathbf{x}), \tanh(\mathbf{x}) \right] \in {R}^D, \end{equation} $$ where the output dimensions will be \(D = 3 m\).
By default, the input and output can also be processed with the optional pre- or post-processing functions in the hyperbolic expansion function.
Attributes:
Name | Type | Description |
---|---|---|
name |
str, default = 'hyperbolic_expansion'
|
Name of the 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/trigonometric_expansion.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
__init__(name='hyperbolic_expansion', *args, **kwargs)
The initialization method of the hyperbolic expansion function.
It initializes a hyperbolic 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 hyperbolic expansion function. |
'hyperbolic_expansion'
|
Returns:
Type | Description |
---|---|
transformation
|
The hyperbolic expansion function. |
Source code in tinybig/expansion/trigonometric_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 hyperbolic expansion function, the expansion space dimension will be $$ D = 3m. $$
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/trigonometric_expansion.py
forward(x, device='cpu', *args, **kwargs)
The forward method of the data expansion function.
It performs the hyperbolic data expansion of the input data and returns the expansion result as $$ \begin{equation} \kappa (\mathbf{x}) = \left[ \cosh(\mathbf{x}), \sinh(\mathbf{x}), \tanh(\mathbf{x}) \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. |