Differentiable Euler-density morphology loss / REPORT.md
Mechanism confirmed, baseline not beaten
Differentiable Euler-density morphology loss
Implementation
run_experiment.py implements the proposed cubical statistic for images in [0,1]:
chi = mean(s) - mean(horizontal pairs) - mean(vertical pairs) + mean(2x2 products)
where s=sigmoid((x-threshold)/temperature). It also includes an exact hard-threshold implementation and a small denoising experiment with an auxiliary multi-threshold Euler loss.
Run with:
/home/maxwelhelp/main/bin/python3 run_experiment.py
The output is saved to results.json.
Toy mechanism checks
Fixed seeds were used throughout.
-
Zero-temperature prediction: away from threshold ties, the soft statistic should converge to the hard cubical statistic as
T -> 0. Observed mean absolute errors:- T=0.20: 0.02207
- T=0.10: 0.01469
- T=0.05: 0.01004
- T=0.02: 0.00599
- T=0.01: 0.00394
This is monotonic convergence, consistent with the sigmoid becoming a binary occupancy.
-
Constant-field prediction: for an entirely occupied or empty bulk lattice, the per-area inclusion-exclusion terms cancel:
1-1-1+1=0for occupied and0for empty. The observed values were occupied0.0and empty1.93e-22, matching prediction. -
IID Bernoulli prediction: if occupancy is iid Bernoulli(q), the expected statistic is
q-q²-q²+q⁴ = q-2q²+q⁴. At q=0.35, prediction is0.12000625; the measured value over 512 48x48 fields was0.11982739, absolute error0.00017886.
These checks support the inclusion-exclusion mechanism and its differentiable relaxation.
Mini denoising experiment
A tiny 3-layer convolutional denoiser was trained for 80 equal optimizer steps on 128 synthetic 16x16 images containing noisy disks or rectangles. The Euler target was computed from the clean training set at thresholds [0.2,0.4,0.6,0.8] with temperature 0.05. The idea model used lambda=0.2 and temperature 0.1; the baseline used the same network, seed, data, optimizer, and steps with lambda=0.
| metric | baseline | Euler loss | |---|---:|---:| | pixel MSE | 0.00597470 | 0.00597462 | | hard Euler curve MAE | 0.00132996 | 0.00132935 | | soft target MSE | 0.00031454 | 0.00031418 |
The morphology improvements are about 0.05% relative and the pixel MSE difference is negligible. Thus the mechanism is real and numerically verified, but this tiny test does not establish a meaningful practical quality win.