[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN114707600A - Anomaly detection method and system based on generative model - Google Patents

Anomaly detection method and system based on generative model Download PDF

Info

Publication number
CN114707600A
CN114707600A CN202210339922.XA CN202210339922A CN114707600A CN 114707600 A CN114707600 A CN 114707600A CN 202210339922 A CN202210339922 A CN 202210339922A CN 114707600 A CN114707600 A CN 114707600A
Authority
CN
China
Prior art keywords
generator
low
dimensional feature
encoder
loss
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210339922.XA
Other languages
Chinese (zh)
Inventor
齐飞
司马攀科
李天翔
陶倩
石光明
梅辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xidian University
Original Assignee
Xidian University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xidian University filed Critical Xidian University
Priority to CN202210339922.XA priority Critical patent/CN114707600A/en
Publication of CN114707600A publication Critical patent/CN114707600A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/213Feature extraction, e.g. by transforming the feature space; Summarisation; Mappings, e.g. subspace methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Artificial Intelligence (AREA)
  • General Physics & Mathematics (AREA)
  • Evolutionary Computation (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Evolutionary Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Image Analysis (AREA)

Abstract

The invention discloses an anomaly detection method and system based on a generative model, which are used for obtaining a first sample data set; a generator is constructed, the first sample data set is input into the generator, low-dimensional feature extraction of the first sample data set is carried out through a first encoder, low-dimensional feature vector constraint of a first low-dimensional feature extraction result is carried out through a second encoder, the constrained first low-dimensional feature extraction result is decoded through a decoder, authenticity judgment of a first reconstructed sample set is carried out through a discriminator, and first data to be detected are obtained; and inputting the first data to be detected into the generator to obtain first reconstruction data, and performing anomaly detection judgment according to the residual error value of the first data to be detected and the first reconstruction data. The technical problems that in the prior art, the requirement for samples is large, the quantity of sample data with defects is small, and the labeling is time-consuming and labor-consuming in the process of carrying out abnormity detection, so that the abnormity detection cost is high and the detection effect is poor are solved.

Description

Anomaly detection method and system based on generative model
Technical Field
The invention relates to the field of anomaly detection, in particular to an anomaly detection method and system based on a generative model.
Background
With the rapid development of science and technology, the production and manufacturing processes of products are continuously improved and improved, and higher requirements are also made on the quality of the products. Unqualified products can bring great influence to reputation and benefit of enterprises and the security of the lives and properties of users, so that accurate detection on product quality is of great importance.
In the current process of anomaly detection, a target detection method based on supervised learning is generally adopted to achieve better performance, but the target detection method based on supervised learning has higher requirement on data, and in an actual industrial production scene, because the number of defects is small, the defect acquisition and defect labeling are time-consuming and labor-consuming, and the problem of imbalance of types of defect samples and normal samples also exists. Due to data problems, the target detection method based on supervised learning has a lot of difficulties in solving the defect detection task.
However, in the process of implementing the technical scheme of the invention in the application, the technology at least has the following technical problems:
in the prior art, in the process of anomaly detection, the requirement for samples is large, the quantity of sample data with defects is small, and the labeling is time-consuming and labor-consuming, so that the technical problems of high anomaly detection cost and poor detection effect are caused.
Disclosure of Invention
The abnormity detection method and system based on the generated model solve the technical problems that in the abnormity detection process in the prior art, the requirement for samples is large, the sample data volume of defects is small, labeling is time-consuming and labor-consuming, the abnormity detection cost is high, and the detection effect is poor, the requirement for the sample data volume is reduced, the class imbalance is relieved, and the technical effect of improving the abnormity detection accuracy while the time and the labor cost are controlled is achieved.
In view of the above problems, the present application provides a method and a system for detecting an anomaly based on a generative model.
In a first aspect, the present application provides a method for anomaly detection based on a generative model, the method comprising: obtaining a first sample data set; constructing a generator, wherein the generator comprises a first encoder and a decoder; inputting the first sample data set into the generator, and performing low-dimensional feature extraction on the first sample data set through the first encoder to obtain a first low-dimensional feature extraction result; performing low-dimensional feature vector constraint on the first low-dimensional feature extraction result through a second encoder, and decoding the constrained first low-dimensional feature extraction result through the decoder to obtain a first reconstruction sample set; judging the authenticity of the first reconstruction sample set through a discriminator to obtain a first judgment result; when the output result of the first judgment result meets a first preset threshold value, first data to be detected is obtained; and inputting the first data to be detected into the generator to obtain first reconstruction data, and performing anomaly detection judgment according to the residual error value of the first data to be detected and the first reconstruction data.
In another aspect, the present application further provides a system for anomaly detection based on generative models, the system comprising: a first obtaining unit configured to obtain a first sample data set; a first construction unit for constructing a generator, wherein the generator comprises a first encoder and a decoder; a second obtaining unit, configured to input the first sample data set into the generator, and perform low-dimensional feature extraction on the first sample data set through the first encoder to obtain a first low-dimensional feature extraction result; a third obtaining unit, configured to perform low-dimensional feature vector constraint on the first low-dimensional feature extraction result through a second encoder, and decode the constrained first low-dimensional feature extraction result through the decoder to obtain a first reconstructed sample set; the first judging unit is used for judging the authenticity of the first reconstruction sample set through a discriminator to obtain a first judging result; a fourth obtaining unit, configured to obtain first data to be detected when an output result of the first determination result satisfies a first preset threshold; and the first detection unit is used for inputting the first data to be detected into the generator to obtain first reconstruction data, and performing abnormity detection judgment according to a residual error value of the first data to be detected and the first reconstruction data.
In a third aspect, the present invention provides an electronic device, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the method according to any one of the first aspect when executing the program.
One or more technical solutions provided in the present application have at least the following technical effects or advantages:
obtaining a first sample data set is adopted; inputting the first sample data set into a generator, performing low-dimensional feature extraction on the first sample data set through a first encoder in the generator, performing low-dimensional feature extraction result vector constraint through a second encoder, and decoding the constrained first low-dimensional feature extraction result through a decoder to obtain a first reconstructed sample set; judging the authenticity of the first reconstruction sample set through a discriminator to obtain a first judgment result; and when the output result of the generated model is stable, inputting the first to-be-detected data into the generator to obtain first reconstructed data, and performing anomaly detection judgment according to the residual error value of the first to-be-detected data and the first reconstructed data. The method and the device achieve the technical effects of reducing the requirement on the sample data size, relieving the problem of category imbalance and improving the accuracy of anomaly detection while controlling time and labor cost.
The foregoing description is only an overview of the technical solutions of the present application, and the present application can be implemented according to the content of the description in order to make the technical means of the present application more clearly understood, and the following detailed description of the present application is given in order to make the above and other objects, features, and advantages of the present application more clearly understandable.
Drawings
FIG. 1 is a schematic flow chart of an anomaly detection method based on a generative model according to the present application;
FIG. 2 is a schematic diagram of a first encoder of the anomaly detection method based on generative model according to the present application;
FIG. 3 is a schematic diagram of a decoder of an anomaly detection method based on generative models according to the present application;
FIG. 4 is a schematic diagram of an arbiter for a generative model-based anomaly detection method according to the present application;
FIG. 5 is a schematic diagram of a structure of a generative model-based anomaly detection system according to the present application;
fig. 6 is a schematic structural diagram of an electronic device according to the present application.
Description of the reference numerals: a first obtaining unit 11, a first constructing unit 12, a second obtaining unit 13, a third obtaining unit 14, a first judging unit 15, a fourth obtaining unit 16, a first detecting unit 17, an electronic device 50, a processor 51, a memory 52, an input device 53 and an output device 54.
Detailed Description
The anomaly detection method and system based on the generated model solve the technical problems that in the anomaly detection process of the prior art, the requirement for samples is large, the sample data size of defects is small, time and labor are wasted in labeling, the anomaly detection cost is high, and the detection effect is poor, the requirement for the sample data size is reduced, the problem of category imbalance is relieved, and the technical effect of improving the anomaly detection accuracy while the time and the labor cost are controlled is achieved. Embodiments of the present application are described below with reference to the accompanying drawings. As can be appreciated by those skilled in the art, with the development of technology and the emergence of new scenarios, the technical solutions provided in the present application are also applicable to similar technical problems.
The terms "first," "second," and the like in the description and in the claims of the present application and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the terms so used are interchangeable under appropriate circumstances and are merely descriptive of the various embodiments of the application and how objects of the same nature can be distinguished. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of elements is not necessarily limited to those elements, but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
Summary of the application
Currently, the mainstream technology in the intelligent defect detection in the industrial field is a supervised learning-based method, such as fast-RCNN and MSCNN, but the supervised learning-based method has great requirements on data volume, and is very time-consuming and labor-consuming in acquiring data and labeling data, and is not suitable for large-scale application; reconstructing image blur based on a generation method of an autoencoder AE and its variants; anomaly detection algorithms based on generation of antagonistic networks GAN, such as AnoGA N, GANomaly, ALAD, etc., although these methods have low data requirements, these methods are slow and have low recognition rates. Therefore, an anomaly detection method with less data requirement, high detection speed and high identification rate is urgently needed. In the prior art, in the process of anomaly detection, the requirement for samples is large, the quantity of sample data with defects is small, and the labeling is time-consuming and labor-consuming, so that the technical problems of high anomaly detection cost and poor detection effect are caused.
In view of the above technical problems, the technical solution provided by the present application has the following general idea:
the application provides an anomaly detection method based on a generative model, which comprises the steps of obtaining a first sample data set; inputting the first sample data set into a generator, performing low-dimensional feature extraction on the first sample data set through a first encoder in the generator, performing low-dimensional feature extraction result vector constraint through a second encoder, and decoding the constrained first low-dimensional feature extraction result through a decoder to obtain a first reconstructed sample set; judging the authenticity of the first reconstruction sample set through a discriminator to obtain a first judgment result; and when the output result of the generated model is stable, inputting the first to-be-detected data into the generator to obtain first reconstructed data, and performing anomaly detection judgment according to the residual error value of the first to-be-detected data and the first reconstructed data.
Having thus described the general principles of the present application, various non-limiting embodiments thereof will now be described in detail with reference to the accompanying drawings.
Example one
As shown in fig. 1, the present application provides a method for anomaly detection based on a generative model, the method comprising:
step S100: obtaining a first sample data set;
step S200: constructing a generator, wherein the generator comprises a first encoder and a decoder;
specifically, the first sample data set is a set of real sample data, all sample data in the first sample data set are normal samples, and the first sample data set is a picture data set. The generator is a model for reconstructing pictures and comprises a first encoder and a decoder, wherein a feature extractor of the first encoder is a Residual Network ResNet (ResNet) which has stronger feature extraction capability, a first layer and a second layer of the first encoder are respectively provided with only one convolution layer and a LeakyReLU function, and through the construction of the generator, based on the reconstruction processing of the constructed generator on sample data, data support is provided for accurate abnormal detection in the follow-up process.
Step S300: inputting the first sample data set into the generator, and performing low-dimensional feature extraction on the first sample data set through the first encoder to obtain a first low-dimensional feature extraction result;
step S400: performing low-dimensional feature vector constraint on the first low-dimensional feature extraction result through a second encoder, and decoding the constrained first low-dimensional feature extraction result through the decoder to obtain a first reconstruction sample set;
furthermore, the first encoder is composed of a residual error network, each layer of the first two-layer structure of the first encoder only comprises a convolutional layer and a LeakyReLU function, and the network structures and parameters of the second encoder and the first encoder are consistent.
Specifically, the architecture of the first encoder is as shown in fig. 2 and is composed of a residual error network, each layer of the first two-layer structure of the first encoder only includes one convolution layer and a leak relu function, and is followed by 5 residual error blocks, after the first sample data set (image samples) is input into the generator, the first encoder in the generator performs image processing, firstly, after the processing, the result is a feature map with a size of 4 × 4 after the 5 residual error blocks, and then the feature map with the size of 4 × 4 is subjected to convolution with a convolution kernel size of 4 and the leak relu function to obtain a low-dimensional feature vector with a size of 1 × 1. In order to force the reconstructed sample to be close to the low-dimensional characteristics of the real sample, the second encoder is added, and the network structure and parameters of the second encoder and the first encoder are completely consistent with those of the first encoder. And carrying out low-dimensional feature vector constraint on the first low-dimensional feature extraction result through the second encoder, and inputting the constrained result into the decoder for decoding to obtain the first reconstruction sample set.
Further, as shown in fig. 3, the decoder is structured as a Skip generator. The low-dimensional feature vector of the feature map can be constrained by adding the second encoder, so that the consistency of the low-dimensional features of the reconstructed image and the sample image is improved, a high-quality image is generated, and the structural design of the decoder can avoid simple learning of the network model to the identity mapping from the image space to the feature space; when the decoder generates a higher-resolution image, the low latitude information of the image can be better combined to be matched with the low-dimensional features, a reconstructed image with higher quality is obtained, and data support is provided for subsequent accurate model training and anomaly detection.
Step S500: judging the authenticity of the first reconstruction sample set through a discriminator to obtain a first judgment result;
furthermore, each layer of the first two-layer structure of the discriminator only comprises a convolution layer and a LeakyReL U function, and then 5 DeBlock blocks are connected.
Step S600: when the output result of the first judgment result meets a first preset threshold value, first data to be detected is obtained;
step S700: and inputting the first data to be detected into the generator to obtain first reconstruction data, and performing anomaly detection judgment according to the residual error value of the first data to be detected and the first reconstruction data.
Specifically, the discriminator is a model for performing sample true probability judgment, and the structure of the discriminator is shown in fig. 4, the first two layers of the discriminator are also convolution and activation functions, and then 5 DeBlock blocks, namely, the convolution layer Conv, the batch standard normalized BN and the activation function, are connected, when the size of the feature map is 4 × 4, the convolution and activation function with the convolution kernel size of 4 is directly adopted, and finally, the result is output through a full connection layer. The final output of the discriminator is a scalar used to evaluate the probability that the input image belongs to a real sample. The first preset threshold is a preset threshold for determining whether the result is stable by the determiner, and in essence, the first preset threshold is a threshold for evaluating whether the result of reconstructing the image by the generator is stable. When the output result of the first judgment result meets the first preset threshold value, the characteristic distribution rule of normal data mastered by the generator is represented, and the generator can execute an abnormal detection task.
Further, data in an anomaly detection task, namely the first data to be detected, is input into the generator, and first reconstruction data is obtained through the generator. After the generator grasps the characteristic distribution rule of normal data. When the input is an abnormal sample, the generator forces the input abnormal sample to approach the characteristics of the normal sample, and finally, the residual value of the input sample and the reconstructed sample is used for determining that the abnormal detection is finished. The method and the device achieve the technical effects of reducing the requirement on the sample data size, relieving the problem of category imbalance and improving the accuracy of anomaly detection while controlling time and labor cost.
Further, the present application also includes:
and calculating the reconstruction loss of the generator according to the following calculation formula:
Lrecon=‖x,GDe(Gen(x))‖1
wherein L isreconTo reconstruct the loss, GDeTo a decoder, GenFor the first encoder, an optimal compensation of the generator is performed based on the calculated reconstruction loss.
Specifically, in order to improve the accuracy of the generator in continuously optimizing the reconstructed image, the reconstruction loss function of the generator is constructed for optimization compensation. The formula is defined as follows:
Lrecon=‖x,GDe(Gen(x))‖1
wherein L isreconTo reconstruct the loss, GDeIs a decoder, GenAnd for the first encoder, performing optimization compensation on the generator according to the reconstruction loss obtained by calculation. The reconstruction Loss in the application adopts a calculation mode of L1 Loss instead of Mean Squared Error (MSE), the L1 Loss can generate a clearer image, and the image generated by the MSE Loss is fuzzy. When the MSE loss is used as a reconstruction error function, a part with a large reconstruction error in an image is punished greatly, a position with a small reconstruction error in the image is punished lightly, and the MSE loss is influenced easily when the deviation value is large. If the reconstruction error is too large, gradient explosion is easily caused during back propagation; on the other hand, when the reconstruction error is relatively largeIn a short time, the MSE gradient is small, the convergence performance is poor, and the overall convergence speed of the model is influenced. Therefore, the L1 loss is adopted to have better convergence performance relative to MSE, and the convergence speed of the model is improved. And the MSE loss only concerns the relation between the original image and the corresponding pixels of the reconstructed image, and does not concern the correlation of image neighborhoods, which easily causes that the reconstructed image is only close to the input image on the pixels but can not display vivid effect, thereby causing that the residual value of the input image and the reconstructed image is very small, and bringing very poor visual experience to people. Because the adjacent pixels of the image have strong relevance, the basic characteristics of the image can be considered in the L1 loss function, the neighborhood information of the composite material member is considered in the loss function, the global characteristics of the image are obtained from the neighborhood, the loss at the pixel level is considered at the same time, and the reconstruction result and the real result are closer by combining the two.
Further, the present application also includes:
calculating the coding loss of the generator according to the following formula:
Figure BDA0003578789140000091
wherein L islatentFor coding loss, z is the low-dimensional feature vector of the first sample data set,
Figure BDA0003578789140000092
a low-dimensional feature vector of a first set of reconstructed samples;
calculating to obtain a total loss function of the generator according to the reconstruction loss and the coding loss, wherein the calculation formula is as follows:
LG=λreconLreconssim(1―Lssim)+λlatentLlatent
wherein L isGAs a function of total loss, LssimFor loss of structural similarity, λreconTo reconstruct the lost weights, λssimWeight lost for structural similarity, λlatentFor the weight of the coding loss, an optimized compensation of the generator is performed by the total loss function.
In particular, the loss of the generator consists of three parts, namely a reconstruction loss, a structural similarity loss and a coding loss, the coding loss LlatentFor scaling input sample x and reconstructed sample
Figure BDA0003578789140000101
Similarity in low-dimensional features, thereby ensuring input sample x and reconstructed sample
Figure BDA0003578789140000102
Semantic consistency in the high level space. Where z is a low-dimensional feature vector of the first sample data set,
Figure BDA0003578789140000103
for the low-dimensional feature vector of the first set of reconstructed samples, the coding loss is calculated as follows:
Figure BDA0003578789140000104
and calculating to obtain a total loss function of the generator according to the reconstruction loss and the coding loss, wherein the calculation formula is as follows:
LG=λreconLreconssim(1―Lssim)+λlatentLlatent
wherein L isGAs a function of total loss, LssimFor loss of structural similarity, λreconTo reconstruct the lost weights, λssimWeight lost for structural similarity, λlatentFor the weight of the coding loss, an optimized compensation of the generator is performed by the total loss function. By constructing the reconstruction loss, the coding loss and the structural similarity loss function in the generator and carrying out the optimization compensation of the generator based on the construction result, the convergence speed of the model can be improved, and the reconstruction result is closer to the real result.
Further, as shown, the present application further includes:
and calculating the loss of the discriminator according to the following calculation formula:
Figure BDA0003578789140000105
wherein L isDAnd performing optimization compensation on the discriminator according to the loss of the discriminator.
Specifically, the loss of the discriminator is the loss of the conventional GAN, and the calculation formula is as follows:
Figure BDA0003578789140000111
wherein L isDAnd G is a generator, D is a discriminator, and the optimized compensation of the discriminator is carried out according to the loss of the discriminator.
In summary, the anomaly detection method based on the generative model provided by the present application has the following technical effects:
1. obtaining a first sample data set is adopted; inputting the first sample data set into a generator, performing low-dimensional feature extraction on the first sample data set through a first encoder in the generator, performing low-dimensional feature extraction result vector constraint through a second encoder, and decoding the constrained first low-dimensional feature extraction result through a decoder to obtain a first reconstructed sample set; judging the authenticity of the first reconstruction sample set through a discriminator to obtain a first judgment result; and when the output result of the generated model is stable, inputting the first to-be-detected data into the generator to obtain first reconstructed data, and performing anomaly detection judgment according to the residual error value of the first to-be-detected data and the first reconstructed data. The method and the device achieve the technical effects of reducing the requirement on the sample data size, relieving the problem of category imbalance and improving the accuracy of anomaly detection while controlling time and labor cost.
2. The low-dimensional feature vector of the feature map can be constrained by adding the second encoder, so that the consistency of the low-dimensional features of the reconstructed image and the sample image is improved, a high-quality image is generated, and the structural design of the decoder can avoid simple learning of the network model to the identity mapping from the image space to the feature space; when the decoder generates a higher-resolution image, the low latitude information of the image can be better combined to be matched with the low-dimensional features, a reconstructed image with higher quality is obtained, and data support is provided for subsequent accurate model training and anomaly detection.
3. The basic features of the image can be considered in the L1 loss function, the neighborhood information of the composite material member is considered in the loss function, the global features of the image are obtained from the neighborhood, the loss at the pixel level is considered at the same time, and the reconstruction result and the real result can be closer by combining the two.
4. By constructing the reconstruction loss, the coding loss and the structural similarity loss function in the generator and carrying out the optimization compensation of the generator based on the construction result, the convergence speed of the model can be improved, and the reconstruction result is closer to the real result.
Example two
Based on the same inventive concept as the anomaly detection method based on the generative model in the foregoing embodiment, the present invention further provides an anomaly detection system based on the generative model, as shown in fig. 5, the system includes:
a first obtaining unit 11, configured to obtain a first sample data set by the first obtaining unit 11;
a first constructing unit 12, wherein the first constructing unit 12 is used for constructing a generator, wherein the generator comprises a first coder and a decoder;
a second obtaining unit 13, where the second obtaining unit 13 is configured to input the first sample data set into the generator, and perform low-dimensional feature extraction on the first sample data set through the first encoder to obtain a first low-dimensional feature extraction result;
a third obtaining unit 14, where the third obtaining unit 14 is configured to perform low-dimensional feature vector constraint on the first low-dimensional feature extraction result through a second encoder, and decode the constrained first low-dimensional feature extraction result through the decoder to obtain a first reconstructed sample set;
a first judging unit 15, where the first judging unit 15 is configured to judge authenticity of the first reconstructed sample set through a discriminator to obtain a first judgment result;
a fourth obtaining unit 16, where the fourth obtaining unit 16 is configured to obtain first data to be detected when an output result of the first determination result meets a first preset threshold;
a first detecting unit 17, where the first detecting unit 17 is configured to input the first to-be-detected data into the generator, obtain first reconstruction data, and perform anomaly detection and judgment according to a residual value between the first to-be-detected data and the first reconstruction data.
Furthermore, the first encoder is composed of a residual error network, each layer of the first two-layer structure of the first encoder only comprises a convolution layer and a LeakyReLU function, and the network structures and parameters of the second encoder and the first encoder are consistent.
Furthermore, each layer of the first two-layer structure of the discriminator only comprises a convolution layer and a LeakyReL U function, and then 5 DeBlock blocks are connected.
Further, the system further comprises:
a first calculating unit for calculating a reconstruction loss of the generator, the calculation formula being as follows:
Lrecon=‖x,GDe(Gen(x))‖1
wherein L isreconTo reconstruct the loss, GDeTo a decoder, GenFor the first encoder, an optimal compensation of the generator is performed based on the calculated reconstruction loss.
Further, the system further comprises:
a second calculating unit, configured to calculate a coding loss of the generator, according to the following calculation formula:
Figure BDA0003578789140000131
wherein L islatentFor coding loss, z is the low-dimensional feature vector of the first sample data set,
Figure BDA0003578789140000132
a low-dimensional feature vector of a first set of reconstructed samples;
a third calculating unit, configured to calculate a total loss function of the generator according to the reconstruction loss and the coding loss, where the calculation formula is as follows:
LG=λreconLreconssim(1―Lssim)+λlatentLlatent
wherein L isGAs a function of total loss, LssimFor loss of structural similarity, λreconTo reconstruct the lost weights, λssimWeight lost for structural similarity, λlatentFor the weight of the coding loss, an optimized compensation of the generator is performed by the total loss function.
Further, the system further comprises:
a fourth calculating unit, configured to calculate a loss of the discriminator, where a calculation formula is as follows:
Figure BDA0003578789140000141
wherein L isDAnd performing optimization compensation on the discriminator according to the loss of the discriminator.
Further, the decoder is structured as Skip generator.
Various changes and specific examples of the above-mentioned method for detecting an anomaly based on a generative model in the first embodiment of fig. 1 are also applicable to the system for detecting an anomaly based on a generative model in the present embodiment, and through the foregoing detailed description of the method for detecting an anomaly based on a generative model, those skilled in the art can clearly know the method for implementing the system for detecting an anomaly based on a generative model in the present embodiment, so for the brevity of the description, detailed descriptions are omitted here.
Exemplary electronic device
The electronic device of the present application is described below with reference to fig. 6.
Fig. 6 illustrates a schematic structural diagram of an electronic device according to the present application.
The present invention also provides an electronic device based on the inventive concept of a generative model-based anomaly detection method as in the foregoing embodiments, and the electronic device according to the present application is described below with reference to fig. 6. The electronic device may be a removable device itself or a stand-alone device independent thereof, on which a computer program is stored which, when being executed by a processor, carries out the steps of any of the methods as described hereinbefore.
As shown in fig. 6, the electronic device 50 includes one or more processors 51 and a memory 52.
The processor 51 may be a Central Processing Unit (CPU) or other form of processing unit having data processing capabilities and/or instruction execution capabilities, and may control other components in the electronic device 50 to perform desired functions.
The memory 52 may include one or more computer program products that may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory. The volatile memory may include, for example, Random Access Memory (RAM), cache memory (cache), and/or the like. The non-volatile memory may include, for example, Read Only Memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium and executed by the processor 51 to implement the methods of the various embodiments of the application described above and/or other desired functions.
In one example, the electronic device 50 may further include: an input device 53 and an output device 54, which are interconnected by a bus system and/or other form of connection mechanism (not shown).
The embodiment of the invention provides an anomaly detection method based on a generative model, which comprises the following steps: obtaining a first sample data set; constructing a generator, wherein the generator comprises a first encoder and a decoder; inputting the first sample data set into the generator, and performing low-dimensional feature extraction on the first sample data set through the first encoder to obtain a first low-dimensional feature extraction result; performing low-dimensional feature vector constraint on the first low-dimensional feature extraction result through a second encoder, and decoding the constrained first low-dimensional feature extraction result through the decoder to obtain a first reconstruction sample set; judging the authenticity of the first reconstruction sample set through a discriminator to obtain a first judgment result; when the output result of the first judgment result meets a first preset threshold value, first data to be detected is obtained; and inputting the first data to be detected into the generator to obtain first reconstruction data, and performing anomaly detection judgment according to the residual error value of the first data to be detected and the first reconstruction data. The technical problems that in the prior art, the requirement for a sample is large, the quantity of sample data with defects is small, the labeling is time-consuming and labor-consuming, the abnormal detection cost is high, and the detection effect is poor are solved, the requirements for the quantity of the sample data are reduced, the class imbalance is relieved, and the technical effect of improving the accuracy of the abnormal detection is achieved while the time and the labor cost are controlled.
Through the above description of the embodiments, those skilled in the art will clearly understand that the present application can be implemented by software plus necessary general-purpose hardware, and certainly can also be implemented by special-purpose hardware including special-purpose integrated circuits, special-purpose CPUs, special-purpose memories, special-purpose components and the like. Generally, functions performed by computer programs can be easily implemented by corresponding hardware, and specific hardware structures for implementing the same functions may be various, such as analog circuits, digital circuits, or dedicated circuits. However, for the present application, the implementation of a software program is more preferable. Based on such understanding, the technical solutions of the present application may be substantially embodied in the form of a software product, which is stored in a readable storage medium, such as a floppy disk, a usb disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk of a computer, and includes several instructions for causing a computer device to execute the method according to the embodiments of the present application.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of 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, the procedures or functions described in accordance with the present application are generated, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored on or transmitted from a computer-readable storage medium to another computer-readable storage medium, which may be magnetic (e.g., floppy disks, hard disks, tapes), optical (e.g., DVDs), or semiconductor (e.g., Solid State Disks (SSDs)), among others.
It should be appreciated that reference throughout this specification to "one embodiment" or "an embodiment" means that a particular feature, structure or characteristic described in connection with the embodiment is included in at least one embodiment of the present application. Thus, the appearances of the phrases "in one embodiment" or "in an embodiment" in various places throughout this specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. It should be understood that, in the various embodiments of the present application, the sequence numbers of the above-mentioned processes do not mean the execution sequence, and the execution sequence of the processes should be determined by the functions and the inherent logic, and should not constitute any limitation to the implementation process of the present application.
Additionally, the terms "system" and "network" are often used interchangeably herein. The term "and/or" herein is merely an association describing an associated object, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
It should be understood that in this application, "B corresponding to A" means that B is associated with A, from which B can be determined. It should also be understood that determining B from a does not mean determining B from a alone, but may be determined from a and/or other information.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the technical solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In short, the above description is only a preferred embodiment of the present disclosure, and is not intended to limit the scope of the present disclosure. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (9)

1. An anomaly detection method based on generative models, the method comprising:
obtaining a first sample data set;
constructing a generator, wherein the generator comprises a first encoder and a decoder;
inputting the first sample data set into the generator, and performing low-dimensional feature extraction on the first sample data set through the first encoder to obtain a first low-dimensional feature extraction result;
performing low-dimensional feature vector constraint on the first low-dimensional feature extraction result through a second encoder, and decoding the constrained first low-dimensional feature extraction result through the decoder to obtain a first reconstruction sample set;
judging the authenticity of the first reconstruction sample set through a discriminator to obtain a first judgment result;
when the output result of the first judgment result meets a first preset threshold value, first data to be detected is obtained;
and inputting the first data to be detected into the generator to obtain first reconstruction data, and performing anomaly detection judgment according to the residual error value of the first data to be detected and the first reconstruction data.
2. The method of claim 1, wherein the first encoder is formed by a residual network, and each layer of the first two-layer structure of the first encoder comprises only one convolutional layer and a LeakyReLU function, and the network structures and parameters of the second encoder and the first encoder are identical.
3. The method of claim 1, wherein the first two-layer structure of the discriminator contains only one convolutional layer and a LeakyReLU function per layer, followed by 5 DeBlock blocks.
4. The method of claim 1, wherein the method further comprises:
and calculating the reconstruction loss of the generator according to the following calculation formula:
Lrecon=||x,GDe(Gen(x))||1
wherein L isreconTo reconstruct the loss, GDeIs a decoder, GenFor the first encoder, an optimal compensation of the generator is performed based on the calculated reconstruction loss.
5. The method of claim 4, wherein the method further comprises:
calculating the coding loss of the generator according to the following formula:
Figure FDA0003578789130000021
wherein L islatentFor coding loss, z is the low-dimensional feature vector of the first sample data set,
Figure FDA0003578789130000022
a low-dimensional feature vector of a first set of reconstructed samples;
calculating to obtain a total loss function of the generator according to the reconstruction loss and the coding loss, wherein the calculation formula is as follows:
LG=λreconLreconssim(1-Lssim)+λlatentLlatent
wherein L isGAs a function of total loss, LssimFor loss of structural similarity, λreconTo reconstruct the lost weights, λssimWeight, λ, lost for structural similaritylatentFor the weight of the coding loss, an optimized compensation of the generator is performed by the total loss function.
6. The method of claim 1, wherein the method further comprises:
and calculating the loss of the discriminator according to the following calculation formula:
Figure FDA0003578789130000023
wherein L isDAnd performing optimization compensation on the discriminator according to the loss of the discriminator.
7. The method of claim 1, wherein the decoder is structured as a Skip generator.
8. A generative model-based anomaly detection system, the system comprising:
a first obtaining unit configured to obtain a first sample data set;
a first construction unit for constructing a generator, wherein the generator comprises a first encoder and a decoder;
a second obtaining unit, configured to input the first sample data set into the generator, and perform low-dimensional feature extraction on the first sample data set through the first encoder to obtain a first low-dimensional feature extraction result;
a third obtaining unit, configured to perform low-dimensional feature vector constraint on the first low-dimensional feature extraction result through a second encoder, and decode the constrained first low-dimensional feature extraction result through the decoder to obtain a first reconstructed sample set;
the first judging unit is used for judging the authenticity of the first reconstruction sample set through a discriminator to obtain a first judging result;
a fourth obtaining unit, configured to obtain first data to be detected when an output result of the first determination result satisfies a first preset threshold;
and the first detection unit is used for inputting the first data to be detected into the generator to obtain first reconstruction data, and performing abnormity detection judgment according to a residual error value of the first data to be detected and the first reconstruction data.
9. An electronic device comprising a processor and a memory; the memory is used for storing; the processor is used for executing the method of any one of claims 1 to 7 through calling.
CN202210339922.XA 2022-04-01 2022-04-01 Anomaly detection method and system based on generative model Pending CN114707600A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210339922.XA CN114707600A (en) 2022-04-01 2022-04-01 Anomaly detection method and system based on generative model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210339922.XA CN114707600A (en) 2022-04-01 2022-04-01 Anomaly detection method and system based on generative model

Publications (1)

Publication Number Publication Date
CN114707600A true CN114707600A (en) 2022-07-05

Family

ID=82173556

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210339922.XA Pending CN114707600A (en) 2022-04-01 2022-04-01 Anomaly detection method and system based on generative model

Country Status (1)

Country Link
CN (1) CN114707600A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117034020A (en) * 2023-10-09 2023-11-10 贵州大学 Unmanned aerial vehicle sensor zero sample fault detection method based on CVAE-GAN model

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117034020A (en) * 2023-10-09 2023-11-10 贵州大学 Unmanned aerial vehicle sensor zero sample fault detection method based on CVAE-GAN model
CN117034020B (en) * 2023-10-09 2024-01-09 贵州大学 Unmanned aerial vehicle sensor zero sample fault detection method based on CVAE-GAN model

Similar Documents

Publication Publication Date Title
WO2021136365A1 (en) Application development method and apparatus based on machine learning model, and electronic device
CN110111334B (en) Crack segmentation method and device, electronic equipment and storage medium
JP6182242B1 (en) Machine learning method, computer and program related to data labeling model
CN111476719B (en) Image processing method, device, computer equipment and storage medium
CN112001399B (en) Image scene classification method and device based on local feature saliency
US20230342893A1 (en) Transferring faces between digital images by combining latent codes utilizing a blending network
CN105719248A (en) Real-time human face deforming method and system
CN114462356B (en) Text error correction method and device, electronic equipment and medium
CN112307991A (en) Image recognition method, device and storage medium
CN114707600A (en) Anomaly detection method and system based on generative model
CN116978105A (en) AI face-changing image anomaly detection method
CN115861284A (en) Printed product linear defect detection method, printed product linear defect detection device, electronic equipment and storage medium
CN116228654A (en) Defect detection method, device, equipment and storage medium
Liu et al. Attentive semantic and perceptual faces completion using self-attention generative adversarial networks
CN110852974A (en) Image anti-aliasing processing method, training method and device of image generator
CN110796115B (en) Image detection method and device, electronic equipment and readable storage medium
CN118297979A (en) Image processing method, apparatus, electronic device, storage medium, and program product
CN113052798A (en) Screen aging detection model training method and screen aging detection method
US20240161362A1 (en) Target-augmented material maps
CN114528976B (en) Equal transformation network training method and device, electronic equipment and storage medium
US20230326028A1 (en) Utilizing machine learning models to generate refined depth maps with segmentation mask guidance
CN115797709A (en) Image classification method, device, equipment and computer readable storage medium
CN114067370A (en) Neck shielding detection method and device, electronic equipment and storage medium
CN112802075A (en) Training method of texture generation model, image processing method and device
CN113222843A (en) Image restoration method and related equipment thereof

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination