Closed gschlafly closed 5 months ago
In 50aa4c2, I was able to causes only a subset of the birefringence array to be optimized by applying a mask to Delta_n.grad
before optimizer.step()
.
For pytorch backend, the shifted collision voxels are stored in the dictionary rays.vox_indices_ml_shifted
.
In commit https://github.com/PolarizedLightFieldMicroscopy/GeoBirT/commit/57a56075621c91c728a60dab592029478169171f, the class instance attribute vox_indices_by_mla_idx
was created, which contains the voxels involved with each ray and microlens.
Description
Suppose the birefringence array is the concatenation of two arrays. We want to be able to only backpropagate the gradients of one of the two subset arrays.
Here is an example preparation of the two subset arrays.
The optimizer is created as follows where the
trainable_parameters
includes the nn.Parametervolume.Delta_n_first_part
.In each iteration, we do the following before the applying the forward model:
In the forward pass, the calculations are done with
volume.birefringence
instead ofvolume.Delta_n
.Files
To Reproduce
Go to the alt_delta branch. The latest commit is 7e6951f00c9e14995372e40343be150285988a37. Set
OPTIMIZING_MODE = False
in birefringence_implementations.py, andDEBUG_MODE = True
in reconstruction.py. Then, view the print statements afterloss.backward()
. Also, it should be able to be observed that only a subset of the birefringence values updates across iterations.