Adversarial network training method, adversarial network training device, medium and equipment

By sharing the feature extraction network, the generator and the discriminator share the network structure, which solves the problems of low training efficiency and high resource consumption in the existing technology, and achieves efficient training and resource saving of the adversarial network.

CN118569351APending Publication Date: 2024-08-30GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202310185222.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-02-28
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

The existing semantic adversarial network training efficiency is low, and the generator and discriminator are large in size and occupy a lot of computing and storage resources.

Method used

Using a shared feature extraction network, the generator and the discriminator share the same network structure, thus lightweighting the generator and the discriminator. It only needs to generate the mask features of the sample features and the recognition results of the reference features, and adjust the network parameters based on these results. train.

Benefits of technology

It improves the training efficiency of the adversarial network, reduces the consumption of computing and storage resources, makes the generator and discriminator smaller, and saves resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118569351A
    Figure CN118569351A
Patent Text Reader

Abstract

The invention provides an adversarial network training method, an adversarial network training device, a computer readable storage medium and electronic equipment, and relates to the technical field of deep learning, and the method can consider a similar network structure of a generator and a discriminator, and determines the similar network structure as a shared feature extraction network. The shared feature extraction network is shared by the generator and the discriminator, so that the generator and the discriminator are lightened, only mask features corresponding to the sample features need to be generated for the lightened generator, only mask recognition results corresponding to the reference features need to be generated for the lightened discriminator, and then the mask recognition results corresponding to the reference features need to be generated for the lightened discriminator. The adversarial network can be trained by adjusting the network parameters of the adversarial network on the basis of the mask recognition result, and compared with a generator with a large volume and a discriminator with a large volume in the prior art, the training efficiency can be improved by training the adversarial network designed by the invention.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of deep learning technology, and more specifically, to an adversarial network training method, an adversarial network training device, a computer-readable storage medium, and an electronic device. Background Art

[0002] Adversarial networks are deep learning models that consist of a generator and a discriminator. The generator is used to generate fake data similar to real data, while the discriminator is used to distinguish between real data and fake data. During the training process, the generator and the discriminator are alternating and continuously optimizing their own parameters until the generator can generate fake data that is closer and closer to real data, while the discriminator has difficulty distinguishing between real data and fake data.

[0003] Generally speaking, for semantic adversarial networks, it is necessary to mask the input corpus to a certain extent, and trigger the generator to predict the real data corresponding to the mask through feature extraction and other means, and input the prediction result into the discriminator, so that the discriminator can determine whether the prediction result is real data through feature extraction and other means. The adversarial network can be trained through the loss between the judgment result and the real data. However, this method has the problem of low training efficiency.

[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present application, and therefore may include information that does not constitute relevant technology known to ordinary technicians in the field. Summary of the invention

[0005] The purpose of the present application is to provide an adversarial network training method, an adversarial network training device, a computer-readable storage medium and an electronic device, which can take into account the same network structure of a generator and a discriminator, and determine the same network structure as a shared feature extraction network, so that the generator and the discriminator share the shared feature extraction network, thereby lightweighting the generator and the discriminator. For a lightweight generator, it is only necessary to generate mask features corresponding to sample features. For a lightweight discriminator, it is necessary to generate mask recognition results corresponding to reference features. Then, the network parameters of the adversarial network are adjusted based on the mask recognition results to achieve training of the adversarial network. Compared with the larger generators and larger discriminators in the related art, the training efficiency can be improved by training the adversarial network designed in the present application.

[0006] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.

[0007] According to one aspect of the present application, a method for training an adversarial network is provided, wherein the adversarial network includes a generator and a discriminator, and the method includes:

[0008] Extract features from sample data through a shared feature extraction network to obtain sample features, and generate mask features corresponding to the sample features based on the generator;

[0009] The mask features are extracted through a shared feature extraction network to obtain reference features, and a mask recognition result corresponding to the reference features is generated based on the discriminator;

[0010] Adjust the network parameters of the adversarial network based on the mask recognition results.

[0011] According to one aspect of the present application, a device for training an adversarial network is provided, wherein the adversarial network includes a generator and a discriminator, and the device includes:

[0012] A first feature extraction unit, configured to extract features from sample data through a shared feature extraction network to obtain sample features, and to generate mask features corresponding to the sample features based on a generator;

[0013] A second feature extraction unit is used to extract the mask feature through a shared feature extraction network to obtain a reference feature, and generate a mask recognition result corresponding to the reference feature based on the discriminator;

[0014] The network training unit is used to adjust the network parameters of the adversarial network based on the mask recognition results.

[0015] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in the above-mentioned various optional implementations.

[0016] According to one aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, any one of the above methods is implemented.

[0017] According to one aspect of the present application, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform any one of the above methods by executing the executable instructions.

[0018] The exemplary embodiments of the present application may have some or all of the following beneficial effects:

[0019] In the adversarial network training method provided in an example embodiment of the present application, the similar network structure of the generator and the discriminator can be taken into account, and the similar network structure can be determined as a shared feature extraction network so that the generator and the discriminator share the shared feature extraction network, thereby lightweighting the generator and the discriminator. For the lightweight generator, it is only necessary to generate mask features corresponding to the sample features, and for the lightweight discriminator, it is only necessary to generate mask recognition results corresponding to the reference features. Then, the network parameters of the adversarial network are adjusted based on the mask recognition results to achieve the training of the adversarial network. Compared with the larger generators and larger discriminators in the related art, the training efficiency can be improved by training the adversarial network designed in this application. In addition, since the present application can enable the generator and the discriminator to share the above-mentioned shared feature extraction network, the adversarial network designed in this application is smaller in size than the adversarial network in the related art, which can save computing resources and storage resources.

[0020] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0022] Figure 1 A flowchart of an adversarial network training method according to an embodiment of the present application is schematically shown;

