naive_gamma_expansion
Bases: transformation
The naive gamma data expansion function.
It performs the naive gamma 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 gamma 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 gamma distribution with hyper-parameter \(\theta_d\), $$ \begin{equation} P\left(x | \theta_d\right) = P(x | k, \theta) = \frac{1}{\Gamma(k) \theta^k} x^{k-1} \exp^{- \frac{x}{\theta}}. \end{equation} $$
For naive gamma 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_gamma_expansion'
|
Name of the naive gamma 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
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 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 |
|
__init__(name='naive_gamma_expansion', *args, **kwargs)
The initialization method of the naive gamma probabilistic expansion function.
It initializes a naive gamma 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 gamma expansion function. |
'naive_gamma_expansion'
|
Returns:
Type | Description |
---|---|
transformation
|
The naive gamma 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 gamma 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 gamma probabilistic expansion function.
It performs the naive gamma 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. |