Operator Reference

fit_dl_out_of_distributionT_fit_dl_out_of_distributionFitDlOutOfDistributionFitDlOutOfDistributionfit_dl_out_of_distribution (Operator)

fit_dl_out_of_distributionT_fit_dl_out_of_distributionFitDlOutOfDistributionFitDlOutOfDistributionfit_dl_out_of_distribution — Extend a deep learning model for Out-of-Distribution Detection.

Signature

fit_dl_out_of_distribution( : : DLModelHandle, DLDataset, GenParam : )

Herror T_fit_dl_out_of_distribution(const Htuple DLModelHandle, const Htuple DLDataset, const Htuple GenParam)

void FitDlOutOfDistribution(const HTuple& DLModelHandle, const HTuple& DLDataset, const HTuple& GenParam)

static void HOperatorSet.FitDlOutOfDistribution(HTuple DLModelHandle, HTuple DLDataset, HTuple genParam)

def fit_dl_out_of_distribution(dlmodel_handle: HHandle, dldataset: HHandle, gen_param: HHandle) -> None

Description

fit_dl_out_of_distributionfit_dl_out_of_distributionFitDlOutOfDistributionFitDlOutOfDistributionfit_dl_out_of_distribution extends a trained deep learning model DLModelHandleDLModelHandleDLModelHandleDLModelHandledlmodel_handle of 'type'"type""type""type""type" = 'classification'"classification""classification""classification""classification" for Out-of-Distribution Detection. This functionality allows the model to detect samples that differ significantly from the classes it was trained on, known as “Out-of-Distribution” (OOD) samples.

When apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelapply_dl_model is called subsequently, the results will include the following additional entries related to Out-of-Distribution Detection:

'ood_result'"ood_result""ood_result""ood_result""ood_result":

Indicates whether the sample is predicted as out-of-distribution.

'ood_score'"ood_score""ood_score""ood_score""ood_score":

Indicates how much the sample differs from the trained classes. The higher this score, the more likely it is that the sample is out-of-distribution.

'ood_threshold'"ood_threshold""ood_threshold""ood_threshold""ood_threshold":

If 'ood_score'"ood_score""ood_score""ood_score""ood_score" exceeds this threshold, the sample is predicted as out-of-distribution. The out-of-distribution threshold is computed during the execution of fit_dl_out_of_distributionfit_dl_out_of_distributionFitDlOutOfDistributionFitDlOutOfDistributionfit_dl_out_of_distribution and stored within the model handle DLModelHandleDLModelHandleDLModelHandleDLModelHandledlmodel_handle as 'ood_threshold'. If required, the threshold can be adjusted manually using the operator set_dl_model_paramset_dl_model_paramSetDlModelParamSetDlModelParamset_dl_model_param.

For fit_dl_out_of_distributionfit_dl_out_of_distributionFitDlOutOfDistributionFitDlOutOfDistributionfit_dl_out_of_distribution to work properly, it is important that DLDatasetDLDatasetDLDatasetDLDatasetdldataset is the same dataset with the same split and preprocessing parameters, as the one used for training DLModelHandleDLModelHandleDLModelHandleDLModelHandledlmodel_handle. It is crucial that the provided dataset DLDatasetDLDatasetDLDatasetDLDatasetdldataset contains diverse and sufficient samples for each class to ensure reliable Out-of-Distribution Detection. If the dataset is too small or lacks variation, fit_dl_out_of_distributionfit_dl_out_of_distributionFitDlOutOfDistributionFitDlOutOfDistributionfit_dl_out_of_distribution may return an error. In such cases, additional training data should be added to the dataset.

fit_dl_out_of_distributionfit_dl_out_of_distributionFitDlOutOfDistributionFitDlOutOfDistributionfit_dl_out_of_distribution can be applied to any classification model supported by HALCON. For models created using Deep Learning / Framework operators or read from an ONNX model file, Out-of-Distribution Detection compatibility may vary depending on the architecture.

The performance of the model for Out-of-Distribution Detection can be evaluated using the procedure evaluate_dl_model. To evaluate the model on out-of-distribution data, these can be added to the DLDataset using the procedure add_dl_out_of_distribution_data, allowing for testing whether the model can accurately separate in-distribution from out-of-distribution data. Adjustments to the 'ood_threshold'"ood_threshold""ood_threshold""ood_threshold""ood_threshold" will affect evaluation results. Therefore, it is recommended to re-evaluate the model after making such changes.

GenParamGenParamGenParamgenParamgen_param is a dictionary for setting generic parameters. Currently no generic parameters are supported.

Attention

If fit_dl_out_of_distributionfit_dl_out_of_distributionFitDlOutOfDistributionFitDlOutOfDistributionfit_dl_out_of_distribution is called for a model that has already been extended with Out-of-Distribution Detection, the previous internal calculations are discarded and the model is adapted anew

Certain modifications to the model, such as changing the number of classes or continuing training of the model, cannot be performed once the model has been extended for Out-of-Distribution Detection. To make such changes possible, the model internal Out-of-Distribution Detection must first be removed from the model using the parameter 'clear_ood'"clear_ood""clear_ood""clear_ood""clear_ood" in set_dl_model_paramset_dl_model_paramSetDlModelParamSetDlModelParamset_dl_model_param. Once removed, fit_dl_out_of_distributionfit_dl_out_of_distributionFitDlOutOfDistributionFitDlOutOfDistributionfit_dl_out_of_distribution can be called again to re-enable Out-of-Distribution Detection.

Execution Information

  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).
  • Multithreading scope: global (may be called from any thread).
  • Processed without parallelization.

Parameters

DLModelHandleDLModelHandleDLModelHandleDLModelHandledlmodel_handle (input_control)  dl_model HDlModel, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Handle of a deep learning classification model.

DLDatasetDLDatasetDLDatasetDLDatasetdldataset (input_control)  dict HDict, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Dataset, which was used for training the model.

GenParamGenParamGenParamgenParamgen_param (input_control)  dict HDict, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Dictionary for generic parameters.

Possible Predecessors

read_dl_modelread_dl_modelReadDlModelReadDlModelread_dl_model

Module

Deep Learning Professional