Refactoring model creation code
Created by: APJansen
Aim
I am refactoring the code that creates the PDF model (and perhaps the full one as well). The main objective is to make the code and the resulting architecture more readable, without changing anything in the behavior. If anything I expect the changes to make it slightly faster and smaller in memory, but either way this will likely be negligible.
It is still a work in progress, but here is a summary of the changes I made so far, roughly from big to small:
- I changed the structure of the sum rule code. Before there was a function
msr_impose
that creates a function that takes a pdf function and returns a normalized pdf function. Now it is a tensorflow model that takes as input the unnormalized pdf on the grid and on the integration grid, and the integration grid itself, and outputs the normalized pdf. This makes the code and the resulting model plots much easier to read. - I grouped all the actual neural layers into a neural network model, for the same reason
- All of the smaller steps I put into named lambda layers, shared wherever possible between replicas and grids
With these changes, it's possible to create much more understandable plots of the architecture using tf.keras.utils.plot_model
. These are from the basic runcard: