Registration generation network system and sample generation method

By generating synthetic samples through a generative module, fusing feature maps with a multi-scale feature discriminator, calculating feature matching loss and gradient penalty terms, and dynamically adjusting weights, the problem of low reliability of anomaly detection results in adversarial generative network systems is solved, achieving efficient anomaly detection.

CN121859959APending Publication Date: 2026-04-14BEIJING REALAI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-08
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

In existing technologies, when using adversarial generative network systems for anomaly detection, it is difficult to quickly generate reliable synthetic samples, resulting in low reliability of anomaly detection results.

Method used

Multiple synthetic samples are generated using a generation module. Feature maps are fused using a multi-scale feature discriminator. Feature matching loss and gradient penalty terms are calculated, weights are dynamically adjusted, and a comprehensive anomaly score is output. An adversarial training module is then constructed to update the network parameters.

Benefits of technology

It improves the consistency between synthetic samples and normal samples, suppresses discriminator overfitting, enhances the adaptability and reliability of anomaly detection, and strengthens the adaptability of anomaly detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121859959A_ABST
    Figure CN121859959A_ABST
Patent Text Reader

Abstract

The invention discloses an adversarial generation network system and a sample generation method, and the network comprises a generation module which is used for generating a plurality of synthetic samples based on a plurality of normal samples; the multi-scale feature discriminator is used for fusing the plurality of feature maps of each sample to obtain a multi-scale fusion feature, and determining the discriminator confidence coefficient of each sample based on the multi-scale fusion feature; the adversarial training module is used for calculating the feature matching loss and the gradient penalty term between the synthetic sample and the normal sample, feeding back the network parameters of the updating generation module according to the feature matching loss, and feeding back and updating the network parameters of the multi-scale feature discriminator according to the gradient penalty term; the dynamic weight adjustment module is used for revising the weight of the confidence coefficient of the discriminator according to the distribution variance of the sample sequence and outputting the comprehensive abnormal score of each sample; a reliable synthetic sample can be quickly generated, and the reliability of an anomaly detection result is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of anomaly detection technology, specifically to an adversarial generative network system and a sample generation method. Background Technology

[0002] Anomaly detection is crucial in key areas such as industrial defect detection and financial fraud identification. Because anomaly samples are scarce and costly to obtain, existing technologies generally employ unsupervised learning methods based on normal samples. Specifically, generative adversarial networks (GANs) perform anomaly detection by learning the distribution of normal data.

[0003] However, when standard generative adversarial networks are directly applied to this task, the diversity and complexity of normal samples make it difficult to fully capture their true distribution characteristics, which in turn makes it difficult to generate high-quality and diverse synthetic samples. In addition, during the process of learning the feature distribution of normal samples, the generator is easily affected by noise, which can lead to overfitting or pattern collapse, making it difficult to quickly generate the required sample data and ultimately affecting the discriminator's ability to identify abnormal samples.

[0004] Therefore, existing technologies for anomaly detection using adversarial generative network systems suffer from low reliability of anomaly detection results due to the difficulty in quickly generating reliable synthetic samples. Summary of the Invention

[0005] This invention provides an adversarial generative network system and a sample generation method, aiming to solve the problem that the reliability of anomaly detection results is low due to the difficulty in quickly generating reliable synthetic samples in the process of anomaly detection using adversarial generative network systems.

[0006] To address the aforementioned technical problems, the embodiments of the present invention provide the following technical solutions: An adversarial generative network system, comprising: The generation module is used to generate multiple synthetic samples based on multiple normal samples; A multi-scale feature discriminator is used to fuse multiple feature maps of each sample to obtain multi-scale fused features, and to determine the discriminator confidence of each sample based on the multi-scale fused features. The adversarial training module is used to calculate the feature matching loss and gradient penalty term between the synthetic sample and the normal sample, and update the network parameters of the generation module based on the feature matching loss, and update the network parameters of the multi-scale feature discriminator based on the gradient penalty term. The dynamic weight adjustment module is used to revise the weights of the discriminator confidence based on the distribution variance of the sample sequence and output the comprehensive anomaly score for each sample.

[0007] Optionally, the generation module includes a generator, a data augmentation unit, and an encoder; the generation of multiple synthetic samples based on multiple normal samples includes: The data augmentation unit performs data augmentation processing on multiple normal samples to obtain augmented samples; The augmented sample is input into the encoder to obtain the latent space vector of the augmented sample, and the latent space distribution of normal data is constructed based on the latent space vector; The generator is used to generate the plurality of synthetic samples based on the potential spatial distribution of the normal data.

[0008] Optionally, the generator and the encoder form an autoencoder structure; The generator generates potential reconstruction samples based on the potential spatial distribution of the normal data; The encoder updates its parameters based on the potential reconstruction error of the potential reconstruction sample until it obtains the minimum potential reconstruction error value. The generator also updates its parameters based on the potential reconstruction error.

[0009] Optionally, the multi-scale feature discriminator includes a deep convolutional network with skip connections, an average pooling layer, a vector fusion layer, and a fully connected layer; the step of fusing multiple feature maps for each sample to obtain multi-scale fused features, and determining the discriminator confidence for each sample based on the multi-scale fused features, includes: Each sample is input into the deep convolutional network with skip connections to obtain multiple feature maps of each sample at different levels; The average pooling layer performs global average pooling on multiple feature maps in the last multiple layers to obtain the feature vector of each feature map. The vector fusion layer fuses multiple feature vectors into a single fused feature vector, and the fully connected layer determines the discriminator confidence of each sample based on the fused feature vector.

[0010] Optionally, the adversarial training module includes a feature matching loss calculation unit and a gradient penalty term calculation unit; the step of calculating the feature matching loss and gradient penalty term between the synthetic sample and the normal sample, updating the network parameters of the generation module based on the feature matching loss, and updating the network parameters of the multi-scale feature discriminator based on the gradient penalty term includes: The feature matching loss calculation unit determines the feature matching loss based on the difference in feature output between the synthetic sample and the normal sample at each level; The generation module is also used to update the network parameters of each layer in reverse according to the feature matching loss, so as to reduce the feature matching loss value; The gradient penalty term calculation unit determines the gradient penalty term based on the gradient of the weighted sample of the synthetic sample and the normal sample; The multi-scale feature discriminator is also used to update the network parameters of each layer in reverse based on the gradient penalty term, so as to reduce the value of the gradient penalty term.

[0011] Optionally, the gradient penalty term calculation unit generates interpolated samples of the synthetic sample and the normal sample through linear interpolation; The multi-scale feature discriminator performs gradient calculation on the interpolated samples to determine the gradient vector of each interpolated sample; The gradient vector is incorporated into the loss function of the multi-scale feature discriminator to obtain a multi-scale feature discriminator with smoothly updated parameters.