[0023] Figure 2 A schematic diagram of an adversarial network structure according to an embodiment of the present application is shown;

[0024] Figure 3 A schematic diagram of a shared block network structure according to an embodiment of the present application is shown;

[0025] Figure 4 A schematic diagram of training effect according to an embodiment of the present application is shown schematically;

[0026] Figure 5 A flowchart of an adversarial network training method according to another embodiment of the present application is schematically shown;

[0027] Figure 6 A schematic diagram of the structure of an adversarial network training device according to an embodiment of the present application is shown;

[0028] Figure 7 The structure diagram of a computer system suitable for implementing an electronic device of an embodiment of the present application is schematically shown. DETAILED DESCRIPTION

[0029] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present application will be more comprehensive and complete, and the concept of the example embodiments will be fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical solutions of the present application may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present application.

[0030] See also Figure 1 , Figure 1 The flowchart of the adversarial network training method according to an embodiment of the present application is schematically shown, and the adversarial network includes a generator and a discriminator. Figure 1 As shown, the method includes the following steps.

[0031] Step S110: extract features from the sample data through a shared feature extraction network to obtain sample features, and generate mask features corresponding to the sample features based on the generator.

[0032] Step S120: extracting features from the mask features through a shared feature extraction network to obtain reference features, and generating mask recognition results corresponding to the reference features based on the discriminator.

[0033] Step S130: adjusting the network parameters of the adversarial network based on the mask recognition result.

[0034] Implementation Figure 1The method shown can take into account the similar network structure of the generator and the discriminator, and determine the similar network structure as a shared feature extraction network so that the generator and the discriminator share the shared feature extraction network, thereby lightweighting the generator and the discriminator. For the lightweight generator, it is only necessary to generate mask features corresponding to the sample features, and for the lightweight discriminator, it is only necessary to generate mask recognition results corresponding to the reference features. Then, the network parameters of the adversarial network are adjusted based on the mask recognition results to achieve the training of the adversarial network. Compared with the larger generators and larger discriminators in the related art, the training efficiency can be improved by training the adversarial network designed in this application. In addition, since the present application can enable the generator and the discriminator to share the above-mentioned shared feature extraction network, the adversarial network designed in this application is smaller in size than the adversarial network in the related art, which can save computing resources and storage resources.

[0035] Next, the above steps of this exemplary embodiment are described in more detail.

[0036] In step S110, feature extraction is performed on sample data through a shared feature extraction network to obtain sample features, and mask features corresponding to the sample features are generated based on the generator.

[0037] Specifically, considering that in the related art, there are similar structures in the generator and the discriminator, such as word embedding layer (Embedding) and multiple block networks (N*Blocks). For the generator, it is necessary to extract features of the samples through the internal word embedding layer (Embedding) and multiple block networks (N*Blocks), and then generate false data to input into the discriminator; for the discriminator, it is also necessary to extract features of the false data through the internal word embedding layer (Embedding) and multiple block networks (N*Blocks), and then generate the judgment result for the false data. It can be seen that the generator and discriminator in the related art are large in size, which tends to occupy more computing resources and storage resources, and the training efficiency will be relatively low.

