Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 63 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,61 @@
# Accuracy Bounds

Install project with
This repository contains the official python-based implementation accompanying the paper:
**“Computable Sharp Accuracy Bounds for Inverse Problems”** ([arXiv:2510.10229](https://arxiv.org/abs/2510.10229))

""
pip install -e .
""
If you use this software in your work, please cite our [preprint](https://arxiv.org/abs/2510.10229):

```bibtex
@article{gottschling2025average,
title={Average Kernel Sizes--Computable Sharp Accuracy Bounds for Inverse Problems},
author={Gottschling, Nina M and Iagaru, David and Gawlikowski, Jakob and Sgouralis, Ioannis},
journal={arXiv preprint arXiv:2510.10229},
year={2025}
}
```

For the definition of the worst-case kernel size, see [preprint](https://arxiv.org/abs/2311.16898):

```bibtex
@article{gottschling2023existence,
title={On the existence of optimal multi-valued decoders and their accuracy bounds for undersampled inverse problems},
author={Gottschling, Nina Maria and Campodonico, Paolo and Antun, Vegard and Hansen, Anders C},
journal={arXiv preprint arXiv:2311.16898},
year={2023}
}
```

## Installation

This project has been tested under **Python 3.7** on a Unix development environment.

### 1. Clone the repository and create a virtual environment and change into the repository folder.
```
git clone https://github.com/nm19000/AccuracyBounds.git
cd AccuracyBounds
```

### 2. Create and activate a virtual environment
```
python -m venv venv
source venv/bin/activate
```
### 3. Install the project
#### 3.1 Lightweight Version (without PyTorch)
```
pip install -e .
```
#### 3.2 Full version (with PyTorch)
```
pip install -e .[torch]
```

# Average Kernel Sizes - Computable Sharp Accuracy Bounds for Inverse Problems

The reconstruction of an unknown quantity from noisy measurements is a mathematical problem relevant in most applied sciences, for example, in medical imaging, radar inverse scattering, or astronomy. This underlying mathematical problem is often an ill-posed (non-linear) reconstruction problem, referred to as an ill-posed inverse problem. To tackle such problems, there exist a myriad of methods to design approximate inverse maps, ranging from optimization-based approaches, such as compressed sensing, over Bayesian approaches, to data-driven techniques such as deep learning. For all stable approximate inverse maps, there are accuracy limits that are strictly larger than zero for ill-posed inverse problems, due to the accuracy-stability tradeoff [Gottschling et al., SIAM Review, 67.1 (2025)] and [Colbrook et al., Proceedings of the National Academy of Sciences, 119.12 (2022)]. The variety of methods that aim to solve such problems begs for a unifying approach to help scientists choose the approximate inverse map that obtains this theoretical optimum. Up to now there do not exist computable accuracy bounds to this optimum that are applicable to all inverse problems. We provide computable sharp accuracy bounds to the reconstruction error of solution methods to inverse problems. The bounds are method-independent and purely depend on the dataset of signals, the forward model of the inverse problem, and the noise model. To facilitate the use in scientific applications, we provide an algorithmic framework and an accompanying software library to compute these accuracy bounds.

## Accuracy Bounds for Inverse Problems


Computation of worst-case and average kernel size for an inverse problem with noise of the form:

$$
Expand All @@ -27,38 +68,15 @@ The lower bound to the worst-case error of any approximate inverse map is the wo

# Testing

The algorithms for computing the worst-case and average kernel size are tested against linear algebra examples, where the worst-case and average kernel size can be calculated analytically in the limit of infinite datapoints. Thus, we ensure that the implemented algorithms compute the correct quantities. The algorithm versions that run with cuda can be tested with test/test_toy_example_cuda.py. The algorithm versions that only run with numpy can be tested with test/test_toy_example_np.py.
The algorithms for computing the worst-case and average kernel size are tested against linear algebra examples, where the worst-case and average kernel size can be calculated analytically in the limit of infinite datapoints. Thus, we ensure that the implemented algorithms compute the correct quantities. The algorithm versions that run with cuda can be tested with ``test/test_toy_example_torch.py``. The algorithm versions that only run with numpy can be tested with ``test/test_toy_example_np.py``. All tests in the project can be automatically run by calling ``pytest``.

For computing the feasible sets there are two versions to compute these available: in terms of list and in terms of feasible appartenance matrices that allocate data points to feasible sets. Both versions are suitable for forward models with additive noise.

For interactive testing the algorithms to compute the worst-case and average kernel size with numpy and cuda please see test/playground/testing.ipynb.

# References
If you use this software in your work, please cite our [preprint](https://arxiv.org/abs/2510.10229):

```bibtex
@article{gottschling2025average,
title={Average Kernel Sizes--Computable Sharp Accuracy Bounds for Inverse Problems},
author={Gottschling, Nina M and Iagaru, David and Gawlikowski, Jakob and Sgouralis, Ioannis},
journal={arXiv preprint arXiv:2510.10229},
year={2025}
}
```

For the definition of the worst-case kernel size, see [preprint](https://arxiv.org/abs/2311.16898):

```bibtex
@article{gottschling2023existence,
title={On the existence of optimal multi-valued decoders and their accuracy bounds for undersampled inverse problems},
author={Gottschling, Nina Maria and Campodonico, Paolo and Antun, Vegard and Hansen, Anders C},
journal={arXiv preprint arXiv:2311.16898},
year={2023}
}
```
For interactive testing the algorithms to compute the worst-case and average kernel size with numpy and cuda please see ``test/playground/testing.ipynb``.

## Experiments from [Paper](https://arxiv.org/abs/2510.10229)

We demonstrate the validity of the algorithms on two inverse problems from different domains: fluorescence localization microscopy and super-resolution of multi-spectral satellite data. The code for generating the data for reproducing the localization microscopy experiments can be found in examples/data/localization_microscopy/data_A/source_code. The data used for the localization microscopy experiments can be found in examples/data/localization_microscopy. To reproduce the tabular data for the figures and tables in this manuscript, the average kernel size and loss computations, can be found in examples/example_localizationmicroscopy.ipynb. The instructions for reproducing the satellite data super-resolution experiments are to be found below.
We demonstrate the validity of the algorithms on two inverse problems from different domains: fluorescence localization microscopy and super-resolution of multi-spectral satellite data. The code for generating the data for reproducing the localization microscopy experiments can be found in ``examples/data/localization_microscopy/data_A/source_code``. The data used for the localization microscopy experiments can be found in examples/data/localization_microscopy. To reproduce the tabular data for the figures and tables in this manuscript, the average kernel size and loss computations, can be found in ``examples/example_localizationmicroscopy.ipynb``. The instructions for reproducing the satellite data super-resolution experiments are to be found below.

### Satellite Data Super Resolution Experiments

Expand Down Expand Up @@ -104,37 +122,43 @@ The data used in our experiments can be downloaded from the indications on [hugg
### Preliminary Kernel Size Computations

Run the command
" python test/S2_SR/Kernelsize_computations.py "
with the desired options specified in the file Kernelsize_computations.py
```
python test/S2_SR/Kernelsize_computations.py
```
with the desired options specified in the file ``Kernelsize_computations.py``

### Preliminary Operator Computations

To calculate the downsampling operator and its kernel projection in matrix form, run

" python examples/S2_SR/op_testing.py "
```
python examples/S2_SR/op_testing.py
```

Manually change the values of the following variables inside the python file to enable or discard the corresponding computation or visualization :

```
plot_sparsity = False # To plot the sparsity pattern of the operators \
check_DSOp = False # To check that the downsampling operator uner matrix is correctly computed \
computeDS = False # To compute the downsampling operator under matrix form \
compute_P_null = False # To compute the kenrel projection \
check_P_null = False # To check that the kernel projection operator uner matrix is correctly computed\
scale_plot = False # To plot some satellite images with the scale bars \
```


### Run the experiments

After having run the preliminary kernel size and kernel projection operator computations, the experiments are ready to be reproduced with the command

""
```
python test/S2_SR/experiments.py
""
```

Adjust the following parameters inside the python file:

```
DSHR = True # Whether the lower resolution image is the downsampled version of the high resolution image (we run the experiments with DSHR = true)\
light_loading = False # Whether you use the light dataloader or you want to use stored patches. We run the experiments with the parameter set to false, but it is recommended for more memory and speed efficiency. Warning : it has to correspond with the value of the --light_load parameter in the kernel size computations . If light_loading is set to false, you will need to generate a dataset where each file corresponds to a patch. This can be done using the function build_S2_patched_dataset_DSHR or build_S2_patched_dataset in the utils.py file. Warning such a patched dataset may contain more than 100 000 patches files for 119 full sized images. It is therefore not recommended. If activated, use the dataset SRDataset_perimg_lightload instead of the dataset SRDataset_perimg \
light_loading = False # Whether you use the light dataloader or you want to use stored patches. We run the experiments with the parameter set to false, but it is recommended for more memory and speed efficiency. Warning : it has to correspond with the value of the ``--light_load`` parameter in the kernel size computations . If light_loading is set to false, you will need to generate a dataset where each file corresponds to a patch. This can be done using the function ``build_S2_patched_dataset_DSHR`` or ``build_S2_patched_dataset`` in the ``utils_torch.py`` file. Warning such a patched dataset may contain more than 100 000 patches files for 119 full sized images. It is therefore not recommended. If activated, use the dataset SRDataset_perimg_lightload instead of the dataset SRDataset_perimg \
PS_X = 16 # Patch size in high resolution (has to correspond with the kernel size computations) \
PS_Y = PS_X//4 \
p_norm = 2 # Defines the used norm among the $L^p$ norms \
Expand All @@ -143,7 +167,7 @@ noise_level_KS = 4000 # has to Correspond with the preliminary computations of t
preload_feas_info = True # Preload or not the feasible information from the feasible appartenance matrix. It has to be activated the first time so that the json file grouping the essential information from the feasible appartenance matrix can be saved (it may take more than 30 minutes for 100 000 patches in the dataset). \
pred_type = 'bicub' # The model used for the predictions ('diff' for the opensr-modelm 'bilin' for bilinear interpolation and 'bicub' for bicubic interpolation) \
p = 2 # The p parameter for kernel size and the loss computations

```

Modify the paths root_folder, feas_app_lightl_path etc manually in the file, according the needs.

Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ dependencies = [
"click",
"pdoc",
"numpy",
"torch",
"tqdm",
"joblib",
"scipy",
]

[project.optional-dependencies]
torch = [
"torch",
]

[build-system]
requires = [
"setuptools",
Expand Down
Loading