multihop_chain_interdependence
Bases: chain_interdependence
A multihop chain-based interdependence function.
Notes
To accumulate all data instances within \(h\)-hops, we introduce the accumulative multi-hop chain-based structural interdependence function as follows:
\[ \begin{equation}\label{equ:chain_accumulative} \xi(\mathbf{x} | 0:h) = \mathbf{I} + \mathbf{A} + \mathbf{A}^2 + \mathbf{A}^3 + \cdots + \mathbf{A}^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 chain. |
accumulative |
bool
|
Whether to accumulate interdependence over multiple hops. |
Methods:
Name | Description |
---|---|
__init__ |
Initializes the multihop chain interdependence function. |
calculate_A |
Computes the multihop interdependence matrix. |
Source code in tinybig/interdependence/topological_interdependence.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
|
__init__(h=1, accumulative=False, name='multihop_chain_interdependence', *args, **kwargs)
Initializes the multihop chain 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_chain_interdependence'. |
'multihop_chain_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. |