[0038] The present application conceives that the generator and the discriminator can be lightweight so that the generator and the discriminator share their similar structures, that is, a shared feature extraction network. After the sample data is feature extracted through the shared feature extraction network, the obtained sample features can be directly applied to the generator, and the generator can generate the corresponding mask features without additional processing of the sample features. The mask features can be understood as the generation results of some mask positions in the sample data, that is, the mask features are the predicted results of the mask positions in the sample data, and the predicted results may be the same as or different from the original data of the mask positions.

[0039] As an optional embodiment, the shared feature extraction network includes: a shared word embedding layer and multiple shared block networks. This can realize the sharing of similar structures to achieve lightweight generators and discriminators, which is conducive to improving the training efficiency of the adversarial network.

[0040] Specifically, the shared word embedding layer is used to extract the word vectors expected by the text, and multiple consecutive shared block networks are used to extract features from the word vectors. For multiple shared block networks, the output of the previous network is the input of the next network.

[0041] For details, please refer to Figure 2 , Figure 2 The schematic diagram of the adversarial network structure according to an embodiment of the present application is shown schematically. Figure 2 As shown, the adversarial network includes a shared feature extraction network 210, a generator (Generator LM Head) 220, and a discriminator (Discriminator Head) 230; wherein the shared feature extraction network 210 includes a shared word embedding layer (Embedding) 211 and multiple shared block networks (N*Blocks) 212. Specifically, the shared word embedding layer (Embedding) 211 is used to extract word vectors of sample data, and multiple shared block networks (N*Blocks) 212 are used to perform feature extraction on the word vectors to obtain sample features. Then, the sample features can be input into the generator (Generator LM Head) 220, so that the generator (Generator LM Head) 220 generates mask features corresponding to the sample features. The generator (Generator LMHead) 220 can input the mask features into the discriminator (Discriminator Head) 230, and the discriminator (DiscriminatorHead) 230 is used to perform feature extraction on the mask features through the shared word embedding layer (Embedding) 211 and multiple shared block networks (N*Blocks) 212 to obtain reference features, and generate mask recognition results corresponding to the reference features.

[0042] As an optional embodiment, feature extraction is performed on sample data through a shared feature extraction network to obtain sample features, including: generating a first feature vector corresponding to the sample data through a shared word embedding layer; determining the skip probability of the first network block corresponding to the generator; triggering multiple target shared block networks in multiple shared block networks that meet the skip probability of the first network block, and extracting features from the first feature vector to obtain sample features. In this way, the generator and the discriminator can share network parameters, but the generator corresponds to the skip probability of the first network block, so as to control the generator's ability to improve efficiency, thereby facilitating the effectiveness of the adversarial network.

[0043] Specifically, you can refer to the Replaced Token Detection (RTD) training strategy based on Layerdrop to improve the training efficiency of the network. The RTD training strategy based on Layerdrop is a strategy for improving the robustness of the network. During the pre-training process, the block network is randomly skipped according to the preset probability, which can improve the training speed. When the preset probability is greater than the fixed value, the block network involved in the forward and backward calculations will be reduced, which is likely to affect the network performance.

[0044] Based on this, considering the different capacity improvement efficiencies of the generator and discriminator in the adversarial network, the present application proposes that the training strategy can be applied to the adversarial network to balance the capacity improvement efficiency of the generator and discriminator by adjusting the skip probabilities of the generator and discriminator.

[0045] Specifically, a first feature vector (i.e., word vector) corresponding to the sample data can be generated through a shared word embedding layer, and then the skip probability of the first network block corresponding to the generator can be determined, wherein the skip probability of the first network block is used to indicate the skip probability for multiple shared block networks (N*Blocks). If the skip probability of the first network block = 0.6, that is, the average value of the skip probabilities corresponding to all shared block networks (Blocks) in the multiple shared block networks (N*Blocks) is equal to 0.6. For example, if the skip probability corresponding to the first shared block network (Block) in the multiple shared block networks (N*Blocks) is 0.6, it means that the probability of skipping the first shared block network (Block) is 0.6. For multiple shared block networks, the total number of shared block networks that are skipped will not exceed 60%. Further, multiple shared block networks can be traversed based on the skip probability of the first network block, and multiple target shared block networks that meet the skip probability of the first network block can extract features from the first feature vector to obtain sample features.

