Skip to main content

Unified forward models, surrogate models, and inverse EM pipelines.

Project description

Inverse Source EM

Deep Learning Methods for Electromagnetic Inverse Source Problems

Version: 0.9.0-beta

This repository provides a complete scientific machine learning framework for electromagnetic inverse source problems in cylindrical geometries. It combines:

  • Physics-based analytical solvers (Helmholtz equation, TM polarization)
  • Neural surrogate models for fast forward simulations
  • Deep learning pipelines for classification and localization of internal sources
  • Modular evaluation suites for reproducible benchmarking
  • A clean, pip-installable Python package (inverse_source_em)

The project has been fully migrated from notebooks into a modern, modular, production-ready architecture.


1. Abstract

We study an inverse source problem inside a dielectric cylinder, belonging to the broader class of inverse scattering problems. The goal is to recover the:

  • number of internal line sources,
  • positions (Cartesian or polar),
  • strengths,

using only electric surface field measurements at a single frequency.

The forward problem is solved analytically using cylindrical harmonics and Bessel/Hankel special functions. The PhysicsTM class provides a stable, vectorized implementation of the TM-polarized Helmholtz equation.

On top of this, we build three machine learning pipelines:

  1. Surrogate EM models for fast forward simulations
  2. Classification models for predicting the number of sources (1–5)
  3. Regression models for localizing 1, 2, or 3 internal sources

The surrogate models enable large-scale dataset generation with high accuracy. The regression pipelines incorporate geometric sampling, canonical ordering, structured losses, and permutation-invariant evaluation.

The results demonstrate high accuracy, strong noise robustness, and reliable generalization even in challenging geometries.


2. Project Structure

inverse-source-em/
│
├── data/
│   ├── classification/
│   ├── regression_1src/
│   ├── regression_2src/
│   ├── regression_3src/
│   └── surrogate/
│
├── models/
│   ├── surrogate_Esurf.pth
│   ├── surrogate_Hsurf.pth
│   ├── classifier_1_to_5_resnet1d.pt
│   ├── regression_1src/
│   ├── regression_2src/
│   └── regression_3src/
│
├── scripts/
│   ├── make_1src_dataset.py
│   ├── make_2src_dataset.py
│   ├── make_3src_dataset.py
│   ├── make_classification_dataset.py
│   ├── make_surrogate_dataset.py
│   ├── train_1src_model.py
│   ├── train_2src_model.py
│   ├── train_3src_model.py
│   ├── train_classification_model.py
│   └── train_surrogate_models.py
│
├── evaluation/
│   ├── classification/
│   ├── regression_1src/
│   ├── regression_2src/
│   ├── regression_3src/
│   └── surrogates/
│
├── notebooks/
│   ├── regression_1src_evaluation.ipynb
│   ├── regression_2src_evaluation.ipynb
│   ├── regression_3src_evaluation.ipynb
│   ├── classification_evaluation.ipynb
│   └── physics_vs_surrogate.ipynb
│
├── src/inverse_source_em/
│   ├── surrogate/
│   ├── data/
│   ├── physics/
│   ├── training/
│   ├── evaluation/
│   └── utils/
│
├── pyproject.toml
├── requirements.txt
└── README.md

3. Surrogate Pipeline (Canonical & Frozen)

The surrogate pipeline is complete and frozen. It provides:

  • SurrogateEM — unified EM surrogate model
  • SurrogateMLP — configurable MLP surrogate
  • SurrogateWrapper — PhysicsTM-compatible interface
  • Sampling and dataset generation utilities

These models form the reference baseline for all inverse tasks.


4. Classification Pipeline (Completed)

Predicts the number of internal sources (1–5) from surface field intensities.

Includes:

  • Sampling (sampling_classification.py)
  • Dataset generation (generator_classification.py)
  • PyTorch dataset wrapper (dataset_classification.py)
  • ResNet1D classifier (classification_model.py)
  • Training script (train_classification_model.py)
  • Evaluation suite (evaluation/classification/)

Baseline performance:

  • Validation accuracy: ~0.984
  • Test accuracy: ~0.985
  • Strong robustness to additive noise

5. Regression Pipelines

5.1 Single-Source Localization (1src)

  • Predicts (x, y, I)
  • Canonical sampling
  • High accuracy and noise robustness
  • Full evaluation suite

