naive_chi2_expansion
Bases: transformation
The naive chi2 data expansion function.
It performs the naive chi2 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 chi2 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 chi2 distribution with hyper-parameter \(\theta_d\), $$ \begin{equation} P\left(x | \theta_d\right) = P(x| k) = \frac{1}{2^{\frac{k}{2}} \Gamma(\frac{k}{2})} x^{(\frac{k}{2}-1)} \exp^{-\frac{x}{2}}. \end{equation} $$
For naive chi2 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_chi2_expansion'
|
The name of the naive chi2 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
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 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 |
|
__init__(name='naive_chi2_expansion', *args, **kwargs)
The initialization method of the naive chi2 probabilistic expansion function.
It initializes a naive chi2 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 chi2 expansion function. |
'naive_chi2_expansion'
|
Returns:
Type | Description |
---|---|
transformation
|
The naive chi2 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 chi2 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 chi2 probabilistic expansion function.
It performs the naive chi2 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. |