Main Content

BaselineDistributionDiscriminator

Baseline distribution discriminator

Since R2023a

    Description

    The BaselineDistributionDiscriminator object is a distribution discriminator that uses the baseline method 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 an BaselineDistributionDiscriminator object using the networkDistributionDiscriminator function and setting the method input argument to "baseline".

    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", or "hbos". For more information, see Distribution Confidence Scores.

    Properties

    expand all

    This property is read-only.

    Method for computing the distribution confidence scores, returned as "baseline". 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.

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

    Example: 0.98

    Object Functions

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

    Examples

    collapse all

    Load a pretrained classification network.

    load("digitsClassificationMLPNet.mat");

    Load ID data. Convert the data to a dlarray object.

    XID = digitTrain4DArrayData;
    XID = dlarray(XID,"SSCB");

    Modify the ID training data to create an OOD set.

    XOOD = XID.*0.3 + 0.1;

    Create a discriminator using the baseline method.

    method = "baseline";
    discriminator = networkDistributionDiscriminator(net,XID,XOOD,method)
    discriminator = 
      BaselineDistributionDiscriminator with properties:
    
           Method: "baseline"
          Network: [1x1 dlnetwork]
        Threshold: 0.9743
    
    

    Assess the performance of the discriminator on the OOD data.

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

    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

    Version History

    Introduced in R2023a

    expand all