GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - wcz234/d2nn-robustness-hybrid: Protocol-bound numerical evaluation of diffractive neural network robustness and hybrid optoelectronic readout (MNIST + Fashion-MNIST)

BranchesTags
Open more actions menu

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
docs
docs
 
 
paper
paper
 
 
results
results
 
 
simulator
simulator
 
 
third_party/nonlinear-d2nn
third_party/nonlinear-d2nn
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CITATION.cff
CITATION.cff
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build_protocol_v2.py
build_protocol_v2.py
 
 
build_protocol_v3.py
build_protocol_v3.py
 
 
build_protocol_v4.py
build_protocol_v4.py
 
 

Repository files navigation

Protocol-bound numerical evaluation of D²NN robustness and hybrid optoelectronic inference

Diffractive deep neural networks (D²NN) are sensitive to layer misalignment, propagation-distance error, phase noise, detector noise and phase quantization. Published robustness-training methods and hybrid optoelectronic readouts are usually evaluated under their own training settings, condition sets and statistical conventions, so their results cannot be compared directly, and the boundary between numerical-simulation evidence and hardware-performance claims is often blurred.

This repository contains the code, frozen experiment protocols, result summaries and manuscript sources for a protocol-bound comparison of four families of methods on MNIST and Fashion-MNIST:

  • baseline D²NN — ten fixed detector regions, clean training
  • robust D²NN — perturbation-aware training over misalignment, gap error, phase noise and detector noise
  • hybrid — the same optical front end with a learned electronic readout
  • pure-electronic references — a 784-18-10 MLP and a LeNet-5-style CNN

All optical-compatible methods share one frozen evaluation plan of 14 conditions and 34 deployment draws, evaluated on the complete test set. The independent statistical unit is the training seed; test images, deployment draws and timing repeats are not treated as independent replicates.

Headline results

Finding Evidence
Perturbation-aware training is condition-selective, not uniformly better 1.33 pp clean cost; +2.20 / +2.76 / +17.91 pp at 0.50 px shift, mixed stress and four-level quantization; below baseline under gap error, phase noise and detector noise
The four-level quantization failure is a training problem, not an architectural one QAT hybrid reaches 94.10% (95% CI 92.61–95.58) at four levels versus 67.69% for the non-QAT hybrid; paired gain +26.41 pp (9.26–43.56)
The hybrid gain comes from a learned readout, not from electronic nonlinearity Replacing the 64-32-10 MLP with a single linear map gives 96.60% (paired +0.91 pp, CI −0.21–2.02, not distinguishable); 4×4 pooling instead of 8×8 costs nothing detectable
The comparison depends on how strong the electronic reference is LeNet-5 reaches 98.25% clean, above the hybrid's 95.68%
The condition-ordering pattern replicates on a second dataset On Fashion-MNIST the hybrid is best in 13 of 14 conditions, with four-level quantization again the exception

Full numbers, intervals and per-seed values are in results/ and are registered in docs/EVIDENCE_LEDGER.md.

Repository layout

simulator/        training, evaluation and summarization code (PyTorch)
docs/             frozen protocols, evidence ledger, literature matrix, references
results/          result summaries, per-seed metrics, manifests (predictions excluded)
paper/            manuscript sources (Markdown/Typst), figures, figure source data, tools
third_party/      upstream attribution and the local delta patch

Reproduction

Environment used for the reported runs: Python 3.11.7, PyTorch 2.10.0 (CPU) and 2.5.1+cu124 (GPU), torchvision 0.25.0 / 0.20.1, NumPy 2.4.6, Matplotlib 3.11.1.

cd simulator
python -m pip install -r ../requirements-cpu.txt   # or: uv sync

# 1. train one method/seed (MNIST example, frozen configuration)
python train.py --task classification --dataset mnist \
  --epochs 3 --size 64 --layers 3 --batch-size 128 --lr 0.01 \
  --optics-preset d2nn2018_thz --rs-backend fft \
  --seed 42 --num-workers 0 --experiment-stage formal_mnist_v2 \
  --run-name formal_mnist_v2_baseline_d2nn_seed42 --save-dir ../artifacts/formal_mnist_v2

