jacobi_expansion
Bases: transformation
The jacobi data expansion function.
It performs the jacobi 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 jacobi expansion up to degree \(d\) can be represented as $$ \begin{equation} \kappa(\mathbf{x} | d) = \left[ P_1^{(\alpha, \beta)}(\mathbf{x}), P_2^{(\alpha, \beta)}(\mathbf{x}), \cdots, P_d^{(\alpha, \beta)}(\mathbf{x})\right] \in {R}^D, \end{equation} $$ where \(P_d^{(\alpha, \beta)}(\mathbf{x})\) denotes the jacobi expansion polynomial of \(\mathbf{x}\) degree \(d\). The output dimension of jacobi expansion will be \(D = m d\).
As to the specific representations of jacobi polynomials, they can be defined recursively based on the lower-degree terms according to the following equations:
(1) Base jacobi polynomials with degree \(d=0\), \(d=1\) and \(d=2\): $$ \begin{align} P_0^{(\alpha, \beta)}(x) &= 1,\\ P_1^{(\alpha, \beta)}(x) &= (\alpha + 1) + (\alpha + \beta + 2) \frac{(x-1)}{2},\\ P_2^{(\alpha, \beta)}(x) &= \frac{(\alpha+1)(\alpha+2)}{2} + (\alpha+2)(\alpha+\beta+3) \frac{x-1}{2} + \frac{(\alpha + \beta + 3)(\alpha + \beta + 4)}{2} \left( \frac{x-1}{2} \right)^2. \end{align} $$
(2) Higher-degree jacobi polynomials with \(d \ge 2\): $$ \begin{align} P_d^{(\alpha, \beta)}(x) &= \frac{(2d + \alpha + \beta -1) \left[ (2d + \alpha + \beta)(2d + \alpha + \beta -2) x + (\alpha^2 - \beta^2) \right]}{2d(d + \alpha + \beta)(2d + \alpha + \beta - 2) } P_{d-1}^{(\alpha, \beta)}(x)\\ & - \frac{2(d+\alpha-1)(d+\beta-1)(2d+\alpha+\beta)}{2d(d + \alpha + \beta)(2d + \alpha + \beta - 2) }P_{d-2}^{(\alpha, \beta)}(x). \end{align} $$
By default, the input and output can also be processed with the optional pre- or post-processing functions in the jacobi expansion function.
Attributes:
Name | Type | Description |
---|---|---|
name |
str, default = 'jacobi_polynomial_expansion'
|
Name of the expansion function. |
d |
int, default = 2
|
Degree of jacobi expansion. |
alpha |
float, default = 1.0
|
Parameter of jacobi polynomial representation. |
beta |
float, default = 1.0
|
Parameter of jacobi polynomial representation. |
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/recursive_expansion.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
|
__init__(name='jacobi_polynomial_expansion', d=2, alpha=1.0, beta=1.0, *args, **kwargs)
The initialization method of jacobi expansion function.
It initializes a jacobi 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
|
str
|
The name of the jacobi expansion function. |
'jacobi_polynomial_expansion'
|
d
|
int
|
The degree of the jacobi expansion function. |
2
|
alpha
|
float
|
Parameter of jacobi polynomial representation. |
1.0
|
beta
|
float
|
Parameter of jacobi polynomial representation. |
1.0
|
Returns:
Type | Description |
---|---|
transformation
|
The jacobi expansion function. |
Source code in tinybig/expansion/recursive_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 jacobi expansion function, the expansion space dimension is determined by m and d, which can be represented as:
\[ D = m d. \]
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/recursive_expansion.py
forward(x, device='cpu', *args, **kwargs)
The forward method of the data expansion function.
It performs the jacobi data expansion of the input data and returns the expansion result according to the following equation: $$ \begin{equation} \kappa(\mathbf{x} | d) = \left[ P_1^{(\alpha, \beta)}(\mathbf{x}), P_2^{(\alpha, \beta)}(\mathbf{x}), \cdots, P_d^{(\alpha, \beta)}(\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. |