Skip to content

fit_dl_out_of_distributionFitDlOutOfDistributionFitDlOutOfDistributionfit_dl_out_of_distributionT_fit_dl_out_of_distributionπŸ”—

Short descriptionπŸ”—

fit_dl_out_of_distributionFitDlOutOfDistributionFitDlOutOfDistributionfit_dl_out_of_distributionT_fit_dl_out_of_distribution β€” Extend a deep learning model for Out-of-Distribution Detection.

SignatureπŸ”—

fit_dl_out_of_distribution( dl_model DLModelHandle, dict DLDataset, dict 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

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

DescriptionπŸ”—

fit_dl_out_of_distributionFitDlOutOfDistribution extends a trained deep learning model DLModelHandleDLModelHandledlmodel_handle of 'type'"type" = '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_modelApplyDlModel is called subsequently, the results will include the following additional entries related to Out-of-Distribution Detection:

  • 'ood_result'"ood_result": Indicates whether the sample is predicted as out-of-distribution.

  • '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": If '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_distributionFitDlOutOfDistribution and stored within the model handle DLModelHandleDLModelHandledlmodel_handle as 'ood_threshold'. If required, the threshold can be adjusted manually using the operator set_dl_model_paramSetDlModelParam.

For fit_dl_out_of_distributionFitDlOutOfDistribution to work properly, it is important that DLDatasetDLDatasetdldataset is the same dataset with the same split and preprocessing parameters, as the one used for training DLModelHandleDLModelHandledlmodel_handle. It is crucial that the provided dataset DLDatasetDLDatasetdldataset contains diverse and sufficient samples for each class to ensure reliable Out-of-Distribution Detection. If the provided DLDatasetDLDatasetdldataset contains less than or equal to 15 training samples per class and no validation samples, fit_dl_out_of_distributionFitDlOutOfDistribution will return an error. In such cases, additional training data should be added to the dataset.

fit_dl_out_of_distributionFitDlOutOfDistribution 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" will affect evaluation results. Therefore, it is recommended to re-evaluate the model after making such changes.

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

AttentionπŸ”—

If fit_dl_out_of_distributionFitDlOutOfDistribution 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" in set_dl_model_paramSetDlModelParam. Once removed, fit_dl_out_of_distributionFitDlOutOfDistribution can be called again to re-enable Out-of-Distribution Detection.

Execution informationπŸ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

This operator modifies the state of the following input parameter:

During execution of this operator, access to the value of this parameter must be synchronized if it is used across multiple threads.

ParametersπŸ”—

DLModelHandleDLModelHandledlmodel_handle (input_control, state is modified) dl_model β†’ (handle)HTuple (HHandle)HDlModel, HTuple (IntPtr)HHandleHtuple (handle)

Handle of a deep learning classification model.

DLDatasetDLDatasetdldataset (input_control) dict β†’ (handle)HTuple (HHandle)HDict, HTuple (IntPtr)HHandleHtuple (handle)

Dataset, which was used for training the model.

GenParamgenParamgen_param (input_control) dict β†’ (handle)HTuple (HHandle)HDict, HTuple (IntPtr)HHandleHtuple (handle)

Dictionary for generic parameters.

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

read_dl_modelReadDlModel

ModuleπŸ”—

Deep Learning Professional