[0012] Optionally, the dynamic weight adjustment module includes a reconstruction error calculation unit, a distribution variance calculation unit, a weight correction unit, and a comprehensive anomaly score determination unit; the step of revising the weights of the discriminator confidence score based on the distribution variance of the sample sequence and outputting the comprehensive anomaly score for each sample includes: The reconstruction error calculation unit obtains the reconstructed samples of the sample sequence and determines the reconstruction error of each sample based on the sample sequence and the reconstructed samples. Based on the distribution variance calculation unit, the test discriminator confidence distribution variance is determined according to the test discriminator confidence corresponding to the sample sequence, and the reconstruction error distribution variance is determined according to the reconstruction error; The weight correction unit determines the target weight of the discriminator confidence based on the variance of the test discriminator confidence distribution and the variance of the reconstruction error distribution; The comprehensive anomaly score determination unit determines the comprehensive anomaly score for each sample based on the reconstruction error of each sample, the target weight, and the confidence of the test discriminator.

[0013] Optionally, determining the reconstruction error of each sample based on the sample sequence and the reconstructed samples includes: The reconstruction error of each sample is determined based on the mean squared error between each sample and its corresponding reconstructed sample and the structural similarity index.

[0014] Optionally, the adversarial generative network system further includes a sample classification module, which is used to determine that the sample is an anomalous sample when the comprehensive anomaly score is greater than a dynamic threshold; The dynamic threshold is periodically updated based on the statistical percentile of the sample sequence.

[0015] A sample generation method based on an adversarial generative network system includes: Based on the adversarial generative network system described above, multiple test synthetic samples corresponding to the target sample are generated; The test synthetic sample whose comprehensive anomaly score is greater than a preset threshold is determined as the target generated sample of the target sample.

[0016] In this embodiment, a generation module simulates normal samples to generate synthetic samples. A multi-scale feature discriminator fuses features from multiple scales to improve the accuracy of the discriminator's confidence score. Since the adversarial training module calculates the feature matching loss between the synthetic and normal samples and updates the network parameters of the generation module based on the feature matching loss feedback, the feature distribution of the synthetic samples generated by the generation module can approximate that of normal samples, improving the consistency between the synthetic and normal samples and ensuring the reliability of the synthetic samples. In addition, the gradient penalty term can effectively suppress discriminator overfitting by constraining the gradient of the multi-scale feature discriminator, improving the stability and convergence speed of adversarial training, and thus accelerating the operating efficiency of the adversarial generative network system. Finally, the dynamic weight adjustment module revises the weights of the discriminator's confidence score based on the distribution variance of the sample sequence, which can effectively improve the correlation between the comprehensive anomaly score and the sample sequence, thereby enhancing the adaptability of anomaly detection and ensuring the reliability of the anomaly detection results. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in this embodiment, the accompanying drawings used in the description of the embodiment will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 A structural block diagram of an embodiment of the adversarial generative network system provided by the present invention; Figure 2 A schematic flowchart of an embodiment of the sample generation method based on an adversarial generative network system provided by the present invention; Figure 3 This is a flowchart of an embodiment of the sample generation method provided by the present invention; Figure 4 This is a schematic diagram of an embodiment of the electronic device provided by the present invention. Detailed Implementation

[0019] The technical solutions in this embodiment will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0020] In the following description, specific embodiments of the invention will be illustrated with reference to steps and symbols performed by one or more computers, unless otherwise stated. Therefore, these steps and operations will be referred to several times as being performed by a computer, and computer execution as referred to herein includes operations by a computer processing unit representing electronic signals of data in a structured format. This operation transforms the data or maintains it at a location in the computer's memory system, which can be reconfigured or otherwise alter the operation of the computer in a manner well known to those skilled in the art. The data structure maintained by the data is the physical location of the memory, which has specific characteristics defined by the data format. However, the principles of the invention described above are not intended to be limiting, and those skilled in the art will understand that many of the steps and operations described below can also be implemented in hardware.

[0021] The terms "module" or "unit" as used herein can be considered as software objects executing on the computing system. The different components, modules, engines, and services described herein can be considered as implementation objects on the computing system. The apparatus and methods described herein are preferably implemented in software, but can also be implemented in hardware, both of which are within the scope of this invention.

[0022] This invention provides an adversarial generative network system and a sample generation method.

[0023] Please see Figure 1 , Figure 1 This is a structural block diagram of an embodiment of the adversarial generative network system provided by the present invention. The adversarial generative network system 100 includes: Generation module 101 is used to generate multiple synthetic samples based on multiple normal samples; A multi-scale feature discriminator 102 is used to fuse multiple feature maps of each sample to obtain multi-scale fused features, and to determine the discriminator confidence of each sample based on the multi-scale fused features. The adversarial training module 103 is used to calculate the feature matching loss and gradient penalty term between the synthetic sample and the normal sample, and update the network parameters of the generation module 101 based on the feature matching loss feedback, and update the network parameters of the multi-scale feature discriminator 102 based on the gradient penalty term feedback. The dynamic weight adjustment module 104 is used to revise the weights of the discriminator confidence based on the distribution variance of the sample sequence and output the comprehensive anomaly score for each sample.

[0024] It should be noted that normal samples refer to pre-prepared samples that meet user requirements. By training the adversarial generative network system based on normal samples, the adversarial generative network system can generate samples that are highly similar to normal samples. In one specific embodiment, normal samples can consist of high-resolution images of defect-free products, or time-series data or text corpora that meet specific quality standards. In other embodiments, normal samples can also be other types of samples, which are not limited here.

[0025] Synthetic samples refer to data generated by the generation module 101 based on the learned normal sample distribution, which has similar characteristics to normal samples; that is, generated virtual samples.

[0026] The multi-scale feature discriminator 102 processes both normal and synthetic samples.

[0027] Multiple feature maps refer to the feature representations of samples extracted by the multi-scale feature discriminator 102 at different network layers, covering the local details and global semantic information of the samples at multiple spatial resolutions.

[0028] Discriminator confidence is the output probability value of the multi-scale feature discriminator 102 in evaluating the authenticity of normal samples and synthetic samples. It reflects the degree of certainty that a sample is a real sample. The higher the discriminator confidence value, the closer the sample is to the normal distribution.

[0029] Feature matching loss refers to a parameter that quantifies the difference in feature output between synthetic samples and normal samples in the intermediate layer of the discriminator. It can constrain the distribution of synthetic samples generated by the generation module 101 to approximate the distribution of real samples in the feature space.

[0030] The gradient penalty term refers to the interpolation point between the synthetic sample and the normal sample. It can constrain the smoothness of the multi-scale feature discriminator 102 and prevent gradient explosion or mode collapse problems during model training.

[0031] The overall anomaly score is the final indicator used to quantify the degree of anomaly of a sample. It is directly related to the confidence of the discriminator. The higher the overall anomaly score, the higher the degree of anomaly of the sample and the more likely it is to be an anomalous sample.

[0032] In this embodiment, the generation module 101 simulates normal samples to generate synthetic samples, and the multi-scale feature discriminator 102 fuses features from multiple scales to improve the accuracy of the discriminator's confidence. Since the adversarial training module 103 calculates the feature matching loss between the synthetic samples and normal samples and updates the network parameters of the generation module 101 based on the feature matching loss feedback, the feature distribution of the synthetic samples generated by the generation module 101 can approximate that of normal samples, improving the consistency between the synthetic samples and normal samples and ensuring the reliability of the synthetic samples. In addition, the gradient penalty term can effectively suppress discriminator overfitting by constraining the gradient of the multi-scale feature discriminator 102, improving the stability and convergence speed of adversarial training, and thus accelerating the running efficiency of the adversarial generative network system. Finally, the dynamic weight adjustment module 104 adjusts the weights of the discriminator's confidence based on the distribution variance of the sample sequence, which can effectively improve the correlation between the comprehensive anomaly score and the sample sequence, thereby enhancing the adaptability of anomaly detection and ensuring the reliability of the anomaly detection results.

