Skip to main content
LearnMLAcademy
Advanced10 min read

Physics-Informed, KAN and Topological Networks

Solve differential equations with PINNs and learnable spline nets, with sequence diagrams, attention calculations, and model-code exercises.

What you will master in this lesson
Intuitive core mechanisms & practical real-world intuition
Step-by-step mathematical breakdown & visual diagrams
Runnable Python implementation & practical trade-offs

Deep Learning · Emerging Scientific Architectures

Physics-Informed, Kolmogorov–Arnold and Topological Networks

These are three distinct ways to give a neural model more structure than a standard dense network: enforce known equations through a loss, learn flexible functions on connections, or represent higher-order relationships beyond pairwise edges. We will build each idea from a small calculation, identify where it may help, and keep the limitations visible because all three require careful comparison with mature baselines.

Why These Methods Exist

A normal supervised network learns from input–target examples and an architecture's built-in assumptions. Scientific and relational problems often offer additional knowledge: a differential equation that every solution should approximately satisfy, a low-dimensional function whose shape scientists want to inspect, or a three-way interaction that cannot be distinguished from three independent pairwise edges.

The methods in this lesson place that knowledge in different parts of the learning system. They are not drop-in upgrades for every neural network.

Three advanced families answer three different questions

Physics-Informed NN

put governing equations into the loss

Best clue: known physics + sparse observations

Kolmogorov–Arnold Network

learn a function on each connection

Best clue: function fitting/scientific exploration

Topological Network

learn on higher-order relationships

Best clue: edges, triangles, cells or hyperedges

They are grouped here as research-oriented architectures, not because one evolves into the next. Compare each with a strong conventional baseline.

Physics-Informed Neural Networks Put Equations Into the Loss

Suppose u(t) describes a cooling quantity and should follow the ordinary differential equation du/dt+u=0 with initial condition u(0)=1. The equation and initial value come from scientific knowledge, while a Physics-Informed Neural Network represents the unknown solution with a differentiable neural function uθ(t). Automatic differentiation calculates duθ/dt from the network graph at chosen coordinates.

The equation residual r(t)=duθ/dt+uθ(t) should be zero for a valid solution. The loss combines boundary/initial conditions, optional observations, and mean squared residual at collocation points—developer-sampled coordinates inside the domain that do not need target solution values.

A PINN is trained at observations, boundaries and physics collocation points

PINN curve with boundary and collocation pointsA neural network approximates a decaying curve. One boundary point enforces u zero equals one, sparse observations constrain the curve, and collocation points evaluate the differential equation residual.time tu(t)boundary u(0)=1observedobservedAt every gold collocation pointautodiff computes duθ/dtresidual r(t)=duθ/dt+uθ(t)
Collocation points do not require measured targets. They are coordinates where the model's derivatives are inserted into the governing equation; nonzero residual becomes loss.

A simple PINN objective

L = λbc[uθ(0)−1]² + λphys(1/N)Σir(ti)² + λdataLobserved

Subtracting known targets creates residuals, squaring prevents positive and negative violations from cancelling, averaging summarizes N collocation points, and adding combines all requirements into one optimizer target. The λ terms are developer-chosen weights for components with different scales—not physical constants or learned solution values.

Calculate One Physics Residual by Hand

To show the check without hiding it inside a network, manually choose the imperfect candidate u(t)=1−0.8t and collocation point t=0.5. The coefficient −0.8 and point 0.5 are teaching choices. In training, u comes from the current neural network and collocation points are sampled across the domain. This candidate satisfies the boundary at t=0, but its derivative is du/dt=−0.8.

1. Candidate value
u(0.5)=1−0.8×0.5
=0.6

2. Equation residual
r=du/dt+u
=−0.8+0.6=−0.2

3. Physics loss
r²=(−0.2)²
=0.04

Interpretation: the boundary term is zero but the physics term is not, so training receives a signal to change the function inside the domain. The exact solution e−t has derivative −e−t, making this residual zero everywhere.

A Minimal PINN for the Cooling Equation

The code samples t values, asks PyTorch for du/dt, constructs the residual and combines it with the initial-condition loss. The optimizer adjusts network parameters—not the coordinates.

pinn_cooling_ode.py
import torch
from torch import nn

model = nn.Sequential(
    nn.Linear(1, 32), nn.Tanh(),
    nn.Linear(32, 32), nn.Tanh(),
    nn.Linear(32, 1),
)
optimizer = torch.optim.Adam(model.parameters(), lr=1e-3)

for step in range(5000):
    # Collocation coordinates need gradients so du/dt can be computed.
    t = torch.rand(128, 1, requires_grad=True)
    u = model(t)
    du_dt = torch.autograd.grad(
        u, t,
        grad_outputs=torch.ones_like(u),
        create_graph=True,
    )[0]

    residual = du_dt + u                 # target residual is zero
    physics_loss = (residual ** 2).mean()

    u_zero = model(torch.zeros(1, 1))
    boundary_loss = (u_zero - 1.0).pow(2).mean()
    loss = physics_loss + boundary_loss

    optimizer.zero_grad()
    loss.backward()
    optimizer.step()

Where the values come from

One input and one output follow from t→u. Two hidden layers of width 32, 5,000 steps, batch 128 and learning rate 0.001 are chosen training hyperparameters. rand samples t in [0,1); zero and target 1.0 come from the initial condition u(0)=1.

Why create a derivative graph?

requires_grad=True lets autograd differentiate u with respect to t. create_graph=True keeps that derivative differentiable so loss.backward() can determine how the physics residual depends on model weights. Coordinates receive temporary gradients; only parameters passed to Adam are updated.

After training, validate against an analytical solution when one exists or a trusted numerical solver—not only the training residual. Check error across the complete domain and conservation/units relevant to the real system.

PINNs Are Optimization Methods, Not Automatic Solver Replacements

Forward problem

Known equation/parameters; approximate the state u across the domain.

Inverse problem

Use observations plus physics to infer unknown parameters or fields.

Potential advantage

Softly combine sparse/noisy data and differentiable governing knowledge.

Common difficulty

Stiff, multiscale, chaotic or high-dimensional problems can be very hard to optimize.

Loss imbalance

Boundary and residual terms may differ greatly in scale; one can improve while another is ignored.

Baseline requirement

Compare accuracy, runtime and robustness with finite-difference/finite-element/spectral and hybrid methods.

KANs Move Learnable Nonlinearity Onto Connections

A standard dense layer multiplies inputs by scalar weights, sums them, then applies a fixed activation such as ReLU at a node. A Kolmogorov–Arnold Network (KAN), inspired by the Kolmogorov–Arnold representation theorem, instead places a learnable one-variable function φ on each edge and sums incoming edge outputs at a node.

In a KAN, each connection applies a learned one-dimensional function

x₁
x₂

x₁ → y₁

φ₁₁(x₁)

x₂ → y₁

φ₁₂(x₂)

x₁ → y₂

φ₂₁(x₁)

x₂ → y₂

φ₂₂(x₂)

y₁=Σφ₁ᵢ
y₂=Σφ₂ᵢ
The curves are illustrative. Practical KAN implementations parameterize edge functions with splines or other bases and learn their coefficients. A node sums incoming transformed values.

One KAN-style layer

xl+1,j = Σi=1nl φl,j,i(xl,i)

xl,i is the i-th model-produced value entering layer l; nl is that layer's chosen width; φl,j,i is a learned one-variable edge function. The sum is necessary to combine all incoming transformed values without inventing an ordering. Implementations choose a function basis, grid and parameterization as architecture hyperparameters.

A two-edge numerical example

Manually choose two readable edge functions φ₁(x)=x² and φ₂(x)=2x, and teaching inputs x₁=2 and x₂=3. Real inputs come from data or the previous layer, while training learns the edge curves.

φ₁(2)=2²=4
φ₂(3)=2×3=6
y=φ₁(x₁)+φ₂(x₂)=4+6=10

Interpretation: each connection transforms its scalar input with its own curve, then the node adds the two results. This illustrates a KAN-style layer; it is not a fitted scientific law.

When to Treat KANs as an Experiment

KAN edge curves can be inspected, simplified and visualized, which is attractive for low-dimensional scientific discovery. But “interpretable” is not automatic: many layers and edges can still produce a complex coupled system, and a fitted curve may reflect correlations or extrapolate poorly.

Benchmark against an MLP under equal conditions

Match data splits, parameter/compute budget, tuning effort and seeds. Measure training/inference cost and out-of-range behavior. KAN tooling and hardware optimization are newer than standard dense layers, so a paper result does not guarantee an advantage on your task.

Topological Networks Go Beyond Pairwise Edges

A graph records pairwise relationships. Some systems have meaningful multi-way units: three atoms can form a face, multiple authors can participate in one collaboration, and flow may live on edges or surfaces rather than nodes. A simplicial complex can include vertices (0-simplices), edges (1-simplices), filled triangles (2-simplices) and higher-dimensional simplices, together with their faces.

A graph triangle and a filled triangle do not encode the same relation

pairwise graph

ABC

V=3, E=3, F=0
χ=V−E+F=0

three pairwise relationships; central hole

2-simplex / filled face

ABC

V=3, E=3, F=1
χ=V−E+F=1

one explicit three-way relation; no central hole

Both have the same three nodes and edges, but the right structure says the triple itself forms a 2-dimensional cell. The Euler characteristic χ is a simple topological summary; full topological learning uses richer incidence and message-passing operators.

Topological neural networks pass information between cells of the same or different ranks using incidence/neighborhood structure. Other domains include cell complexes, hypergraphs and combinatorial complexes. Choosing the domain is part of modelling: a filled triangle should mean a real three-way relation, not be added merely because three pairwise edges form a cycle.

