statistical_kernel_based_interdependence
Bases: interdependence
A statistical kernel-based interdependence function.
This class computes the interdependence matrix using a specified statistical kernel function.
Notes
Formally, given a data batch \(\mathbf{X} \in R^{b \times m}\), we can define the statistical kernel-based interdependence function as:
\[ \begin{equation} \xi(\mathbf{X}) = \mathbf{A} \in R^{m \times m'} \text{, where } \mathbf{A}(i, j) = \text{kernel} \left(\mathbf{X}(:, i), \mathbf{X}(:, j)\right). \end{equation} \]
Attributes:
Name | Type | Description |
---|---|---|
kernel |
Callable
|
The kernel function used to compute the interdependence matrix. |
Methods:
Name | Description |
---|---|
__init__ |
Initializes the statistical kernel-based interdependence function. |
calculate_A |
Computes the interdependence matrix using the specified kernel. |
Source code in tinybig/interdependence/statistical_kernel_interdependence.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
__init__(b, m, kernel, interdependence_type='attribute', name='statistical_kernel_based_interdependence', require_data=True, require_parameters=False, device='cpu', *args, **kwargs)
Initializes the statistical kernel-based interdependence function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
b
|
int
|
Number of rows in the input tensor. |
required |
m
|
int
|
Number of columns in the input tensor. |
required |
kernel
|
Callable
|
The kernel function used to compute the interdependence matrix. |
required |
interdependence_type
|
str
|
Type of interdependence ('attribute', 'instance', etc.). Defaults to 'attribute'. |
'attribute'
|
name
|
str
|
Name of the interdependence function. Defaults to 'statistical_kernel_based_interdependence'. |
'statistical_kernel_based_interdependence'
|
require_data
|
bool
|
If True, requires input data for matrix computation. Defaults to True. |
True
|
require_parameters
|
bool
|
If True, requires parameters for matrix computation. Defaults to False. |
False
|
device
|
str
|
Device for computation (e.g., 'cpu' or 'cuda'). Defaults to 'cpu'. |
'cpu'
|
*args
|
tuple
|
Additional positional arguments for the parent class. |
()
|
**kwargs
|
dict
|
Additional keyword arguments for the parent class. |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
If no kernel function is provided. |
Source code in tinybig/interdependence/statistical_kernel_interdependence.py
calculate_A(x=None, w=None, device='cpu', *args, **kwargs)
Computes the interdependence matrix using the specified kernel function.
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 (e.g., 'cpu' or 'cuda'). Defaults to 'cpu'. |
'cpu'
|
*args
|
tuple
|
Additional positional arguments for interdependence functions. |
()
|
**kwargs
|
dict
|
Additional keyword arguments for interdependence functions. |
{}
|
Returns:
Type | Description |
---|---|
Tensor
|
The computed interdependence matrix. |
Raises:
Type | Description |
---|---|
AssertionError
|
If |