[0033] In one specific embodiment, the generation module includes a generator, a data augmentation unit, and an encoder; generating multiple synthetic samples based on multiple normal samples includes: the data augmentation unit performing data augmentation processing on multiple normal samples to obtain augmented samples; inputting the augmented samples into the encoder to obtain the latent space vector of the augmented samples, and constructing the latent space distribution of normal data based on the latent space vector; the generator is used to generate multiple synthetic samples based on the latent space distribution of normal data.

[0034] It should be noted that data augmentation specifically includes: applying controlled noise injection, random occlusion, and color jitter to normal samples to simulate boundary samples that are close to abnormal but are still essentially normal, in order to enhance the robustness of the discriminator.

[0035] Specifically, controllable noise injection refers to adding random perturbations of adjustable amplitude to normal samples, which can be achieved using Gaussian noise or salt-and-pepper noise, with the aim of simulating subtle noise interference that may occur in normal samples; random occlusion refers to randomly covering local areas of normal samples, which can be achieved using rectangular areas or irregular shapes of occlusion, with the aim of simulating partial information loss situations commonly seen in real-world scenarios; color dithering refers to dynamically adjusting the hue, saturation, and brightness parameters of samples, which can be achieved by randomly adjusting RGB channel values ​​or HSV space parameters, with the aim of simulating the natural variations of normal samples under different lighting or environments.

[0036] For normal sample datasets ,right Perform data augmentation operations, including: Controllable noise injection: Add standard deviation of Gaussian noise; Random occlusion: using a size of to The rectangular region randomly occludes the image; Color jitter: in Randomly adjust the brightness, contrast, and saturation of the image within a specified range; The enhanced sample is input into the encoder. Obtain the latent space vector ,in To enhance the sample; Based on all Construct a compact latent spatial distribution Z for normal data.

[0037] In this application, a diverse training set of boundary samples is generated by sequentially applying controllable noise injection, random occlusion, and color jitter to normal samples. During data preprocessing, these enhancements are applied to normal samples to simulate sample variants that are close to anomalous but essentially normal. During adversarial training, the discriminator learns from these boundary samples, enabling it to distinguish subtle perturbations from genuine anomalous features. Noise injection adapts the discriminator to sensor noise interference, random occlusion improves the discriminator's stability under conditions of missing information, and color jitter enhances the discriminator's tolerance to changes in illumination. The combined effect of these three elements allows the discriminator to establish a more robust decision boundary in the edge regions of normal data distribution, thereby accurately identifying genuine anomalous signals during the inference stage.

[0038] In one specific implementation, in an industrial defect detection scenario, slight Gaussian noise is applied to normal product images to simulate sensor noise interference in the production environment; random-sized rectangular regions are used for partial occlusion to simulate partial information loss during conveyor belt operation; and the brightness and contrast of the image are adjusted to simulate natural variations under different lighting conditions. The boundary samples generated by these enhancement operations are incorporated into the training set for optimizing the discriminator during the adversarial training phase, enabling the discriminator to effectively distinguish the edge morphology of normal samples from real defect features.

[0039] Through the above data augmentation processing, the discriminator's sensitivity to samples at the edge of the normal data distribution is effectively reduced, and the number of samples that are at the distribution boundary but are actually not abnormal are misclassified as abnormal is significantly reduced, thereby suppressing the increase in the false positive rate.

[0040] Furthermore, after data augmentation of the normal samples, multiple augmented samples are obtained. To fully utilize the features of these augmented samples, they are input into the encoder to extract the corresponding latent space vectors, thus forming a high-density and compact latent space distribution of normal data. Clearly, the latent space distribution of normal data is constructed based on the inherent structural features of normal data, providing a stable learning foundation for the generation of synthetic samples and effectively suppressing the mode collapse phenomenon that may occur during generator training.

[0041] In one specific embodiment, in order to improve the collaborative optimization efficiency of the generator and encoder, the generator and encoder form an autoencoder structure; wherein, the generator generates potential reconstruction samples based on the potential spatial distribution of normal data; the encoder updates its parameters based on the potential reconstruction error of the potential reconstruction samples until the minimum potential reconstruction error value is obtained; the generator also updates its parameters based on the potential reconstruction error.

[0042] It should be noted that, due to the lack of a co-initialization mechanism between the encoder and generator, the formation of the latent space distribution is susceptible to the randomness of parameters in the early stages of training, leading to slow convergence and blurred distribution boundaries. This, in turn, exacerbates the risk of generator mode collapse and affects the generation module's ability to learn complete data from normal data and its subsequent discrimination accuracy. Therefore, the encoder and generator are combined into an autoencoder structure and pre-trained in the early stages of training to accelerate the stable formation of the latent space distribution.

[0043] Among them, the autoencoder structure refers to the architecture in which the encoder and generator form a closed-loop mapping. It can be implemented using a fully connected neural network or a convolutional neural network. Its purpose is to ensure the tight coupling between the latent space and the data reconstruction process and avoid feature alignment bias. Pre-training refers to the end-to-end optimization of the autoencoder before adversarial training begins. It can be implemented using the mean squared error loss function, structural similarity loss function or other reconstruction loss functions. Its purpose is to quickly establish a stable mapping relationship between the input data and the latent space.

[0044] In summary, this application pre-trains the autoencoder structure composed of the encoder and generator using normal sample data in the early stage of training. This enables the encoder to map the input data to a compact latent space, and the generator to reconstruct the latent space vector back to the original data. This process optimizes the parameter coordination between the encoder and generator, reduces the impact of random fluctuations in initial parameters on the latent space distribution, thereby accelerating the stable formation of the distribution and laying a solid foundation for subsequent adversarial training.

[0045] As a preferred embodiment, in an industrial defect detection scenario, the encoder uses a convolutional neural network structure to extract image features, and the generator uses a transposed convolutional neural network structure to reconstruct the image. During the pre-training stage, normal product image samples are used, and the network parameters are optimized by minimizing the reconstruction loss.

[0046] Through the above methods, this application significantly shortens the convergence time of the potential spatial distribution, makes the distribution boundary clearer, reduces the risk of generator pattern collapse, and thus improves the anomaly detection model's ability to learn the complete data manifold and its discrimination accuracy.

[0047] In one specific embodiment, the multi-scale feature discriminator includes a deep convolutional network with skip connections, an average pooling layer, a vector fusion layer, and a fully connected layer. It fuses multiple feature maps for each sample to obtain multi-scale fused features, and determines the discriminator confidence for each sample based on these multi-scale fused features. This includes: inputting each sample into the deep convolutional network with skip connections to obtain multiple feature maps for each sample at different levels; the average pooling layer performing global average pooling on the multiple feature maps at the last multiple levels to obtain feature vectors for each feature map; the vector fusion layer fusing multiple feature vectors into a single fused feature vector; and a fully connected layer determining the discriminator confidence for each sample based on the fused feature vector.