Choose the Structure From Knowledge You Truly Have

Evidence in the problemReasonable model to testWhyRequired comparison
Known ODE/PDE; sparse measurementsPINN or another physics-informed methodEquation residual supplies supervision between observationsCompare numerical solvers and hybrid/surrogate methods
Small scientific function-fitting problemKAN and MLP baselinesEdge functions may provide inspectable fitted curvesDo not infer universal superiority from toy results
Pairwise entity relationshipsGNNGraph structure already matches the dataHigher-order complex may add needless complexity
Meaningful group/face/cell relationshipsTopological/hypergraph networkPreserves interactions a pairwise graph can collapseConstruction and tooling are less mature

Diagnostics for Research-Oriented Models

ObservationPossible causeCheck
PINN residual low but boundary wrongLoss imbalance or poor boundary samplingReport every loss term and domain-wise error separately
PINN fits points but violates conservationEquation/units/derivatives implemented incorrectlyUse manufactured solutions and dimensional/unit tests
KAN train fit is excellent; extrapolation unstableFlexible splines unsupported outside training rangePlot each relevant edge function and test out-of-range inputs
KAN beats one untuned MLPUnequal tuning or parameter/compute budgetRun matched baselines across seeds
Topological model adds no valueHigher-order cells are artificial or features dominateCompare graph-only, topology-only and feature-only ablations
Result changes under harmless reindexing/orientationBroken invariance/equivariance handlingRun permutation/orientation transformation tests

What to Remember

  • A PINN differentiates a neural approximation and penalizes equation residuals plus boundaries and observations.
  • Low residual is not enough; validate domain error, constraints and performance against trusted solvers.
  • A KAN sums learned one-dimensional edge functions instead of scalar-weighted inputs followed by fixed node activations.
  • KAN curves may aid inspection, but matched MLP benchmarks and extrapolation tests remain necessary.
  • Topological networks represent meaningful higher-order cells that pairwise graphs cannot distinguish.
  • These are specialized, evolving tools. Use them because the problem supplies matching structure—not because the names are new.

Related Learning

Apply this concept in a real hands-on project

You have studied the idea. Now use it in working Python code, see the calculation and output, and explain what changed. Each project includes step-by-step instructions, full source and tests.

Practice challenge: predict an outcome first, run the code, and explain the difference.

Track Your Progress0% curriculum done

Finished "Physics-Informed, KAN and Topological Networks"?

Mark this lesson as completed to update your progress bar and track your milestones across the full curriculum.

Overall Progress0 / 167 lessons

Was this tutorial helpful?

Your feedback helps us continuously refine and improve our open-access tutorials.

Knowledge Check

Progress: 0/5

Test your active recall. Choose one answer for each question, then check it to reveal the step-by-step reasoning.

Question 1 of 5conceptual
What does a PINN add to an ordinary data loss?
Question 2 of 5numerical/formula
For residual r=-0.2, what is the squared physics penalty?
Question 3 of 5debugging/diagnostic
Why use create_graph=True when computing a PINN derivative in PyTorch?
Question 4 of 5conceptual
How does a KAN edge differ from an ordinary MLP weight?
Question 5 of 5interpretation
What distinguishes a filled triangle from three pairwise graph edges?

Knowledge Check Review & Explanations

Review the questions, verified correct answers, and conceptual explanations for this lesson.

1What does a PINN add to an ordinary data loss?▼

Correct Answer: Equation and boundary residual penalties

Physics-informed training penalizes violation of known governing equations and constraints.

2For residual r=-0.2, what is the squared physics penalty?▼

Correct Answer: 0.04

Squaring gives (-0.2)²=0.04 and prevents positive and negative violations from cancelling.

3Why use create_graph=True when computing a PINN derivative in PyTorch?▼

Correct Answer: The derivative must remain differentiable with respect to model weights

The final loss depends on the derivative, so backward needs a graph through that derivative calculation.

4How does a KAN edge differ from an ordinary MLP weight?▼

Correct Answer: It can learn a one-dimensional function rather than one scalar multiplier

KANs place learnable functions on connections instead of only scalar weights with fixed node activations.

5What distinguishes a filled triangle from three pairwise graph edges?▼

Correct Answer: It explicitly represents a three-way higher-order cell

A simplicial face encodes a relation among the full triple that pairwise edges alone do not express.

Keep moving through the path

Continue Learning

Free Download: ML Interview Cheatsheet

100 essential Machine Learning interview questions and answers covering foundations, algorithms, evaluation, deep learning, Python, system design and interview strategy. Enter your email to download it instantly.

Optional Learning Resources

These resources may complement the lesson. They are optional and are not required to use ML Academy.

As an Amazon Associate I earn from qualifying purchases. Other links are identified separately when they are not affiliate links.

Finish