Skip to content
Yanis André
FRRésumé ↓
← Back to home

Internship · ISEP · ANR HERBS project

Indoor LoRa localisation with physics-informed neural networks

Bringing the radio propagation model into training so fewer positions need measuring, then industrialising the code: replayable experiments, a model served by an API.

Period
May to September 2026
Role
Research intern, alone on the topic, supervised by three researchers; code industrialised afterwards on my own
Skills
  • Physics-guided deep learning
  • Validation on never-seen zones
  • Putting a model into production
Tools
PyTorch · PINN · MLflow · FastAPI · Docker · pytest · GitHub Actions · Autodiff · NumPy · LaTeX
−16%
error when locating a part of the building that was never measured
−27%
on the worst errors: the level that 90% of positions stay under
1 command
reproduces every experiment
22,203
radio measurements, 63 positions

Context

Visually impaired people need precise indoor localisation, where GPS doesn’t reach. The ANR HERBS project studies radio fingerprinting with LoRa, a long-range, low-power radio technology. Fingerprinting comes down to recognising a place by its radio “fingerprint”. The received signal strength, or RSSI, is measured by several gateways (fixed receiving antennas) at a large number of known positions, and a model then learns to recover the position from the RSSI values. The problem is the cost of this collection. Every building needs hours of measurements before the system works.

The internship’s question: if we inject into training what we already know of the physics, the log-distance propagation model, in which the signal weakens with the logarithm of the distance, can we reach the same accuracy with fewer measured positions?

The dataset, collected by project partners in the basement of a building, comprises 22,203 measurements across 63 positions, six gateways, two bands (868 MHz and 2.4 GHz).

GW1GW2GW3GW4GW5GW62 m
measurement positiongateway
The surveyed basement seen from above: about 10 m by 9 m. The 63 measurement positions sit on a grid with a one-metre step; the diamonds are the six gateways. At each position, we recorded the powers received by the six gateways, on two frequency bands: this series of values is what the model learns to link to the position.

Method

I first built a solid baseline: a 1D CNN, that is, a neural network that reads the vector of six received powers as a short signal. It reproduces published results on a random split. In that split, the test measurements are drawn at random, so each test position also took part in training. I replaced that split with protocols that genuinely measure spatial generalisation, that is, the ability to localise a position never seen before. In leave-one-out, one position is withheld from training then localised, and this is repeated for each one. In spatial K-fold, a whole zone is withheld in the same way, out of ten. Finally, I progressively reduced the number of training positions. The diagrams below show, on the plan of the basement, what each protocol hides and what it keeps, then where the ten zones are.

Random split
Every position is used for both training and testing: the model has nothing to guess.
Leave-one-out
One position is hidden, then located; this is repeated for each one.
Spatial K-fold
A whole zone is hidden (here zone 9 of the plan below): the model has to extrapolate.
Data reduction
Training uses only a fraction of the positions (example draw).
filled dot: used for traininghollow dot: hidden, then to be locatedfaded dot: not used
The ten zones of the spatial K-fold
6666611144441777111101010107910101077999955995558833355538833322223222
Each position carries the number of its zone, and an outline surrounds each zone. The zones are not drawn by hand: they come from an automatic grouping (K-means, a method that gathers nearby points) of the positions by their coordinates, which gives 4 to 8 neighbouring positions per zone. In spatial K-fold, the model trains on nine zones and is tested on the tenth.

Two ways of injecting the physics were compared:

  • A hybrid loss (the loss, that is, the error that training tries to reduce): the network predicts a position, the RSSI the physics predicts at that position is computed, and the gap with the measured RSSI is penalised. The propagation model’s parameters are learned, and the constraint is introduced progressively.
  • A collocation-point PINN, following a reference paper. A PINN is a “physics-informed” neural network, whose training is constrained by a physical equation. Here, it is a partial differential equation linking the variation of RSSI to that of position. It is imposed at collocation points: randomly drawn positions, without measurements, where the network is only required to satisfy the equation.

By analysing this equation, I showed that it is written for a single isolated antenna and cannot be satisfied by the inverse of a multi-gateway model. I proposed an exact reformulation, based on the trace identity of the Jacobian. The Jacobian is the matrix of derivatives of the network’s output with respect to its input: it tells how the predicted position moves when the RSSI values change. I validated this reformulation numerically. This is the internship’s most original contribution.

Results

Here, the error is the distance between the position the model predicts and the true position. To get a sense of scale: the basement is about 10 m by 9 m, and the positions are one metre apart. A model that always answered the centre of the measured positions would be off by 3.77 m on average. An error of 2 m is two grid steps.

Map of the 63 basement positions, coloured by mean leave-one-out localisation error, with the six gateways
Mean error per position in leave-one-out, reformulated PINN variant. Positions at the edges and far from the gateways remain the most difficult.

On positions already densely surrounded by measurements, the physical constraints add almost nothing: the baseline CNN is already good, with 1.66 m mean error in leave-one-out. The benefit appears when the model is asked to extrapolate. In the table, λ is the weight given to the physical constraint during training; at 0 the network ignores physics. The median is the error that splits the positions into two halves. P90, that is, the error below which 90% of positions fall, measures the worst cases.

To read the table, first look at the difference between the two groups of rows. The first two interpolate: the hidden position is surrounded by measured neighbours. The next three extrapolate: a whole zone is hidden, or few positions remain. This is where the physics helps.

Protocol 1D CNN (baseline) Reformulated PINN, λ = 0.1 Gain
Leave-one-out, mean error 1.66 m 1.66 m 0%
Leave-one-out, median 1.53 m 1.42 m −7%
Spatial K-fold, mean error 2.70 m 2.28 m −16%
Spatial K-fold, P90 4.00 m 2.91 m −27%
20% of positions, mean error 2.43 m 2.10 m −14%

The test bench below covers the variants of the internship report. Switch protocol, tick other models: each view matches an experiment that the command shown at the bottom replays.

Test bench

Pick a protocol, tick the models to compare: the internship results update.

A whole zone, out of ten, is withheld from training then located: the model has to extrapolate. The ten zones are an automatic grouping (K-means) of neighbouring positions; each dot on the map carries its zone number.

Models to compare (four at most)
Metric
  • 1D CNN (baseline)
  • Reformulated PINN, λ = 0.1
0.02.04.06.012345678910ZoneError (m)

Error map

6666611144441777111101010107910101077999955995558833355538833322223222GW1GW2GW3GW4GW5GW6

0.68 m6.21 mMean error per position, from lowest to highest◆ Gateway

Comparison

ModelMean (m)Median (m)P90 (m)Gap to the CNN (mean)
1D CNN (baseline)2.702.514.00baseline
Reformulated PINN, λ = 0.12.282.272.91−16%

Reproduce

This view matches a replayable experiment: save the configuration, run the command.

configs/banc_essai_kfold.yaml

nom: banc_essai_kfold
experience_mlflow: kfold_spatial
protocole:
  type: kfold
  zones: 10
  variantes: [cnn, "mlp_pinn:0.1:trace"]
uv run herbs evaluate kfold --config configs/banc_essai_kfold.yaml --resultats /tmp/banc_essai

Results precomputed from the real runs on the private dataset; nothing is recomputed in your browser. Replaying all the protocols is estimated at about 6 h on an Apple Silicon Mac.

Spatial K-fold: 2 model(s) compared

In leave-one-out, the reformulated PINN improves the median (1.53 → 1.42 m) but not the largest errors: its P90 is 2.42 m against 2.25 m for the CNN. Its gains appear in extrapolation, in spatial K-fold and with less data.

The reformulated form of the PINN is the most consistent variant across all protocols. The paper’s original form does no better than a network without physics. The initial target, 0.87 m obtained in a published paper using an SVM, a classic machine-learning method, on ten test positions, is not reached: the best variant gives 1.18 m on these positions.

From research to a service