[0048] It should be noted that the multi-scale feature discriminator is a deep convolutional network with skip connections. It concatenates the feature maps of the last three convolutional layers into a fused feature vector by performing global average pooling. Finally, the discriminator confidence is output based on this fused feature vector through a fully connected layer.

[0049] In this context, skip connections refer to establishing direct feature transfer paths between network layers, which can be implemented using residual connections or dense connections, aiming to avoid information attenuation of shallow details during propagation into deeper layers. Deep convolutional networks (DCNNs) are feature extraction architectures composed of multiple stacked convolutional layers, which can be implemented using standard convolutional neural networks such as VGG or ResNet, aiming to capture local texture and global semantic features of the input data hierarchically. The last three convolutional layers refer to the three consecutive convolutional layers near the output in the discriminator network; these three layers are the key layers responsible for high-level abstract feature extraction. The feature map refers to the two-dimensional feature representation matrix output by the convolutional layers, which can be obtained using... Feature maps with different resolutions and number of channels are used to achieve this; global average pooling refers to averaging the spatial dimensions of the feature map to compress it into a one-dimensional vector, which can be implemented using a global average pooling layer, with the aim of eliminating spatial location dependencies and enhancing channel-level feature responses; concatenation refers to connecting multiple one-dimensional feature vectors along the channel dimension, which can be implemented using the concatenation function; fused feature vectors refer to the comprehensive feature representation generated by concatenation, which can be understood as an integrated carrier of multi-scale features; fully connected layers refer to the decision layers in neural networks where neurons are fully interconnected, which can be implemented using standard fully connected layers, with the aim of outputting discriminator confidence based on fused feature vectors.

[0050] In this embodiment, after receiving input data, the multi-scale feature discriminator extracts features layer by layer in the deep convolutional network. Skip connections ensure that shallow edge and texture features are directly transmitted to deep layers, avoiding the loss of key detail information. Subsequently, the feature maps output by the last three convolutional layers are extracted simultaneously. Global average pooling is performed on each feature map to compress spatial dimensions and highlight channel response intensity. The three pooled one-dimensional feature vectors are then concatenated to form a fused feature vector. Finally, the fully connected layer calculates the discrimination result based on the fused feature vector, enabling the model to simultaneously evaluate the consistency of input data at both low-level local features and high-level semantic features, thereby achieving multi-scale comprehensive discrimination of data authenticity.

[0051] In one specific implementation, the multi-scale feature discriminator can be implemented based on the ResNet architecture, where the skip connections adopt a residual block structure; the last three convolutional layers correspond to the consecutive convolutional stages at the end of the network, for example, in a typical implementation, they refer to the output layers of the third-to-last, second-to-last, and first convolutional modules; global average pooling is applied to the feature maps of these layers, converting each feature map into a fixed-length channel vector; a concatenation operation connects the three channel vectors into a single fused feature vector; and the fully connected layer receives this vector and outputs the discriminant result.

[0052] Specifically, the multi-scale feature discriminator D employs a deep convolutional network with skip connections (such as one based on ResNet). 34 architecture), containing 5 convolutional stages; The last three convolutional stages ( conv3_x, conv4_x, conv5_x The output feature maps are then subjected to global average pooling to obtain feature vectors. ;Will Concatenate into a fused feature vector ; based on a fully connected layer Output the discrimination result .

[0053] In this embodiment, the multi-scale feature discriminator adopts the ResNet-34 architecture, which The output feature maps of the layer have resolutions of 28×28, 14×14, and 7×7, with 256, 512, and 512 channels, respectively. Global average pooling compresses these feature maps into 256-dimensional, 512-dimensional, and 512-dimensional feature vectors, which are then concatenated to form a 1280-dimensional fused feature vector. Clearly, the multi-scale feature discriminator can respond simultaneously to... Layer captures localized texture imperfections (such as scratches) and Global structural anomalies (such as missing components) captured by the layer. In comparative experiments with a standard adversarial generative network system (using only the final output layer), this application improved the detection sensitivity (recall) for minor solder joint defects from 68% to 85%, a relative improvement of approximately 25%, significantly reducing the false negative rate.

[0054] In summary, this embodiment effectively enhances the multi-scale feature discriminator's ability to integrate features at different levels of abstraction, significantly improves the quantitative response accuracy to hidden anomalies, and can more reliably distinguish the boundary between subtle anomaly samples and normal samples.

[0055] In one specific embodiment, during the training of the adversarial generative network system, it is necessary to accurately jointly optimize the generation module and the multi-scale feature discriminator to quickly obtain a reliable adversarial generative network system. Specifically, the adversarial training module includes a feature matching loss calculation unit and a gradient penalty term calculation unit; it calculates the feature matching loss and gradient penalty term between the synthetic sample and the normal sample, and updates the network parameters of the generation module based on the feature matching loss feedback, and updates the network parameters of the multi-scale feature discriminator based on the gradient penalty term feedback. This includes: the feature matching loss calculation unit determining the feature matching loss based on the feature output difference between the synthetic sample and the normal sample at each level; the generation module is also used to update the network parameters of each layer in reverse based on the feature matching loss to reduce the feature matching loss value; the gradient penalty term calculation unit determining the gradient penalty term based on the gradient of the weighted sample of the synthetic sample and the normal sample; and the multi-scale feature discriminator is also used to update the network parameters of each layer in reverse based on the gradient penalty term to reduce the value of the gradient penalty term.

[0056] In some implementations, the features of samples generated by the feature matching loss constraint generator are consistent with the feature distribution of normal samples in the intermediate layer of the multi-scale feature discriminator. However, due to the lack of a specific definition of the quantization loss function, the feature matching process cannot accurately control the feature distribution of the synthetic samples in each layer of the multi-scale feature discriminator, which may cause the synthetic samples to deviate from the normal data manifold. Especially in the multi-scale feature fusion scenario, the multi-scale feature discriminator has insufficient ability to identify subtle anomalies, resulting in missed detection of hidden anomalies and an increased misclassification rate of normal samples.

[0057] Therefore, it is quantitatively represented through the feature matching loss function, specifically, the feature matching loss... The definition is as follows:

[0058] in, It refers to feature matching loss, which is implemented using a quantitative index based on the difference in feature vectors. It can transform the difference in feature distribution between synthetic samples and normal samples into an optimizable mathematical expression, thereby providing a clear direction for the generator to optimize. To approximate the expected distribution of normal sample data, the statistical average of small batch training samples can be used. This can reflect the overall distribution characteristics of normal data and avoid local random fluctuations interfering with the stability of feature matching. It refers to the number of layers in the multi-scale feature discriminator; ∑ This represents the summation operation of multiple intermediate layer features of a multi-scale feature discriminator. Specifically, it can be implemented using feature extraction layers of different depths in a convolutional network. The purpose is to integrate multi-scale feature information and enhance the model's sensitivity to abnormal patterns at different levels. It is the first The number of features in a layer It refers to the feature quantity normalization factor, which can dynamically adjust the weight according to the scale of the feature dimension of each layer. Specifically, it can be implemented by taking the reciprocal of the number of channels in the feature map. It can balance the contribution of shallow detailed features and deep semantic features and prevent high-dimensional feature layers from dominating the loss calculation. This is a normal sample; surface The multi-scale feature discriminator is shown in the first step. The feature output of the layer, For the latent space vector, For synthetic samples; It means L2 The squared norm difference measure can be calculated based on the squared Euclidean distance of the feature vectors, specifically by using the sum of squared vector differences. The difference measure can provide a continuous and smooth gradient signal, supporting the generator to converge stably during training.

[0059] In this embodiment, the difference in feature distribution between synthetic samples and normal samples at each intermediate layer of the multi-scale feature discriminator is quantified into an optimizable loss function. The expectation calculation based on the real data distribution ensures that feature matching reflects the overall statistical regularity, avoiding random interference from mini-batch training. Simultaneously, for... L The feature outputs of the multi-scale feature discriminator layers are weighted and summed to fully utilize the structural advantages of the multi-scale feature discriminator. This ensures that the generation process not only focuses on the final discrimination result but also forces the matching of intermediate features at different depths of the network, thereby comprehensively constraining the synthesized samples to fit the normal data manifold; feature quantity normalization factor. The weights are dynamically adjusted according to the feature dimension of each layer to ensure the fairness of feature matching at each scale and to prevent layers with a large number of features from excessively affecting the loss value. L2 The norm squared difference measure provides a stable gradient update direction, enabling the generator to precisely adjust the feature distribution of the synthesized samples, especially maintaining high sensitivity to small anomaly shifts in the feature space, ultimately achieving a high degree of consistency between the synthesized samples and the normal data distribution in the multi-scale feature space.

[0060] In one specific embodiment, when constructing a multi-scale feature discriminator, a deep convolutional network structure with skip connections is used, and the last three convolutional layers are selected as feature extraction layers. L =3), each layer of feature maps generates a fixed-dimensional feature vector through global average pooling; when calculating the feature matching loss, for each layer of feature vectors... L2 Distance is normalized, with the normalization factor dynamically determined based on the dimension of the pooled feature vector. During training, the generator optimizes its parameters by minimizing them, ensuring that the synthesized samples maintain consistency with normal samples in both the texture details of the shallow convolutional layers and the semantic structure of the deep convolutional layers, thereby ensuring that the synthesized samples closely match the normal data distribution.

