Nn¶
manify.predictors.nn
¶
Neural network layers for KappaGCN and related models.
FermiDiracDecoder(manifold, learnable_params=True)
¶
Bases: Module
Fermi-Dirac decoder for link prediction tasks.
Computes pairwise distances and applies Fermi-Dirac transformation to predict edge probabilities.
| Parameters: |
|
|---|
Source code in manify/predictors/nn/layers.py
306 307 308 309 310 311 312 313 314 315 316 | |
forward(X, A_hat=None)
¶
Forward pass through Fermi-Dirac decoder.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in manify/predictors/nn/layers.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
KappaGCNLayer(in_features, out_features, manifold, nonlinearity=torch.relu)
¶
Bases: Module
Implementation for the Kappa GCN layer.
| Parameters: |
|
|---|
| Attributes: |
|
|---|
Source code in manify/predictors/nn/layers.py
33 34 35 36 37 38 39 40 41 42 43 44 45 | |
forward(X, A_hat=None)
¶
Forward pass for the Kappa GCN layer.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in manify/predictors/nn/layers.py
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 | |
KappaSequential(*layers)
¶
Bases: Module
Sequential container for κ-layers that properly handles adjacency matrices.
Similar to nn.Sequential but passes the adjacency matrix through each layer. All layers should accept (X, A_hat) and return X.
| Parameters: |
|
|---|
Source code in manify/predictors/nn/layers.py
114 115 116 | |
forward(X, A_hat=None)
¶
Forward pass through all layers.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in manify/predictors/nn/layers.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
append(layer)
¶
Add a layer to the end of the sequence.
Source code in manify/predictors/nn/layers.py
134 135 136 | |
StereographicLogits(out_features, manifold, apply_softmax=False)
¶
Bases: Module
Stereographic logits layer for classification and regression on product manifolds.
Computes signed distances from hyperplanes in the product manifold space. Can optionally apply softmax for classification tasks.
| Parameters: |
|
|---|
Source code in manify/predictors/nn/layers.py
170 171 172 173 174 175 176 177 178 179 180 181 | |
forward(X, A_hat=None, aggregate_logits=False)
¶
Forward pass through stereographic logits.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in manify/predictors/nn/layers.py
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 | |
layers
¶
Neural network layers for product manifolds.
KappaGCNLayer(in_features, out_features, manifold, nonlinearity=torch.relu)
¶
Bases: Module
Implementation for the Kappa GCN layer.
| Parameters: |
|
|---|
| Attributes: |
|
|---|
Source code in manify/predictors/nn/layers.py
33 34 35 36 37 38 39 40 41 42 43 44 45 | |
forward(X, A_hat=None)
¶
Forward pass for the Kappa GCN layer.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in manify/predictors/nn/layers.py
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 | |
KappaSequential(*layers)
¶
Bases: Module
Sequential container for κ-layers that properly handles adjacency matrices.
Similar to nn.Sequential but passes the adjacency matrix through each layer. All layers should accept (X, A_hat) and return X.
| Parameters: |
|
|---|
Source code in manify/predictors/nn/layers.py
114 115 116 | |
forward(X, A_hat=None)
¶
Forward pass through all layers.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in manify/predictors/nn/layers.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
append(layer)
¶
Add a layer to the end of the sequence.
Source code in manify/predictors/nn/layers.py
134 135 136 | |
StereographicLogits(out_features, manifold, apply_softmax=False)
¶
Bases: Module
Stereographic logits layer for classification and regression on product manifolds.
Computes signed distances from hyperplanes in the product manifold space. Can optionally apply softmax for classification tasks.
| Parameters: |
|
|---|
Source code in manify/predictors/nn/layers.py
170 171 172 173 174 175 176 177 178 179 180 181 | |
forward(X, A_hat=None, aggregate_logits=False)
¶
Forward pass through stereographic logits.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in manify/predictors/nn/layers.py
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 | |
FermiDiracDecoder(manifold, learnable_params=True)
¶
Bases: Module
Fermi-Dirac decoder for link prediction tasks.
Computes pairwise distances and applies Fermi-Dirac transformation to predict edge probabilities.
| Parameters: |
|
|---|
Source code in manify/predictors/nn/layers.py
306 307 308 309 310 311 312 313 314 315 316 | |
forward(X, A_hat=None)
¶
Forward pass through Fermi-Dirac decoder.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in manify/predictors/nn/layers.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
StereographicLayerNorm(manifold, embedding_dim, curvatures)
¶
Bases: Module
Stereographic Layer Normalization.
| Parameters: |
|
|---|
| Attributes: |
|
|---|
Source code in manify/predictors/nn/layers.py
358 359 360 361 362 363 364 365 | |
forward(X)
¶
Apply layer normalization on the stereographic manifold.
Source code in manify/predictors/nn/layers.py
367 368 369 370 371 | |
GeometricLinearizedAttention(curvatures, num_heads, head_dim)
¶
Bases: Module
Geometric Linearized Attention.
| Parameters: |
|
|---|
| Attributes: |
|
|---|
Source code in manify/predictors/nn/layers.py
390 391 392 393 394 395 396 397 398 | |
forward(Q, K, V, mask)
¶
Forward pass for the geometric linearized attention layer.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in manify/predictors/nn/layers.py
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 | |
StereographicAttention(manifold, num_heads, dim, head_dim)
¶
Bases: Module
Stereographic Attention Layer.
| Parameters: |
|
|---|
| Attributes: |
|
|---|
Source code in manify/predictors/nn/layers.py
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | |
forward(X, mask=None)
¶
Forward pass for the stereographic attention layer.
Source code in manify/predictors/nn/layers.py
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 | |
StereographicTransformer(manifold, num_heads, dim, head_dim, use_layer_norm=True)
¶
Bases: Module
Stereographic Transformer Block.
| Parameters: |
|
|---|
| Attributes: |
|
|---|
Source code in manify/predictors/nn/layers.py
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 | |
forward(X, mask=None)
¶
Forward pass through the stereographic transformer block.
Source code in manify/predictors/nn/layers.py
581 582 583 584 585 586 587 588 589 590 591 592 | |