Skip to content

Commit 3487d99

Browse files
committed
Accepted to ICLR 24 :)
1 parent 06977d4 commit 3487d99

9 files changed

+66
-37
lines changed

README.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
[![Python 3.8.0](https://img.shields.io/badge/python-3.8.10+-blue?logo=python&logoColor=white)](https://www.python.org/downloads/release/python-3810/)
1+
[![Python 3.8.10](https://img.shields.io/badge/python-3.8.10+-blue?logo=python&logoColor=white)](https://www.python.org/downloads/release/python-3810/)
22
[![NumPy](https://img.shields.io/badge/numpy-1.24.3+-green?logo=numpy&logoColor=white)](https://pypi.org/project/numpy/1.24.3/)
33
[![Matplotlib](https://img.shields.io/badge/matplotlib-3.7.1+-green?logo=plotly&logoColor=white)](https://pypi.org/project/matplotlib/3.7.1)
44
[![Notebook](https://img.shields.io/badge/notebook-6.5.4+-green?logo=jupyter&logoColor=white)](https://pypi.org/project/notebook/6.5.4)
55
[![torch](https://img.shields.io/badge/torch-2.0.0+-green?logo=pytorch&logoColor=white)](https://pytorch.org/)
66
[![torchvision](https://img.shields.io/badge/torchvision-0.15.1+-green?logo=pytorch&logoColor=white)](https://pytorch.org/)
77

8-
# On the Posterior Distribution in Denoising: Application to Uncertainty Quantification Official Implementation
8+
# On the Posterior Distribution in Denoising: Application to Uncertainty Quantification Official Implementation [ICLR 2024]
9+
910

1011
### [Project page](https://HilaManor.github.io/GaussianDenoisingPosterior) | [Arxiv](https://arxiv.org/abs/2309.13598) | [Supplementary materials](https://hilamanor.github.io/GaussianDenoisingPosterior/resources/supp.pdf)
1112

@@ -92,10 +93,12 @@ https://github.com/HilaManor/GaussianDenoisingPosterior/assets/53814901/7d209056
9293
If you use this code for your research, please cite our paper:
9394
9495
```
95-
@article{manor2023posterior,
96+
@inproceedings{
97+
manor2024posterior,
9698
title={On the Posterior Distribution in Denoising: Application to Uncertainty Quantification},
97-
author={Hila Manor and Tomer Michaeli}, journal={arXiv preprint arXiv:2305.10124},
98-
journal={arXiv preprint arXiv:2309.13598},
99-
year={2023},
99+
author={Hila Manor and Tomer Michaeli},
100+
booktitle={The Twelfth International Conference on Learning Representations},
101+
year={2024},
102+
url={https://openreview.net/forum?id=adSGeugiuj}
100103
}
101104
```

docs/index.html

+32-19
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
<!-- top - author names, affiliation and links -->
5454
<center>
5555
<h1>On the Posterior Distribution in Denoising:<br> Application to Uncertainty Quantification</h1>
56-
<h4>Under Review</h4>
56+
<h4>ICLR 2024</h4>
5757
<div class="container-xl">
5858
<div class="row justify-content-center">
5959
<div class="col-md-auto">
@@ -72,9 +72,6 @@ <h4>Under Review</h4>
7272
<div class="col-md-auto">
7373
<span style="font-size:24px"><a href='resources/paper.pdf' target="_blank" rel="noopener noreferrer">[<i class="fas fa-file-pdf"></i> Paper]</a></span>
7474
</div>
75-
<div class="col-md-auto">
76-
<span style="font-size:24px"><a href='resources/supp.pdf' target="_blank" rel="noopener noreferrer">[<i class="fas fa-file-pdf"></i> Supplementary]</a></span>
77-
</div>
7875
<div class="col-md-auto">
7976
<span style="font-size:24px"><a href="https://github.com/HilaManor/GaussianDenoisingPosterior/" target="_blank" rel="noopener noreferrer">[<i class="fab fa-github"></i> Code]</a></span>
8077
</div>
@@ -441,20 +438,23 @@ <h1 style="margin-top: 10px;">Abstract</h1>
441438
border-radius: 20px;
442439
padding: 0;;">
443440

444-
@article{manor2023posterior,
441+
@inproceedings{
442+
manor2024posterior,
445443
title={On the Posterior Distribution in Denoising: Application to Uncertainty Quantification},
446-
author={Hila Manor and Tomer Michaeli}, journal={arXiv preprint arXiv:2305.10124},
447-
journal={arXiv preprint arXiv:2309.13598},
448-
year={2023},
444+
author={Hila Manor and Tomer Michaeli},
445+
booktitle={The Twelfth International Conference on Learning Representations},
446+
year={2024},
447+
url={https://openreview.net/forum?id=adSGeugiuj}
449448
}
449+
450450
</pre>
451451
</tbody>
452452
</table>
453453
<!-- end bibtex citation -->
454454

455455
<div class="container-xl">
456456
<p class="text-left">
457-
More results and further discussion about our method can be found in the <a href="resources/supp.pdf" target="_blank" rel="noopener noreferrer">supplementary material</a>.<br>
457+
More results and further discussion about our method can be found in the supplementary material (included in the <a href="resources/paper.pdf" target="_blank" rel="noopener noreferrer">paper</a>).<br>
458458
Our official code implementation can be found in the official <a href="https://github.com/HilaManor/GaussianDenoisingPosterior" target="_blank" rel="noopener noreferrer">github repository</a>.
459459
</p>
460460
</div>
@@ -463,21 +463,13 @@ <h1 style="margin-top: 10px;">Abstract</h1>
463463
<table class="table" width="1" style="max-width: 400px;">
464464
<tbody>
465465
<tr>
466-
<td width="50%" style="text-align: center;">
467-
<a target="_blank" rel="noopener noreferrer" href="resources/supp.pdf" style="color:black !important;">
468-
<img alt="" id="supp" class="round" width="100%" style="max-width:150px" border="1px solid" src="./resources/supp.jpg"/>
469-
</a>
470-
</td>
471466
<td width="50%" style="text-align: center;">
472467
<a href="https://github.com/HilaManor/GaussianDenoisingPosterior" target="_blank" rel="noopener noreferrer">
473468
<img alt="" id="github_logo" class="round" width="100%" style="max-width:150px" src="./resources/github_logo.png"/>
474469
</a>
475470
</td>
476471
</tr>
477472
<tr>
478-
<td style="font-size:14pt; text-align: center;">
479-
<a href='resources/supp.pdf' target="_blank" rel="noopener noreferrer">[Supplementary]</a>
480-
</td>
481473
<td style="font-size:14pt; text-align: center;">
482474
<a target="_blank" rel="noopener noreferrer" href='https://github.com/HilaManor/GaussianDenoisingPosterior'>[Code]</a>
483475
</td>
@@ -488,15 +480,36 @@ <h1 style="margin-top: 10px;">Abstract</h1>
488480

489481
<hr>
490482
<br>
483+
<!-- NPPC -->
484+
<div class="container-xl">
485+
<center><h3>Related Work</h3></center>
486+
<p style="font-size: 11pt;">
487+
The field of Uncertainty quantification has seen increased interest over the last few years.
488+
Apart from related works discussed in the paper, we would like to highlight a concurrent related work by
489+
<a target="_blank" rel="noopener noreferrer" href="https://eliasnehme.github.io/">Elias Nehme</a>,
490+
<a target="_blank" rel="noopener noreferrer" href="https://www.linkedin.com/in/yairomer/">Omer Yair</a>,
491+
and <a href="https://tomer.net.technion.ac.il/" target="_blank" rel="noopener noreferrer">Tomer Michaeli</a>:
492+
</p>
493+
<center>
494+
<p style="font-size:14pt; margin-top: 5px;"><strong>Uncertainty Quantification via Neural Posterior Principal Components</strong><br>
495+
Elias Nehme, Omer Yair, Tomer Michaeli.
496+
<a href="https://arxiv.org/abs/2309.15533" target="_blank" rel="noopener noreferrer">[<i class="ai ai-arxiv"></i> ArXiv]</a>
497+
<a href="https://eliasnehme.github.io/NPPC/" target="_blank" rel="noopener noreferrer">[Project Webpage]</a>
498+
<br>
499+
</p>
500+
</center>
501+
</div>
502+
503+
<hr><br>
491504

492505
<!-- acknowledgement -->
493506
<div class="container-xl">
494507
<center><h3>Acknowledgements</h3></center>
495508
<p style="font-size: 11pt;">
496509
This webpage was originally made by <a href="https://www.linkedin.com/in/matan-kleiner/" target="_blank" rel="noopener noreferrer">Matan Kleiner</a> with the
497510
help of <a target="_blank" rel="noopener noreferrer" href="https://www.linkedin.com/in/hilamanor/">Hila Manor</a>
498-
for <a target="_blank" rel="noopener noreferrer" href="https://matankleiner.github.io/sinddm/">SinDDM</a> and can be used as a template.<br>
499-
It is inspired by the template that was originally made by <a target="_blank" rel="noopener noreferrer" href="http://web.mit.edu/phillipi/">Phillip Isola</a> and
511+
for <a target="_blank" rel="noopener noreferrer" href="https://matankleiner.github.io/sinddm/">SinDDM</a> and can be used as a <a target="_blank" rel="noopener noreferrer" href="https://github.com/matankleiner/academic-webpage-template/tree/main">template</a>.<br>
512+
It is inspired by the template that was originally made by <a target="_blank" rel="noopener noreferrer" href="http://web.mit.edu/phillipi/">Phillip Isola</a> and
500513
<a target="_blank" rel="noopener noreferrer" href="http://richzhang.github.io/">Richard Zhang</a> for a <a target="_blank" rel="noopener noreferrer" href="http://richzhang.github.io/colorization/">colorful</a> ECCV project;
501514
the code for the original template can be found <a target="_blank" rel="noopener noreferrer" href="https://github.com/richzhang/webpage-template">here</a>.<br>
502515
A lot of features are taken from <a target="_blank" rel="noopener noreferrer" href="https://getbootstrap.com/">bootstrap</a>. All icons are taken from <a target="_blank" rel="noopener noreferrer" href="https://fontawesome.com/">font awesome</a>.

docs/resources/paper.pdf

100755100644
14.4 MB
Binary file not shown.

docs/resources/supp.jpg

-188 KB
Binary file not shown.

docs/resources/supp.pdf

-14.1 MB
Binary file not shown.

main.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@
150150
sigma = args.noise_std
151151
else:
152152
sigma = (args.noise_std / 255.)
153-
nim = im + sigma * torch.randn_like(im)
153+
noisemap = torch.randn_like(im)
154+
nim = im + sigma * noisemap
154155
# if 'DDPM_FFHQ' not in args.denoiser:
155156
if 'MNIST' in args.denoiser:
156157
nim = nim.clip(0, 1)
@@ -186,20 +187,23 @@
186187
os.makedirs(outdir, exist_ok=True)
187188

188189
# pylint: disable=unbalanced-tuple-unpacking
189-
eigvecs, eigvals, mmse, sigma, subspace_corr = get_eigvecs(model,
190+
eigvecs, eigvals, masked_mmse, sigma, subspace_corr, mmse = get_eigvecs(model,
190191
nim, # .unsqueeze(0),
191192
mask, # .unsqueeze(0),
192193
args.n_ev,
193194
sigma,
194195
device,
195196
c=args.const, iters=args.iters,
196197
double_precision=args.double_precision)
198+
save_im = model.save_im
199+
toim = model.toim
200+
save_im(toim(mmse.cpu()), os.path.join(outdir, 'mmse.png'))
197201
save_eigvecs(eigvecs, eigvals, outdir)
198202

199203
max_entropy_params = None
200204
if args.marginal_dist:
201205
moments = calc_moments(model, nim, mask, sigma, device,
202-
mmse, eigvecs, eigvals,
206+
masked_mmse, eigvecs, eigvals,
203207
var_c=args.var_c, skew_c=args.skew_c, kurt_c=args.kurt_c,
204208
use_poly=args.use_poly, poly_deg=args.poly_deg,
205209
poly_bound=args.poly_bound, poly_pts=args.poly_pts,
@@ -209,7 +213,7 @@
209213

210214
patch = im[mask.to(torch.bool).cpu()].reshape(
211215
mask.shape[0], int(np.floor(selected_coords['y2'])) - int(np.ceil(selected_coords['y1'])), -1)
212-
rpatch = mmse[mask.to(torch.bool)].reshape(
216+
rpatch = masked_mmse[mask.to(torch.bool)].reshape(
213217
mask.shape[0], int(np.floor(selected_coords['y2'])) - int(np.ceil(selected_coords['y1'])), -1)
214218
npatch = nim[mask.to(torch.bool).cpu()].reshape(
215219
mask.shape[0], int(np.floor(selected_coords['y2'])) - int(np.ceil(selected_coords['y1'])), -1)
@@ -224,4 +228,5 @@
224228
name, outdir, args.denoiser, path_name,
225229
amount=args.amount,
226230
max_entropy_params=max_entropy_params,
227-
subspace_corr=subspace_corr)
231+
subspace_corr=subspace_corr,
232+
noisemap=noisemap)

max_entropy_utils.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def _validate_fit_converged(moments: Moments, ev_idx: int, coeffs: List[float],
6363

6464
est_vmu1 = delta * sum(xs * pdf)
6565
est_vmu2 = delta * sum((xs - est_vmu1)**2 * pdf)
66+
est_vmu3 = delta * sum((xs - est_vmu1)**3 * pdf)
67+
est_vmu4 = delta * sum((xs - est_vmu1)**4 * pdf)
6668

6769
return (abs(est_vmu1 - moments.vmu1[ev_idx]) / abs(moments.vmu1[ev_idx])) < 0.5 and \
68-
(abs(est_vmu2 - moments.vmu2[ev_idx]) / abs(moments.vmu2[ev_idx])) < 0.5
70+
(abs(est_vmu2 - moments.vmu2[ev_idx]) / abs(moments.vmu2[ev_idx])) < 0.5 and \
71+
(abs(est_vmu3 - moments.vmu3[ev_idx]) / abs(moments.vmu3[ev_idx])) < 0.5 and \
72+
(abs(est_vmu4 - moments.vmu4[ev_idx]) / abs(moments.vmu4[ev_idx])) < 0.5

moments_calculations.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def get_eigvecs(model: torch.nn.Module,
2323
iters: int = 5,
2424
double_precision: bool = False,
2525
compare_backprop: bool = False) -> Union[
26-
Tuple[torch.Tensor, torch.Tensor, torch.Tensor, float, Optional[List]],
27-
Tuple[torch.Tensor, torch.Tensor, torch.Tensor, float, Optional[List],
26+
Tuple[torch.Tensor, torch.Tensor, torch.Tensor, float, Optional[List]], torch.Tensor,
27+
Tuple[torch.Tensor, torch.Tensor, torch.Tensor, float, Optional[List], torch.Tensor,
2828
List[Tuple[float, float]], torch.Tensor]]:
2929
r"""Calculate the eigvecs of the covariance matrix using power iterations
3030
$\mu_1(y + \epsilon) - \mu_1(y) ~ \frac{d\mu_1(y)}{dy}\cdot\epsilon$$
@@ -47,6 +47,7 @@ def get_eigvecs(model: torch.nn.Module,
4747
nim = nim.to(device)
4848
with torch.no_grad():
4949
im_mmse = _forward_directional(model, nim.unsqueeze(0), device, 0, 0, double_precision).squeeze(0)
50+
5051
print(f'MSE (x_hat, y): {torch.nn.functional.mse_loss(im_mmse, nim)}')
5152
print(f'sqrt (MSE (x_hat, y)): {torch.nn.functional.mse_loss(im_mmse, nim).sqrt()}')
5253
print(f'assumed noise sigma: {sigma}')
@@ -59,7 +60,7 @@ def get_eigvecs(model: torch.nn.Module,
5960
sigma = torch.nn.functional.mse_loss(im_mmse, nim).sqrt().item()
6061
print(f'Using assumed noise sigma: {sigma}')
6162
b_masked_mmse = (im_mmse * mask).repeat(n_ev, *[1]*len(nim.shape)).to(device)
62-
del im_mmse
63+
# del im_mmse
6364
torch.cuda.empty_cache()
6465
nim = nim.repeat(n_ev, *[1]*len(nim.shape)).to(device)
6566
eigvecs = torch.randn(*nim.shape, device=device, dtype=nim.dtype) * mask * c
@@ -112,9 +113,9 @@ def get_eigvecs(model: torch.nn.Module,
112113
eigvecs = eigvecs[indices, ...] # TODO ?????? swap places??
113114

114115
if compare_backprop:
115-
return eigvecs, eigvals, b_masked_mmse[0], sigma, corr, cosine_similarity, timing, eigvecs_backprop
116+
return eigvecs, eigvals, b_masked_mmse[0], sigma, corr, im_mmse, cosine_similarity, timing, eigvecs_backprop
116117

117-
return eigvecs, eigvals, b_masked_mmse[0], sigma, corr
118+
return eigvecs, eigvals, b_masked_mmse[0], sigma, corr, im_mmse
118119

119120

120121
def calc_moments(model: torch.nn.Module,

plotting.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ def plot_eigvecs(model: ModelWrapper,
5050
amount: int = 1,
5151
subspace_corr: Optional[List] = None,
5252
max_axis: float = 3,
53-
delta: float = 0.01):
53+
delta: float = 0.01,
54+
noisemap: Optional[torch.Tensor] = None):
5455

5556
n_ev = eigvecs.shape[0]
5657

@@ -151,6 +152,8 @@ def plot_eigvecs(model: ModelWrapper,
151152
save_im(toim(im), os.path.join(outdir, 'im.png'))
152153
save_im(toim(nim), os.path.join(outdir, 'nim.png'))
153154
save_im(toim(fullnim), os.path.join(outdir, 'fullnim.png'))
155+
if noisemap is not None:
156+
torch.save(noisemap.cpu(), os.path.join(outdir, 'noisemap.pth'))
154157

155158
plt.close(fig)
156159

0 commit comments

Comments
 (0)