picasso.predictors
: From halo properties to gas properties#
|
A wrapper class around flax.linen.Module to generate fully connected multi-layer perceptrons, that can be instantiated easily with list of strings and integers for the layer sizes and activation functions. |
|
A wrapper class to predict picasso model parameters and gas properties from an input halo properties vector and network parameters. |
|
A wrapper class to predict picasso model parameters and gas properties from an input halo properties vector, with a fixed set of network parameters. |
FlaxRegMLP#
- class picasso.predictors.FlaxRegMLP(X_DIM, Y_DIM, hidden_features=(16, 16), activations=('selu', 'selu', 'selu', 'linear'), extra_args_output_activation=(), parent=<flax.linen.module._Sentinel object>, name=None)[source]#
A wrapper class around flax.linen.Module to generate fully connected multi-layer perceptrons, that can be instantiated easily with list of strings and integers for the layer sizes and activation functions.
- Parameters:
X_DIM (int) – Number of features on the input layer.
Y_DIM (int) – Number of features on the output layer.
hidden_features (Sequence[int]) – Number of features for each hidden layer, defaults to [16, 16].
activations (Sequence[str]) – Name of the activation functions to be used for each layer, including input and output. Accepted names are [“selu”, “relu”, “tanh”, “sigmoid”, “clip”, “linear]. Defaults to [“selu”, “selu”, “selu”, “linear”].
extra_args_output_activation (Iterable) – Extra arguments to be passed to the output activation function, defaults to ().
See also
PicassoPredictor#
- class picasso.predictors.PicassoPredictor(mlp, transform_x=<function PicassoPredictor.<lambda>>, transform_y=<function PicassoPredictor.<lambda>>, fix_params={}, f_nt_model='broken_plaw', input_names=['log M200', 'c200', 'cacc/c200', 'cpeak/c200', 'log dx/R200c', 'e', 'p', 'a25', 'a50', 'a75', 'almm', 'mdot'], name='model')[source]#
A wrapper class to predict picasso model parameters and gas properties from an input halo properties vector and network parameters.
- Parameters:
mlp (FlaxRegMLP) – Predictor for model parameters from halo properties.
transform_x (Callable, optional) – Transformation to be applied to input vector, by default lambda x: x
transform_y (Callable, optional) – Transformation to be applied to output vector, by default lambda y: y
fix_params (dict, optional) – List and values of parameters to be fixed, formatted as {parameter name: fixed value}, by default {}
f_nt_model (str, optional) – Non-thermal pressure fraction model to be used, one of [“broken_plaw”, “Nelson14”], by default “broken_plaw”
input_names (list[str], optional) – The names of input parameters. This is never used, only stored to be accessed by one to remind oneself of what the inputs are, bu default the inputs of the baseline model
name (str, optional) – A name for the model, by default “model”
- predict_model_parameters(x, net_par)[source]#
Predicts the gas model parameters based on halo properties.
- Parameters:
x (Array) – Halo properties.
net_par (dict) – Parameters of the MLP to be used for the prediction.
- Returns:
Gas model parameters.
- Return type:
Array
- predict_gas_model(x, phi, r_pol, r_fnt, net_par)[source]#
Predicts the gas properties from halo properties ant potential values.
- Parameters:
x (Array) – Halo properties.
phi (Array) – Potential values.
r_pol (Array) – Normalized radii to be used for the polytropic model.
r_fnt (Array) – Normalized radii to be used for the non-thermal pressure fraction model.
net_par (dict) – Parameters of the MLP to be used for the prediction.
- Returns:
A sequence of arrays containing the predicted gas model parameters:
- rho_gArray
The predicted gas density.
- P_totArray
The predicted total pressure.
- P_thArray
The predicted thermal pressure.
- f_nthArray
The predicted non-thermal pressure fraction.
- Return type:
Sequence[Array]
- save(filename)[source]#
Serializes the object using dill and saves it to disk.
- Parameters:
filename (str) – File to save the model to.
PicassoTrainedPredictor#
- class picasso.predictors.PicassoTrainedPredictor(net_par, *args, **kwargs)[source]#
A wrapper class to predict picasso model parameters and gas properties from an input halo properties vector, with a fixed set of network parameters.
- Parameters:
net_par (dict) – Parameters of the MLP to be used for the predictions.
mlp (FlaxRegMLP) – Predictor for model parameters from halo properties.
transform_x (Callable, optional) – Transformation to be applied to input vector, by default lambda x: x
transform_y (Callable, optional) – Transformation to be applied to output vector, by default lambda y: y
fix_params (dict, optional) – List and values of parameters to be fixed, formatted as {parameter name: fixed value}, by default {}
f_nt_model (str, optional) – Non-thermal pressure fraction model to be used, one of [“broken_plaw”, “Nelson14”], by default “broken_plaw”
- predict_gas_model(x, phi, r_pol, r_fnt, *args)[source]#
Predicts the gas properties from halo properties ant potential values.
- Parameters:
x (Array) – Halo properties.
phi (Array) – Potential values.
r_pol (Array) – Normalized radii to be used for the polytropic model.
r_fnt (Array) – Normalized radii to be used for the non-thermal pressure fraction model.
- Returns:
A sequence of arrays containing the predicted gas model parameters:
- rho_gArray
The predicted gas density.
- P_totArray
The predicted total pressure.
- P_thArray
The predicted thermal pressure.
- f_nthArray
The predicted non-thermal pressure fraction.
- Return type:
Sequence[Array]
- predict_model_parameters(x, *args)[source]#
Predicts the gas model parameters based on halo properties.
- Parameters:
x (Array) – Halo properties.
- Returns:
Gas model parameters.
- Return type:
Array
- save(filename)#
Serializes the object using dill and saves it to disk.
- Parameters:
filename (str) – File to save the model to.
- classmethod load(filename)#
Reads a model object from disk using dill.
- Parameters:
filename (str) – File to read the saved model from.
- Returns:
The saved model.
- Return type: