Rather than build a target shape into the architecture, make the shape a differentiable objective and penalise the network whenever its output has the wrong topology.

A topological loss turns topological data analysis (TDA) into a training signal. From the network’s output one builds a filtration, a nested family of sublevel sets grown as the threshold increases, and reads off its persistent homology (see persistent-homology). The resulting persistence diagram is a multiset of birth–death pairs recording when each connected component, loop, or void appears and disappears. Points far from the diagonal are robust topological features, whereas points near it are noise. The Betti numbers count components, loops and voids at a scale.

The map from the function values to the coordinates of the diagram is (almost everywhere) differentiable. Each birth or death is attained at some vertex or simplex, and away from a measure-zero set the responsible simplex is locally constant, so is well defined. A loss written on those coordinates therefore backpropagates into the network, whether it pushes a chosen set of points off the diagonal or matches the to prescribed values. The constraint is thus optimised for, not guaranteed. Unlike a hard architectural invariant, a soft penalty steers the output toward the prescribed topology without certifying it. This is the same discipline as a physics-informed-neural-network, and complementary to building structure in directly as topological-deep-learning does.

As an objective it is a task term plus a topological penalty,

a function of the persistence diagram of the output . For a segmentation that must be a single blob with no holes (, ) one keeps the most persistent component and loop and drives every other point to the diagonal, , so gradient descent erases the extra components and holes. That penalty is the whole constraint.

Where the penalty pays off

Typical applications enforce the correct count of features where pixel-wise losses cannot, such as segmentation masks that must have exactly one connected component or the right number of loops (vessels, membranes, neurons), and generative outputs constrained to a target genus. Used more weakly it is a topological regulariser, biasing representations or reconstructions toward simple, low-Betti-number shape without fixing it.

Attribution. Feeding persistence to a network as input originates with Hofer et al., Deep Learning with Topological Signatures. The differentiable optimisation side, persistence as an objective minimised by gradient descent, is developed in Gabrielsson et al., A Topology Layer for Machine Learning, and Carrière et al. (differentiating functions of persistence diagrams). Its use as a segmentation loss that fixes the Betti numbers is due to Clough et al. and Hu et al. (topology-preserving segmentation).