exponential_approx_multihop_chain_interdependence
Bases: chain_interdependence
An approximate multihop chain interdependence function using matrix exponentiation.
This class computes the interdependence matrix by approximating multihop relationships through matrix exponentiation.
Notes
To further optimize the computations, we propose approximating the accumulative interdependence function using Taylor's polynomial expansion series. Considering the Taylor's expansions of the exponential function \(\exp(x)\):
\[ \begin{equation} \exp(x) = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \cdots = \sum_{h=0}^{\infty} \frac{x^h}{h!}. \end{equation} \]
Based on them, we define the reciprocal structural interdependence function and exponential structural interdependence function for approximating the above multi-hop chain-structured topological interdependence relationships as:
\[ \begin{equation} \xi(\mathbf{x}) = \exp(\mathbf{A}) \in R^{m \times m}. \end{equation} \]
Methods:
Name | Description |
---|---|
__init__ |
Initializes the approximate multihop chain interdependence function. |
calculate_A |
Computes the approximate multihop interdependence matrix using matrix exponentiation. |
Source code in tinybig/interdependence/topological_interdependence.py
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 |
|
__init__(name='exponential_approx_multihop_chain_interdependence', normalization=False, normalization_mode='row', *args, **kwargs)
Initializes the approximate multihop chain interdependence function using matrix exponentiation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the interdependence function. Defaults to 'exponential_approx_multihop_chain_interdependence'. |
'exponential_approx_multihop_chain_interdependence'
|
normalization
|
bool
|
Whether to normalize the interdependence matrix. Defaults to False. |
False
|
normalization_mode
|
str
|
The mode of normalization ('row', 'column', etc.). Defaults to 'row'. |
'row'
|
*args
|
tuple
|
Additional positional arguments. |
()
|
**kwargs
|
dict
|
Additional keyword arguments. |
{}
|
Source code in tinybig/interdependence/topological_interdependence.py
calculate_A(x=None, w=None, device='cpu', *args, **kwargs)
Computes the approximate multihop interdependence matrix using matrix exponentiation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
Tensor
|
Input tensor of shape |
None
|
w
|
Parameter
|
Parameter tensor. Defaults to None. |
None
|
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
|
The computed approximate multihop interdependence matrix. |
Raises:
Type | Description |
---|---|
AssertionError
|
If the computed matrix shape is invalid. |