-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add multi-GPU support to unrolled ADMM.
- Loading branch information
Showing
8 changed files
with
62 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
# ================== | ||
# Authors : | ||
# Yohann PERRON [[email protected]] | ||
# Eric BEZZAM [[email protected]] | ||
# ############################################################################# | ||
|
||
import pathlib as plib | ||
|
@@ -192,7 +193,7 @@ def unfreeze_post_process(self): | |
for param in self.post_process_model.parameters(): | ||
param.requires_grad = True | ||
|
||
def batch_call(self, batch, psfs=None): | ||
def forward(self, batch, psfs=None): | ||
""" | ||
Method for performing iterative reconstruction on a batch of images. | ||
This implementation is a properly vectorized implementation of FISTA. | ||
|
@@ -216,7 +217,7 @@ def batch_call(self, batch, psfs=None): | |
# assert same shape | ||
assert psfs.shape == batch.shape, "psfs must have the same shape as batch" | ||
# -- update convolver | ||
self._convolver = RealFFTConvolve2D(psfs.to(self._psf.device), **self._convolver_param) | ||
self._convolver = RealFFTConvolve2D(psfs.to(self._data.device), **self._convolver_param) | ||
|
||
# pre process data | ||
if self.pre_process is not None: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
# ================= | ||
# Authors : | ||
# Yohann PERRON [[email protected]] | ||
# Eric BEZZAM [[email protected]] | ||
# ############################################################################# | ||
|
||
from lensless.recon.trainable_recon import TrainableReconstructionAlgorithm | ||
|
@@ -130,19 +131,23 @@ def _PsiT(self, U): | |
return finite_diff_adj(U) | ||
|
||
def reset(self, batch_size=1): | ||
|
||
if self._data is not None: | ||
device = self._data.device | ||
else: | ||
device = self._convolver._H.device | ||
|
||
# ensure that mu1, mu2, mu3, tau are positive | ||
self._mu1 = torch.abs(self._mu1_p) | ||
self._mu2 = torch.abs(self._mu2_p) | ||
self._mu3 = torch.abs(self._mu3_p) | ||
self._tau = torch.abs(self._tau_p) | ||
self._mu1 = torch.abs(self._mu1_p).to(device) | ||
self._mu2 = torch.abs(self._mu2_p).to(device) | ||
self._mu3 = torch.abs(self._mu3_p).to(device) | ||
self._tau = torch.abs(self._tau_p).to(device) | ||
|
||
# TODO initialize without padding | ||
if self._initial_est is not None: | ||
self._image_est = self._initial_est | ||
self._image_est = self._initial_est.to(device) | ||
else: | ||
self._image_est = torch.zeros([1] + self._padded_shape, dtype=self._dtype).to( | ||
self._psf.device | ||
) | ||
self._image_est = torch.zeros([1] + self._padded_shape, dtype=self._dtype).to(device) | ||
|
||
self._X = torch.zeros_like(self._image_est) | ||
self._U = torch.zeros_like(self._Psi(self._image_est)) | ||
|
@@ -163,7 +168,7 @@ def reset(self, batch_size=1): | |
self._R_divmat = 1.0 / ( | ||
self._mu1[:, None, None, None, None, None] | ||
* (torch.abs(self._convolver._Hadj * self._convolver._H))[None, ...] | ||
+ self._mu2[:, None, None, None, None, None] * torch.abs(self._PsiTPsi) | ||
+ self._mu2[:, None, None, None, None, None] * torch.abs(self._PsiTPsi).to(device) | ||
+ self._mu3[:, None, None, None, None, None] | ||
).type(self._complex_dtype) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters