minerva.losses.topological_loss
Classes
Calculate persistent homology using aleph.  | 
|
Base class for all neural network modules.  | 
|
Topological signature.  | 
|
An implementation of a Union--Find class. The class performs path  | 
Module Contents
- class minerva.losses.topological_loss.AlephPersistenHomologyCalculation(compute_cycles, sort_selected)[source]
 Calculate persistent homology using aleph.
- Args:
 compute_cycles: Whether to compute cycles sort_selected: Whether to sort the selected pairs using the
distance matrix (such that they are in the order of the filteration)
- __call__(distance_matrix)[source]
 Do PH calculation.
- Args:
 distance_matrix: numpy array of distances
Returns: tuple(edge_featues, cycle_features)
- compute_cycles
 
- sort_selected
 
- class minerva.losses.topological_loss.TopologicalLoss(p=2)[source]
 Bases:
torch.nn.modules.loss._LossBase class for all neural network modules.
Your models should also subclass this class.
Modules can also contain other Modules, allowing them to be nested in a tree structure. You can assign the submodules as regular attributes:
import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self) -> None: super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x))
Submodules assigned in this way will be registered, and will also have their parameters converted when you call
to(), etc.Note
As per the example above, an
__init__()call to the parent class must be made before assignment on the child.- Variables:
 training (bool) – Boolean represents whether this module is in training or evaluation mode.
- Parameters:
 p (int)
Initialize the TopologicalLoss class.
Parameters
- pint, optional
 Order of norm used for distance computation, by default 2
- latent_norm
 
- p = 2
 
- topological_signature_distance
 
- class minerva.losses.topological_loss.TopologicalSignatureDistance(sort_selected=False, use_cycles=False, match_edges=None)[source]
 Bases:
torch.nn.ModuleTopological signature.
Topological signature computation.
- Args:
 p: Order of norm used for distance computation use_cycles: Flag to indicate whether cycles should be used
or not.
- forward(distances1, distances2)[source]
 Return topological distance of two pairwise distance matrices.
- Args:
 distances1: Distance matrix in space 1 distances2: Distance matrix in space 2
- Returns:
 distance, dict(additional outputs)
- match_edges = None
 
- static sig_error(signature1, signature2)[source]
 Compute distance between two topological signatures.
- signature_calculator
 
- use_cycles = False
 
- class minerva.losses.topological_loss.UnionFind(n_vertices)[source]
 An implementation of a Union–Find class. The class performs path compression by default. It uses integers for storing one disjoint set, assuming that vertices are zero-indexed.
Initializes an empty Union–Find data structure for a given number of vertices.
- _parent