Modely Class
- class nnodely.nnodely.Modely(*, visualizer: str | EmptyVisualizer | None = 'Standard', exporter: str | EmptyExporter | None = 'Standard', seed: int | None = None, workspace: str | None = None, log_internal: bool = False, save_history: bool = False)[source]
Bases:
Composer,Trainer,Loader,Validator,ExporterCreate the main object, the nnodely object, that will be used to create the network, train and export it.
- Parameters:
visualizer (str, Visualizer, optional) – The visualizer to be used. Default is the ‘Standard’ visualizer.
exporter (str, Exporter, optional) – The exporter to be used. Default is the ‘Standard’ exporter.
seed (int, optional) – Set the seed for all the random modules inside the nnodely framework. Default is None.
workspace (str) – The path of the workspace where all the exported files will be saved.
log_internal (bool) – Whether or not save the logs. Default is False.
save_history (bool) – Whether or not save the history. Default is False.
Example
>>> model = Modely()
- property constants
- property internals
- property json
- property neuralized
- property parameters
- resetSeed(seed: int) None[source]
Resets the random seed for reproducibility.
This method sets the seed for various random number generators used in the project to ensure reproducibility of results.
- Parameters:
seed (int) – The seed value to be used for the random number generators.
Example
>>> model = nnodely() >>> model.resetSeed(42)
- property states
- property traced
- trainAndAnalyze(*, test_dataset: str | list | dict | None = None, test_batch_size: int = 128, **kwargs)[source]
Trains the model using the provided datasets and parameters. After training, it analyzes the results on the training, validation, and test datasets.
- Parameters:
test_dataset (str or None, optional) – The name of the datasets used for test. Default is None.
test_batch_size (int, optional) – The batch size for testing. Default is 1.
models (list or None, optional) – A list of models to train. Default is None.
train_dataset (str or None, optional) – The name of datasets to use for training. Default is None.
validation_dataset (str or None, optional) – The name of datasets to use for validation. Default is None.
dataset (str or None, optional) – The name of the datasets to use for training, validation and test.
splits (list or None, optional) – A list of 3 elements specifying the percentage of splits for training, validation, and testing. The three elements must sum up to 100! The parameter splits is only used when dataset is not None
closed_loop (dict or None, optional) – A dictionary specifying closed loop connections. The keys are input names and the values are output names. Default is None.
connect (dict or None, optional) – A dictionary specifying connections. The keys are input names and the values are output names. Default is None.
step (int or None, optional) – The step size for training. A big value will result in less data used for each epochs and a faster train. Default is None.
prediction_samples (int or None, optional) – The size of the prediction horizon. Number of samples at each recurrent window Default is None.
shuffle_data (bool or None, optional) – Whether to shuffle the data during training. Default is None.
early_stopping (Callable or None, optional) – A callable for early stopping. Default is None.
early_stopping_params (dict or None, optional) – A dictionary of parameters for early stopping. Default is None.
select_model (Callable or None, optional) – A callable for selecting the best model. Default is None.
select_model_params (dict or None, optional) – A dictionary of parameters for selecting the best model. Default is None.
minimize_gain (dict or None, optional) – A dictionary specifying the gain for each minimization loss function. Default is None.
num_of_epochs (int or None, optional) – The number of epochs to train the model. Default is None.
train_batch_size (int or None, optional) – The batch size for training. Default is None.
val_batch_size (int or None, optional) – The batch size for validation. Default is None.
optimizer (Optimizer or None, optional) – The optimizer to use for training. Default is None.
lr (float or None, optional) – The learning rate. Default is None.
lr_param (dict or None, optional) – A dictionary of learning rate parameters. Default is None.
optimizer_params (list or dict or None, optional) – A dictionary of optimizer parameters. Default is None.
optimizer_defaults (dict or None, optional) – A dictionary of default optimizer settings. Default is None.
training_params (dict or None, optional) – A dictionary of training parameters. Default is None.
add_optimizer_params (list or None, optional) – Additional optimizer parameters. Default is None.
add_optimizer_defaults (dict or None, optional) – Additional default optimizer settings. Default is None.
- Raises:
RuntimeError – If no data is loaded or if there are no modules with learnable parameters.
KeyError – If the sample horizon is not positive.
ValueError – If an input or output variable is not in the model definition.