[0046] In addition, optionally, in each round of training, the probability of skipping the first block network can be the same or different, and in different rounds of training, the skipping results for the same layer of block networks can also be different. For example, for the first block network in the first round of training, the corresponding first block network skipping probability = 0.6, in the first round of training, the random number generated for the first block network can be greater than 0.6 or less than 0.6, and in the second round of training, the random number generated for the first block network is the same, therefore, in different rounds, the random number corresponding to the first block network may be different, and therefore, the results of whether to skip the first block network are also different.

[0047] As an optional embodiment, multiple target shared block networks that meet the skip probability of the first block network are triggered, and the first feature vector is extracted to obtain sample features, including: determining multiple target shared block networks that meet the skip probability of the first block network in multiple shared block networks; extracting the long-distance dependency features of the first feature vector through the self-attention layer in the target shared block network; extracting the context features of the first feature vector through the dynamic convolution layer in the target shared block network; generating sample features based on the long-distance dependency features and the context features. In this way, long-distance dependencies can be captured through the self-attention layer, and context modeling can be efficiently performed through the dynamic convolution layer, which is conducive to improving the convergence efficiency of training.

[0048] For details, please refer to Figure 3 , Figure 3 The following schematically shows a shared block network structure diagram according to an embodiment of the present application. Figure 3 As shown, the shared block network (Block) 300 includes: a dynamic convolution layer (Dynamic Conv) 310, a self-attention layer (Self attention) 320, Add&Norm 330, FFN 340, and Add&Norm 350. Among them, the dynamic convolution layer (Dynamic Conv) 310 includes: Linear 311, GLU 312, Linear 313, LConv 314, and Linear 315. The input of the shared block network (Block) 300 can be the first feature vector.

[0049] In a neural network, a Block usually refers to a module containing multiple layers, which is used to enhance the features in the input data and convert it into a higher-level representation. The design of the Block is to make the hierarchical structure of the neural network more modular, making the network easier to build, debug, and optimize. In this application, the parameter ShareGroup can be set to N so that adjacent N-layer blocks share weight parameters to achieve network depth with a small amount of parameters.

[0050] Specifically, the dynamic convolution layer (Dynamic Conv) 310 can dynamically adjust the convolution operation of the convolution kernel size according to the input to extract the contextual features of the first feature vector. The dynamic convolution layer (Dynamic Conv) 310 can adapt to different sizes and shapes in the input data, thereby improving the generalization ability and adaptability of the model. The dynamic convolution layer (DynamicConv) 310 can usually be implemented using deformable convolution, which is a convolution operation that adapts to inputs of different shapes by fine-tuning the sampling position of the convolution kernel. In deformable convolution, each convolution kernel position is decomposed into multiple sampling points, and each sampling point can adjust its position and weight according to the information in the input data, thereby achieving a more flexible convolution operation.

[0051] The self-attention layer 320 can extract important information from the input sequence by assigning different weights to each element in the input sequence, thereby paying more attention to important information and ignoring unimportant information, that is, extracting the long-distance dependency features of the first eigenvector.

[0052] The Add layer in Add&Norm 330 is a mathematical operation layer that adds multiple input tensors and outputs the result. It is usually used to design residual networks to increase the depth of the network while alleviating the problems of gradient vanishing and gradient exploding. The Norm layer is a normalization layer that is used to reduce the covariate drift problem between different layers in a neural network. In addition, Add&Norm 350 has the same structure as Add&Norm 330 but different parameters.

[0053] FFN 340 refers to a feed-forward neural network, i.e. a fully connected layer / multi-layer perceptron, which is used to map data to the output space and perform nonlinear transformations through activation functions. For FFN340, the parameter GroupSize can be set to N, i.e., the fully connected networks are divided into N groups, with full connections within each group and no connections between groups, to reduce the number of parameters.

[0054] Linear 311 is a linear transformation layer used to map input data to output space to output prediction results or feature representations. In addition, Linear 313, Linear 315, and Linear 311 have the same structure but different parameters.

[0055] LConv 314 refers to lightweight convolution, which usually has a small number of parameters and can reduce the computational and storage costs of the model while maintaining accuracy.

[0056] GLU 312 refers to the Gated Linear Unit, which is an activation function used to design sequence models. It can selectively pass input features through a gating mechanism, thereby improving the expressiveness and generalization capabilities of the model.

[0057] In step S120, feature extraction is performed on the mask feature through the shared feature extraction network to obtain a reference feature, and a mask recognition result corresponding to the reference feature is generated based on the discriminator.