5.2 Two-Source Localization (2src)

  • Predicts (x1, y1), (x2, y2)
  • Fully permutation-invariant
  • Strong performance across all geometry levels
  • Full evaluation suite

5.3 Three-Source Localization (3src) — New in v0.9.0-beta

  • Predicts (x1, y1), (x2, y2), (x3, y3)
  • Canonical ordering
  • Geometry-level sampling (Levels 1–8)
  • Modular evaluation suite:
    • accuracy
    • error tables
    • noise robustness
    • stress tests
    • timing
    • run_all (CLI entrypoint)

Run the full evaluation:

python -m evaluation.regression_3src.run_all

6. Installation

From source

git clone https://github.com/<username>/inverse-source-em.git
cd inverse-source-em
pip install -e .

Requirements

pip install -r requirements.txt

7. Usage Examples

Surrogate forward model

from inverse_source_em.surrogate import SurrogateEM, SurrogateWrapper
from inverse_source_em.physics import PhysicsTM

phys = PhysicsTM()
sur = SurrogateEM(
    path_E="models/surrogate_Esurf.pth",
    path_H="models/surrogate_Hsurf.pth",
    R=phys.R
)
wrap = SurrogateWrapper(sur)

E = wrap.Esurf(rho_s, phi_s, theta)

Classification inference

import torch
from inverse_source_em.training.classification_model import SourceCountResNet1D

model = SourceCountResNet1D(...)
model.load_state_dict(torch.load("models/classifier_1_to_5_resnet1d.pt"))
model.eval()

pred = model(X).argmax(dim=1)

8. Evaluation Suites

Each task has a complete evaluation suite under evaluation/:

  • classification/
  • regression_1src/
  • regression_2src/
  • regression_3src/
  • surrogates/

Each suite includes:

  • accuracy
  • error tables
  • noise robustness
  • stress tests
  • timing
  • run_all (CLI entrypoint)

Run an evaluation:

python -m evaluation.regression_3src.run_all

9. Reproducibility

  • Surrogate pipeline is canonical and frozen
  • Deterministic dataset generation
  • Fixed seeds in training scripts
  • Versioned datasets and models
  • Modular evaluation suites
  • Clean separation of concerns (physics / surrogate / ML / evaluation)

10. License

This project is licensed under the MIT License.


11. Citation

If you use this project in academic work, please cite:

Papadopoulos, T. D.
Master Thesis in Applied Mathematics
Hellenic Open University


12. Roadmap

  • Surrogate pipeline (canonical)
  • Classification pipeline
  • Regression 1src
  • Regression 2src
  • Regression 3src
  • Unified evaluation suites
  • GitHub release v0.9.0-beta
  • pip packaging
  • Regression IV (variable number of sources)
  • v1.0.0 stable release

13. Acknowledgments

I would like to express my sincere gratitude to my supervisor, Professor Nikolaos Tsitsas, whose guidance, insight, and continuous support were instrumental throughout the development of this research.

I would also like to acknowledge the team behind Microsoft Copilot for developing an advanced AI assistant that greatly facilitated the organization, refinement, and documentation of this project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inverse_source_em-0.1.0.tar.gz (51.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

inverse_source_em-0.1.0-py3-none-any.whl (69.0 kB view details)

Uploaded Python 3

File details

Details for the file inverse_source_em-0.1.0.tar.gz.

File metadata

  • Download URL: inverse_source_em-0.1.0.tar.gz
  • Upload date:
  • Size: 51.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for inverse_source_em-0.1.0.tar.gz
Algorithm Hash digest
SHA256 894314cd810b9584b192d4245bf4748c500e8f84d9f0eea5bd3b8802ea83da4a
MD5 85472408f9e3ca28296ebde5b97fe3d4
BLAKE2b-256 2ead5d9cd40470d4aa4f32c3a47995954e71d860999f2416d163c56bcadaa99a

See more details on using hashes here.

File details

Details for the file inverse_source_em-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for inverse_source_em-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 598ae06d7dc0f3a8f11201b1b1bfdef007e56656ea24cff74af1a7a8fd3626a7
MD5 5bb66b8c9d063fa539cfb4944b614478
BLAKE2b-256 f1934af2dbb65ce491bc914870b4a2f24648eeeaefc6952ae7940e40a87ffc45

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page