API Reference: Training

masterful.training.TrainingReport

class masterful.training.TrainingReport(validation_results=None, gpu_info=None, history=None, model=None, policy_name=None)

Structure which holds the results of a training run.

Parameters
  • validation_results (Dict[str, float]) – The final results from evaluating the model on the validation set.

  • gpu_info (Sequence[masterful.utils.gpu.GpuInfo]) – A list of GpuInfo objects, with relevant gpu usage information.

  • history (tensorflow.python.keras.callbacks.History) – The full training history report, containing the results at the end of each epoch for key metrics.

  • model (Optional[tensorflow.python.keras.engine.training.Model]) – A reference to the trained model. This will be different than the model passed in for training if model_ensemble is greater than 1.

  • policy_name (str) – The name of the training policy used. Can be visualized in the masterful-gui frontend.

Return type

None

masterful.training.train

masterful.training.train(model, model_params, optimization_params, regularization_params, ssl_params, training_dataset, training_dataset_params, validation_dataset=None, validation_dataset_params=None, unlabeled_datasets=None, synthetic_datasets=None, **kwargs)

Trains a model using the Masterful platform.

The model passed into this function will be trained against the passed in datasets using the given parameters for regularization, optimization, and semi-supervised learning.

Example:

model: tf.keras.Model = ...
model_params: masterful.architecture.params.ArchitectureParams = ...
optimization_params: masterful.optimization.params.OptimizationParams = ...
regularization_params: masterful.regularization.RegularizationParams = ...
ssl_params: masterful.ssl.params.SemiSupervisedParams = ...
training_dataset: tf.data.Dataset = ...
training_dataset_params: masterful.data.params.DataParams = ...
training_report = masterful.training.train(
    model=model,
    model_params=model_params,
    optimization_params=optimization_params,
    regularization_params=regularization_params,
    ssl_params=ssl_params,
    training_dataset=training_dataset,
    training_dataset_params=training_dataset_params)
Parameters
  • model (tensorflow.python.keras.engine.training.Model) – The model to train.

  • model_params (masterful.architecture.params.ArchitectureParams) – Parameters of the model to train.

  • optimizer_params – Parameters to use for optimization. These can be created directly, or found automatically using masterful.optimization.learn_optimization_params().

  • regularization_params (masterful.regularization.params.RegularizationParams) – Parameters to use for regularization. These can be created directly, or found automatically using masterful.regularization.learn_regularization_params().

  • ssl_params (masterful.ssl.params.SemiSupervisedParams) – Parameters to use for semi-supervised training. These can be created directly, or learned automatically using masterful.ssl.learn_ssl_params().

  • training_dataset (Union[tensorflow.python.data.ops.dataset_ops.DatasetV2, numpy.ndarray, Tuple[numpy.ndarray, numpy.ndarray], tensorflow.python.keras.utils.data_utils.Sequence, Tuple[Callable[[], Iterator], Tuple[tensorflow.python.framework.tensor_spec.TensorSpec, tensorflow.python.framework.tensor_spec.TensorSpec]]]) – The labeled dataset to use during training.

  • training_dataset_params (masterful.data.params.DataParams) – The parameters of the labeled dataset.

  • validation_dataset (Optional[Union[tensorflow.python.data.ops.dataset_ops.DatasetV2, numpy.ndarray, Tuple[numpy.ndarray, numpy.ndarray], tensorflow.python.keras.utils.data_utils.Sequence, Tuple[Callable[[], Iterator], Tuple[tensorflow.python.framework.tensor_spec.TensorSpec, tensorflow.python.framework.tensor_spec.TensorSpec]]]]) – An optional validation dataset to use during training. If no validation set is specified, Masterful will autmoatically create one from the labeled dataset.

  • validation_dataset_params (Optional[masterful.data.params.DataParams]) – Optional parameters of the validation dataset.

  • unlabeled_datasets (Optional[Sequence[Tuple[Union[tensorflow.python.data.ops.dataset_ops.DatasetV2, numpy.ndarray, Tuple[numpy.ndarray, numpy.ndarray], tensorflow.python.keras.utils.data_utils.Sequence, Tuple[Callable[[], Iterator], Tuple[tensorflow.python.framework.tensor_spec.TensorSpec, tensorflow.python.framework.tensor_spec.TensorSpec]]], masterful.data.params.DataParams]]]) – Optional sequence of unlabled datasets and their parameters, to use during training. If an unlabeled dataset is specified, then a set of algorithms must be specified in ssl_params otherwise this will have no effect.

  • synthetic_datasets (Optional[Sequence[Tuple[Union[tensorflow.python.data.ops.dataset_ops.DatasetV2, numpy.ndarray, Tuple[numpy.ndarray, numpy.ndarray], tensorflow.python.keras.utils.data_utils.Sequence, Tuple[Callable[[], Iterator], Tuple[tensorflow.python.framework.tensor_spec.TensorSpec, tensorflow.python.framework.tensor_spec.TensorSpec]]], masterful.data.params.DataParams]]]) – Optional sequence of synthetic data and parameters to use during training. The amount of synthetic data used during training is controlled by masterful.regularization.RegularizationParams.synthetic_proportion.

  • optimization_params (masterful.optimization.params.OptimizationParams) –

Returns

An instance of TrainingReport with the full results of training the model with the given parameters.

Return type

masterful.training.TrainingReport