[0058] As an optional embodiment, the mask feature is extracted through a shared feature extraction network to obtain a reference feature, and further includes: generating a second feature vector corresponding to the mask feature through a shared word embedding layer; determining the skip probability of the second network corresponding to the discriminator; wherein the skip probability of the second network is less than the skip probability of the first network; triggering multiple target shared block networks in multiple shared block networks that meet the skip probability of the second network, and extracting features from the second feature vector to obtain a reference feature. In this way, the generator and the discriminator can share the network parameters of the shared feature extraction network, but the discriminator corresponds to the skip probability of the second network, and the skip probability of the second network is less than the skip probability of the first network, so as to control the ability improvement efficiency of the discriminator, which is originally difficult to improve, to be greater than that of the generator, so that the discriminator and the generator can be improved synchronously.

[0059] Specifically, a second feature vector (i.e., word vector) corresponding to the mask feature can be generated through a shared word embedding layer, and then the second block network skip probability corresponding to the discriminator can be determined, wherein the second block network skip probability is used to indicate the skip probability for multiple shared block networks (N*Blocks). If the second block network skip probability = 0.5, that is, the average value of the skip probabilities corresponding to all shared block networks (Blocks) in the multiple shared block networks (N*Blocks) is equal to 0.6. For example, if the skip probability corresponding to the first shared block network (Block) in the multiple shared block networks (N*Blocks) is 0.5, it means that the probability of skipping the first shared block network (Block) is 0.5. Further, multiple shared block networks can be traversed based on the second block network skip probability, and multiple target shared block networks that meet the second block network skip probability can extract features from the second feature vector to obtain reference features.

[0060] In addition, optionally, in each round of training, the skipping probability of the second network block may be the same or different, and in different rounds of training, the skipping results for the same layer of the network block may also be different.

[0061] As an optional embodiment, for multiple ordered shared block networks, the shared block network sequence number is positively correlated with the block network skip probability; or, multiple shared block networks correspond to the same block network skip probability. In this way, by controlling the relationship between the block network skip probability and multiple shared block networks, probability settings based on different training objectives can be achieved, which is conducive to making the adversarial network structure adaptable to different application scenarios.

[0062] Specifically, if the shared block network sequence number is positively correlated with the block network skip probability, the block network skip probability will increase with the increase of the shared block network sequence number. It can be understood that the larger the shared block network sequence number, the greater the block network skip probability, that is, the earlier shared block networks are less likely to be skipped, and the later shared block networks are more likely to be skipped. In addition, if multiple shared block networks correspond to the same block network skip probability, it means that the block network skip probabilities corresponding to each shared block network are consistent.

[0063] In step S130, the network parameters of the adversarial network are adjusted based on the mask recognition result.

[0064] Specifically, network parameters may include but are not limited to: the number of hidden layers num_hidden_layers, the number of neurons in the hidden layer hidden_size, the number of attention heads num_attention_heads, the number of neurons in the intermediate layer intermediate_size, the dimension size of the input embedding vector embedding_size, the ratio self_attn_ratio used to calculate QKV in the self-attention mechanism, the number of groups in the grouped convolution num_groups, and the parameter share_groups of the shared grouped convolution in the grouped convolution. The adversarial network trained in this application can be applicable to network requirements of various parameter magnitudes, and can be used in conjunction with lightweight solutions such as matrix low-rank decomposition, pruning, and distillation.

[0065] For details, please refer to Figure 4 , Figure 4 The following is a schematic diagram showing the training effect according to an embodiment of the present application. Figure 4 As shown, the lightweight adversarial network trained through the above steps has higher convergence efficiency than the adversarial network of related technologies.

[0066] As an optional embodiment, adjusting the network parameters of the adversarial network based on the mask recognition result includes: determining the loss function between the mask recognition result and the sample data; adjusting the network parameters corresponding to the shared word embedding layer, multiple shared block networks, the generator, and the discriminator according to the loss function. In this way, network training based on the loss function of the mask recognition result and the sample data can be implemented on the basis of the shared network parameters of the generator and the discriminator. Since the shared feature extraction network is shared by the generator and the discriminator, there is no need to set the word embedding layer and the block network in the generator and the discriminator, thereby improving the efficiency of network training.

[0067] Specifically, the loss function between the mask feature and the sample data can also be determined, and the network parameters of the adversarial network can be adjusted by combining the loss function between the mask recognition result and the sample data.

