Closed andreufont closed 1 year ago
Using the emulator's interface, the only parameters that can vary are kmax, zmax, emu_typ, emu_algorithm and ndeg. The easiest thing could be to define and overwrite these arguments of the function is a predefined emulator (e.g. Pedersen+21) is defined and print a warning message.
Example:
if emulator_label=='Pedersen23':
print('Select emulator used in Pedersen et al. 2023')
emuparams = ['Delta2_p', 'n_p', 'mF', 'sigT_Mpc', 'gamma', 'kF_Mpc']
zmax, kmax_Mpc, ndeg, emu_type = 4.5, 3, 4, 'polyfit'
print(r'Gaussian Process emulator predicting the optimal P1D fitting coefficients to a 4th degree polynomial. It goes to scales of 3Mpc^{-1} and z<4.5. The parameters passed to the emulator will be overwritten to match these ones')
What do you think?
@lauracabayol - we can close this issue, right?
Yes
It is often convenient to read a pre-trained emulator from file, particularly if it might take a while to train. Something like:
emulator = NNEmulator(archive,emuparams,save_path=None, model_path='NNmodels/NNEmulator_LaCEHC.pt', train=False)
However, what happens if some of the parameters provided (here emuparams, or the archive) are not consistent with the ones that were used to train the emulator that we are reading from file? Ideally, the code would crash in this case.
One option is to add this test when reading emulator from file, if it is not difficult to implement.
The other option is to do not admit any other parameter when providing a file, i.e., if you provide model_path!=None, you should not specify anything else or the code would crash.
Another way to look at it, is that reading the emulator from file or not should not change the behavior of the emulator object, it should just be a speed up. So you should get the same result if you run
emulator = NNEmulator(archive, many_options, model_path='NNmodels/NNEmulator_LaCEHC.pt', train=False)
or if you runemulator = NNEmulator(archive, many_options, model_path=None, train=True)