At the end of the internship, my research code could be neither rerun nor called by anyone else. A six-step chain fixes that: every result becomes replayable (estimated at about 6 h to replay everything), and the model usable by another application.

  1. A package and one commanduvTyperYAML + pydantic
    The problem
    The research code was a package and six scripts: nobody else knew what to run.
    What I did
    A single command, herbs, reads a settings file (YAML) and replays an experiment. Pydantic checks the file before any computation.
    Real excerpt
    configs/kfold_pinn_trace.yaml
    nom: kfold_pinn_trace
    …
    protocole:
      type: kfold
    …
    to run
    uv run herbs evaluate kfold --config configs/kfold_pinn_trace.yaml
    Skill
    Making a Python project installable and runnable by someone else.
  2. Tests without private datapytestsynthetic dataGitHub Actions
    The problem
    The real data is private: I cannot publish it to prove that the code works.
    What I did
    More than 70 tests (93% of lines) run in about ten seconds, on synthetic data in the same format as the real data.
    Real excerpt
    .github/workflows/ci.yml
    - run: uv run ruff check src tests scripts && uv run ruff format --check src tests scripts
    - run: uv run pytest -m "not lent" --cov --cov-report=term --cov-fail-under=80
    - run: uv run herbs reproduce --rapide --donnees data/sample/synthetique.mat --resultats /tmp/res --sans-mlflow
    A GitHub Actions workflow (a service that reruns the tests on every change) is written; it will run once the repository is online.
    Skill
    Writing tests that run without the private data, and automating them.
  3. A record of every runMLflow
    The problem
    A number without its settings or its code version cannot be redone.
    What I did
    Every run is recorded in MLflow, a tracking tool: settings, metrics, figures and the exact Git commit.
    Real excerpt
    src/herbs_loc/tracking.py · tags_environnement
    "git_sha": sha or "inconnu",
    "git_propre": str(etat == "") if etat is not None else "inconnu",
    "version_package": __version__,
    Skill
    Keeping a record of every experiment so it can be compared and redone.
  4. An APIFastAPIinput validation
    The problem
    Another application must be able to ask for a position without knowing anything about PyTorch.
    What I did
    A FastAPI service receives twelve RSSI values (six per band) and returns x and y in metres. It rejects any value outside −150 to 0 dBm.
    Real excerpt
    docs/api.md
    curl -s -X POST localhost:8000/predict -H 'content-type: application/json' \
      -d '{"rssi_868":[-70,-75,-80,-85,-72,-78],"rssi_2_4":[-80,-85,-90,-95,-82,-88]}'
    recorded response
    {"x":4.870173931121826,"y":2.671583652496338,"model":"cnn_hybride_lam0.4","version":"214731f"}
    Response recorded on the demonstration model, trained on synthetic data.
    Skill
    Exposing a model as a reliable web service that rejects absurd inputs.
  5. A containerDockermulti-stage imagenon-root userread-only model
    The problem
    “It works on my machine” is not enough: the service must run the same elsewhere.
    What I did
    A container is a box that carries the program and its dependencies. My Docker image is multi-stage: the API and training images share a base, run unprivileged, and the model is mounted read-only.
    Real excerpt
    docker/Dockerfile
    FROM python:3.12-slim AS base
    …
    USER herbs
    …
    FROM base AS api
    docker/compose.yml
    volumes: ["../artefacts:/app/artefacts:ro"]
    Skill
    Packaging a service so it runs identically anywhere, with limited rights.
  6. A serverOnlineVPS (rented server)CaddyHTTPS
    The problem
    An API running on my computer is of no use to anyone else.
    What I did
    The service runs on a server rented from OVH (a VPS), behind Caddy, a reverse proxy (a doorman placed in front of the API) that obtains its HTTPS certificate on its own.
    Real excerpt
    to run
    curl -s https://api.yanis-andre.fr/health
    recorded response
    {"status":"ok","model":"cnn_hybride_lam0.4","deployed":"…"}
    docker/Caddyfile
    @publiques {
    method GET HEAD OPTIONS
    path /health /model /openapi.json /docs
    }
    SSH by key only, firewall open on three ports, automatic security updates. A script copies a whitelist of files and rebuilds the image on the server. Demonstration model only (synthetic data).
    Skill
    Putting a service online over HTTPS and connecting it to a web page.
The code stays private; it is available on request.

Try the API

Twelve signal-strength measurements (RSSI), six per band, in dBm. Edit them, then locate.
Service online: the button calls the API live.
868 MHz
2.4 GHz
Accepted values: from −150 to 0 dBm.
The served model is a demonstration model trained on synthetic data: its positions are not those of the real basement.

What I took from it

A result only makes sense relative to the protocol that produces it: the same model goes from 1.66 m to 2.70 m depending on whether it interpolates or extrapolates. I learned to use PyTorch’s automatic differentiation, the mechanism that computes derivatives on its own, beyond backpropagation, which trains the network. I used it to place Jacobians of the output with respect to the input inside the loss function. And I learned to read a reference paper by looking for its implicit assumptions, to the point of correcting its equation.

Industrialising the code taught me the other half of the job. A model is only useful if someone else can rerun it and call it: that takes written configurations rather than parameters buried in code, a record of every run, tests that work without the private data and an interface that rejects absurd inputs.

Code access

Private code, available on request

Next projectArrhythmia detection using Legendre polynomials