[0061] In summary, this embodiment achieves precise quantitative control of the feature matching process, ensuring that the synthesized samples strictly follow the normal data manifold in the multi-scale feature space of the multi-scale feature discriminator. This significantly improves the multi-scale feature discriminator's ability to identify subtle anomalies and effectively reduces the missed detection rate of hidden anomalies and the misclassification rate of normal samples.

[0062] Furthermore, the gradient penalty term calculation unit generates interpolated samples of synthetic and normal samples through linear interpolation; the multi-scale feature discriminator calculates the gradient of the interpolated samples to determine the gradient vector of each interpolated sample; the gradient vector is incorporated into the loss function of the multi-scale feature discriminator to obtain a multi-scale feature discriminator with smooth parameter updates.

[0063] It should be noted that the gradient penalty term is applied to the interpolation point between the real data and the generated data to force the multi-scale feature discriminator to satisfy the Lipschitz (Lipschitz continuity) constraint.

[0064] The gradient penalty term refers to a regularization loss term used to force the multi-scale feature discriminator to satisfy the Lipschitz constraint. It can be implemented by calculating the gradient norm in the input space of the multi-scale feature discriminator and adding it as a penalty term to the total loss function. The interpolation point can be understood as an intermediate data point between normal samples and synthetic samples through linear interpolation. It can be generated by randomly selecting normal samples and synthetic samples and mixing them in a certain proportion. The Lipschitz constraint means that the loss function of the multi-scale feature discriminator satisfies the Lipschitz continuity condition, that is, the rate of change of the output of the loss function is restricted to a constant range, which can ensure the stability and smoothness of the training process of the multi-scale feature discriminator.

[0065] In one specific implementation, for the generator and multi-scale feature discriminator

[0066]

[0067] in, These are the weight coefficients for the feature matching loss, which are constants. The weights of the gradient penalty term are constants; feature matching loss. The calculation formula is:

[0068] Select One intermediate layer (corresponding to) conv2_x, conv3_x, conv4_x ), The number of features in each layer; Gradient penalty term The calculation is as follows:

[0069]

[0070] in, The interpolation coefficients are in the range [0,1]; U is the standard notation for uniform distribution. express It is a random variable that is uniformly distributed in the interval [0,1], that is, The probability of selecting any value between 0 and 1 is equal; interpolation point Through real samples With synthetic samples Random sampling is generated from the connections, and this penalty term is designed to force the multi-scale feature discriminator to... The region between the real data and the generated data satisfies the 1-Lipschitz constraint.

[0071] In this embodiment, the feature matching loss weight is set to 10, and the gradient penalty term weight is also set to 10. The feature matching loss forces the generator to match the true feature distribution across multiple intermediate layers, effectively preventing the generator from degenerating into a single mode that easily deceives the multi-scale feature discriminator. The gradient penalty term replaces weight pruning with soft constraints, avoiding drastic gradient fluctuations in the multi-scale feature discriminator. The synergistic effect of both reduces the generator loss oscillation by approximately 60% in the early stages of training (the first 50 epochs), reduces the number of training iterations required to achieve the same reconstruction quality (SSIM > 0.95) from 200 epochs to 170 epochs, and accelerates convergence by approximately 15%.

[0072] Specifically, this application introduces a gradient penalty term to optimize the loss function of the multi-scale feature discriminator during adversarial training. The gradient penalty term acts on the interpolation point between normal and synthetic samples, forcing the multi-scale feature discriminator to satisfy the Lipschitz constraint. In each training iteration, the interpolation point between normal and synthetic samples is first generated, then the gradient norm of the multi-scale feature discriminator at that interpolation point is calculated and added as a penalty term to the loss function. Clearly, this gradient-based soft constraint method avoids hard parameter truncation, making the optimization process of the multi-scale feature discriminator smoother and more continuous, effectively mitigating the oscillation phenomenon caused by parameter mutations in the early stages of training. Simultaneously, since the interpolation point covers the continuous manifold space between normal and synthetic samples, the effectiveness of the constraint in the data distribution transition region is ensured, thereby preventing the multi-scale feature discriminator from exhibiting overly sensitive discriminative behavior at the distribution boundary, avoiding the loss of normal data diversity learning due to pattern collapse, and ultimately ensuring the global smoothness of the loss function, enabling the generator to more comprehensively capture subtle feature changes in normal data.

[0073] As a preferred embodiment, in adversarial training, for each training batch, normal samples and synthetic samples are randomly selected, and interpolation points are generated through linear interpolation. Then, the gradient of the multi-scale feature discriminator at that interpolation point is calculated, and the square of the gradient norm is added as a penalty term to the loss function. For example, a random number generator can be used to determine the interpolation ratio, ensuring that the interpolation points are evenly distributed between the real and generated data.

[0074] Through the above methods, this application effectively alleviates the oscillation phenomenon during the training process, prevents pattern collapse, and enables the generator to more comprehensively cover the diverse distribution of normal data, thereby reducing the false positive rate of marginal normal samples and improving the ability to detect hidden anomalies.

[0075] In one specific embodiment, the dynamic weight adjustment mechanism adaptively calculates the comprehensive anomaly score based on the reconstruction error and discriminator confidence of the current batch of data. Therefore, the weight coefficients are crucial. To improve the accuracy of the comprehensive anomaly score, the dynamic weight adjustment module includes a reconstruction error calculation unit, a distribution variance calculation unit, a weight correction unit, and a comprehensive anomaly score determination unit. The module revises the weights of the discriminator confidence based on the distribution variance of the sample sequence and outputs the comprehensive anomaly score for each sample. This includes: obtaining reconstructed samples of the sample sequence based on the reconstruction error calculation unit, and determining the reconstruction error for each sample based on the sample sequence and the reconstructed samples; determining the distribution variance of the test discriminator confidence based on the distribution variance of the test discriminator corresponding to the sample sequence, and determining the distribution variance of the reconstruction error based on the reconstruction error; determining the target weight of the discriminator confidence based on the distribution variance of the test discriminator confidence and the distribution variance of the reconstruction error based on the weight correction unit; and determining the comprehensive anomaly score for each sample based on the reconstruction error, target weight, and test discriminator confidence for each sample by the comprehensive anomaly score determination unit.

[0076] Furthermore, the reconstruction error of each sample is determined based on the sample sequence and the reconstructed sample, including: determining the reconstruction error of each sample based on the mean square error between each sample and its corresponding reconstructed sample and the structural similarity index.

[0077] Specifically, the comprehensive abnormal score Due to reconstruction error and discriminator confidence The weighted calculation yields:

[0078] Among them, the weighting coefficient Based on the data in the current batch and The distribution variance is dynamically and adaptively adjusted; the larger the distribution variance, the smaller the weighting coefficient.

[0079] Comprehensive abnormal score This refers to a comprehensive indicator used to quantify the degree of sample anomaly. It can be achieved by a weighted combination of reconstruction error and discriminator confidence, aiming to integrate multi-dimensional anomaly signals to improve detection accuracy; reconstruction error This refers to the measurement of reconstruction deviation of a sample in pixel space. Specifically, it can be implemented using mean squared error, structural similarity index, or a combination thereof, reflecting the degree of anomaly of the sample at the low-level visual feature level; discriminator confidence. Specifically, it refers to the sample authenticity probability value output by the multi-scale feature discriminator. For example, the output based on the multi-scale feature fusion structure can serve as an indicator to evaluate the normality of a sample at the high-level semantic feature level; weight coefficients This refers to the parameter used to dynamically adjust the contribution ratio of reconstruction error to discriminator confidence. Specifically, it can be adaptively calculated based on the distribution characteristics of each indicator in the current batch of data, which can ensure the adaptability of the scoring mechanism to changes in data distribution. Distribution variance can be understood as the statistical measure of the dispersion of a certain indicator value in the current batch of data. Specifically, it can be calculated using statistical methods such as sample variance or standard deviation, which can quantify the reliability of the indicator and guide the weight allocation.

[0080] In one specific implementation, for the test sample Calculate its reconstructed sample for: ; in, Indicates the test sample Find the expected value of the probability distribution.

[0081] Calculate reconstruction error :

[0082] in , The preset balance coefficient; Obtain the discriminator confidence ; Calculate the current batch of data and Distribution variance and ; Dynamically adjust weighting coefficients :

[0083] Clearly, the dynamic weight adjustment mechanism ensures that when the variance of a certain indicator (such as reconstruction error) increases due to drastic changes in illumination within a batch, its weight is automatically reduced, and the system relies more on the semantic-level judgment of the multi-scale feature discriminator, thus avoiding batch false alarms caused by non-semantic changes. Simultaneously, the combination of MSE (=0.7) and SSIM (=0.3) makes the reconstruction error both sensitive to pixel-level defects and robust to structural anomalies. In industrial data stream testing containing batches with different illumination conditions, this mechanism, compared to fixed weights (…),… With a score of 0.5, the false positive rate was steadily reduced from an average of 15% to below 5%, achieving a reduction of 10%-18% in different scenarios.

[0084] Specifically, after the model training stabilizes, the reconstruction error in the current batch of data is calculated in real time. and discriminator confidence The distribution variance is calculated, and the weighting coefficients are dynamically determined based on the variance. Subsequently, the reconstruction error and the discriminator confidence complement are weighted and fused using this weighting coefficient to generate a comprehensive anomaly score. When the reconstruction error or the variance of the discriminator confidence distribution increases, the weight ratio of this indicator in the overall score is automatically reduced, so that the overall anomaly score can adaptively respond to changes in data distribution and ensure that it can maintain a stable anomaly detection effect even in scenarios with fluctuating data flow.

[0085] In one specific implementation, in an industrial defect detection scenario, when processing a new batch of product image data, the reconstruction error of all samples in that batch is first calculated. and discriminator confidence Then statistics and Their respective sample variances; if found The variance is significantly higher than The variance will automatically decrease. The value makes the overall anomaly score S depend more on the discriminant confidence complement (1). Finally, the comprehensive anomaly score for each sample is calculated based on the adjusted weights and compared with the dynamic threshold to determine anomalies.

[0086] In summary, the anomaly scoring mechanism of this application can dynamically adjust the weights according to the current data distribution characteristics, effectively overcoming the problem of rigid scoring mechanisms, significantly improving the detection stability in data flow fluctuation scenarios, and reducing the false alarm rate caused by changes in data distribution.

[0087] Furthermore, single pixel-level reconstruction errors are sensitive to noise and irrelevant texture changes, and cannot effectively distinguish between semantic-level anomalies and normal changes, leading to a decrease in the accuracy of anomaly detection. Therefore, reconstruction errors... A combination of mean squared error and structural similarity index is used, namely:

[0088] in, This is a normal sample; To reconstruct the sample; and The constant coefficients are preset; mean square error This refers to calculating the average of the sum of squared differences in pixel values ​​between normal samples and reconstructed samples. Specifically, this can be achieved by comparing pixels one by one and calculating the mean of the squared errors. (Mean squared error) It can provide fine-grained information on local changes; the Structural Similarity Index (SSIM) is a metric for measuring the structural similarity of images. It can be obtained by comparing the similarity between normal samples and reconstructed samples in three dimensions: brightness, contrast, and structure, and can perceive higher-level semantic anomalies; the balance coefficient... and This refers to the preset weight parameters, which can be set to fixed values ​​based on experience, or dynamically adjusted according to actual needs, thereby adjusting the relative contributions of mean square error and structural similarity index to reconstruction error.

[0089] In this embodiment, the reconstruction error is defined by combining mean squared error and structural similarity index, so that the reconstruction error can simultaneously capture the precise differences at the pixel value level and the semantic features at the image structure level. The mean squared error part provides sensitivity to local changes based on pixel value differences, while the part of 1 minus SSIM quantifies the dissimilarity of brightness, contrast and structure, enhancing robustness to semantic anomalies. Through a preset balance coefficient, this combination retains the sensitivity of pixel-level precision and incorporates the stability of structure perception during the calculation process, thereby more accurately reflecting the true degree of anomaly of the sample.

