Out-of-distribution detection methods, equipment, and media based on decoupled evidence deep learning

By decoupling evidence-based deep learning, and utilizing gradient truncation and out-of-distribution sample constraints, a Dirichlet distribution concentration parameter is constructed. This solves the feature confusion problem in out-of-distribution sample identification of deep learning models, and achieves accurate differentiation and credibility assessment of in-distribution and out-of-distribution samples.

CN122156829BActive Publication Date: 2026-07-17NANJING UNIV OF POSTS & TELECOMM

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NANJING UNIV OF POSTS & TELECOMM
Filing Date
2026-05-08
Publication Date
2026-07-17

AI Technical Summary

Technical Problem

Existing deep learning models struggle to accurately identify and provide reliable uncertainty estimates when faced with out-of-distribution samples, potentially leading to serious consequences in safety-critical areas. Furthermore, the coupling of classification and evidence results in feature confusion, making it difficult to distinguish between in-distribution and out-of-distribution samples.

Method used

We employ a deep learning approach based on decoupled evidence, using a gradient truncation strategy to decouple the training of the classification branch and the evidence branch. By combining a normalized cosine classification head and explicit constraints from out-of-distribution samples, we construct a concentration parameter vector of the Dirichlet distribution and use differential entropy for credibility assessment.

Benefits of technology

It significantly improves the model's ability to distinguish between difficult samples within the distribution and samples outside the distribution, avoids feature confusion, and provides reliable uncertainty estimation and rejection decision basis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122156829B_ABST
    Figure CN122156829B_ABST
Patent Text Reader

Abstract

This invention discloses an out-of-distribution detection method, device, and medium based on decoupled evidence deep learning. The method includes: constructing a classification network based on evidence deep learning, modeling the neural network output as concentration parameters of a Dirichlet distribution; designing a decoupled training objective function, independently constraining the total amount of evidence and category distribution of both in-distribution and out-of-distribution samples, and optimizing model parameters by minimizing the difference between the predicted distribution and the target Dirichlet distribution; and calculating the differential entropy of the predicted Dirichlet distribution based on the concentration parameters output by the network during the inference phase, using this as an uncertainty metric for out-of-distribution detection. This invention solves the problem of difficulty in distinguishing between samples in weak feature distributions and samples out of strong feature distributions in the feature space in traditional methods by decoupling the correlation between evidence amplitude and distribution uncertainty, effectively improving out-of-distribution detection performance in general image classification scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer vision and deep learning technology, specifically relating to an out-of-distribution detection method, device and medium based on decoupled evidence deep learning, which can be used for out-of-distribution sample detection and reliable inference in image classification tasks. Background Technology

[0002] With the rapid development of deep learning technology, image classification methods based on decoupled evidence network models have achieved remarkable results in many fields. However, existing deep learning models face a serious problem in practical applications: when the input samples come from outside the training distribution, i.e., out-of-distribution samples, the model often struggles to accurately identify and provide reliable uncertainty estimates, which could lead to serious consequences in safety-critical fields such as autonomous driving and medical diagnosis.

[0003] To address the aforementioned issues, researchers have proposed an evidence-based deep learning approach. This method models the class probability distribution using a Dirichlet distribution, enabling simultaneous output of prediction results and uncertainty estimates. Existing evidence-based deep learning methods typically construct the concentration parameter of the Dirichlet distribution as follows: the logits output by the decoupled evidence network model are directly converted into evidence quantities using activation functions such as ReLU or Softplus, and then 1 is added to obtain the concentration parameter.

[0004] This approach tightly couples the classification task and the evidence collection task into the same network branch, leading to feature confusion caused by the coupling of classification and evidence: since the classification score and the amount of evidence are output by the same set of neurons, the gradient of the classification loss directly affects the learning of the evidence parameters. When the model optimizes classification on in-distribution samples, it tends to output a large amount of evidence for all samples, including hard samples, to improve classification confidence. This makes it difficult for the model to distinguish between in-distribution hard samples and out-of-distribution samples, because the two may have similar uncertainty features in the feature space. However, coupled training forces the model to output a high amount of evidence for in-distribution hard samples as well.

[0005] Therefore, how to design an effective evidence deep learning framework that decouples the training process of the classification branch and the evidence branch, and combines explicit out-of-distribution sample constraints, to accurately identify out-of-distribution samples while ensuring classification accuracy, is a technical problem that urgently needs to be solved. Summary of the Invention

[0006] The purpose of this invention is to overcome the shortcomings of the prior art and provide an out-of-distribution detection method based on decoupled evidence deep learning. By using a gradient truncation strategy to achieve decoupled training of the classification branch and the evidence branch, and combining a normalized cosine classification head and explicit constraints on out-of-distribution samples, this invention effectively solves the feature confusion problem caused by the coupling of classification and evidence in existing evidence deep learning methods, and improves the model's ability to distinguish between difficult in-distribution samples and out-of-distribution samples.

[0007] To achieve the above objectives, the present invention adopts the following technical solution: an out-of-distribution detection method based on decoupled evidence deep learning, characterized in that the following steps are performed by a computer device:

[0008] Step 1: Obtain the training dataset containing in-distribution samples and the auxiliary training dataset containing out-of-distribution samples;

[0009] Step 2: Construct a decoupled evidence network model, including constructing a feature extractor, a normalized cosine classification head, and an evidence prediction head;

[0010] Step 3: Define the forward propagation mechanism of the decoupled evidence network model. After performing gradient truncation on the output of the normalized cosine classification head, it is fused with the output of the evidence prediction head to generate a concentration parameter vector of Dirichlet distribution.

[0011] Step 4: Based on the decoupled evidence network model and the forward propagation mechanism, construct a decoupled objective function that includes classification loss and distribution uncertainty constraints, and use the training dataset and auxiliary training dataset to perform end-to-end training on the decoupled evidence network model;

[0012] Step 5: Obtain the image to be detected and input it into the trained decoupled evidence network model. Calculate the differential entropy of the predicted distribution based on the concentration parameter vector generated by the Dirichlet distribution.

[0013] Step 6: Based on the calculated differential entropy of the predicted distribution, perform a credibility assessment. If the differential entropy is greater than the preset threshold, the image to be detected is determined to be an out-of-distribution sample; otherwise, it is determined to be an in-distribution sample.

[0014] Preferably, step 1 specifically includes the following steps:

[0015] Step 1.1: Obtain the in-distribution training dataset ,in For in-distribution image samples, For category labels, The total number of samples within the distribution. Let C represent the set of real numbers, W be the number of channels in the image, H be the height of the image, K be the total number of categories of samples in the distribution, and i be the index of the sample in the distribution, with a value range of 1, 2, ..., N.

[0016] Step 1.2: Obtain the out-of-distribution auxiliary training dataset ,in Image samples that do not belong to the in-distribution category set. Let be the total number of out-of-distribution samples, and j be the index of the out-of-distribution sample, with a value range of 1, 2, ..., M;

[0017] Step 1.3: Perform data augmentation and normalization preprocessing on the in-distribution and out-of-distribution image samples respectively. The preprocessing includes random cropping, random horizontal flipping, tensor quantization, and channel-wise normalization; let the normalization parameter be the mean vector. with standard deviation vector For images The Normalize each channel:

[0018]

[0019] in, This indicates an assignment operation. This represents a two-dimensional tensor consisting of all pixel values ​​in the c-th channel of image x, where c is the channel index, with values ​​ranging from 0, 1, ..., C. 1, Mean vector The c-th channel element, which is the mean of the c-th channel of the image. Standard deviation vector The c-th channel element is the standard deviation of the c-th channel of the image.

