Open b-remy opened 2 years ago
For the illustration, here are some plots using the tf-1.15 version of the code:
For longer chains, see https://github.com/b-remy/gems/issues/11#issuecomment-1151476123
A simple first task to test the deep_galaxy_model
is to fit the latent variables to a set of observations. This is the aim of MAP_dgm.py using edward2.
Generating observations with the COSMOS-25.2
catalog and a gaussian noise level of 0.01
we get the following fit and residuals (displayed using np.arcsinh(img/s)*s
, s=1e-3
):
Reconstruction from MAP
Residuals (observations-reconstruction_MAP)
Note that I don't fit the centroid here.
It looks like there is a very few residuals when optimizing on the latent variable :-)
However, I was not able to use tf.function
with the way I imported the hub Module, because of the following error:
RuntimeError: Module must be applied in the graph it was instantiated for.
Maybe you know the right way to import the models within TensorFlow graphs @EiffL ?
It turns out we can use edward2 within Tensorflow Probability (0.7.0) compatible with TensorFlow 1.15. So I was able to run the latests scripts after a few updates of the code :-)
Thanks to this, I think that there is no need to change the PPL to tfp.JointDistributionCoroutine since I am used to edward2 and everything seems compatible.
I can now shift to the deep morphological model using the same framework as before.
This is still a draft pull request, I don't really know how to merge this since there is still a lot of TF2 code in the repo... Here is the code already converted to TF 1.15 (and tfp==0.7.0), compared to the latest version of the code (https://github.com/b-remy/gems/tree/gaussiansinf , ab506ca)
gems/models.py
sersic_model
sersic_model_cosmos
gaussian_model
varying_shear_gaussian_model
(just needs to update the interpolator)sersic2morph_model
gems/ed_utils.py
gems/shear.py
gems/utils.py
scripts
cosmo_shear_paramtric.py
cosmo_shear_real.py
simpler_model.py
varying_shear_gaussians.py
Also note that it requires to install GalFlow from https://github.com/b-remy/GalFlow/tree/tf1