deephyper.nas.trainer

class deephyper.nas.trainer.BaseTrainer(config, model)[source]

Bases: object

evaluate(dataset='train')[source]

Evaluate the performance of your model for the same configuration.

Parameters

dataset (str, optional) – must be “train” or “valid”. If “train” then metrics will be evaluated on the training dataset. If “valid” then metrics will be evaluated on the “validation” dataset. Defaults to ‘train’.

Returns

a list of scalar values corresponding do config loss & metrics.

Return type

list

init_history()[source]
load_data()[source]
load_data_generator()[source]
load_data_ndarray()[source]
model_compile()[source]
predict(dataset: str = 'valid', keep_normalize: bool = False)tuple[source]

[summary]

Parameters
  • dataset (str, optional) – ‘valid’ or ‘train’. Defaults to ‘valid’.

  • keep_normalize (bool, optional) – if False then the preprocessing will be reversed after prediction. if True nothing will be reversed. Defaults to False.

Raises

DeephyperRuntimeError – [description]

Returns

(y_true, y_pred)

Return type

tuple

preprocess_data()[source]
set_dataset_train()[source]
set_dataset_valid()[source]
setup_losses_and_metrics()[source]
train(num_epochs: Optional[int] = None, with_pred: bool = False, last_only: bool = False)[source]

Train the model.

Parameters
  • num_epochs (int, optional) – override the num_epochs passed to init the Trainer. Defaults to None, will use the num_epochs passed to init the Trainer.

  • with_pred (bool, optional) – will compute a prediction after the training and will add (‘y_true’, ‘y_pred’) to the output history. Defaults to False, will skip it (use it to save compute time).

  • last_only (bool, optional) – will compute metrics after the last epoch only. Defaults to False, will compute metrics after each training epoch (use it to save compute time).

Raises

DeephyperRuntimeError – raised when the num_epochs < 0.

Returns

a dictionnary corresponding to the training.

Return type

dict

class deephyper.nas.trainer.HorovodTrainer(config, model)[source]

Bases: object

evaluate(dataset='train')[source]

Evaluate the performance of your model for the same configuration.

Parameters

dataset (str, optional) – must be “train” or “valid”. If “train” then metrics will be evaluated on the training dataset. If “valid” then metrics will be evaluated on the “validation” dataset. Defaults to ‘train’.

Returns

a list of scalar values corresponding do config loss & metrics.

Return type

list

init_history()[source]
load_data()[source]
load_data_generator()[source]
load_data_ndarray()[source]
model_compile()[source]
predict(dataset: str = 'valid', keep_normalize: bool = False)tuple[source]

[summary]

Parameters
  • dataset (str, optional) – ‘valid’ or ‘train’. Defaults to ‘valid’.

  • keep_normalize (bool, optional) – if False then the preprocessing will be reversed after prediction. if True nothing will be reversed. Defaults to False.

Raises

DeephyperRuntimeError – [description]

Returns

(y_true, y_pred)

Return type

tuple

preprocess_data()[source]
set_dataset_train()[source]
set_dataset_valid()[source]
setup_losses_and_metrics()[source]
train(num_epochs: Optional[int] = None, with_pred: bool = False, last_only: bool = False)[source]

Train the model.

Parameters
  • num_epochs (int, optional) – override the num_epochs passed to init the Trainer. Defaults to None, will use the num_epochs passed to init the Trainer.

  • with_pred (bool, optional) – will compute a prediction after the training and will add (‘y_true’, ‘y_pred’) to the output history. Defaults to False, will skip it (use it to save compute time).

  • last_only (bool, optional) – will compute metrics after the last epoch only. Defaults to False, will compute metrics after each training epoch (use it to save compute time).

Raises

DeephyperRuntimeError – raised when the num_epochs < 0.

Returns

a dictionnary corresponding to the training.

Return type

dict