denspp.offline.dnn.training.classifier_train#

Module Contents#

Classes#

SettingsClassifier

Class for handling the PyTorch training/inference pipeline Attributes: model_name: String with the model name patience: Integer value with number of epochs before early stopping optimizer: String with PyTorch optimizer name loss: String with method name for the loss function deterministic_do: Boolean if deterministic training should be done deterministic_seed: Integer with the seed for deterministic training num_kfold: Integer value with applying k-fold cross validation num_epochs: Integer value with number of epochs batch_size: Integer value with batch size data_split_ratio: Float value for splitting the input dataset between training and validation data_do_shuffle: Boolean if data should be shuffled before training custom_metrics: List with string of custom metrics to calculate during training

TrainClassifier

Data#

API#

class denspp.offline.dnn.training.classifier_train.SettingsClassifier[source]#

Bases: denspp.offline.dnn.training.common_train.SettingsPytorch

Class for handling the PyTorch training/inference pipeline Attributes: model_name: String with the model name patience: Integer value with number of epochs before early stopping optimizer: String with PyTorch optimizer name loss: String with method name for the loss function deterministic_do: Boolean if deterministic training should be done deterministic_seed: Integer with the seed for deterministic training num_kfold: Integer value with applying k-fold cross validation num_epochs: Integer value with number of epochs batch_size: Integer value with batch size data_split_ratio: Float value for splitting the input dataset between training and validation data_do_shuffle: Boolean if data should be shuffled before training custom_metrics: List with string of custom metrics to calculate during training

denspp.offline.dnn.training.classifier_train.DefaultSettingsTrainingCE#

‘SettingsClassifier(…)’

class denspp.offline.dnn.training.classifier_train.TrainClassifier(config_train: denspp.offline.dnn.training.classifier_train.SettingsClassifier, config_data: denspp.offline.dnn.data_config.SettingsDataset, do_train: bool = True)[source]#

Bases: denspp.offline.dnn.training.common_train.PyTorchHandler

Initialization

Class for Handling Training of Classifiers

Parameters:
  • config_data – Settings for handling and loading the dataset (just for saving)

  • config_train – Settings for handling the PyTorch Trainings Routine of a Classifier

  • do_train – Do training of model otherwise only inference

Returns:

None

load_dataset(dataset: denspp.offline.dnn.data_config.DatasetFromFile) None[source]#

Loading the loaded dataset and transform it into right dataloader

Parameters:

dataset – Dataclass with dataset loaded from extern

Returns:

None

do_training(path2save=Path('.')) dict[source]#

Start model training incl. validation and custom-own metric calculation Args: path2save: Path for saving the results [Default: ‘’ –> generate new folder] Returns: Dictionary with metrics from training (loss_train, loss_valid, own_metrics)

do_post_training_validation(do_ptq: bool = False) denspp.offline.dnn.training.common_train.DataValidation[source]#

Performing the post-training validation with the best model

Parameters:

do_ptq – Boolean for activating post training quantization during post-training validation

Returns:

Dataclass with results from validation phase