Unsupervised OOD detection method and device for hierarchical semantic reconstruction based on diffusion model
Through a hierarchical semantic reconstruction method based on diffusion model, multi-layer semantic features are extracted and reconstructed, and reconstruction errors are calculated to realize OOD detection, which solves the problem of low detection efficiency in the prior art and significantly improves the calculation efficiency and detection rate .
Patent Information
- Application Number
- CN202411372461.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2044-09-29
AI Technical Summary
The existing unsupervised OOD detection methods take a long time during the detection process, have low computational efficiency, and cannot accurately capture sample distribution.
The hierarchical semantic reconstruction method based on the diffusion model is adopted, and the semantic feature reconstruction is layer by layer through multi-layer semantic feature extraction, normalization and distortion, and the reconstruction error is calculated to determine whether the data is out of distribution data.
The calculation efficiency is significantly improved, effective OOD detection is realized, detection rate is improved, and reconstruction of secondary features that are not related to image understanding is avoided.
Smart Images

Figure CN119399762A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image processing, and in particular relates to an unsupervised OOD detection method and device based on hierarchical semantic reconstruction of a diffusion model. Background Art
[0002] Unsupervised Out-of-Distribution (OOD) detection aims to determine whether a data point belongs to an in-distribution (ID) or out-of-distribution dataset by learning only from unlabeled in-distribution training samples. OOD detection plays a vital role in developing secure real-world machine learning systems, ensuring that the model only operates on data with the same distribution as its training data. If the test data does not conform to the training distribution, the model may produce meaningless predictions, leading to some misleading conclusions. Therefore, OOD detection is one of the key technologies to ensure the robustness and security of the model.
[0003] Existing research mainly studies OOD detection in two settings: supervised and unsupervised methods. Among them, supervised methods are usually based on classification, which usually uses the probability of the maximum activation function (Softmax) output of the final fully connected (FC) layer as a score to judge the ID (In-Distribution) sample; but classification-based OOD detection methods often encounter the problem of assigning the probability of high activation function output to OOD samples. For example, Liu et al. in the document "Hendrycks D, Gimpel K. A baseline for detecting misclassified and out-of-distribution examples in neural networks [J]. arXiv preprint arXiv: 1610.02136, 2016." and Sun et al. in the document "Sun Y, Li Y. Dice: Leveraging sparsification for out-of-distribution detection [C] / / European Conference on Computer Vision. Cham: Springer Nature Switzerland, 2022: 691-708." tried to alleviate this problem. Unsupervised OOD detection can be roughly divided into distance-based metric evaluation methods and generative model-based reconstruction methods. Distance-based methods assume that OOD data is far away from the center of the ID category; Ren et al. in the literature "Ren J, Fort S, Liu J, et al. A simple fix to mahalanobis distance for improving near-ood detection [J]. arXiv preprint arXiv: 2106.09022, 2021." improve OOD detection by separating the image foreground and background and calculating the Mahalanobis distance separately, and then combining them; Techapanurak et al. in "Techapanurak E, Suganuma M, Okatani T. Hyperparameter-free out-of-distribution detection using cosine similarity [C] / / Proceedings of the Asian conference on computer vision. 2020." use cosine similarity to measure the distance between test data features and ID data to identify OOD data. These methods usually cannot accurately capture the sample distribution.In the generative model-based methods, OOD detection uses the idea that the generative network produces different reconstruction errors for ID and OOD data, such as Sakurad et al. in the paper "Sakurada M, Yairi T. Anomaly detection using autoencoders with nonlinear dimensionality reduction [C] / / Proceedings of the MLSDA 2014 2nd workshop on machine learning for sensory data analysis. 2014: 4-11." using autoencoders to analyze the reconstruction error. GAN-based methods, such as Schlegl et al. in the paper "Schlegl T,. P, Waldstein SM, et al. Unsupervised anomaly detection with generative adversarial networks to guide marker discovery [C] / / International conference on information processing in medical imaging. Cham: Springer International Publishing, 2017: 146-157. " used reconstruction error and discriminator to detect anomalies; for example, Graham et al. applied diffusion model to model the pixel-level distribution of the image in the document "Graham MS, Pinaya WH L, Tudosiu PD, et al. Denoising diffusion models for out-of-distribution detection [C] / / Proceedings of the IEEE / CVF Conference on Computer Vision and Pattern Recognition. 2023: 2947-2956. " and used the error of multiple reconstructions for OOD detection.
[0004] The existing research takes a long time and has low computational efficiency in the OOD detection process; therefore, an OOD detection method is provided to improve the above-mentioned defects of the prior art. Summary of the invention
[0005] In order to solve the above problems existing in the prior art, the present invention provides an unsupervised OOD detection method and device based on hierarchical semantic reconstruction of a diffusion model. The technical problem to be solved by the present invention is achieved through the following technical solutions:
[0006] In a first aspect, the present invention provides an unsupervised OOD detection method based on hierarchical semantic reconstruction of a diffusion model, comprising:
[0007] Obtain the data to be tested;
[0008] The data to be detected is processed by a preset processing model to extract multi-layer semantic features of the data to be detected to obtain multi-layer features;
[0009] The multi-layer features are normalized and distorted in sequence, and the distorted multi-layer features are semantically reconstructed layer by layer to obtain multi-layer reconstructed features;
[0010] The reconstruction error between the multi-layer reconstructed features and the normalized multi-layer feature vector is obtained. If the reconstruction error meets the preset conditions, it is determined that the data to be detected is out-of-distribution data.
[0011] In a second aspect, the present invention further provides an unsupervised OOD detection device based on hierarchical semantic reconstruction of a diffusion model, comprising:
[0012] A data acquisition module, used for acquiring data to be detected;
[0013] The data processing module 1 is used to process the data to be detected by using a preset processing model, so as to extract multi-layer semantic features of the data to be detected and obtain multi-layer features;
[0014] The data processing module 2 is used to normalize and distort the multi-layer features in sequence, and reconstruct the semantic features of the distorted multi-layer features layer by layer to obtain multi-layer reconstructed features;
[0015] The data judgment module is used to obtain the reconstruction error between the multi-layer reconstructed features and the normalized multi-layer feature vector. If the reconstruction error meets the preset conditions, it is determined that the data to be detected is out-of-distribution data.
[0016] Beneficial effects of the present invention:
[0017] The present invention provides an unsupervised OOD detection method and device based on hierarchical semantic reconstruction of a diffusion model. By extracting multiple layers of features and reconstructing the multiple layers of features, feature reconstruction on multiple layers of semantic features encourages the potential features in the domain to be more tightly distributed in a specific space so as to better reconstruct the features. At the same time, OOD samples are not reconstructed, which can significantly improve computational efficiency and achieve effective OOD detection, and can also improve the detection rate. In addition, the reconstruction of secondary features that are not related to image understanding is avoided.
[0018] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a flow chart of an unsupervised OOD detection method based on hierarchical semantic reconstruction of a diffusion model provided by an embodiment of the present invention;
[0020] Figure 2 is a schematic diagram of a processing model provided by an embodiment of the present invention;
[0021] Figure 3 It is a schematic diagram of a residual block provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0022] The present invention is further described in detail below with reference to specific embodiments, but the embodiments of the present invention are not limited thereto.
[0023] See also Figure 1 , Figure 1 It is a flow chart of an unsupervised OOD detection method based on hierarchical semantic reconstruction of a diffusion model provided by an embodiment of the present invention. The unsupervised OOD detection method based on hierarchical semantic reconstruction of a diffusion model provided by the present invention comprises:
[0024] S101, obtaining data to be detected.
[0025] Specifically, in this embodiment, the data to be detected may be an image.
[0026] S102: Process the data to be detected by using a preset processing model to extract multi-layer semantic features from the data to be detected to obtain multi-layer features.
[0027] S103, normalizing and distorting the multi-layer features in sequence, and reconstructing the semantic features of the distorted multi-layer features layer by layer to obtain multi-layer reconstructed features.
[0028] Specifically, see Figure 2 and Figure 3 , Figure 2 is a schematic diagram of a processing model provided by an embodiment of the present invention, Figure 3 is a schematic diagram of a residual block provided in an embodiment of the present invention. In this embodiment, before the data to be detected is processed by a preset processing model, the following is also included:
[0029] Building a processing model;
[0030] By training the initial processing model and setting the parameters of the processing model, a preset processing model is obtained;
[0031] Among them, the processing model includes an encoder, a normalization layer and a latent feature diffusion network. The input end of the encoder receives the data to be detected and is used to extract the multi-layer features of the data to be detected. The input end of the normalization layer is connected to the output end of the encoder and is used to normalize the multi-layer features to obtain a multi-layer feature vector. A Gaussian noise vector is added to each layer of feature vectors in the multi-layer feature vector to obtain a multi-layer low-dimensional feature vector. The input end of the latent feature diffusion network receives the multi-layer low-dimensional feature vector and the embedding time step, and is used to process the multi-layer low-dimensional feature vector and the embedding time step to obtain a multi-layer initial reconstruction feature. The multi-layer initial reconstruction feature is sampled to obtain a multi-layer reconstruction feature.
[0032] In this embodiment, given an image x∈R 3×w×h , w and h are the width and height of the image to be processed, respectively. Through the encoder processing, the feature map of the image to be processed is extracted from different layers, from low-level to high-level semantic blocks. Optionally, the encoder can be Resnet50 to obtain M-layer feature F m , the feature representation of the mth layer is m∈{1,…,M}, where c m 、w m and h m Represents the number, width and height of channels; multi-layer features F m The features in are globally averaged and pooled to obtain a one-dimensional feature vector Z-score normalization, applied to each eigenvector The normalized feature vector is expressed as:
[0033]
[0034] Among them, Var(f m ) indicates f m The variance along the channel elements, δ represents a very small constant, and finally a multi-layer feature vector is obtained, which is expressed as:
[0035]
[0036] Among them, H(x) represents the entire feature extraction process.
[0037] In this embodiment, the semantic feature distortion process can be defined as converting the semantic features into distorted correspondences with different noise levels. For each layer of embedding time step t belonging to [1,…,T], the expression of the multi-layer low-dimensional feature vector is:
[0038]
[0039] Among them, z 0 represents the multi-layer feature vector, t represents the embedding time step, represents a predefined noise level, which is used to control the amount of Gaussian noise added to each layer of low-dimensional feature vector, ε represents the Gaussian noise vector, represents Gaussian distribution, 0 c represents a c-dimensional 0-dimensional zero vector, I c×c represents the c×c identity matrix.
[0040] In this embodiment, in order to reconstruct semantic features from distorted semantic features, a latent feature diffusion network (LFDN) consisting of 16 residual blocks is constructed.
[0041] The latent feature diffusion network includes a plurality of residual blocks, each of which includes a first unit, a second unit and a third unit; wherein the first unit and the second unit have the same structure, both including a group normalization layer, a SiLU function and a linear layer connected in sequence, and the third unit includes a linear layer, a SiLU function and a linear layer connected in sequence;
[0042] The input end of the latent feature diffusion network receives multiple layers of low-dimensional feature vectors and embedding time steps, and processes the multiple layers of low-dimensional feature vectors and embedding time steps to obtain multiple layers of initial reconstruction features, including:
[0043] Different residual blocks process low-dimensional feature vectors of different layers;
[0044] The first unit processes the low-dimensional feature vector to obtain a first feature, the third unit processes the embedding time step to obtain a second feature, the first feature and the second feature are concatenated, the concatenated feature is input into the second unit for processing to obtain a third feature, the third feature is concatenated with the low-dimensional feature vector to obtain an initial reconstructed feature corresponding to the low-dimensional feature vector;
[0045] According to the calculation process of the denoising diffusion implicit model, LFDN is used to remove the noise injected into the semantic features, and the skip step is denoted as s, z t The detailed denoising process of is described as follows, where s is set to a value randomly selected from {1,…,t}. After all residual blocks are processed, the multi-layer initial reconstruction features are obtained, which are expressed as:
[0046]
[0047] in, represents the multi-layer initial reconstruction features, LFDN(·) represents the feed-forward process of the latent feature diffusion network, z t represents a multi-layer low-dimensional feature vector, and t represents the embedding time step.
[0048] It should be noted that the time step embedding specific to the latent feature diffusion model refers to the embedding of time into multi-scale features through an MLP.
[0049] In this embodiment, the initial reconstruction features are sampled to obtain multi-layer reconstruction features, including:
[0050] By multi-layer low-dimensional feature vector z t The noise correction vector is estimated, and its estimated value It is expressed as:
[0051]
[0052] in, represents a predefined noise level;
[0053] According to the estimated value Initial reconstruction features for multiple layers Sampling is performed, and the characteristics after sampling It is expressed as:
[0054]
[0055] in, represents the variance of the additive noise, represents the predefined noise level corresponding to the embedding time step t', t' = max(ts,0);
[0056] The features after sampling The corresponding embedded time step t' is input into the potential feature diffusion network for processing, and the reconstruction feature of the t'th time step is predicted, which is expressed as:
[0057]
[0058] From t'=t to t'=0, we get multi-layer reconstruction features, which are expressed as:
[0059]
[0060] Here, denoise(·) means denoising.
[0061] It is understandable that the latent feature diffusion network is used to reconstruct the features to ensure It is not derived from LFDN output alone, but is continuously improved by DDIM, integrating detailed corrections to achieve high accuracy in reconstructing the original data from noisy observations.
[0062] In an optional embodiment of the present invention, the preset processing model is obtained by training the initial processing model and setting the parameters of the processing model, including:
[0063] Get training samples;
[0064] The training samples are input into the initial processing model for iterative training. Within the preset number of iterations, the loss function value reaches the minimum, the parameters of the processing model are determined, and the preset processing model is obtained.
[0065] In this embodiment, in order to optimize the network parameters of LFDN, the mean square error is used as the loss function to bring the output of LFDN closer to the original semantic features. The expression of the loss function L is:
[0066]
[0067] Where N is the total number of training samples, x is the data input to the processing model, Represents the three-dimensional features of the data input to the processing model, z 0 represents the multi-layer feature vector, LFDN(·) represents the feed-forward process of the latent feature diffusion network, z t represents a multi-layer low-dimensional feature vector, and t represents the embedding time step.
[0068] During the iterative training process, t is randomly selected from {1,…,T}.
[0069] S104, obtaining a reconstruction error between the multi-layer reconstructed features and the normalized multi-layer feature vector, and if the reconstruction error meets a preset condition, determining that the data to be detected is out-of-distribution data.
[0070] Specifically, in this embodiment, obtaining the reconstruction error between the multi-layer reconstructed features and the normalized multi-layer feature vector includes:
[0071] The reconstruction error between multi-layer reconstructed features and multi-layer feature vectors is measured by mean square error (MSE);
[0072] Alternatively, the reconstruction error between the multi-layer reconstructed features and the multi-layer feature vector is measured by likelihood regret; where likelihood regret LR = MSE initial -MSE final , quantifies the change in mean square error from the initial iterative training to the final iterative training; reflects the evolving certainty of the model during training, as the model becomes more familiar with the ID samples, the reconstruction error of the ID samples decreases, while the reconstruction error of the OOD samples remains relatively stable;
[0073] Alternatively, the reconstruction error between the multi-layer reconstructed features and the multi-layer feature vectors is measured by multi-layer semantic similarity.
[0074] In this embodiment, the reconstruction error between the multi-layer reconstructed features and the multi-layer feature vectors is measured by multi-layer semantic similarity, including:
[0075] Calculate the cosine similarity between multi-layer reconstruction features and multi-layer features, and its expression is:
[0076]
[0077] in, represents the feature vector, Represents reconstruction features;
[0078] According to the cosine similarity, the reconstruction error is calculated, and its expression is:
[0079]
[0080] Where M represents the number of feature maps.
[0081] It can be understood that the lower the MFsim score, the more likely the detected data is in-distribution data.
[0082] In summary, the present invention provides an unsupervised OOD detection method based on hierarchical semantic reconstruction of a diffusion model, which introduces a diffusion model to reconstruct multi-scale features, which not only utilizes the stable reconstruction ability of the diffusion model but also establishes a comprehensive and discriminative feature representation. By designing a multi-layer semantic feature extraction strategy, feature reconstruction on multi-layer semantic features encourages the latent features in the domain to be more tightly distributed in a specific space, so as to better reconstruct ID samples while not reconstructing OOD samples. In general, by distorting the extracted multi-layer features with Gaussian noise and applying the diffusion model for feature reconstruction, the separation of ID and OOD samples is achieved according to the reconstruction error. It should be noted that the proposed latent feature diffusion network (LFDN) is built on the feature level instead of the traditional pixel level, which can significantly improve the computational efficiency and achieve effective OOD detection; in addition, the reconstruction of secondary features that are not related to image understanding is avoided.
[0083] In an optional embodiment of the present invention, the effect of the unsupervised OOD detection method based on hierarchical semantic reconstruction of the diffusion model provided in the above embodiment is verified by simulation experiments, specifically:
[0084] 1. Simulation conditions
[0085] The simulation experimental conditions of this embodiment include a central processing unit of Inter(R)Core(TM)i7-11700CPU, an NVIDIA RTX 4090GPU, and an Ubuntu 20.04 operating system, and simulation is performed using Facebook's open source pytorch1.8.
[0086] 2. Simulation content and result analysis
[0087] In Table 1, CIFAR-10 is used as the ID dataset to compare the proposed method with pixel-level generative model methods, including GLOW and PixelCNN++. In order to verify the effectiveness of LFDN, a variant of the proposed method is implemented by replacing LFDN with AutoEncoder and using MFsim to estimate the OOD score.
[0088] Compared to the best pixel-level method VAE, the proposed method improves the average AUROC by 9.1% when using MFsim for OOD score estimation. Compared to DDPM, the proposed method variants show significant improvement in average AUROC. For example, when combined with MSE, the proposed method is 20.4% higher than DDPM in AUROC.
[0089] This indirectly shows that performing OOD detection at the pixel level is far inferior to performing OOD detection at the feature level. Generating pixels may reconstruct more content that is irrelevant to the image semantics, which may interfere with the identification of OOD samples. Making the model focus on the reconstruction of compactly distributed semantic features helps to distinguish between ID and OOD samples.
[0090] In terms of test speed, the proposed method is nearly 100 times faster than DDPM, greatly improving performance and reducing detection costs. In addition, the final version of the proposed method is based on LFDN, and the average AUROC is improved by 18.5% compared to the variant based on AutoEncoder, because the diffusion model captures the data distribution more effectively.
[0091] In Table 2, the proposed method is compared with VAE, DDPM and AutoEncoder, using CelebA as the ID dataset. The proposed method combined with MFsim achieves state-of-the-art performance, with an AUROC improvement of 19.89% compared to DDPM, and the performance of the other two indicators also far exceeds the baseline, demonstrating the general applicability of the proposed method.
[0092] Table 1 AUROC for OOD detection when CIFAR10 is the ID dataset compared with generation-based methods
[0093]
[0094] Table 2 AUROC for OOD detection when CelebA is the ID dataset compared with generation-based methods
[0095]
[0096] Similarly, when CelebA is used as the distribution, the method proposed in the present invention still has significant advantages.
[0097] Based on the same inventive concept, the present invention also provides an unsupervised OOD detection device based on hierarchical semantic reconstruction of a diffusion model, which is used to implement an unsupervised OOD detection method based on hierarchical semantic reconstruction of a diffusion model provided in the above embodiment of the present invention. The embodiment of the method is referred to above and will not be repeated here; the device comprises:
[0098] A data acquisition module, used for acquiring data to be detected;
[0099] The data processing module 1 is used to process the data to be detected by using a preset processing model, so as to extract multi-layer semantic features of the data to be detected and obtain multi-layer features;
[0100] The data processing module 2 is used to normalize and distort the multi-layer features in sequence, and reconstruct the semantic features of the distorted multi-layer features layer by layer to obtain multi-layer reconstructed features;
[0101] The data judgment module is used to obtain the reconstruction error between the multi-layer reconstructed features and the normalized multi-layer feature vector. If the reconstruction error meets the preset conditions, the detection data is determined to be out-of-distribution data.
[0102] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the term "include", "comprise" or any other variant is intended to cover non-exclusive inclusion, so that the article or device including a series of elements includes not only those elements, but also other elements that are not explicitly listed. In the absence of more restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the article or device including the elements. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. The orientation or position relationship indicated by "up", "down", "left", "right", etc. is based on the orientation or position relationship shown in the accompanying drawings, which is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present invention.
[0103] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification.
[0104] The above contents are further detailed descriptions of the present invention in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. For ordinary technicians in the technical field to which the present invention belongs, several simple deductions or substitutions can be made without departing from the concept of the present invention, which should be regarded as falling within the protection scope of the present invention.
Claims
1. An unsupervised OOD detection method based on hierarchical semantic reconstruction of diffusion model, characterized in that: include: Obtain the data to be tested; The data to be detected is processed by a preset processing model to extract multi-layer semantic features from the data to be detected to obtain multi-layer features; The multi-layer features are normalized and distorted in sequence, and semantic features are reconstructed layer by layer on the distorted multi-layer features to obtain multi-layer reconstructed features; A reconstruction error between the multi-layer reconstructed features and the normalized multi-layer feature vector is obtained, and if the reconstruction error meets a preset condition, it is determined that the data to be detected is out-of-distribution data.
2. The unsupervised OOD detection method based on hierarchical semantic reconstruction of a diffusion model according to claim 1 is characterized in that: Before the data to be detected is processed by a preset processing model, the method further includes: Building a processing model; By training the initial processing model and setting the parameters of the processing model, the preset processing model is obtained; Among them, the processing model includes an encoder, a normalization layer and a latent feature diffusion network, the input end of the encoder receives the data to be detected and is used to extract multi-layer features of the data to be detected, the input end of the normalization layer is connected to the output end of the encoder and is used to normalize the multi-layer features to obtain multi-layer feature vectors, add a Gaussian noise vector to each layer of feature vectors in the multi-layer feature vectors to obtain multi-layer low-dimensional feature vectors, the input end of the latent feature diffusion network receives the multi-layer low-dimensional feature vectors and the embedding time step, and is used to process the multi-layer low-dimensional feature vectors and the embedding time step to obtain multi-layer initial reconstruction features, and sample the multi-layer initial reconstruction features to obtain multi-layer reconstruction features.
3. The unsupervised OOD detection method based on hierarchical semantic reconstruction of diffusion model according to claim 2 is characterized in that: The expression of the multi-layer low-dimensional feature vector is: Among them, z0 represents the multi-layer feature vector, t represents the embedding time step, represents a predefined noise level, which is used to control the amount of Gaussian noise added to the low-dimensional feature vector of each layer, ε represents a Gaussian noise vector, represents Gaussian distribution, 0 c represents a c-dimensional 0-dimensional zero vector, I c×c represents the c×c identity matrix.
4. The unsupervised OOD detection method based on hierarchical semantic reconstruction of diffusion model according to claim 2 is characterized in that: The latent feature diffusion network includes a plurality of residual blocks, each of which includes a first unit, a second unit and a third unit; wherein the first unit and the second unit have the same structure, both including a group normalization layer, a SiLU function and a linear layer connected in sequence, and the third unit includes a linear layer, a SiLU function and a linear layer connected in sequence; The input end of the potential feature diffusion network receives the multi-layer low-dimensional feature vector and the embedding time step, and is used to process the multi-layer low-dimensional feature vector and the embedding time step to obtain a multi-layer initial reconstruction feature, including: Different residual blocks process low-dimensional feature vectors of different layers; The first unit processes the low-dimensional feature vector to obtain a first feature, the third unit processes the embedding time step to obtain a second feature, the first feature and the second feature are spliced, the spliced feature is input into the second unit for processing to obtain a third feature, and the third feature is spliced with the low-dimensional feature vector to obtain an initial reconstructed feature corresponding to the low-dimensional feature vector; After all the residual blocks are processed, a multi-layer initial reconstruction feature is obtained, which is expressed as: in, represents the multi-layer initial reconstruction features, LFDN(·) represents the feed-forward process of the latent feature diffusion network, z t represents a multi-layer low-dimensional feature vector, and t represents the embedding time step.
5. The unsupervised OOD detection method based on hierarchical semantic reconstruction of diffusion model according to claim 3 is characterized in that: The sampling of the initial reconstruction features to obtain multi-layer reconstruction features includes: By t The noise correction vector is estimated, and its estimated value It is expressed as: in, represents a predefined noise level; According to the estimated value Initial reconstruction features for multiple layers Sampling is performed, and the characteristics after sampling It is expressed as: in, represents the variance of the additive noise, represents the predefined noise level corresponding to the embedding time step t', t' = max(ts,0); The features after sampling The corresponding time step t' is input into the potential feature diffusion network for processing, and the reconstruction feature of the t'th time step is predicted, and its expression is: From t'=t to t'=0, we get multi-layer reconstruction features, which are expressed as: Here, denoise(·) means denoising.
6. The unsupervised OOD detection method based on hierarchical semantic reconstruction of diffusion model according to claim 2 is characterized in that: The method of training the initial processing model and setting the parameters of the processing model to obtain the preset processing model includes: Get training samples; The training samples are input into the initial processing model for iterative training. Within a preset number of iterations, the loss function value reaches a minimum, the parameters of the processing model are determined, and a preset processing model is obtained.
7. The unsupervised OOD detection method based on hierarchical semantic reconstruction of diffusion model according to claim 6 is characterized in that: The expression of the loss function L is: Where N is the total number of training samples, x is the data input to the processing model, represents the three-dimensional features of the data input to the processing model, z0 represents the multi-layer feature vector, LFDN(·) represents the feedforward process of the latent feature diffusion network, z t represents a multi-layer low-dimensional feature vector, and t represents the embedding time step.
8. The unsupervised OOD detection method based on hierarchical semantic reconstruction of diffusion model according to claim 1 is characterized in that: The obtaining of the reconstruction error between the multi-layer reconstruction feature and the normalized multi-layer feature vector includes: Measuring the reconstruction error between the multi-layer reconstruction features and the multi-layer feature vector by a mean square error; Alternatively, a reconstruction error between the multi-layer reconstructed features and the multi-layer feature vector is measured by likelihood regret; Alternatively, the reconstruction error between the multi-layer reconstructed features and the multi-layer feature vectors is measured by multi-layer semantic similarity.
9. The unsupervised OOD detection method based on hierarchical semantic reconstruction of diffusion model according to claim 8 is characterized in that: The measuring the reconstruction error between the multi-layer reconstructed features and the multi-layer feature vectors by multi-layer semantic similarity includes: The cosine similarity between the multi-layer reconstruction feature and the multi-layer feature is calculated, and the expression is: in, represents the feature vector, Represents reconstruction features; According to the cosine similarity, the reconstruction error is calculated, and its expression is: Where M represents the number of feature maps.
10. An unsupervised OOD detection device based on hierarchical semantic reconstruction of a diffusion model, characterized in that: include: A data acquisition module, used for acquiring data to be detected; The data processing module 1 is used to process the data to be detected by using a preset processing model to extract multi-layer semantic features from the data to be detected to obtain multi-layer features; The second data processing module is used to normalize and distort the multi-layer features in sequence, and reconstruct the distorted multi-layer features into semantic features layer by layer to obtain multi-layer reconstructed features; The data judgment module is used to obtain the reconstruction error between the multi-layer reconstructed features and the normalized multi-layer feature vector. If the reconstruction error meets a preset condition, it is determined that the data to be detected is out-of-distribution data.
Citation Information
Patent Citations
Uplink interference identification method, device and system
CN111683390A
Out-of-distribution data detection method and device, server and storage medium
CN112966819A
Face forgery detection method based on reconstruction error distribution
CN116206347A
Radiation source signal open set identification method based on diffusion model
CN116522242A
Binocular image generation method and system based on potential diffusion model
CN117523024A