[0068] In addition, optionally, the adversarial network can be verified through the Tinyclue task, and the task effect of the adversarial network can be determined based on the verification results (i.e., the scores of each task in the Tinyclue task). Among them, Tinyclue can be understood as a benchmark library of natural language processing (NLP) tasks and data sets, which aims to help relevant personnel develop and evaluate NLP models. Tinyclue tasks may include but are not limited to the following subtasks: a question-answer matching task (Ant Financial Question Matching Challenge) for determining the semantic similarity between two questions, a Chinese news classification task (TNEWS) for classifying short texts into different news categories, a speech recognition evaluation task (IFYTEK) for converting speech signals into corresponding texts, a Chinese natural language inference task (CMNLI) for determining the logical relationship between sentences, a natural language inference task (WSC) for determining the referent of a pronoun in a sentence based on the context, a semantic similarity task (CSL) for measuring the semantic similarity between two Chinese sentences, and a natural language inference task (OCNLI) for determining the logical relationship between Chinese sentences.

[0069] See also Figure 5 , Figure 5 The flowchart of the adversarial network training method according to another embodiment of the present application is schematically shown. Figure 5 As shown, the adversarial network training method includes: steps S510 to S530.

[0070] Step S510: Generate a first feature vector corresponding to the sample data through a shared word embedding layer.

[0071] Step S512: Determine the skip probability of the first network block corresponding to the generator.

[0072] Step S514: Determine multiple target shared block networks that meet the first block network skip probability among multiple shared block networks; wherein, for multiple ordered shared block networks, the shared block network sequence number is positively correlated with the block network skip probability; or, multiple shared block networks correspond to the same block network skip probability.

[0073] Step S516: Extract the long-distance dependency features of the first feature vector through the self-attention layer in the target shared block network.

[0074] Step S518: extracting context features of the first feature vector through the dynamic convolutional layer in the target shared block network.

[0075] Step S520: Generate sample features based on the long-distance dependency features and the context features, and generate mask features corresponding to the sample features based on the generator.

[0076] Step S522: Generate a second feature vector corresponding to the mask feature through the shared word embedding layer.

[0077] Step S524: determining the skip probability of the second network block corresponding to the discriminator; wherein the skip probability of the second network block is less than the skip probability of the first network block.

[0078] Step S526: trigger multiple target shared block networks in the multiple shared block networks that meet the skipping probability of the second block network, perform feature extraction on the second feature vector to obtain a reference feature, and generate a mask recognition result corresponding to the reference feature based on the discriminator.

[0079] Step S528: Determine the loss function between the mask recognition result and the sample data.

[0080] Step S530: Adjust the network parameters corresponding to the shared word embedding layer, multiple shared block networks, the generator, and the discriminator according to the loss function.

[0081] It should be noted that steps S510 to S530 are Figure 1 The steps and their embodiments shown correspond to each other. For the specific implementation of steps S510 to S530, please refer to Figure 1 The steps and embodiments shown are not described in detail here.

[0082] It can be seen that the implementation Figure 5The method shown can take into account the similar network structure of the generator and the discriminator, and determine the similar network structure as a shared feature extraction network so that the generator and the discriminator share the shared feature extraction network, thereby lightweighting the generator and the discriminator. For the lightweight generator, it is only necessary to generate mask features corresponding to the sample features, and for the lightweight discriminator, it is only necessary to generate mask recognition results corresponding to the reference features. Then, the network parameters of the adversarial network are adjusted based on the mask recognition results to achieve the training of the adversarial network. Compared with the larger generators and larger discriminators in the related art, the training efficiency can be improved by training the adversarial network designed in this application. In addition, since the present application can enable the generator and the discriminator to share the above-mentioned shared feature extraction network, the adversarial network designed in this application is smaller in size than the adversarial network in the related art, which can save computing resources and storage resources.

[0083] See also Figure 6 , Figure 6 The structure block diagram of the adversarial network training device in one embodiment of the present application is schematically shown, and the adversarial network includes a generator and a discriminator. Figure 6 As shown, the adversarial network training device 600 may include the following units.

[0084] A first feature extraction unit 601 is used to extract features from sample data through a shared feature extraction network to obtain sample features, and to generate mask features corresponding to the sample features based on a generator;

[0085] A second feature extraction unit 602 is used to extract the mask feature through a shared feature extraction network to obtain a reference feature, and generate a mask recognition result corresponding to the reference feature based on the discriminator;