# 2. evaluate the frozen optical conditions
python evaluate_robustness.py create-protocol-plan \
  --reference-checkpoint ../artifacts/formal_mnist_v2/best_mnist.formal_mnist_v2_baseline_d2nn_seed42.pth \
  --protocol ../docs/FORMAL_EXPERIMENT_PROTOCOL_V2.json \
  --output ../results/formal_mnist_v2/robustness_plan.json
python evaluate_robustness.py run \
  --plan ../results/formal_mnist_v2/robustness_plan.json \
  --checkpoint ../artifacts/formal_mnist_v2/best_mnist.formal_mnist_v2_baseline_d2nn_seed42.pth \
  --output-dir ../results/formal_mnist_v2/robustness/baseline_d2nn_seed42 \
  --method-id baseline_d2nn --batch-size 64 --device cpu

# 3. summarize across training seeds
python summarize_robustness.py \
  --evaluations ../results/formal_mnist_v2/robustness/baseline_d2nn_seed42 ... \
  --output-dir ../results/formal_mnist_v2/robustness_summary

Protocols v2/v3/v4 in docs/ were generated by the scripts at the repository root; re-running them reproduces the frozen protocol files.

Paper build:

python paper/build_typst_zh.py
typst compile --root . paper/manuscript_zh.typ paper/MANUSCRIPT_ZH.pdf
python paper/audit_manuscript_zh.py          # integrity gate over citations, metrics, figures, tables
python paper/tools/verify_manuscript_numbers.py   # re-derives every reported comparison

The audit script needs pypdf; with only PyPDF2 present, provide a shim module named pypdf.

What is not in this repository

  • Per-sample prediction streams (predictions.jsonl, ~240 MB per robustness evaluation). They are regenerated by the evaluate_robustness.py run command for any checkpoint.
  • Training checkpoints (*.pth). The adjacent manifests, which carry configuration, seeds, split hashes, source hashes and checkpoint SHA-256, are retained; the checkpoints themselves are distributed via releases.
  • 600 dpi TIFF figures, which are publisher submission assets; vector PDF/SVG and PNG previews are included.
  • The MNIST / Fashion-MNIST raw files, downloaded automatically by torchvision on first run.

Provenance disclosure

25 evaluation_manifest.json files under results/ embed the environment snapshot taken at run time. That snapshot includes the interpreter path of the machine that produced the run (a Windows user-profile path). It is retained deliberately: each summary manifest references these files by SHA-256, so editing them would break the audit chain that lets a reader recompute every aggregate from the per-seed records. The path contains no credential; it is recorded here so nothing in the tree is a surprise.

Scope and claim boundaries

All results are numerical simulations of fully coherent scalar propagation. The study contains no physical optical bench and no real edge-device measurement. Parameter counts, representation dimensions and CPU wall-clock timings describe model structure and simulator cost only; they are not physical optical latency, device latency, power or energy efficiency, and must not be read as such.

Third-party code

simulator/ is a fork of yeungmkw/nonlinear-d2nn (MIT), pinned at commit f1ae6e3. Upstream attribution, the pinned commit and the exact local delta are recorded in third_party/nonlinear-d2nn/. See also docs/THIRD_PARTY.md.

Citation

See CITATION.cff. The manuscript is included as paper/MANUSCRIPT_ZH.pdf.

License

Research code in this repository is released under the MIT License (see LICENSE). Forked upstream code retains its original MIT license and copyright notice.

About

Protocol-bound numerical evaluation of diffractive neural network robustness and hybrid optoelectronic readout (MNIST + Fashion-MNIST)

Topics

diffractive-neural-networkfashion-mnistmnistnumerical-simulationoptical-computingoptoelectronic-computingphase-quantizationpytorchreproducible-researchrobustness

Resources

Readme
License
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.