Hauptinhalt

KDEDistributionDiscriminator

R2026b

Kernel density estimate distribution discriminator

Since R2026a

    Description

    The KDEDistributionDiscriminator object is a distribution discriminator that uses kernel density estimation (KDE) to compute distribution confidence scores. The object contains a threshold that you can use to separate observations into in-distribution (ID) and out-of-distribution (OOD) data sets.

    Creation

    Create a KDEDistributionDiscriminator object using the networkDistributionDiscriminator function and setting the method input argument to "kde". This object requires Statistics and Machine Learning Toolbox™.

    Note

    The object type depends on the method you specify when you use the networkDistributionDiscriminator function. The method determines how the software computes the distribution confidence scores. You can set the method argument to either "baseline", "odin", "energy", "hbos", or "kde" (since R2026a). For more information, see Distribution Confidence Scores.

    Properties

    expand all

    This property is read-only.

    Method for computing the distribution confidence scores, returned as "kde". For more information, see Distribution Confidence Scores.

    This property is read-only.

    Deep learning network, returned as a dlnetwork object.

    This property is read-only.

    Layer names for the KDE method, returned as a string array.

    The software computes the distribution confidence scores using the principal components from all of the specified layers. For more information, see Density-Based Methods.

    Note

    To create a discriminator, the software must first compute the principal component features for each layer. Computing the principal components can be slow for layers with a large output size and can cause you to run out of memory. If you run out of memory, try specifying layers with a smaller output size. For more information, see Density-Based Methods.

    Example: ["out_1" "out_2"]

    This property is read-only.

    Variance cutoff for the KDE method, returned as a scalar in the range [0, 1].

    The variance cutoff controls the number of principal component features that the software uses to compute the distribution confidence scores. Using a greater number of features takes more computation time. The closer the VarianceCutoff value is to 1, the fewer principal components the software uses to compute the scores. For more information, see Density-Based Methods.

    Example: 0.01

    Distribution threshold, returned as a scalar in the range [-Inf, 0]. The threshold separates the ID and OOD data using the distribution confidence scores.

    Example: -10

    Object Functions

    isInNetworkDistributionDetermine whether data is within the distribution of the network
    distributionScoresDistribution confidence scores

    Examples

    collapse all

    Load a pretrained regression network.

    load("digitsRegressionMLPNetwork.mat")

    Load ID data.

    XID = digitTrain4DArrayData;

    Modify the ID training data to create an OOD set.

    XOOD = XID.*0.3 + 0.1;

    Create a discriminator using the KDE method.

    method = "kde";
    discriminator = networkDistributionDiscriminator(net,XID,XOOD,method)
    discriminator = 
      KDEDistributionDiscriminator with properties:
    
                Method: "kde"
               Network: [1×1 dlnetwork]
            LayerNames: "fc_3"
        VarianceCutoff: 1.0000e-03
             Threshold: 0.0176
    
    

    Assess the performance of the discriminator on the OOD data.

    tf = isInNetworkDistribution(discriminator,XOOD);
    accuracy = sum(tf == 0)/numel(tf)
    accuracy = 
    0.9970
    

    More About

    expand all

    References

    [1] Shalev, Gal, Gabi Shalev, and Joseph Keshet. “A Baseline for Detecting Out-of-Distribution Examples in Image Captioning.” In Proceedings of the 30th ACM International Conference on Multimedia, 4175–84. Lisboa Portugal: ACM, 2022. https://doi.org/10.1145/3503161.3548340.

    [2] Shiyu Liang, Yixuan Li, and R. Srikant, “Enhancing The Reliability of Out-of-distribution Image Detection in Neural Networks” arXiv:1706.02690 [cs.LG], August 30, 2020, http://arxiv.org/abs/1706.02690.

    [3] Weitang Liu, Xiaoyun Wang, John D. Owens, and Yixuan Li, “Energy-based Out-of-distribution Detection” arXiv:2010.03759 [cs.LG], April 26, 2021, http://arxiv.org/abs/2010.03759.

    [4] Markus Goldstein and Andreas Dengel. "Histogram-based outlier score (hbos): A fast unsupervised anomaly detection algorithm." KI-2012: poster and demo track 9 (2012).

    [5] Jingkang Yang, Kaiyang Zhou, Yixuan Li, and Ziwei Liu, “Generalized Out-of-Distribution Detection: A Survey” August 3, 2022, http://arxiv.org/abs/2110.11334.

    [6] Lee, Kimin, Kibok Lee, Honglak Lee, and Jinwoo Shin. “A Simple Unified Framework for Detecting Out-of-Distribution Samples and Adversarial Attacks.” arXiv, October 27, 2018. http://arxiv.org/abs/1807.03888.

    Extended Capabilities

    expand all

    Version History

    Introduced in R2026a