[0090] In one specific implementation, the task of detecting surface defects in industrial products is carried out as follows: When processing image samples to be detected, reconstructed samples are obtained through an encoder and generator. The mean squared error and structural similarity index between the reconstructed sample and the original sample are calculated, and the two are weighted and combined according to a preset balance coefficient to obtain the reconstruction error. For example, the balance coefficient... and These values ​​can be set to higher and lower values ​​respectively to adapt to the noise characteristics of different datasets.

[0091] In this embodiment, the reconstruction error can effectively distinguish between semantic-level anomalies and normal changes, reducing misjudgments caused by noise or slight positional changes, as well as missed detections caused by high-level semantic anomalies with small pixel-level changes, thereby improving the accuracy and reliability of anomaly detection.

[0092] In one specific embodiment, after obtaining the comprehensive anomaly score of a sample, it is also necessary to determine whether the sample is an anomalous sample. Therefore, the adversarial generative network system also includes a sample classification module, which is used to determine that the sample is an anomalous sample when the comprehensive anomaly score is greater than a dynamic threshold. The dynamic threshold is periodically updated based on the statistical percentile of the sample sequence.

[0093] It should be noted that the dynamic threshold is not a fixed value, but is determined by calculating the statistical percentile of the comprehensive abnormal scores of all training normal samples, and is periodically updated based on the real-time data stream during the inference phase.

[0094] Specifically, dynamic threshold refers to a threshold setting mechanism that adaptively adjusts based on data distribution characteristics. It can be obtained using calculation methods based on statistical distribution characteristics, thereby avoiding misjudgments caused by fixed thresholds when data distribution changes. Among them, statistical percentile is a statistical indicator used to quantify the boundaries of normal data distribution. It can be obtained by using preset percentile intervals, thereby objectively reflecting the distribution pattern of abnormal scores in normal samples and reducing subjective bias caused by human setting. Periodic update refers to the operation process of dynamically adjusting the threshold during the inference stage. It can be implemented using triggering mechanisms based on time windows or sample accumulation, thereby continuously tracking changes in the statistical characteristics of the data stream and maintaining the matching of the threshold with the current data distribution.

[0095] In one specific implementation, the comprehensive abnormality score distribution of the training normal samples is calculated. Percentile as the initial dynamic threshold ; Test samples and Compare: like It was determined to be an abnormal sample; Otherwise, it is judged as a normal sample; During the reasoning phase, each process After 100 samples, based on the most recent Update threshold for the score distribution of each sample .

[0096] This scheme sets each process... N =After 1000 samples, based on the most recent M =Recalculate the score distribution of 5000 samples Percentiles are used as the new threshold. This sliding window-style periodic update mechanism allows the judgment criteria to closely follow the slow data distribution drift caused by seasonality, raw material changes, or equipment wear and tear in the production environment. In a simulated deployment test lasting up to 6 months, the system performance (F1 score) without threshold updates degraded by more than 20%, while the system performance degradation using this dynamic threshold technology was controlled to within 5%, demonstrating excellent long-term environmental adaptability.

[0097] In this embodiment, by systematically analyzing the comprehensive abnormal score distribution of all normal samples during the training phase, the statistical percentile is used to accurately define the boundary range of normal data, thereby establishing an initial threshold closely related to the intrinsic characteristics of the data. During the inference phase, the threshold update operation is periodically performed based on the real-time input data stream, and the statistical regularity of the new data is integrated into the threshold calculation process, forming a closed-loop optimization mechanism from training to inference, which effectively addresses the challenges brought about by data distribution drift.

[0098] In one specific implementation, in an industrial production line defect detection scenario, the dynamic threshold is determined based on the statistical distribution of the comprehensive anomaly scores of all qualified product images during the training phase; during actual operation, the threshold is periodically recalculated based on the continuously flowing production line detection data to adapt to minor changes caused by lighting conditions or equipment wear.

[0099] In this embodiment, the dynamic threshold can significantly improve the stability of anomaly detection in dynamic environments, ensuring that the threshold always remains consistent with the current data distribution characteristics, thereby reducing the false alarm rate and false negative rate caused by data distribution drift.

[0100] This invention also provides a sample generation method based on an adversarial generative network system; please refer to [link to relevant documentation]. Figure 2 , Figure 2 A flowchart illustrating an embodiment of the sample generation method based on an adversarial generative network system provided by the present invention includes: S201: Generate multiple test synthetic samples corresponding to the target sample based on an adversarial generative network system; S202: Determine the test synthetic sample whose comprehensive anomaly score is greater than the preset threshold as the target generated sample of the target sample.

[0101] In this embodiment, by selecting test synthetic samples with a comprehensive anomaly score greater than a preset threshold as target generated samples, samples with significant abnormal characteristics or that meet the target requirements can be retained, thereby improving the relevance and effectiveness of the target generated samples.

[0102] In one specific embodiment, please refer to Figure 3 , Figure 3The flowchart of an embodiment of the sample generation method provided by the present invention is as follows: First, data preprocessing and latent space construction are performed; then, the multi-scale feature discriminator is constructed. Due to the adoption of a multi-scale feature discriminator structure, the last three layers of convolutional feature maps are pooled and concatenated through skip connections, effectively fusing shallow texture features and deep semantic features. This improves the model's sensitivity to detecting subtle and hidden anomalies by approximately 25%, significantly reduces the false negative rate, and improves discrimination accuracy. Subsequently, adversarial training and feature matching are performed. Due to the introduction of a collaborative stabilization mechanism between feature matching loss and gradient penalty term, the feature matching loss constrains the feature distribution of synthesized samples in the intermediate layers of the multi-scale feature discriminator, and the gradient penalty term replaces weight clipping to force the multi-scale feature discriminator to satisfy Lipschit... The z-constraint and adversarial training mechanism effectively suppress pattern collapse and training oscillations, accelerating the convergence speed of the training process by 15% and enhancing training stability. Subsequently, dynamic weight adjustment and anomaly score calculation are performed. Due to the use of a dynamic weight adjustment mechanism combined with MSE+SSIM composite reconstruction error, the dynamic weights are adaptively allocated based on the variance of the current batch of data. The composite error balances pixel-level accuracy and structural similarity, enhancing the robustness of the anomaly scoring mechanism to data distribution fluctuations and noise. The false positive rate is reduced by 10%-18% in different scenarios, improving scoring reliability. Anomaly detection and output are then performed based on the calculation results. A dynamic threshold determination technique based on statistical percentiles and capable of periodic updates is used. The threshold is determined based on the score distribution of normal training samples and updated periodically during the inference phase. This technique enables the system to adapt to changes in the data flow, with a performance degradation rate of less than 5% in long-term deployment, improving system adaptability.

[0103] This invention also provides an electronic device, such as... Figure 4 As shown, Figure 4 This is a schematic diagram of an embodiment of the electronic device provided by the present invention, specifically: The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will understand that... Figure 4 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein: The processor 401 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines. By running or executing software programs and / or modules stored in the memory 402, and by calling data stored in the memory 402, it performs various functions and processes data, thereby providing overall monitoring of the electronic device. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor. The application processor mainly handles the operation of the storage medium, user interface, and application programs, while the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 401.

[0104] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area. The program storage area may store applications required for operating the storage medium and at least one function (such as sound playback function, image playback function, etc.); the data storage area may store data created according to the use of the electronic device. In addition, the memory 402 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.