[0086] The network training unit 603 is used to adjust the network parameters of the adversarial network based on the mask recognition result.

[0087] It can be seen that the implementation Figure 6The device shown can take into account the similar network structure of the generator and the discriminator, and determine the similar network structure as a shared feature extraction network so that the generator and the discriminator share the shared feature extraction network, thereby lightweighting the generator and the discriminator. For the lightweight generator, it is only necessary to generate mask features corresponding to the sample features, and for the lightweight discriminator, it is only necessary to generate mask recognition results corresponding to the reference features. Then, the network parameters of the adversarial network are adjusted based on the mask recognition results to achieve the training of the adversarial network. Compared with the larger generators and larger discriminators in the related art, the training efficiency can be improved by training the adversarial network designed in this application. In addition, since the present application can enable the generator and the discriminator to share the above-mentioned shared feature extraction network, the adversarial network designed in this application is smaller in size than the adversarial network in the related art, which can save computing resources and storage resources.

[0088] As an optional embodiment, the shared feature extraction network includes: a shared word embedding layer and multiple shared block networks.

[0089] It can be seen that the implementation of this optional embodiment can achieve the sharing of similar structures to achieve lightweight generators and discriminators, which is beneficial to improving the training efficiency of the adversarial network.

[0090] As an optional embodiment, feature extraction is performed on sample data through a shared feature extraction network to obtain sample features, including:

[0091] Generate a first feature vector corresponding to the sample data through a shared word embedding layer;

[0092] Determine the first network skip probability corresponding to the generator;

[0093] A plurality of target shared block networks that satisfy the skipping probability of the first network block among the plurality of shared block networks are triggered, and feature extraction is performed on the first feature vector to obtain sample features.

[0094] It can be seen that implementing this optional embodiment can make the generator and the discriminator share network parameters, but make the generator correspond to the probability of skipping the first network block to control the generator's ability to improve efficiency, which is beneficial to improving the effectiveness of the adversarial network.

[0095] As an optional embodiment, triggering multiple target shared block networks that meet the skip probability of the first block network in the multiple shared block networks, and extracting features from the first feature vector to obtain sample features, including:

[0096] Determine multiple target shared block networks that satisfy the skipping probability of the first block network among the multiple shared block networks;

[0097] Extract the long-range dependency features of the first feature vector through the self-attention layer in the target shared block network;

[0098] Extracting context features of the first feature vector through a dynamic convolutional layer in a target shared block network;

[0099] Generate sample features based on long-distance dependency features and context features.

[0100] It can be seen that by implementing this optional embodiment, long-distance dependencies can be captured through the self-attention layer, and context modeling can be efficiently performed through the dynamic convolution layer, which is beneficial to improving the convergence efficiency of training.

[0101] As an optional embodiment, the mask feature is extracted through a shared feature extraction network to obtain a reference feature, and further includes:

[0102] Generate a second feature vector corresponding to the mask feature through a shared word embedding layer;

[0103] Determine the skip probability of the second network block corresponding to the discriminator; wherein the skip probability of the second network block is less than the skip probability of the first network block;

[0104] Trigger multiple target shared block networks that meet the skipping probability of the second block network in the multiple shared block networks, and perform feature extraction on the second feature vector to obtain reference features.

[0105] It can be seen that the implementation of this optional embodiment can make the generator and the discriminator share the network parameters of the shared feature extraction network, but make the discriminator correspond to the skipping probability of the second network block, and the skipping probability of the second network block is smaller than the skipping probability of the first network block, so as to control the ability improvement efficiency of the discriminator, which is originally more difficult to improve, to be greater than that of the generator, so that the discriminator and the generator can be improved synchronously.

[0106] As an optional embodiment, for a plurality of ordered shared block networks, the shared block network sequence number is positively correlated with the block network skip probability; or, the plurality of shared block networks correspond to the same block network skip probability.

[0107] It can be seen that by implementing this optional embodiment, the relationship between the block network skipping probability and multiple shared block networks can be controlled, and the probability setting based on different training objectives can be achieved, which is conducive to making the adversarial network structure adaptable to different application scenarios.

[0108] As an optional embodiment, adjusting the network parameters of the adversarial network based on the mask recognition result includes:

[0109] Determine the loss function between the mask recognition result and the sample data;

[0110] According to the loss function, the network parameters corresponding to the shared word embedding layer, multiple shared block networks, generators, and discriminators are adjusted.

