multihop_graph_interdependence
Bases: graph_interdependence
A multihop graph-based interdependence function.
Notes
To model multi-hop dependency relationships among data instances, we introduce the multi-hop graph interdependence function and the accumulative multi-hop graph interdependence function as follows:
\[ \begin{equation} \xi(\mathbf{x} | h) = \mathbf{A}^h \in R^{m \times m} \text{, and } \xi(\mathbf{x} | 0: h) = \sum_{i=0}^h \mathbf{A}^i \in R^{m \times m}. \end{equation} \]
Attributes:
Name | Type | Description |
---|---|---|
h |
int
|
Number of hops to consider in the graph. |
accumulative |
bool
|
Whether to accumulate interdependence over multiple hops. |
Methods:
Name | Description |
---|---|
__init__ |
Initializes the multihop graph interdependence function. |
calculate_A |
Computes the multihop interdependence matrix. |
Source code in tinybig/interdependence/topological_interdependence.py
729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 |
|
__init__(h=1, accumulative=False, name='multihop_graph_interdependence', *args, **kwargs)
Initializes the multihop graph interdependence function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
h
|
int
|
Number of hops to consider. Defaults to 1. |
1
|
accumulative
|
bool
|
Whether to accumulate interdependence over multiple hops. Defaults to False. |
False
|
name
|
str
|
Name of the interdependence function. Defaults to 'multihop_graph_interdependence'. |
'multihop_graph_interdependence'
|
*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 multihop interdependence matrix.
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 multihop interdependence matrix. |
Raises:
Type | Description |
---|---|
AssertionError
|
If the computed matrix shape is invalid. |