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).
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.
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.
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.
- 1D CNN (baseline)
- Reformulated PINN, λ = 0.1
Error map
0.68 m6.21 mMean error per position, from lowest to highest◆ Gateway
Comparison
| Model | Mean (m) | Median (m) | P90 (m) | Gap to the CNN (mean) |
|---|---|---|---|---|
| 1D CNN (baseline) | 2.70 | 2.51 | 4.00 | baseline |
| Reformulated PINN, λ = 0.1 | 2.28 | 2.27 | 2.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.
A package and one commanduvTyperYAML + pydantic
The problemThe research code was a package and six scripts: nobody else knew what to run.What I didA single command,herbs, reads a settings file (YAML) and replays an experiment. Pydantic checks the file before any computation.Real excerptconfigs/kfold_pinn_trace.yamlnom: kfold_pinn_trace … protocole: type: kfold …to runuv run herbs evaluate kfold --config configs/kfold_pinn_trace.yamlSkillMaking a Python project installable and runnable by someone else.Tests without private datapytestsynthetic dataGitHub Actions
The problemThe real data is private: I cannot publish it to prove that the code works.What I didMore 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-mlflowA GitHub Actions workflow (a service that reruns the tests on every change) is written; it will run once the repository is online.SkillWriting tests that run without the private data, and automating them.A record of every runMLflow
The problemA number without its settings or its code version cannot be redone.What I didEvery run is recorded in MLflow, a tracking tool: settings, metrics, figures and the exact Git commit.Real excerptsrc/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__,SkillKeeping a record of every experiment so it can be compared and redone.An APIFastAPIinput validation
The problemAnother application must be able to ask for a position without knowing anything about PyTorch.What I didA 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 excerptdocs/api.mdcurl -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.SkillExposing a model as a reliable web service that rejects absurd inputs.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 didA 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 excerptdocker/DockerfileFROM python:3.12-slim AS base … USER herbs … FROM base AS apidocker/compose.ymlvolumes: ["../artefacts:/app/artefacts:ro"]SkillPackaging a service so it runs identically anywhere, with limited rights.A serverOnlineVPS (rented server)CaddyHTTPS
The problemAn API running on my computer is of no use to anyone else.What I didThe 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 excerptto runcurl -s https://api.yanis-andre.fr/healthrecorded 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).SkillPutting a service online over HTTPS and connecting it to a web page.
Try the API
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