[0111] It can be seen that by implementing this optional embodiment, it is possible to implement network training based on the loss function of mask recognition results and sample data on the basis of the shared network parameters of the generator and the discriminator. Since the shared feature extraction network is shared by the generator and the discriminator, there is no need to set a word embedding layer and a block network in the generator and the discriminator, thereby improving the efficiency of network training.

[0112] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0113] Since the various functional modules of the adversarial network training device of the example embodiment of the present application correspond to the steps of the example embodiment of the adversarial network training device described above, for details not disclosed in the device embodiment of the present application, please refer to the embodiment of the adversarial network training device described above in the present application.

[0114] See also Figure 7 , Figure 7 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.

[0115] It should be noted that Figure 7 The computer system 700 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0116] like Figure 7 As shown, computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. Various programs and data required for system operation are also stored in RAM 703. CPU 701, ROM 702 and RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to bus 704.

[0117] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.

[0118] In particular, according to an embodiment of the present application, the process described below with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 709, and / or installed from a removable medium 711. When the computer program is executed by a central processing unit (CPU) 701, various functions defined in the method and apparatus of the present application are executed.

[0119] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the method in the above embodiment.

[0120] It should be noted that the computer-readable medium shown in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0121] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0122] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.

[0123] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary technical means in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the claims.

Claims

1. A method for training an adversarial network, characterized in that: The adversarial network includes a generator and a discriminator, including: Extracting features from sample data through a shared feature extraction network to obtain sample features, and generating mask features corresponding to the sample features based on the generator; Extracting features from the mask features through the shared feature extraction network to obtain reference features, and generating mask recognition results corresponding to the reference features based on the discriminator; The network parameters of the adversarial network are adjusted based on the mask recognition result.

2. The method according to claim 1, characterized in that The shared feature extraction network includes: a shared word embedding layer and multiple shared block networks.

3. The method according to claim 2, characterized in that The sample data is extracted through a shared feature extraction network to obtain sample features, including: Generate a first feature vector corresponding to the sample data through the shared word embedding layer; Determining a first-block network skip probability corresponding to the generator; Trigger a plurality of target shared block networks among the plurality of shared block networks that satisfy the skip probability of the first block network, and perform feature extraction on the first feature vector to obtain sample features.

4. The method according to claim 3, characterized in that Triggering a plurality of target shared block networks among the plurality of shared block networks that satisfy the skip probability of the first block network, and performing feature extraction on the first feature vector to obtain sample features, including: Determine a plurality of target shared block networks among the plurality of shared block networks that satisfy the skipping probability of the first block network; Extracting long-distance dependency features of the first feature vector through a self-attention layer in the target shared block network; Extracting context features of the first feature vector through a dynamic convolutional layer in the target shared block network; A sample feature is generated based on the long-distance dependency feature and the context feature.

5. The method according to claim 3, characterized in that: Extracting the mask features through the shared feature extraction network to obtain reference features, further comprising: generating a second feature vector corresponding to the mask feature through the shared word embedding layer; Determine a second network skip probability corresponding to the discriminator; wherein the second network skip probability is less than the first network skip probability; Trigger a plurality of target shared block networks among the plurality of shared block networks that satisfy the skipping probability of the second block network, and perform feature extraction on the second feature vector to obtain a reference feature.

6. The method according to claim 2, characterized in that For the multiple shared block networks in order, the shared block network sequence number is positively correlated with the block network skip probability; or, the multiple shared block networks correspond to the same block network skip probability.

7. The method according to claim 2, characterized in that Adjusting the network parameters of the adversarial network based on the mask recognition result includes: Determining a loss function between the mask recognition result and the sample data; The network parameters corresponding to the shared word embedding layer, the multiple shared block networks, the generator, and the discriminator are adjusted according to the loss function.

8. An adversarial network training device, characterized in that: The adversarial network includes a generator and a discriminator, including: A first feature extraction unit, configured to extract features from sample data through a shared feature extraction network to obtain sample features, and to generate mask features corresponding to the sample features based on the generator; a second feature extraction unit, configured to extract features from the mask features through the shared feature extraction network to obtain reference features, and generate a mask recognition result corresponding to the reference features based on the discriminator; A network training unit is used to adjust the network parameters of the adversarial network based on the mask recognition result.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

10. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 7 by executing the executable instructions.

Citation Information

Cited By

  • Remote sensing image super-resolution reconstruction method and system based on detail recovery

    CN118780987A

  • Sewage treatment soft measurement virtual sample generation method, device, equipment and medium

    CN120296431A