src.model.deeplearn.handle.dl_model_compiler
Classes
|
Class to compile deep learning models. |
- class src.model.deeplearn.handle.dl_model_compiler.DLModelCompiler(compilation_args)
Class to compile deep learning models.
- Variables:
comp_args (dict) – The built compilation arguments (do not confuse with the compilation arguments specification typically referred to as compilation_args instead of comp_args).
class_weighter (
DLClassWeighter) – The class weighter to handle the model’s class weights, if needed/requested.
- __init__(compilation_args)
Initialize a DLModelCompiler.
- Parameters:
compilation_args (dict) – The specification on how to compile the model. See
dl_model_compiler.DLModelCompiler.build_compilation_args()andSimpleDLModelHandler.
- static resolve_metrics(metric_names)
Resolve a list of metric name strings to Keras metric objects.
Supported names:
"accuracy","categorical_accuracy","binary_accuracy","sparse_categorical_accuracy","precision","recall","f1"(macro),"wf1"(micro). Unknown names are passed through to Keras as-is.- Parameters:
metric_names (list of str) – List of metric name strings.
- Returns:
List of Keras metric objects or strings.
- Return type:
list
- compile(mh, X=None, y=None, y_rf=None, **kwargs)
The method that provides the logic to compile a model.
- Parameters:
mh (
DLModelHandler) – The model handler to be compiled.X – Optionally, the coordinates might be used for a better initialization (e.g., automatically derive the number of expected input points, or the dimensionality of the space where the points belong to).
y – Optionally, the labels might be used for a better initialization (e.g., automatically derive the number of classes).
y_rf – The expected values for each receptive field. Can be used to derive class weights.
- Returns:
The model handler itself after compiling the architecture, which implies modifying its internal state.
- Return type:
- static build_compilation_args(comp_args, mh=None)
Build the compilation arguments from given spec.
- Parameters:
comp_args – The specification to build the compilation arguments.
mh (
DLModelHandleror None) – The model handler being compiled. If not given, arguments based on architecture or model handler details will not be built.
- Returns:
The dictionary of compilation arguments.
- Return type:
dict