Model¶
- class mouffet.models.model.Model(opts=None)[source]¶
Base abstract class for defining models. Must be subclassed.
- NAME¶
Name of the model class. Will be used to identify and save classes
- STEP_TRAINING¶
The name of the training step. Will be used in configuration file
- STEP_VALIDATION¶
The name of the validation step. Will be used in configuration file
- abstract create_model()[source]¶
Abstract method where model creation / network initialization should take place
- Raises:
NotImplementedError – [description]
- property opts¶
Property that contains the options related to the model as read in the configuration file
- abstract predict(x)[source]¶
Predict data using the model
- Parameters:
x (data) – the data on which we want to makae a prediction. This function should make only
needed (one prediction and be called numerous times if) –
- Raises:
NotImplementedError – [description]
- prepare_data(data)[source]¶
Prepare the data before training. Allows to perform last minute changes to the data just before training.
- Parameters:
data (Object) – The data to be prepared
- Returns:
The modified data
- Return type:
Object
- abstract save_model(path=None)[source]¶
Save the model to disk
- Parameters:
path (Object, optional) – Path where the model should be saved. Defaults to None.
- Raises:
NotImplementedError – Should be inherited by the final model
- save_options(file_name, options)[source]¶
Save the options related to the model for logging purposes as a yaml file. By default, uses the “results_save_dir” property from the ModelOptions class associated to the model. By default, this will be the following combination: model_dir/model_id/version where model_dir and model_id can be found in the model configuration file and version is calculated automatically.
- Parameters:
file_name (string or pathlib.Path) – The name of the file to be saved
options (Object) – The options to save that can be transcribed as a yaml file