[0105] The electronic device also includes a power supply 403 that supplies power to various components. Preferably, the power supply 403 can be logically connected to the processor 401 via a power management storage medium, thereby enabling functions such as charging, discharging, and power consumption management through the power management storage medium. The power supply 403 may also include one or more DC or AC power supplies, recharge storage media, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0106] The electronic device may also include an input unit 404, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0107] Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 401 in the electronic device loads the executable files corresponding to the processes of one or more applications into the memory 402 according to the following instructions, and the processor 401 runs the applications stored in the memory 402 to realize various functions, as follows: Multiple test synthetic samples corresponding to the target sample are generated based on an adversarial generative network system; Test synthetic samples with an overall anomaly score greater than a preset threshold are identified as target generated samples for the target samples.

[0108] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0109] Therefore, embodiments of the present invention provide a computer-readable storage medium storing a computer program thereon, the computer program being loaded by a processor to execute the steps in any of the sample generation methods based on an adversarial generative network system provided by the present invention. For example, the computer program, when loaded by a processor, can execute the following steps: Multiple test synthetic samples corresponding to the target sample are generated based on an adversarial generative network system; Test synthetic samples with an overall anomaly score greater than a preset threshold are identified as target generated samples for the target samples.

[0110] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0111] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0112] Since the computer program stored in the computer-readable storage medium can execute the steps in any of the sample generation methods based on adversarial generative network systems provided by the present invention, it can achieve the beneficial effects that any of the sample generation methods based on adversarial generative network systems provided by the present invention can achieve, as detailed in the preceding embodiments, which will not be repeated here.

[0113] The above provides a detailed description of the adversarial generative network system and sample generation method provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. An adversarial generative network system, characterized in that, include: The generation module is used to generate multiple synthetic samples based on multiple normal samples; A multi-scale feature discriminator is used to fuse multiple feature maps of each sample to obtain multi-scale fused features, and to determine the discriminator confidence of each sample based on the multi-scale fused features. The adversarial training module is used to calculate the feature matching loss and gradient penalty term between the synthetic sample and the normal sample, and update the network parameters of the generation module based on the feature matching loss, and update the network parameters of the multi-scale feature discriminator based on the gradient penalty term. The dynamic weight adjustment module is used to revise the weights of the discriminator confidence based on the distribution variance of the sample sequence and output the comprehensive anomaly score for each sample.

2. The adversarial generative network system according to claim 1, characterized in that, The generation module includes a generator, a data augmentation unit, and an encoder; The process of generating multiple synthetic samples based on multiple normal samples includes: The data augmentation unit performs data augmentation processing on multiple normal samples to obtain augmented samples; The augmented sample is input into the encoder to obtain the latent space vector of the augmented sample, and the latent space distribution of normal data is constructed based on the latent space vector; The generator is used to generate the plurality of synthetic samples based on the potential spatial distribution of the normal data.

3. The adversarial generative network system according to claim 2, characterized in that, The generator and the encoder together form a self-encoder structure; The generator generates potential reconstruction samples based on the potential spatial distribution of the normal data; The encoder updates its parameters based on the potential reconstruction error of the potential reconstruction sample until it obtains the minimum potential reconstruction error value. The generator also updates its parameters based on the potential reconstruction error.

4. The adversarial generative network system according to claim 1, characterized in that, The multi-scale feature discriminator includes a deep convolutional network with skip connections, an average pooling layer, a vector fusion layer, and a fully connected layer. The process of fusing multiple feature maps for each sample to obtain multi-scale fused features, and determining the discriminator confidence for each sample based on the multi-scale fused features, includes: Each sample is input into the deep convolutional network with skip connections to obtain multiple feature maps of each sample at different levels; The average pooling layer performs global average pooling on multiple feature maps in the last multiple layers to obtain the feature vector of each feature map. The vector fusion layer fuses multiple feature vectors into a single fused feature vector, and the fully connected layer determines the discriminator confidence of each sample based on the fused feature vector.

5. The adversarial generative network system according to claim 1, characterized in that, The adversarial training module includes a feature matching loss calculation unit and a gradient penalty term calculation unit; the calculation of the feature matching loss and gradient penalty term between the synthetic sample and the normal sample, and the updating of the network parameters of the generation module based on the feature matching loss, and the updating of the network parameters of the multi-scale feature discriminator based on the gradient penalty term, includes: The feature matching loss calculation unit determines the feature matching loss based on the difference in feature output between the synthetic sample and the normal sample at each level; The generation module is also used to update the network parameters of each layer in reverse according to the feature matching loss, so as to reduce the feature matching loss value; The gradient penalty term calculation unit determines the gradient penalty term based on the gradient of the weighted sample of the synthetic sample and the normal sample; The multi-scale feature discriminator is also used to update the network parameters of each layer in reverse based on the gradient penalty term, so as to reduce the value of the gradient penalty term.

6. The adversarial generative network system according to claim 5, characterized in that, The gradient penalty term calculation unit generates interpolated samples of the synthetic sample and the normal sample through linear interpolation; The multi-scale feature discriminator performs gradient calculation on the interpolated samples to determine the gradient vector of each interpolated sample; The gradient vector is incorporated into the loss function of the multi-scale feature discriminator to obtain a multi-scale feature discriminator with smoothly updated parameters.

7. The adversarial generative network system according to claim 1, characterized in that, The dynamic weight adjustment module includes a reconstruction error calculation unit, a distribution variance calculation unit, a weight correction unit, and a comprehensive anomaly score determination unit; the step of revising the weights of the discriminator confidence score based on the distribution variance of the sample sequence and outputting the comprehensive anomaly score for each sample includes: The reconstruction error calculation unit obtains the reconstructed samples of the sample sequence and determines the reconstruction error of each sample based on the sample sequence and the reconstructed samples. Based on the distribution variance calculation unit, the test discriminator confidence distribution variance is determined according to the test discriminator confidence corresponding to the sample sequence, and the reconstruction error distribution variance is determined according to the reconstruction error; The weight correction unit determines the target weight of the discriminator confidence based on the variance of the test discriminator confidence distribution and the variance of the reconstruction error distribution; The comprehensive anomaly score determination unit determines the comprehensive anomaly score for each sample based on the reconstruction error of each sample, the target weight, and the confidence of the test discriminator.

8. The adversarial generative network system according to claim 7, characterized in that, The step of determining the reconstruction error of each sample based on the sample sequence and the reconstructed sample includes: The reconstruction error of each sample is determined based on the mean squared error between each sample and its corresponding reconstructed sample and the structural similarity index.

9. The adversarial generative network system according to claim 1, characterized in that, The adversarial generative network system further includes a sample classification module, which is used to determine that the sample is an abnormal sample when the comprehensive anomaly score is greater than a dynamic threshold. The dynamic threshold is periodically updated based on the statistical percentile of the sample sequence.

10. A sample generation method based on an adversarial generative network system, characterized in that, include: The adversarial generative network system according to any one of claims 1-9 generates multiple test synthetic samples corresponding to the target sample; The test synthetic sample whose comprehensive anomaly score is greater than a preset threshold is determined as the target generated sample of the target sample.