laguerre_expansion
Bases: transformation
The laguerre expansion function.
Applies Laguerre polynomial expansion to input data.
Notes
In mathematics, the Laguerre polynomials, named after Edmond Laguerre, are the nontrivial solutions of Laguerre's differential equation:
\[ \begin{equation} x y'' + (\alpha + 1 -x) y' + d y = 0, \end{equation} \]
where \(y = y(x)\) is a function of variable \(x\). Notations \(y'\) and \(y''\) denote first- and second-order derivatives of function \(y\) with respect to variable \(x\). Term \(d \in N\) is a non-negative integer and \(\alpha \in R\) is a hyper-parameter.
The closed-form of the Laguerre polynomials can be represented as follows:
\[ \begin{equation} P^{(\alpha)}_n(x) = \frac{e^x}{n!} \frac{\mathrm{d}^n}{\mathrm{d} x^n} (e^{-x} x^n) = \frac{x^{-\alpha}}{n!} \left( \frac{\mathrm{d}}{\mathrm{d} x} - 1 \right)^n x^{n + \alpha}, \end{equation} \]
where \(\frac{\mathrm{d}}{\mathrm{d} x}\) denotes the derivative operator.
In practice, the Laguerre polynomials can be recursively defined as follows, which will be used for defining the data expansion function below. Specifically, when \(\alpha = 0\), the above Laguerre polynomials are also known as simple Laguerre polynomials.
Base cases \(n=0\) and \(n=1\):
\[ \begin{equation} P^{(\alpha)}_0(x) = 1 \text{, and } P^{(\alpha)}_1(x) = 1 + \alpha - x. \end{equation} \]
High-order cases with degree \(n \ge 2\):
\[ \begin{equation} P^{(\alpha)}_n(x) = \frac{(2n-1+\alpha-x) P^{(\alpha)}_{n-1}(x) - (n-1+\alpha) P^{(\alpha)}_{n-2}(x) }{n} \end{equation} \]
The recursive-form representations of the Laguerre polynomials can be used to define the data expansion function as follows:
\[ \begin{equation} \kappa(\mathbf{x} | d, \alpha) = \left[ P^{(\alpha)}_1(\mathbf{x}), P^{(\alpha)}_2(\mathbf{x}), \cdots, P^{(\alpha)}_d(\mathbf{x}) \right] \in R^D, \end{equation} \]
where \(d\) and \(\alpha\) are the function hyper-parameters and the output dimension \(D = md\).
Attributes:
Name | Type | Description |
---|---|---|
d |
int
|
The degree of Laguerre polynomial expansion. |
alpha |
float
|
Parameter controlling the Laguerre polynomial. |
Methods:
Name | Description |
---|---|
calculate_D |
Calculates the output dimension after expansion. |
forward |
Performs Laguerre polynomial expansion on the input tensor. |
Source code in tinybig/expansion/orthogonal_polynomial_expansion.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
|
__init__(name='laguerre_polynomial_expansion', d=2, alpha=1.0, *args, **kwargs)
Initializes the Laguerre polynomial expansion transformation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the transformation. Defaults to 'laguerre_polynomial_expansion'. |
'laguerre_polynomial_expansion'
|
d
|
int
|
The maximum order of Laguerre polynomials for expansion. Defaults to 2. |
2
|
alpha
|
float
|
The alpha parameter for generalized Laguerre polynomials. Defaults to 1.0. |
1.0
|
*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 Laguerre 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 Laguerre 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. |