[0020] Preferably, step 2 specifically includes the following steps:

[0021] Step 2.1: Construct the feature extraction network: Let the image input to the feature extraction network be... , to image The input is fed into a feature extraction network, which is a deep convolutional network denoted as . ,in The image is a set of learnable parameters for the feature extraction network. The corresponding feature vector is ;

[0022] in , For feature dimension, For parameters Constrained depthwise convolutional feature mapping function Let D be the feature vector corresponding to the i-th sample;

[0023] Step 2.2, Constructing a cosine-normalized classification head: The feature vector output in Step 2.1... The data is input into the cosine normalization classification head, and the classification head is denoted as... The output classification log vector is obtained. ,in , The total number of categories within the distribution; the classification head has a learnable weight matrix. For the feature vector With weight matrix each line Perform separately Normalization yields normalized eigenvectors. with normalized weight vector ;

[0024] in express Norm; For cosine-normalized classification mapping function, This is the category weight vector corresponding to the k-th row of the weight matrix. , These are the normalized feature vector and weight vector, respectively; the first and second normalized feature vectors of the classification logarithm vector. Each component is calculated as follows: ,in Indicates the inner product. This is the scaling factor;

[0025] Step 2.3, Construct the evidence prediction head: The feature vector output in Step 2.1... The information is input into the evidence prediction header, and the evidence prediction header is denoted as... The total strength of evidence is obtained. ,in , indicating sample The total amount of evidence; the evidence prediction head is a multilayer perceptron structure, including at least one fully connected layer, a batch normalization layer, an activation function layer, and uses the Softplus activation function in the last layer to ensure that the output is positive;

[0026] in, For evidence prediction mapping function, Let i be the total strength of evidence for the i-th sample. Represents the set of positive real numbers;

[0027] Step 2.4, Dual-head output: Output the cosine normalization classification by head. With Evidence Prediction Head Output Both are used as the model output.

[0028] Preferably, step 3 specifically includes the following steps:

[0029] Step 3.1, Forward Propagation and Parameter Calculation: In each training iteration, obtain the in-distribution batch from the in-distribution data loader. ,in , , Set the in-distribution batch size; retrieve the out-of-distribution batch from the out-of-distribution data loader. , For the size of the out-of-distribution batch;

[0030] The input is obtained by concatenating the in-distribution batches and out-of-distribution batches along the batch dimension. ; the input Input the decoupled evidence network model and obtain the output. ,in For the classification score tensor, For the total strength of evidence tensor;

[0031] The output is segmented according to the sample source. , , and ;in, This refers to tensor concatenation operations at the batch dimension. Represents the batch image tensor within the distribution. X represents the true class label tensor corresponding to the batch images within the distribution; X represents the total input image tensor obtained by concatenating the batch images within the distribution and the batch images outside the distribution along the batch dimension; L represents the total classification score tensor output by the model. This represents the total evidence strength tensor output by the model;

[0032] This represents the classification score tensor of samples within the corresponding distribution after segmentation. This represents the classification score tensor of the out-of-distribution samples after segmentation. This represents the total evidence strength tensor of samples within the corresponding distribution after segmentation. This represents the total evidence strength tensor of the out-of-distribution samples after segmentation;

[0033] Step 3.2, Calculate the category probability: and The class probabilities are obtained by performing Softmax operations on each class separately:

[0034]

[0035] in, , , Let be the class probability tensor of all samples in the batch within the distribution. is the class probability tensor of all samples in the out-of-distribution batch; k is the index of a single class, with a value range of K; Let be the probability that the i-th sample belongs to the k-th class within the distribution. Let be the probability that the i-th sample outside the distribution belongs to the k-th class. Indicates the first The corresponding in-distribution sample is the th Class score, The score for the i-th sample outside the distribution belonging to the k-th class;

[0036] Step 3.3, Gradient Truncation: Perform gradient truncation on the class probabilities to obtain:

[0037]

[0038] in, , Let be the class probability tensor after gradient truncation. This means that the forward propagation keeps the values ​​unchanged, while the backward propagation blocks the gradient propagation to the classification head parameters, making the gradient based on class probabilities... The constructed evidence constraint loss only updates the evidence prediction head parameters, thus decoupling the classification branch from the evidence branch.

[0039] Step 3.4: Construct the Dirichlet concentration parameter: convert the total evidence strength tensor of the samples within the distribution. and Dirichlet concentration parameters within the fusion structure distribution: The total evidence strength tensor of out-of-distribution samples and Merged structural distribution of Dirichlet concentration parameters:

[0040]

[0041] in , , Let be the Dirichlet concentration parameter tensor for all samples in the batch within the distribution. Let be the Dirichlet concentration parameter tensor for all samples in the out-of-distribution batch. Let i represent the evidence strength tensor of the i-th sample within the distribution. The evidence strength tensor of the i-th sample outside the distribution, Let be the Dirichlet concentration parameter of the k-th sample within the distribution. Let be the Dirichlet concentration parameter of the i-th sample outside the distribution. The uniform prior indicates that the model maintains unbiased predictions for all categories when there is no supporting evidence.

[0042] Preferably, step 4 specifically includes the following steps:

[0043] Step 4.1: Construct the in-distribution classification loss: The in-distribution classification loss is the cross-entropy loss, calculated as follows: in, For the first The true class label of each sample Indicates the first The true class label corresponding to each sample in the distribution. The score, The cross-entropy classification loss is used within the distribution.

[0044] Step 4.2: Construct the out-of-distribution homogenization constraint loss: Apply the out-of-distribution classification score tensor... Logarithmic softmax operation is performed to obtain , of which The first sample The logarithmic probability of the class is: Construct a uniform target distribution any of the elements ; Calculate the external homogenization constraint loss:

[0045]

[0046] in, The out-of-distribution homogenization constraint loss is used to make the class probability distribution of out-of-distribution samples tend to be uniform, where Q is the uniform prior target distribution. It is the target probability value of the i-th out-of-distribution sample and the k-th class in Q;

[0047] Step 4.3: Constructing Evidence-Constrained Loss: Constructing the target concentration parameter within the distribution. This makes the dimension corresponding to the true category take a larger value. The remaining dimensions are set to 1; for the th Samples within a distribution satisfy: in The target evidence strength hyperparameter;

[0048] Constructing out-of-distribution target concentration parameters Make all dimensions equal to 1: This indicates that out-of-distribution samples should have a uniform Dirichlet distribution, corresponding to high uncertainty. This represents the target Dirichlet concentration parameter of the k-th category dimension for the i-th sample in the batch distribution. This represents the target Dirichlet concentration parameter for the k-th category dimension of the i-th sample in an out-of-distribution batch;

[0049] Dirichlet distributions were constructed using the predicted concentration parameters and the target concentration parameters, respectively, and the KL divergence loss was calculated.

[0050] For two Dirichlet distributions and The closed-form solution of its KL divergence is: in, This represents the k-th component of the Dirichlet concentration parameter vector. This represents the k-th component of the Dirichlet distribution of the target. To predict the total concentration parameter of the distribution, The total concentration parameter of the target distribution, , ;

[0051] For the Gamma function, It is the Digamma function;

[0052] The in-distribution evidence constraint loss is: The out-of-distribution evidence constraint loss is:

[0053]

[0054] Where Dir() represents the Dirichlet distribution, and KL() represents the KL divergence. , These represent KL losses constrained by in-distribution and out-of-distribution evidence, respectively. Let be the Dirichlet distribution concentration parameter vector of the i-th sample. Let be the target Dirichlet distribution concentration parameter vector corresponding to the i-th in-distribution sample. Let be the Dirichlet distribution concentration parameter vector of the i-th out-of-distribution sample. Let be the target Dirichlet distribution concentration parameter vector corresponding to the i-th out-of-distribution sample;

[0055] Step 4.4, Calculate the total loss and train: The total loss for a single iteration is: in and The weights are hyperparameters; a stochastic gradient descent optimizer is used to update the network parameters, and the learning rate is adjusted using a cosine annealing strategy. The learning rate is set at the [missing value]th [missing value]. The step is calculated as follows: in The initial learning rate, To minimize the learning rate, Total training steps The total loss of the model, Let t be the current learning rate at step t, where t is the current training iteration step.

[0056] Preferably, step 5 specifically includes the following steps:

[0057] Step 5.1: The image to be detected Input the trained decoupled evidence network model to obtain the classification score vector. With overall strength of evidence ;

[0058] Step 5.2: Convert the classification score vector Performing the Softmax operation yields the class probability vector. :

[0059]

[0060] Step 5.3: Construct the Dirichlet concentration parameter vector : ;in This represents the probability vector of the k-th class after normalization by the Softmax operation;

[0061] Step 5.4: Calculate the differential entropy of the Dirichlet distribution as the uncertainty fraction. The closed-form solution of the differential entropy of the Dirichlet distribution is:

[0062]

[0063] in The multivariate Beta function is defined as follows: Therefore, the differential entropy can be expanded as:

[0064]

[0065] in For the Digamma function, The differential entropy of the Dirichlet distribution is the uncertainty score of the output; the larger the value, the higher the prediction uncertainty.

[0066] Preferably, step 6 specifically includes the following steps:

[0067] Step 6.1: Calculate the uncertainty score. With preset threshold Compare;

[0068] Step 6.2, if If the image to be detected is determined to be an out-of-distribution sample, a rejection signal is output; otherwise, it is determined to be an in-distribution sample, and a category prediction result is output. The category prediction result is... : or equivalently: ;

[0069] in, This represents the classification score vector for the k-th category output by the decoupled evidence network model.

[0070] In another aspect, the present invention also discloses a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform the steps of the method described above.

[0071] In another aspect, the present invention also discloses a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the method described above.

[0072] The beneficial effects of this invention include:

[0073] (1) This invention creatively decouples classification probability calculation from evidence strength prediction through gradient truncation. The classification head is responsible for learning class discrimination features and outputting class probability distribution, while the evidence prediction head independently learns the total evidence strength of the samples. The two are fused through the gradient-trunculated probability vectors to construct the Dirichlet concentration parameter. This design ensures that the gradient of classification loss does not propagate to the evidence prediction head, and the gradient of evidence constraint loss does not propagate to the classification head, thereby avoiding the negative interference of the classification task on evidence learning. This allows the evidence prediction head to focus on learning the uncertainty features of the samples, significantly improving the model's ability to distinguish between in-distribution difficult samples and out-of-distribution samples.

[0074] (2) This invention uses L2-normalized cosine similarity to calculate the classification score and introduces geometric constraints in the feature space. This design makes the classification score actually reflect the angle relationship between the feature vector and the class weight vector. The angle between the feature vector of the in-distribution sample and the corresponding class weight vector is smaller, while the angle between the feature vector of the out-of-distribution sample and all class weight vectors is larger, thereby enhancing the separability of in-distribution and out-of-distribution samples at the feature level.

[0075] (3) This invention introduces an out-of-distribution auxiliary dataset during training and explicitly models the high uncertainty characteristics of out-of-distribution samples through uniform constraint loss and evidence constraint loss, prompting the model to output a Dirichlet distribution close to the uniform prior for out-of-distribution samples. At the same time, the differential entropy of the Dirichlet distribution is used as an uncertainty measure. When the model has high confidence in a certain category, the differential entropy is small, and when the model faces out-of-distribution samples, the differential entropy is large, which can accurately reflect the model's confidence in the prediction results, providing a reliable basis for rejection decision-making in practical applications and realizing truly credible detection. Attached Figure Description

[0076] Figure 1 This is a schematic diagram of the overall process of an embodiment of the present invention;

[0077] Figure 2 This is a schematic diagram showing the effect of fine-tuning the model constructed by the out-of-distribution detection method of the present invention before and after;

[0078] Figure 3 This is a structural block diagram of a computer device according to an embodiment of the present invention. Detailed Implementation

[0079] The technical solution of the present invention will now be described in detail with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only for explaining the present invention and are not intended to limit the scope of protection of the present invention. Various modifications or variations made by those skilled in the art based on the technical solution of the present invention without creative effort should be covered within the scope of protection of the present invention. Furthermore, the technical features in the various embodiments of the present invention can be arbitrarily combined and used without conflicting with each other. The embodiments of the present invention will be further described below with reference to the accompanying drawings. Figure 1 As shown, this invention provides an out-of-distribution detection method based on decoupled evidence deep learning, comprising the following steps:

[0080] Example:

[0081] like Figure 1 As shown in this embodiment, in current clinical medical imaging diagnosis, deep learning-assisted segmentation technology has been widely used for the automatic localization and boundary delineation of lesions such as lung nodules, brain tumors, and liver lesions, significantly improving diagnostic efficiency and consistency. However, when faced with out-of-distribution samples (such as rare lesion types, imaging data from different manufacturers' devices, or low-quality images with motion artifacts or noise), existing mainstream segmentation models often output overconfident and erroneous segmentation results and cannot provide reliable uncertainty indications, posing a serious risk of clinical misdiagnosis.

[0082] Therefore, to address the aforementioned shortcomings, this embodiment proposes an out-of-distribution detection method based on decoupled evidence deep learning, applied to medical image segmentation tasks, including the following steps:

[0083] Step 1: Obtain training data. Obtain a training dataset containing samples within the distribution. ,in For in-distribution image samples, For category labels, The total number of samples within the distribution. Let C represent the set of real numbers, W be the number of channels in the image, H be the height of the image, K be the total number of categories of samples in the distribution, and i be the index of the sample in the distribution, with a value range of 1, 2, ..., N.

[0084] Simultaneously obtain the out-of-distribution auxiliary training dataset ,in Image samples that do not belong to the in-distribution category set. Let be the total number of out-of-distribution samples, and j be the index of the out-of-distribution sample, with a value range of 1, 2, ..., M.

[0085] In this embodiment, the TIN-597 dataset is used as out-of-distribution auxiliary training data. TIN-597 consists of 597 categories selected from the TinyImageNet dataset that do not semantically overlap with CIFAR-10 / 100. The images of TIN-597 are scaled to 32×32×3 to match the size of the CIFAR dataset.

[0086] All image samples undergo data augmentation and normalization preprocessing. Data augmentation operations include: random cropping: images are randomly cropped with a probability of 0.8, with a crop size of 80% to 100% of the original image, and then scaled back to the original size of 32×32; random horizontal flipping: images are horizontally flipped with a probability of 0.5; normalization: each channel of the image is normalized.

[0087] The specific method of normalization is as follows: for the image The Each channel is used to calculate the normalized pixel value: in, This indicates an assignment operation. This represents a two-dimensional tensor consisting of all pixel values ​​in the c-th channel of image x, where c is the channel index, with values ​​ranging from 0, 1, ..., C. 1, Mean vector The c-th channel element, which is the mean of the c-th channel of the image. Standard deviation vector The c-th channel element is the standard deviation of the c-th channel of the image.

[0088] Step 2: Construct a decoupled evidence network model. The decoupled evidence network model constructed in this invention includes three main parts: a feature extractor, a normalized cosine classification head, and an evidence prediction head.

[0089] Step 2.1: Let the image input to the feature extractor be... The number of image channels is The width and height are respectively and ,Right now . Image The input is fed into a feature extractor, which is a deep convolutional network denoted as . ,in These are the learnable parameters of the feature extractor. Then the image... The corresponding feature vector is: .in , For feature dimension, For parameters Constrained depthwise convolutional feature mapping function Let be the D-dimensional feature vector corresponding to the i-th sample.

[0090] In this embodiment, the feature extractor adopts the WideResNet-40-10 structure. WideResNet improves performance by increasing the network width rather than depth, where 40 represents a network depth of 40 layers and 10 represents a width factor of 10. Specifically, the global average pooling layer and fully connected classification layer in the original WideResNet-40-10 structure are removed, retaining the preceding convolutional layers and residual blocks. The network structure includes: an initial convolutional layer (3×3 convolutional kernel, 16 channels), and 3 groups of residual blocks (each group contains 6 residual blocks with 160, 320, and 640 channels respectively). After the last residual block, the feature map is compressed into a one-dimensional feature vector through a global average pooling operation, resulting in... That is, feature dimension .

[0091] The global average pooling calculation method is as follows: for a size of The feature map is used to calculate the average value of each channel. This operation compresses the spatial dimension, resulting in a fixed-dimensional feature vector.

[0092] Step 2.2: Construct a normalized cosine classifier head. This involves converting the feature vector output from Step 2.1... The input is fed into the normalized cosine classification head, and the classification head is denoted as... The output classification score vector is obtained. ,in , This represents the total number of categories within the distribution.

[0093] The classification head has a learnable weight matrix. This matrix can be understood as Each category has a prototype vector, with one row corresponding to each category. ( ).

[0094] For eigenvectors conduct Normalization yields the normalized eigenvectors: .in The norm is calculated as follows: Normalized eigenvectors lie in On the hypersphere, i.e. .

[0095] Similarly, for the weight matrix each line conduct Normalization yields the normalized weight vector: Normalized weight vector Also located On the hypersphere, the unit of dimension.

[0096] in express Norm; For cosine-normalized classification mapping function, This is the category weight vector corresponding to the k-th row of the weight matrix. , These are the normalized feature vector and weight vector, respectively; the classification score vector is... Each component is calculated as follows: ,in The inner product operation is represented as follows: , is the scaling factor, which is an adjustable hyperparameter.

[0097] In this embodiment, the scaling factor Preferably 20. This is achieved by introducing the scaling factor. For values ​​within the range Linear amplification of the normalized inner product value can effectively adjust the sharpness of the output probability distribution of the Softmax activation function, avoiding the problem of the probability distribution becoming too smooth and reducing the convergence effect of the model if the inner product value is directly used as the classification logarithm.

[0098] Furthermore, the normalized cosine classification head classifies the feature vectors... With weight vector Mapping onto the unit hypersphere, the calculated inner product is equivalent to the cosine of the angle between the two surfaces. (in (The angle between the two). This calculation mechanism constructs geometric constraints in the feature space, using angular similarity as the classification score. The measurement criteria drive the feature vectors of similar samples to converge toward the corresponding class weight vector, and promote the separation of features of dissimilar samples, thereby effectively enhancing the model's ability to distinguish features of samples inside and outside the distribution.

[0099] Step 2.3, Construct the evidence prediction head: Combine the feature vector Input into the evidence prediction head In this process, the overall strength of evidence is obtained. ,in . The larger the value, the more sufficient the evidence collected by the network, and the greater the confidence in the prediction results; The smaller the value, the less sufficient the evidence, and the less confidence there is in the prediction results.

[0100] The evidence prediction head is a multilayer perceptron structure, including at least one fully connected layer, a batch normalization layer, and an activation function layer, with the Softplus activation function used in the last layer. To ensure that the output is positive;

[0101] in, For evidence prediction mapping function, Let i be the total strength of evidence for the i-th sample. It represents the set of positive real numbers.

[0102] Step 2.4, Dual-head output. Output the normalized cosine classification head. With Evidence Prediction Head Output Both are used as model outputs. This dual-head design allows the model to perform classification prediction and uncertainty estimation simultaneously. During forward propagation, the feature vector output by the feature extractor... The data are fed into the normalized cosine classification head and the evidence prediction head, respectively. The two heads are calculated in parallel without interfering with each other.

[0103] Step 3: Constructing the Dirichlet Distribution Parameters. This invention uses a gradient truncation strategy to fuse the outputs of the normalized cosine classification head and the evidence prediction head to construct the concentration parameter vector of the Dirichlet distribution. Specifically, this includes the following steps:

[0104] In each training iteration, in-distribution batches are obtained from the in-distribution data loader. ,in For batches of images within the distribution, For the corresponding label batch, This refers to the batch size within the distribution. The off-distribution batch is obtained from the off-distribution data loader. , This refers to the batch size outside the distribution.

[0105] The input is obtained by concatenating the in-distribution batches and out-of-distribution batches along the batch dimension (0th dimension):

[0106]

[0107] The input Input the decoupled evidence network model constructed in step 2, and obtain the output. ,in For the classification score tensor, Let be the total evidence strength tensor. Specifically, for the in the spliced ​​batch... Sample The feature vector is obtained through the feature extractor. Then, the classification score vectors are obtained by using the normalized cosine classifier. The total strength of evidence is obtained through the evidence prediction head. .

[0108] The output is segmented according to the sample source to obtain the in-distribution classification score. Out-of-distribution classification scores Total strength of evidence within the distribution Total strength of evidence outside the distribution The splitting operation is as follows:

[0109]

[0110] in, This refers to tensor concatenation operations at the batch dimension. Represents the batch image tensor within the distribution. X represents the true class label tensor corresponding to the batch images within the distribution; X represents the total input image tensor obtained by concatenating the batch images within the distribution and the batch images outside the distribution along the batch dimension; L represents the total classification score tensor output by the model. This represents the total evidence strength tensor output by the model;

[0111] This represents the classification score tensor of samples within the corresponding distribution after segmentation. This represents the classification score tensor of the out-of-distribution samples after segmentation. This represents the total evidence strength tensor of samples within the corresponding distribution after segmentation. This represents the total evidence strength tensor of the out-of-distribution samples after segmentation;

[0112] Step 3.2: Calculate the class probabilities. Perform a Softmax operation on the classification scores to obtain the class probabilities. The Softmax function maps any real-valued vector to a probability distribution that satisfies... and .

[0113] For samples within the distribution, the first The first sample The probabilities of each category are: Similarly, for out-of-distribution samples, the first The first sample The probabilities of each category are: .

[0114] in , , Let be the class probability tensor of all samples in the batch within the distribution. is the class probability tensor of all samples in the out-of-distribution batch; k is the index of a single class, with a value range of K; Let be the probability that the i-th sample belongs to the k-th class within the distribution. Let be the probability that the i-th sample outside the distribution belongs to the k-th class. Indicates the first The corresponding in-distribution sample is the th Class score, Let be the score of the i-th sample outside the distribution belonging to the k-th class.

[0115] Step 3.3: Perform gradient truncation on the class probabilities. In deep learning frameworks, gradient truncation is performed by... The function implementation has the following effect: during forward propagation, the class probabilities remain unchanged; during backward propagation, the gradient propagation to the classification head parameters is blocked.

[0116] Specifically, gradient truncation is performed on the class probabilities within the distribution: Gradient truncation is applied to the out-of-distribution class probabilities: .

[0117] Perform a gradient truncation operation on the class probabilities to obtain the truncated class probabilities. (Right now and ),in, , Let be the class probability tensor after gradient truncation. This means that the forward propagation keeps the values ​​unchanged, while the backward propagation blocks the gradient propagation to the classification head parameters, making the gradient based on... The constructed evidence constraint loss only updates the evidence prediction head parameters, thus decoupling the classification branch from the evidence branch.

[0118] In this embodiment, the gradient truncation mechanism is configured to: maintain the normal transmission of class probability values ​​during the forward propagation phase; however, forcibly block the gradient backpropagation of this computation node during the backpropagation phase. By introducing this mechanism, subsequent calculations based on the truncated probabilities... When updating parameters, the gradient of the constructed loss function can only propagate to the parameters of the evidence prediction head, and cannot be backpropagated to the original generated probabilities. Classification header parameters With feature extractor parameters Therefore, feature confusion is avoided at the underlying optimization logic level, and strict decoupling training of classification branch and evidence branch is achieved.

[0119] Step 3.4: Construct concentration parameters. The total evidence strength tensor of the samples within the distribution... and The in-distribution Dirichlet concentration parameters are constructed by fusing the data. For in-distribution samples, the first... The first sample The concentration parameters for each category are:

[0120]

[0121] The total evidence strength tensor of out-of-distribution samples and The Dirichlet concentration parameters outside the fusion structure distribution, the first The first sample The concentration parameters for each category are:

[0122]

[0123] The total evidence strength tensor According to category probability Assigned to various categories, obtaining the amount of evidence for each category. Then add 1 to get the concentration parameter. .in , Adding 1 is to ensure that the concentration parameter approaches 1 when the total strength of evidence approaches zero, representing a uniform prior. Let be the Dirichlet concentration parameter tensor for all samples in the batch within the distribution. Let be the Dirichlet concentration parameter tensor for all samples in the out-of-distribution batch. Let i represent the evidence strength tensor of the i-th sample within the distribution. The evidence strength tensor of the i-th sample outside the distribution, Let be the Dirichlet concentration parameter of the k-th dimension of the i-th sample within the distribution. Let be the Dirichlet concentration parameter of the i-th sample in the out-of-distribution set at the k-th level. A uniform prior indicates that the model maintains unbiased predictions for all classes when there is no supporting evidence; when the total evidence strength tensor... At that time, concentration parameter At this point, the Dirichlet distribution degenerates into a uniform prior. , indicating that the model is completely uncertain about all categories.

[0124] The Dirichlet distribution is a continuous probability distribution defined on the probability simplex, and its probability density function is:

[0125]

[0126] in Let be a class probability vector, satisfying and ; A vector of concentration parameters; The multivariate Beta function is defined as follows: ,in This is the Gamma function.

[0127] Step 4: Model Training. Design a decoupled objective function that includes classification loss and distribution uncertainty constraints, and train the model end-to-end using the training dataset and the auxiliary training dataset.

[0128] Step 4.1, In-distribution classification loss. The cross-entropy loss function is used, and the calculation method is as follows: in For the first The true class label of each sample The cross-entropy classification loss is the in-distribution loss.

[0129] In this embodiment, the calculation link of the intra-distribution classification loss depends only on the classification score output by the normalized cosine classification head. Based on this parallel dual-head architecture design, during the backpropagation phase, the gradient update path generated by the classification loss is strictly limited to the weight matrix of the classification head. and the parameters of the feature extractor This independent computing mechanism isolates the propagation of the classification loss gradient to the evidence prediction head parameters at the network topology level, thereby ensuring that the classification optimization process does not interfere with the evidence collection task.

[0130] Step 4.2, Out-of-Distribution Uniformity Constraint Loss. Softmax calculation is performed on the out-of-distribution classification scores to obtain the class probabilities. Construct a uniform target distribution The probability of each category is 1. ,Right now:

[0131]

[0132] Calculate the predicted probability distribution With uniform target distribution KL divergence between:

[0133]

[0134] The Kullback-Leibler divergence is an asymmetric measure of the difference between two probability distributions. The above equation can be simplified to:

[0135]

[0136] in, The loss is the out-of-distribution homogenization constraint loss, where Q is the uniform prior target distribution; In a uniform target distribution Q, the target probability value of the i-th out-of-distribution sample belonging to the k-th class is given. The uniformity constraint loss, as an explicit regularization mechanism, drives the class probability distribution of out-of-distribution samples towards a uniform state during backpropagation optimization. Convergence. By leveling the predicted probabilities of each category, this mechanism effectively suppresses the model's abnormally high confidence in outputting samples from unknown distributions, thereby overcoming the overconfidence defect commonly found in out-of-distribution detection by decoupled evidence network models.

[0137] Step 4.3, In-distribution evidence constraint loss. Construct the in-distribution target concentration parameters. For the first There are 1 sample, and its true category is 1 The target concentration parameter is then constructed as follows: in, The target evidence strength hyperparameter is defined as the preset target concentration parameter, which is used to provide asymmetric supervision signals for evidence learning from samples within the distribution. This represents the target Dirichlet concentration parameter of the k-th category dimension for the i-th sample in the batch distribution. This represents the target Dirichlet concentration parameter for the k-th category dimension of the i-th sample in the out-of-distribution batch.

[0138] Specifically, this is achieved by setting the true category dimension as a high evidence strength threshold. Furthermore, by setting the non-true category dimension to a baseline value of 1 (no evidence), this construction logic forces the evidence prediction head to focus on evidence collection for the true category in the feature space, while suppressing the response to evidence for other categories. This ensures that the model has high confidence and low uncertainty in predicting known samples within the distribution.

[0139] Calculate the predicted concentration parameters With target concentration parameters KL divergence between constructed Dirichlet distributions:

[0140]

[0141] The formula for calculating the KL divergence between two Dirichlet distributions is: in, This represents the k-th component of the Dirichlet concentration parameter vector. This represents the k-th component of the Dirichlet distribution of the target. To predict the total concentration parameter of the distribution, The total concentration parameter of the target distribution, For the Gamma function, Let be the Digamma function, and be the logarithmic derivative of the Gamma function.

[0142] The Gamma function is defined as follows: For positive integers ,have .

[0143] The Digamma function is defined as follows: .

[0144] Step 4.4, Out-of-Distribution Evidence Constraint Loss. Construct out-of-distribution target concentration parameters. Make all dimensions equal to 1: A target concentration parameter of all 1s corresponds to a uniform prior Dirichlet distribution. , indicating that the model is completely uncertain about all categories.

[0145] Calculate the predicted concentration parameters With target concentration parameters KL divergence between constructed Dirichlet distributions:

[0146]

[0147] Where Dir() represents the Dirichlet distribution, and KL() represents the KL divergence. , These represent KL losses constrained by in-distribution and out-of-distribution evidence, respectively. Let be the Dirichlet distribution concentration parameter vector of the i-th sample. Let be the target Dirichlet distribution concentration parameter vector corresponding to the i-th in-distribution sample. Let be the Dirichlet distribution concentration parameter vector of the i-th out-of-distribution sample. Let be the target Dirichlet distribution concentration parameter vector corresponding to the i-th out-of-distribution sample;

[0148] The KL divergence loss function, acting as a regularization constraint for out-of-distribution samples, forces the concentration parameters of each dimension of the network output to converge towards the baseline value of 1 during model parameter updates. This constraint mechanism effectively suppresses the accumulation of false evidence generated by out-of-distribution features, thus objectively representing the high uncertainty state for samples with unknown distributions.

[0149] Step 4.5, Total Loss Function and Optimization. The total loss for a single training iteration is a weighted sum of four loss terms: in, and These are preset weight hyperparameters used to adjust the gradient contribution ratio of each loss term in the joint optimization process. This represents the total loss of the model.

[0150] As a preferred implementation, this embodiment configures the weight hyperparameter as follows: , This parameter configuration mechanism aims to address the gradient dominance problem caused by the difference in numerical magnitude between different loss terms. By introducing a smaller weight coefficient to scale the evidence constraint loss, it can effectively suppress the excessive interference of large-scale loss terms on network parameter updates, ensuring smooth joint convergence of the classification task and the evidence learning task.

[0151] Furthermore, in other alternative implementation scenarios, the weight hyperparameter... and Dynamic optimization and adaptive configuration can also be performed on the independent validation set through grid search or Bayesian optimization algorithms, but this embodiment of the invention does not strictly limit this.

[0152] The learning rate is adjusted using a cosine annealing strategy. In the... For each training step, the learning rate is calculated as follows: in The initial learning rate, To minimize the learning rate, This represents the total number of training steps.

[0153] Step 5: Obtain test data and perform inference. (This involves obtaining the image to be detected.) Input the trained model to obtain feature vectors: .

[0154] eigenvectors By inputting the normalized cosine classification head and the evidence prediction head respectively, the classification score vector is obtained. With overall strength of evidence : Perform a Softmax operation on the classification score vector to obtain the class probability vector: ,in This represents the probability vector of the k-th class after normalization by the Softmax operation.

[0155] By fusing the category probability vector with the total evidence strength, a Dirichlet concentration parameter vector is constructed: The differential entropy of the Dirichlet distribution is calculated as the uncertainty fraction. The differential entropy of the Dirichlet distribution is defined as: The integral has a closed-form solution, and the formula for its calculation is:

[0156]

[0157] in For multivariate Beta functions: .

[0158] In practical calculations, for numerical stability, the logarithm of the Beta function is usually calculated:

[0159]

[0160] Therefore, the formula for calculating differential entropy can be rewritten as:

[0161]

[0162] in, The differential entropy of the Dirichlet distribution, i.e., the uncertainty score of the output, is a key metric. A higher value indicates greater prediction uncertainty. Differential entropy serves as the core measure of the uncertainty level of the Dirichlet distribution. In the actual inference phase, this metric maps the concentration parameters output by the network to continuous scalar values, objectively representing the confidence level of the prediction results. Specifically, when the network produces a high-confidence response to known distribution characteristics, the computational logic outputs a smaller differential entropy value, indicating that the distribution shape converges towards the vertex of the probabilistic simplex; conversely, when facing unknown samples outside the distribution, the concentration parameters in each dimension approach a uniform prior. The formula outputs a value that approximates the maximized differential entropy. This nonlinear quantization mapping effectively distinguishes between in-distribution and out-of-distribution samples, providing a reliable numerical basis for subsequent decision-making.

[0163] Step 6: Out-of-distribution detection and determination. The uncertainty score is... With preset threshold The comparison is performed. The judgment rule is as follows:

[0164]

[0165] When a sample is determined to be within the distribution, the output category prediction result is as follows: .

[0166] In this embodiment, the preset threshold This threshold is a core hyperparameter for the rejection sensitivity of the control system. The calibration mechanism for this threshold aims to balance the false positive rate (FPR) and true positive rate (TPR) in out-of-distribution detection tasks.

[0167] Specifically, if the threshold is configured too low, the system tends to trigger a strict rejection policy, thereby increasing the risk of misclassifying samples within the distribution as anomalies; conversely, if the threshold is configured too high, it will weaken the system's ability to intercept unknown distributions. In actual engineering deployments, the preset threshold... The specific application scenario can be adapted to the security tolerance requirements by relying on the verification set for adaptive optimization and dynamic tuning. This invention does not limit this to a single method.

[0168] This invention uses an evidence-based deep learning method to model uncertainty and decouples the classification branch from the evidence branch through a gradient truncation strategy. This effectively alleviates the overconfidence problem of modern deep networks and reduces the risk of misclassification in image classification systems when faced with out-of-distribution samples. Figure 2 As shown, this embodiment uses CIFAR-100 as the in-distribution (ID) dataset and TIN-597 as the semantic out-of-distribution (OOD) dataset to verify the uncertainty calibration effect of the decoupled evidence network proposed in this invention. It demonstrates the distribution of uncertainty scores for in-distribution (ID) and out-of-distribution (OOD) samples before and after fine-tuning.

[0169] in, Figure 2 The horizontal axis "Differential entropy" represents the differential entropy, a measure of uncertainty calculated from the Dirichlet distribution concentration parameters output by the model. A higher differential entropy value indicates greater uncertainty in the model's prediction of the current sample; a lower value indicates greater certainty in the model's prediction.

[0170] The vertical axis “Density” represents the probability density, which is used to characterize the relative frequency distribution of samples under the corresponding differential entropy value. “CIFAR-100(ID)” corresponds to the blue curve, which represents the uncertainty distribution of samples within the distribution from the CIFAR-100 dataset; “TIN-597(semanticOOD)” corresponds to the red curve, which represents the uncertainty distribution of samples outside the semantic distribution from the TIN-597 dataset.

[0171] As can be seen in the left subplot "Before fine-tuning", the differential entropy distributions of in-distribution samples and out-of-distribution samples have significant overlap, meaning that the two types of samples are poorly separable in the uncertainty space. This indicates that the model cannot effectively distinguish between in-distribution and out-of-distribution samples at this stage, and there is a problem of overconfident prediction of out-of-distribution samples.

[0172] As can be seen in the right-hand subplot “After fine-tuning”, after training with the method of this invention, the differential entropy of the samples within the distribution is mainly concentrated in the low-entropy region, while the differential entropy of the samples outside the distribution is mainly concentrated in the high-entropy region, and the two distributions show a clear separation.

[0173] This indicates that the method of the present invention can effectively improve the uncertainty calibration capability of the model, enabling the model to maintain high confidence in predicting in-distribution samples while outputting higher uncertainty for out-of-distribution samples, thereby significantly improving out-of-distribution detection performance.

[0174] The value is the uncertainty score of the differential entropy calculated in step 5. The vertical axis represents the sample density corresponding to the entropy value. The blue curve represents the entropy distribution of samples within the distribution, and the red curve represents the entropy distribution of samples outside the semantic distribution.

[0175] Before fine-tuning, the differential entropy distributions of in-distribution and out-of-distribution samples almost completely overlapped, and the uncertainty characteristics of the two types of samples had no obvious distinction. The model could not effectively identify out-of-distribution samples, and there was a risk of overconfident and erroneous predictions. After end-to-end fine-tuning with the decoupling objective function proposed in this invention, the differential entropy of in-distribution samples was concentrated in the low-entropy range, while the differential entropy of out-of-distribution samples was concentrated in the high-entropy range. The uncertainty distributions of the two types of samples were completely separated, proving that the proposed method can accurately calibrate the model's prediction uncertainty and significantly improve the accuracy and robustness of out-of-distribution detection. This validation effect can be directly transferred to medical image segmentation tasks, effectively solving the problem of misjudgment of out-of-distribution medical images such as rare lesions and low-quality artifacts.

[0176] In another aspect, the present invention also discloses a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform the steps of the method described above.

[0177] Furthermore, the present invention also discloses a computer device, including a memory and a processor, such as... Figure 3 As shown.

[0178] The computer device includes a processor, memory, input devices, output devices, and a network interface connected via a system bus. The processor provides computing and control capabilities; the memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs, while the internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media.

[0179] The input device is used to receive medical image data, training parameters and detection commands input by the user; the output device is used to display the detection results inside and outside the distribution, lesion segmentation images and uncertainty heatmaps; the network interface is used to communicate with external medical imaging systems and data servers to realize the uploading of medical image data and the distribution of detection results.

[0180] The memory stores a computer program, which, when executed by the processor, causes the processor to perform the steps of the method described above.

[0181] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the out-of-distribution detection methods based on decoupled evidence deep learning in the above embodiments.

[0182] It is understood that the systems, devices, and storage media provided in the embodiments of the present invention correspond to the methods provided in the embodiments of the present invention, and the explanations, examples, and beneficial effects of the relevant content can be referred to the corresponding parts of the above methods.

[0183] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another.

[0184] Those skilled in the art will clearly understand that embodiments of the present invention can be implemented through computer programs and corresponding general-purpose hardware platforms. Based on this understanding, the key technical aspects of the embodiments of the present invention, or those that contribute to the prior art, can be embodied in the form of a computer program, i.e., a software product. This computer program or software product can be stored in a storage medium and includes multiple instructions to drive a device containing a data processing unit, such as a personal computer, server, microcontroller, embedded microcontroller (MCU), or network device, to execute the methods described in different embodiments or certain parts of the embodiments of the present invention.

[0185] This invention provides an out-of-distribution detection method based on decoupled evidence deep learning. There are various methods and approaches to implement this technical solution; the above is merely one specific embodiment of this invention.

[0186] It is worth noting that those skilled in the art can make various improvements and optimizations without departing from the principles of this invention, and these improvements and optimizations should also be considered within the scope of protection of this invention. All components not explicitly described in this embodiment can be implemented using existing technologies.

[0187] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

[0188] Furthermore, it should be noted that if any directional indication (such as up, down, left, right, front, back, etc.) is involved in the embodiments of the present invention, the directional indication is only used to explain the relative positional relationship and movement of each component in a specific posture. If the specific posture changes, the directional indication will also change accordingly.

[0189] Furthermore, if the embodiments of this invention involve descriptions such as "first" or "second," these descriptions are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with "first" or "second" may explicitly or implicitly include at least one of those features. Additionally, the meaning of "and / or" throughout the text includes three parallel solutions; for example, "A and / or B" includes solution A, solution B, or a solution where both A and B are satisfied simultaneously. Furthermore, in the embodiments of this invention, "multiple" refers to two or more. Moreover, the technical solutions of the various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. When the combination of technical solutions is contradictory or impossible to implement, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed by this invention.

Claims

1. An out-of-distribution detection method based on decoupled evidence deep learning, characterized in that, Perform the following steps using a computer device: Step 1: Obtain the training dataset containing in-distribution samples and the auxiliary training dataset containing out-of-distribution samples; Step 2: Construct a decoupled evidence network model, including constructing a feature extractor, a normalized cosine classification head, and an evidence prediction head; Step 3: Define the forward propagation mechanism of the decoupled evidence network model. After performing gradient truncation on the output of the normalized cosine classification head, it is fused with the output of the evidence prediction head to generate a concentration parameter vector of Dirichlet distribution. Step 4: Based on the decoupled evidence network model and the forward propagation mechanism, construct a decoupled objective function that includes classification loss and distribution uncertainty constraints, and use the training dataset and auxiliary training dataset to perform end-to-end training on the decoupled evidence network model; Step 5: Obtain the image to be detected and input it into the trained decoupled evidence network model. Calculate the differential entropy of the predicted distribution based on the concentration parameter vector generated by the Dirichlet distribution. Step 6: Based on the calculated differential entropy of the predicted distribution, perform a credibility assessment. If the differential entropy is greater than the preset threshold, the image to be detected is determined to be an out-of-distribution sample; otherwise, it is determined to be an in-distribution sample.

2. The out-of-distribution detection method based on decoupled evidence deep learning according to claim 1, characterized in that: Step 1 specifically includes the following steps: Step 1.1: Obtain the in-distribution training dataset ,in For in-distribution image samples, For category labels, The total number of samples within the distribution. Let C represent the set of real numbers, W be the number of channels in the image, H be the height of the image, K be the total number of categories of samples in the distribution, and i be the index of the sample in the distribution, with a value range of 1, 2, ..., N. Step 1.2: Obtain the out-of-distribution auxiliary training dataset ,in Image samples that do not belong to the in-distribution category set. Let be the total number of out-of-distribution samples, and j be the index of the out-of-distribution sample, with a value range of 1, 2, ..., M; Step 1.3: Perform data augmentation and normalization preprocessing on the in-distribution and out-of-distribution image samples respectively. The preprocessing includes random cropping, random horizontal flipping, tensor quantization, and channel-wise normalization; let the normalization parameter be the mean vector. with standard deviation vector For images The Normalize each channel: in, This indicates an assignment operation. This represents a two-dimensional tensor consisting of all pixel values ​​in the c-th channel of image x, where c is the channel index, with values ​​ranging from 0, 1, ..., C. 1, Mean vector The c-th channel element, which is the mean of the c-th channel of the image. Standard deviation vector The c-th channel element is the standard deviation of the c-th channel of the image.

3. The out-of-distribution detection method based on decoupled evidence deep learning according to claim 2, characterized in that: Step 2 specifically includes the following steps: Step 2.1: Construct the feature extraction network: Let the image input to the feature extraction network be... , to image The input is fed into a feature extraction network, which is a deep convolutional network denoted as . ,in The image is a set of learnable parameters for the feature extraction network. The corresponding feature vector is ; in , For feature dimension, For parameters Constrained depthwise convolutional feature mapping function Let D be the feature vector corresponding to the i-th sample; Step 2.2, Constructing a cosine-normalized classification head: The feature vector output in Step 2.1... The data is input into the cosine normalization classification head, and the classification head is denoted as... The output classification log vector is obtained. ,in , The total number of categories within the distribution; the classification head has a learnable weight matrix. For the feature vector With weight matrix each line Perform separately Normalization yields normalized eigenvectors. with normalized weight vector ; in express Norm; For cosine-normalized classification mapping function, This is the category weight vector corresponding to the k-th row of the weight matrix. , These are the normalized feature vector and weight vector, respectively; the first and second normalized feature vectors of the classification logarithm vector. Each component is calculated as follows: ,in Indicates the inner product. This is the scaling factor; Step 2.3, Construct the evidence prediction head: The feature vector output in Step 2.1... The information is input into the evidence prediction header, and the evidence prediction header is denoted as... The total strength of evidence is obtained. ,in , indicating sample The total amount of evidence; the evidence prediction head is a multilayer perceptron structure, including at least one fully connected layer, a batch normalization layer, an activation function layer, and uses the Softplus activation function in the last layer to ensure that the output is positive; in, For evidence prediction mapping function, Let i be the total strength of evidence for the i-th sample. Represents the set of positive real numbers; Step 2.4, Dual-head output: Output the cosine normalization classification by head. With Evidence Prediction Head Output Both are used as the model output.

4. The out-of-distribution detection method based on decoupled evidence deep learning according to claim 3, characterized in that: Step 3 specifically includes the following steps: Step 3.1, Forward Propagation and Parameter Calculation: In each training iteration, obtain the in-distribution batch from the in-distribution data loader. ,in , , Set the in-distribution batch size; retrieve the out-of-distribution batch from the out-of-distribution data loader. , For the size of the out-of-distribution batch; The input is obtained by concatenating the in-distribution batches and out-of-distribution batches along the batch dimension. ; the input Input the decoupled evidence network model and obtain the output. ,in For the classification score tensor, For the total strength of evidence tensor; The output is segmented according to the sample source. , , and ;in, This refers to tensor concatenation operations at the batch dimension. Represents the batch image tensor within the distribution. X represents the true class label tensor corresponding to the batch images within the distribution; X represents the total input image tensor obtained by concatenating the batch images within the distribution and the batch images outside the distribution along the batch dimension; L represents the total classification score tensor output by the model. This represents the total evidence strength tensor output by the model; This represents the classification score tensor of samples within the corresponding distribution after segmentation. This represents the classification score tensor of the out-of-distribution samples after segmentation. This represents the total evidence strength tensor of samples within the corresponding distribution after segmentation. This represents the total evidence strength tensor of the out-of-distribution samples after segmentation; Step 3.2, Calculate the category probability: and The class probabilities are obtained by performing Softmax operations on each class separately: in, , , Let be the class probability tensor of all samples in the batch within the distribution. is the class probability tensor of all samples in the out-of-distribution batch; k is the index of a single class, with a value range of K; Let be the probability that the i-th sample belongs to the k-th class within the distribution. Let be the probability that the i-th sample outside the distribution belongs to the k-th class. Indicates the first The corresponding in-distribution sample is the th Class score, The score for the i-th sample outside the distribution belonging to the k-th class; Step 3.3, Gradient Truncation: Perform gradient truncation on the class probabilities to obtain: in, , Let be the class probability tensor after gradient truncation. This means that the forward propagation keeps the values ​​unchanged, while the backward propagation blocks the gradient propagation to the classification head parameters, making the gradient based on class probabilities... The constructed evidence constraint loss only updates the evidence prediction head parameters, thus decoupling the classification branch from the evidence branch. Step 3.4: Construct the Dirichlet concentration parameter: convert the total evidence strength tensor of the samples within the distribution. and Dirichlet concentration parameters within the fusion structure distribution: The total evidence strength tensor of out-of-distribution samples and Merged structural distribution of Dirichlet concentration parameters: in , , Let be the Dirichlet concentration parameter tensor for all samples in the batch within the distribution. Let be the Dirichlet concentration parameter tensor for all samples in the out-of-distribution batch. Let i represent the evidence strength tensor of the i-th sample within the distribution. The evidence strength tensor of the i-th sample outside the distribution, Let be the Dirichlet concentration parameter of the k-th sample within the distribution. Let be the Dirichlet concentration parameter of the i-th sample outside the distribution. The uniform prior indicates that the model maintains unbiased predictions for all categories when there is no supporting evidence.

5. The out-of-distribution detection method based on decoupled evidence deep learning according to claim 4, characterized in that: Step 4 specifically includes the following steps: Step 4.1: Construct the in-distribution classification loss: The in-distribution classification loss is the cross-entropy loss, calculated as follows: in, For the first The true class label of each sample Indicates the first The true class label corresponding to each sample in the distribution. The score, The cross-entropy classification loss is used within the distribution. Step 4.2: Construct the out-of-distribution homogenization constraint loss: Apply the out-of-distribution classification score tensor... Logarithmic softmax operation is performed to obtain , of which The first sample The logarithmic probability of the class is: Construct a uniform target distribution any of the elements ; Calculate the external homogenization constraint loss: ; in, The out-of-distribution homogenization constraint loss is used to make the class probability distribution of out-of-distribution samples tend to be uniform, where Q is the uniform prior target distribution. It is the target probability value of the i-th out-of-distribution sample and the k-th class in Q; Step 4.3: Constructing Evidence-Constrained Loss: Constructing the target concentration parameter within the distribution. This makes the dimension corresponding to the true category take a larger value. The remaining dimensions are set to 1; for the th Samples within a distribution satisfy: in The target evidence strength hyperparameter; Constructing out-of-distribution target concentration parameters Make all dimensions equal to 1: This indicates that out-of-distribution samples should have a uniform Dirichlet distribution, corresponding to high uncertainty. This represents the target Dirichlet concentration parameter of the k-th category dimension for the i-th sample in the batch distribution. This represents the target Dirichlet concentration parameter for the k-th category dimension of the i-th sample in an out-of-distribution batch; Dirichlet distributions were constructed using the predicted concentration parameters and the target concentration parameters, respectively, and the KL divergence loss was calculated. For two Dirichlet distributions and The closed-form solution of its KL divergence is: in, This represents the k-th component of the Dirichlet concentration parameter vector. This represents the k-th component of the Dirichlet distribution of the target. To predict the total concentration parameter of the distribution, The total concentration parameter of the target distribution, , ; For the Gamma function, It is the Digamma function; The in-distribution evidence constraint loss is: The out-of-distribution evidence constraint loss is: Where Dir() represents the Dirichlet distribution, and KL() represents the KL divergence. , These represent KL losses constrained by in-distribution and out-of-distribution evidence, respectively. Let be the Dirichlet distribution concentration parameter vector of the i-th sample. Let be the target Dirichlet distribution concentration parameter vector corresponding to the i-th in-distribution sample. Let be the Dirichlet distribution concentration parameter vector of the i-th out-of-distribution sample. Let be the target Dirichlet distribution concentration parameter vector corresponding to the i-th out-of-distribution sample; Step 4.4, Calculate the total loss and train: The total loss for a single iteration is: in and The weights are hyperparameters; a stochastic gradient descent optimizer is used to update the network parameters, and the learning rate is adjusted using a cosine annealing strategy. The learning rate is set at the [missing value]th [missing value]. The step is calculated as follows: in The initial learning rate, To minimize the learning rate, Total training steps The total loss of the model, Let t be the current learning rate at step t, where t is the current training iteration step.

6. The out-of-distribution detection method based on decoupled evidence deep learning according to claim 5, characterized in that: Step 5 specifically includes the following steps: Step 5.1: The image to be detected Input the trained decoupled evidence network model to obtain the classification score vector. With overall strength of evidence ; Step 5.2: Convert the classification score vector Performing the Softmax operation yields the class probability vector. : Step 5.3: Construct the Dirichlet concentration parameter vector : ;in This represents the probability vector of the k-th class after normalization by the Softmax operation; Step 5.4: Calculate the differential entropy of the Dirichlet distribution as the uncertainty fraction; for the concentration parameter... The closed-form solution of the differential entropy of the Dirichlet distribution is: in The multivariate Beta function is defined as follows: Therefore, the differential entropy can be expanded as: in, For the Digamma function, The differential entropy of the Dirichlet distribution is the uncertainty score of the output; the larger the value, the higher the prediction uncertainty.

7. The out-of-distribution detection method based on decoupled evidence deep learning according to claim 6, characterized in that: Step 6 specifically includes the following steps: Step 6.1: Calculate the uncertainty score. With preset threshold Compare; Step 6.2, if If the image to be detected is determined to be an out-of-distribution sample, a rejection signal is output; otherwise, it is determined to be an in-distribution sample, and a category prediction result is output. The category prediction result is... : or equivalently: ; in, This represents the classification score vector for the k-th category output by the decoupled evidence network model.

8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it causes the processor to perform the steps of the method as described in any one of claims 1 to 7.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the computer program is executed by the processor, it causes the processor to perform the steps of the method as described in any one of claims 1 to 7.