I realised that it isn't obvious how to save the model and reload it for creating reconstructions later on. Here's an example. Note that loading a full saved model (saved with save_model) isn't easy to make work, so instead I've just saved the weights (with save_weights). Then, in GalaxiesVAEplot.py, I create the model again (by importing everything from GalaxiesVAE.py) and load the weights into it. To avoid re-running the training when the file is imported, I put the training code in an if __name__ == "__main__" block.
Note that loading the weights into the model requires that the architecture in GalaxiesVAE.py still match that of the saved weights. When you have a model you want to keep, it's therefore a good idea to record both the git commit id (first 7 characters is plenty) and log name (which is based on the date and time) so you know how they match up.
In this code I also switched back to doing the redshifting transformation from input to target with the redshift condition. I'll let you run it yourself. I look forward to seeing your results! I am available for a meeting tomorrow, if you are (sorry, I got my weeks mixed up).
I realised that it isn't obvious how to save the model and reload it for creating reconstructions later on. Here's an example. Note that loading a full saved model (saved with
save_model
) isn't easy to make work, so instead I've just saved the weights (withsave_weights
). Then, inGalaxiesVAEplot.py
, I create the model again (by importing everything fromGalaxiesVAE.py
) and load the weights into it. To avoid re-running the training when the file is imported, I put the training code in anif __name__ == "__main__"
block.Note that loading the weights into the model requires that the architecture in GalaxiesVAE.py still match that of the saved weights. When you have a model you want to keep, it's therefore a good idea to record both the git commit id (first 7 characters is plenty) and log name (which is based on the date and time) so you know how they match up.
In this code I also switched back to doing the redshifting transformation from input to target with the redshift condition. I'll let you run it yourself. I look forward to seeing your results! I am available for a meeting tomorrow, if you are (sorry, I got my weeks mixed up).