Classes

Class models

The class models buils a model from a set of parameters.

class hyperpy.core.models(initnorm=<Mock name='mock.initializers.RandomNormal()' id='140024184255760'>, min_layers: int = 1, max_layers: int = 13, min_units: int = 4, max_units: int = 128)

Class to build a model with a given topology

BuildModelSimply(self) <Mock name='mock.models.Model' id='140024185113744'>

BuildModelSimply Standar model

Parameters

trial (optuna.Trial) – trial to build the model

Returns

sequential model

Return type

keras.models.Model.Sequential

BuildModel(self) <Mock name='mock.models.Model' id='140024185113744'>

BuildModel Standar model

Parameters

trial (optuna.Trial) – trial to build the model

Returns

sequential model

Return type

keras.models.Model

The fact, all parameters for build model are (default):

  • initnorm=keras.initializers.RandomNormal(mean=0.0, stddev=0.05, seed=1),

  • min_layers:int=1,

  • max_layers:int=13,

  • min_units:int=4,

  • max_units:int=128

and at the moment we can manipulate the model with the following methods:

hyperpy.core.models.BuildModelSimply(trial: <Mock name='mock.Trial' id='140024184256400'>, self) <Mock name='mock.models.Model' id='140024185113744'>

BuildModelSimply Standar model

Parameters

trial (optuna.Trial) – trial to build the model

Returns

sequential model

Return type

keras.models.Model.Sequential

hyperpy.core.models.BuildModel(trial: <Mock name='mock.Trial' id='140024184256400'>, self) <Mock name='mock.models.Model' id='140024185113744'>

BuildModel Standar model

Parameters

trial (optuna.Trial) – trial to build the model

Returns

sequential model

Return type

keras.models.Model

The difference between th two methods is the first use the same activation function for all layers, the second use different activations funcion for each layer.

Class optimizers

The class optimizers build optimizers for the model.

class hyperpy.core.optimizers

class to build a model optimizer

optimizerAdam() <Mock name='mock.optimizers.Adam' id='140024185367504'>

optimizerAdam method to build a model optimizer with Adam

Parameters

trial (optuna.Trial) – trial to build the model

Returns

optimizer

Return type

keras.optimizers.Adam

optimizerRMSprop() <Mock name='mock.optimizers.RMSprop' id='140024185110672'>

optimizerRMSprop method to build a model optimizer with RMSprop

Parameters

trial (optuna.Trial) – trial to build the model

Returns

optimizer

Return type

keras.optimizers.RMSprop

optimizerSGD() <Mock name='mock.optimizers.SGD' id='140024185112912'>

optimizerSGD method to build a model optimizer with SGD

Parameters

trial (optuna.Trial) – trial to build the model

Returns

optimizer

Return type

keras.optimizers.SGD

buildOptimizer() None

buildOptimizer method to build a model optimizer

Parameters

trial (optuna.Trial) – trial to build the model

Returns

optimizer

Return type

keras.optimizers

At the moment, we can select between:

hyperpy.core.optimizers.optimizerAdam(trial: <Mock name='mock.Trial' id='140024184256400'>) <Mock name='mock.optimizers.Adam' id='140024185367504'>

optimizerAdam method to build a model optimizer with Adam

Parameters

trial (optuna.Trial) – trial to build the model

Returns

optimizer

Return type

keras.optimizers.Adam

hyperpy.core.optimizers.optimizerRMSprop(trial: <Mock name='mock.Trial' id='140024184256400'>) <Mock name='mock.optimizers.RMSprop' id='140024185110672'>

optimizerRMSprop method to build a model optimizer with RMSprop

Parameters

trial (optuna.Trial) – trial to build the model

Returns

optimizer

Return type

keras.optimizers.RMSprop

hyperpy.core.optimizers.optimizerSGD(trial: <Mock name='mock.Trial' id='140024184256400'>) <Mock name='mock.optimizers.SGD' id='140024185112912'>

optimizerSGD method to build a model optimizer with SGD

Parameters

trial (optuna.Trial) – trial to build the model

Returns

optimizer

Return type

keras.optimizers.SGD

And if we want that the model is trained with several optimizers, we can use the method:

hyperpy.core.optimizers.buildOptimizer(trial: <Mock name='mock.Trial' id='140024184256400'>) None

buildOptimizer method to build a model optimizer

Parameters

trial (optuna.Trial) – trial to build the model

Returns

optimizer

Return type

keras.optimizers

Class trainers

The class trainers build trainers for the model.

class hyperpy.core.trainers(trial, feat_X, Y, verbose: int = 0, model: hyperpy.core.models = <class 'hyperpy.core.models'>, optimizer: hyperpy.core.optimizers = <class 'hyperpy.core.optimizers'>, type: str = 'Build', initnorm=<Mock name='mock.initializers.RandomNormal()' id='140024184255760'>)

trainers class to build a model trainer

trainer(save: bool = False) None

trainer trainer Method define how to train Neural Network. This works by maximizing the test data set (Exactitud de Validación).

Parameters

save (bool, optional) – save model, defaults to False

Returns

model, cv_x, cv_y

Return type

keras.models, pandas.DataFrame, pandas.Series

The final idea, is to select by several type of trainers. By the way, at moment have onle one trainer:

hyperpy.core.trainers.trainer(self, save: bool = False) None

trainer trainer Method define how to train Neural Network. This works by maximizing the test data set (Exactitud de Validación).

Parameters

save (bool, optional) – save model, defaults to False

Returns

model, cv_x, cv_y

Return type

keras.models, pandas.DataFrame, pandas.Series

Class run

To run a study, you could call hy.run(feat_X, Y) function:

class hyperpy.core.run(feat_X, Y, study_name: str = 'First try', direction: str = 'maximize', n_trials: int = 10)

run class is used to run the experiment.

objective(trial)

objective function is used to define the objective function.

Parameters

trial (optuna.trial.Trial) – trial object

Returns

objective function

Return type

float

buildStudy()

buildStudy function is used to build the study.

Returns

study

Return type

optuna.study.Study

hyperpy.core.run.buildStudy(self)

buildStudy function is used to build the study.

Returns

study

Return type

optuna.study.Study

hyperpy.core.run.objective(self, trial)

objective function is used to define the objective function.

Parameters

trial (optuna.trial.Trial) – trial object

Returns

objective function

Return type

float

Class results

To read results from a study, you could call hy.results(study) function:

class hyperpy.core.results

results class is used to get the results of the study.

results()

results function is used to get the results of the study.

Parameters

study (optuna.study.Study) – study object

Returns

results

Return type

pandas.DataFrame

hyperpy.core.results.results(study)

results function is used to get the results of the study.

Parameters

study (optuna.study.Study) – study object

Returns

results

Return type

pandas.DataFrame