A model training method, device, apparatus and medium
By introducing convolutional groups and feature transformation layers into the model, the feature distribution is adjusted to solve the distribution offset problem, which improves the model training accuracy under small sample data and achieves accurate recognition of images in specific domains.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-07
- Publication Date
- 2026-04-14
AI Technical Summary
When fine-tuning a model pre-trained on a large dataset with small sample data, the model's training accuracy decreases due to distribution shift issues, making it unable to effectively identify images in specific domains.
Multiple convolutional groups and feature transformation layers are introduced into the feature extraction module of the model. The feature transformation layer is activated to adjust the feature distribution so that it tends to a normal distribution. Fine-tuning is performed using a small sample set to optimize the feature extraction capability of the model.
This improves the training accuracy of the model on small sample data, ensuring that the model can more accurately identify images in specific domains.
Smart Images

Figure CN116894997B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to a model training method, apparatus, device, and medium. Background Technology
[0002] In existing technologies, large datasets are often used to train image recognition models, resulting in better performance. In certain fields where the number of samples is small, it is advisable to pre-train the model with a large dataset and then fine-tune it using a small number of samples specific to the field.
[0003] In practical applications, models pre-trained on large datasets tend to focus more on the features of that large dataset. If there is a distributional shift between the large dataset used for pre-training and the small samples used for fine-tuning, it will affect model performance and lead to a decrease in training accuracy. For example, if a large dataset mainly contains animal images, while the fine-tuning model uses plant images as small samples, feeding these small samples into the pre-trained model will result in low accuracy because the pre-trained model will focus on structures that conform to animal characteristics rather than plant characteristics. This leads to a decrease in training accuracy. Summary of the Invention
[0004] This application provides a model training method, apparatus, device, and medium to improve the training accuracy of a model.
[0005] In a first aspect, embodiments of this application provide a model training method, including:
[0006] A first prediction model is obtained, which includes a feature extraction module and a classification module. The feature extraction module includes multiple convolutional groups and multiple feature transformation layers. The multiple convolutional groups and the multiple feature transformation layers correspond one-to-one. Each convolutional group is used to extract features of samples based on one dimension to obtain a feature set corresponding to each convolutional group. The feature transformation layer corresponding to each convolutional group is used to update the feature set corresponding to each convolutional group. The absolute value of the skewness of the updated feature set is less than the absolute value of the skewness of the feature set before the update.
[0007] At least one of the plurality of feature transformation layers is activated, wherein the plurality of feature transformation layers includes the at least one feature transformation layer;
[0008] The first prediction model is trained based on the first sample set to obtain a trained prediction model. The samples in the first sample set belong to the first domain, and the trained prediction model is used to identify images in the first domain.
[0009] In this scheme, a feature transformation layer corresponding to the convolutional group is added to the feature extraction module. At least one feature transformation layer is activated. When the convolutional group corresponding to any of the feature transformation layers outputs a feature set, the feature transformation layer can reduce the absolute value of the skewness of the feature set. This causes the weight of features closer to the extreme values (i.e., features that originally had a greater impact on the model) to decrease, while the weight of features farther from the extreme values (i.e., features that originally had a smaller impact on the model) to increase. The feature distribution becomes smoother and more similar to a normal distribution. Features that originally had a smaller impact on the model can now have a greater impact on the model, making the model output more accurate and improving the training accuracy of the model.
[0010] Optionally, obtaining the first prediction model includes: training the second prediction model based on the second sample set to obtain the first prediction model; the second prediction model includes the feature extraction module and the classification module, and the plurality of feature transformation layers in the second prediction model are in a dormant state; the number of samples in the first sample set is less than the number of samples in the second sample set.
[0011] This method trains a second prediction model using a second sample set in advance to obtain a first prediction model, which enables the first prediction model to extract general image features (such as the ability to extract the contours, textures, and shapes of images). The first prediction model is then fine-tuned based on the first sample set, making it easy to obtain a model that can recognize images in the first domain, thus improving the completeness of the solution.
[0012] Optionally, the at least one feature transformation layer is related to the domain type of the first domain.
[0013] In other words, different domain types may trigger at least one different feature transformation layer.
[0014] Optionally, waking up at least one of the plurality of feature conversion layers includes: determining to wake up the at least one feature conversion layer based on the correspondence between the sample's domain and the feature conversion layer and the domain type of the first domain.
[0015] This method, after determining the domain of the first sample, can determine which feature transformation layers to activate based on the pre-stored mapping relationship. The implementation is simple and efficient, requiring no user operation.
[0016] Optionally, the method further includes: receiving a wake-up command, the wake-up command including an identifier of the at least one feature conversion layer; waking up at least one feature conversion layer among the plurality of feature conversion layers includes: waking up the at least one feature conversion layer according to the wake-up command.
[0017] This method also allows for the determination of which feature conversion layers to activate based on the received wake-up command, thus meeting user needs and improving the flexibility of the solution.
[0018] Optionally, each of the plurality of feature transformation layers updates the feature set corresponding to the convolutional group of each feature transformation layer according to the following formula:
[0019] in, For the updated features, x i Let i be the feature in the feature set corresponding to the convolutional group of each feature transformation layer, i be the index of the feature, α = 0 represents the feature transformation layer is in a dormant state, α = 1 represents the feature transformation layer is in a awake state, c is a preset constant, and β is a variable.
[0020] It is understood that the above is only an example and not a limitation, and the above formula can be modified in other ways.
[0021] Optionally, the first sample set includes at least one labeled sample, the label being used to indicate the true classification result of the sample; training the first prediction model based on the first sample set includes: inputting the first sample set into the first prediction model to obtain at least one classification result of the first sample set, the at least one classification result corresponding one-to-one with the at least one sample; determining a loss value based on the label of the at least one sample and the at least one classification result; and updating the variable β with the goal of minimizing the loss value.
[0022] In this method, when training the first prediction model based on the first sample set, the loss value is determined according to the true classification result of the first sample set and the classification result output by the first prediction model. The variable β is updated with the goal of minimizing the loss value, so that the classification result output by the first prediction model is close to the true classification result of the first sample set, thereby improving the model training accuracy.
[0023] Secondly, embodiments of this application provide a model training apparatus, comprising:
[0024] An acquisition module is used to acquire a first prediction model. The first prediction model includes a feature extraction module and a classification module. The feature extraction module includes multiple convolutional groups and multiple feature transformation layers. The multiple convolutional groups and the multiple feature transformation layers correspond one-to-one. Each convolutional group is used to extract features of samples based on one dimension to obtain a feature set corresponding to each convolutional group. The feature transformation layer corresponding to each convolutional group is used to update the feature set corresponding to each convolutional group. The absolute value of the skewness of the updated feature set is less than the absolute value of the skewness of the feature set before the update.
[0025] The processing module is configured to activate at least one of the plurality of feature transformation layers, the plurality of feature transformation layers including the at least one feature transformation layer; train the first prediction model based on a first sample set to obtain a trained prediction model, wherein the samples in the first sample set belong to a first domain, and the trained prediction model is used to identify images in the first domain.
[0026] Optionally, when acquiring the first prediction model, the acquisition module is specifically used to: train the second prediction model based on the second sample set to obtain the first prediction model; the second prediction model includes the feature extraction module and the classification module, and the multiple feature transformation layers in the second prediction model are in a dormant state; the number of samples in the first sample set is less than the number of samples in the second sample set.
[0027] Optionally, the at least one feature transformation layer is related to the domain type of the first domain.
[0028] Optionally, when the processing module wakes up at least one of the plurality of feature conversion layers, it is specifically used to: determine to wake up the at least one feature conversion layer based on the correspondence between the sample’s domain and the feature conversion layer and the domain type of the first domain.
[0029] Optionally, the processing module is further configured to: receive a wake-up command, the wake-up command including an identifier of the at least one feature conversion layer; waking up at least one feature conversion layer among the plurality of feature conversion layers includes: waking up the at least one feature conversion layer according to the wake-up command.
[0030] Optionally, each of the plurality of feature transformation layers updates the feature set corresponding to the convolutional group of each feature transformation layer according to the following formula:
[0031] in, For the updated features, x i Let i be the feature in the feature set corresponding to the convolutional group of each feature transformation layer, i be the index of the feature, α = 0 represents the feature transformation layer is in a dormant state, α = 1 represents the feature transformation layer is in a awake state, c is a preset constant, and β is a variable.
[0032] Optionally, the first sample set includes at least one labeled sample, the label being used to indicate the true classification result of the sample; when the processing module trains the first prediction model based on the first sample set, it is specifically used to: input the first sample set into the first prediction model to obtain at least one classification result of the first sample set, the at least one classification result corresponding one-to-one with the at least one sample; determine a loss value based on the label of the at least one sample and the at least one classification result; and update the variable β with the goal of minimizing the loss value.
[0033] Thirdly, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the at least one processor performs the steps of the method described in the first aspect by executing the instructions stored in the memory.
[0034] Fourthly, this application provides a computer-readable storage medium storing a computer program, the computer program including program instructions, which, when executed by a computer, cause the computer to perform the steps of the method described in the first aspect above. Attached Figure Description
[0035] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0036] Figure 1 A flowchart illustrating a model training method provided in this application embodiment;
[0037] Figure 2 A structural diagram of a feature extraction module provided in an embodiment of this application;
[0038] Figure 3 A schematic diagram of a feature distribution provided for an embodiment of this application;
[0039] Figure 4 A flowchart illustrating an image recognition method provided in this application embodiment;
[0040] Figure 5 A schematic diagram illustrating an image recognition method provided in an embodiment of this application;
[0041] Figure 6 A schematic diagram of a model training device provided in an embodiment of this application;
[0042] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0043] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments of this application. Obviously, the described embodiments are only some embodiments of the technical solutions of this application, and not all embodiments. Based on the embodiments recorded in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the technical solutions of this application.
[0044] The terms "first" and "second" in the embodiments of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the term "comprising" and any variations thereof are intended to cover non-exclusive protection. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices. The term "multiple" in this application can mean at least two, for example, two, three, or more; the embodiments of this application do not impose any limitations.
[0045] Furthermore, the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article, unless otherwise specified, generally indicates that the preceding and following related objects have an "or" relationship.
[0046] To facilitate understanding of the solutions in the embodiments of this application, the possible application scenarios of the embodiments of this application will be introduced below.
[0047] In existing technologies, where the number of samples is relatively small in certain domains, image recognition models can be pre-trained using large datasets, and then fine-tuned using small samples specific to the domain. However, if the features of the large dataset differ significantly from the features of the small samples used for fine-tuning, or if there is a distribution shift between the large dataset used for pre-training and the small samples used for fine-tuning, the model pre-trained on the large dataset will focus more on the features of the large dataset, resulting in a higher weight for those features and a lower weight for those features of the small samples. Consequently, fine-tuning the model based on the small samples will not yield good performance, and the training accuracy of the model will decrease.
[0048] Therefore, this application provides a technical solution to improve the training accuracy of the model.
[0049] Reference Figure 1 The flowchart below provides a model training method according to an embodiment of this application.
[0050] This method can be executed by computer devices, such as laptops, desktop computers, and servers, and can also be applied to various devices with computing capabilities, as well as various chips with computing capabilities. The above devices are merely illustrative examples, and this application does not impose any limitations.
[0051] The following example illustrates how this method is executed by a computer device. The method includes:
[0052] S101: Obtain the first prediction model.
[0053] The first prediction model is an image recognition model, which is used to input images and output the classification results of the images.
[0054] For example, the first prediction model is the Simple Conditional Neural Adaptive Processes (CNAPS).
[0055] The first prediction model includes a feature extraction module and a classification module.
[0056] The feature extraction module includes multiple convolutional groups and multiple feature transformation layers, with each convolutional group and feature transformation layer corresponding one-to-one. Each convolutional group is used to extract features of the sample based on one dimension, resulting in a feature set corresponding to each convolutional group. Each convolutional group includes multiple residual blocks.
[0057] For example, see Figure 2 , Figure 2 This diagram illustrates the structure of a convolutional group, its corresponding feature transformation layer, and its task encoder. The encoder corresponding to the convolutional group processes the input data, ensuring permutation invariance.
[0058] Understandably, the feature extraction module includes multiple features such as... Figure 2 The structure of the convolutional group and feature transformation layer shown is as follows: Figure 2 This is just one example; it is not the only one shown.
[0059] The feature transformation layer corresponding to each convolutional group is used to update the feature set corresponding to each convolutional group. The absolute value of the skewness of the updated feature set is less than the absolute value of the skewness of the feature set before the update. In other words, the updated feature set is more likely to be normally distributed than the feature set before the update.
[0060] For example, see Figure 3In the graph, the horizontal axis represents the value of the feature, and the vertical axis represents the number of features with the same value. Figure 3 As shown in the left-hand diagram, the feature set before the update has a large absolute value of skewness, many features with values close to 0, and heavy weights, thus having a significant impact on the model. Figure 3 As shown in the figure on the right, the absolute value of the skewness of the updated feature set decreases, the number of features with values close to 0 decreases, and the weights decrease, while the number of features with larger values increases, and the weights increase.
[0061] Taking a five-layer convolutional neural network as an example, the feature extraction module consists of five convolutional groups, layer 1 to layer 5, each followed by a corresponding feature transformation layer. Following the order from layer 1 to layer 5, the feature range output by each convolutional group gradually increases. For example, layer 1 and layer 2 are used to extract edge features of the sample, layer 3 is used to extract a combination of edge features, and layer 4 and layer 5 are used to extract the contour features of the sample.
[0062] In one possible implementation, the computer device trains the second prediction model based on the second sample set to obtain the first prediction model. The second prediction model includes a feature extraction module and a classification module, and multiple feature transformation layers in the second prediction model are in a dormant state.
[0063] In the second sample set, each sample is a labeled image.
[0064] For example, the second sample set is a general large dataset, such as the ImageNet dataset. The first prediction model trained on the second sample set can extract features such as contours, textures, and shapes.
[0065] This method trains a second prediction model using a second sample set in advance to obtain a first prediction model, which enables the first prediction model to extract general image features (such as the ability to extract the contours, textures, and shapes of images). The first prediction model is then fine-tuned based on the first sample set, making it easy to obtain a model that can recognize images in the first domain, thus improving the completeness of the solution.
[0066] S102: Wake up at least one of the multiple feature transformation layers.
[0067] Among them, multiple feature transformation layers include at least one feature transformation layer.
[0068] The ways in which a computer device wakes up at least one feature translation layer include, but are not limited to, the following.
[0069] Method 1: The computer device receives a wake-up command, which includes an identifier of at least one feature conversion layer, and wakes up at least one feature conversion layer according to the wake-up command.
[0070] Understandably, technicians can input wake-up commands into computer devices as needed.
[0071] Using the example of a five-layer convolutional neural network for feature extraction module in S101 above, the technician determines that the first sample set required to train the first prediction model belongs to the first domain. If the first domain is plants, the feature required to identify plants is the outline. If the second sample set belongs to the animal domain, and the structure of animal features is too different from that of plant features, the technician sends a wake-up command to the computer device to wake up the feature conversion layer corresponding to layer 4 and the feature conversion layer corresponding to layer 5.
[0072] Method 2: The computer device pre-stores the correspondence between the sample's domain and the feature transformation layer, where at least one feature transformation layer is associated with the domain type of the first domain. The computer device determines to activate at least one feature transformation layer based on the domain type of the first domain.
[0073] Using the example of a five-layer convolutional neural network in S101 above, the computer device pre-stores the correspondence between plants and the feature transformation layers corresponding to the convolutional groups used to extract sample contour features. When the computer device determines that the first domain is a plant, it activates the feature transformation layers corresponding to layer 4 and layer 5 for extracting sample contour features.
[0074] It is understandable that the sample's domain and feature transformation layer can also be stored on other devices, and this application does not impose any restrictions.
[0075] Method 3: The computer device inputs the first sample set into multiple convolutional groups. Each convolutional group outputs a feature set. The computer device judges the feature set output by each convolutional group and wakes up the feature transformation layer corresponding to the convolutional group whose skewness of the output feature set is greater than a threshold.
[0076] In this approach, when the skewness of the feature set is greater than the threshold, the first prediction model trained on the second sample set pays more attention to the features of the second sample set. The computer device can activate the feature transformation layer corresponding to the convolution group whose output feature set skewness is greater than the threshold, thereby reducing the impact of the features of the second sample set on the first prediction model and improving the reliability of the solution.
[0077] S103: Train the first prediction model based on the first sample set to obtain a trained prediction model.
[0078] The first sample set contains fewer samples than the second sample set. The first sample set includes at least one labeled sample, each sample being an image, with the label indicating the true classification result. The trained prediction model is used to identify images within the first domain.
[0079] In one possible implementation, each feature transformation layer updates the feature set corresponding to the convolutional group of each feature transformation layer according to the following formula:
[0080]
[0081] in, For the updated features, x i Let i be the feature in the feature set corresponding to the convolutional group of each feature transformation layer, i be the index of the feature, α = 0 represents the feature transformation layer is in a dormant state, α = 1 represents the feature transformation layer is in a awake state, c be a preset constant, and β be a variable.
[0082] Understandably, c is a constant approaching 0, used to avoid x i The case where 0 occurs.
[0083] Using the example of a five-layer convolutional neural network in S101 above, if the feature set corresponding to layer1 has a total of 64×64 features and the feature transformation layer corresponding to layer1 is in the active state, then 0<i≤64×64. The feature transformation layer corresponding to layer1 is used to update each feature in the 64×64 features to obtain the updated feature set.
[0084] Understandably, the above is merely an example and not a limitation.
[0085] The training process of the first prediction model specifically includes the following steps:
[0086] Step 1: Input the first sample set into the first prediction model to obtain at least one classification result of the first sample set, wherein at least one classification result corresponds one-to-one with at least one image in the first sample set.
[0087] Step 2: Determine the loss value based on the label of at least one sample and at least one classification result. The loss value characterizes the deviation between the true classification result of the first sample set and the classification result output by the first prediction model.
[0088] Understandably, the loss value is calculated in the same way as the training model parameters. For example, the loss function used to calculate the loss value is the cross-entropy loss function.
[0089] For example, if the true label of a sample is "chair", the number 1 refers to a chair, the classification result of the sample is 2, and the number 2 refers to a table, then the number 1 and the number 2 are input into the loss function to obtain the loss value of the sample.
[0090] Step 3: Update variable β with the goal of minimizing the loss value.
[0091] Understandably, the way to update variable β is the same as the way to update model parameters in the training model. For example, the first prediction model updates variable β based on the loss value through the backpropagation algorithm.
[0092] The computer device repeats steps 1 to 3 above until the loss value no longer changes or the number of repetitions reaches the preset number, at which point training stops.
[0093] See Figure 4 The computer device inputs the image to be identified into the trained prediction model. The feature extraction module extracts the feature set of the image to be identified and updates the feature set corresponding to each convolutional group to obtain the updated feature set. Based on the updated feature set, feature information is obtained (for example, the feature extraction module is a convolutional neural network 18 (Deepresidual network 18, ResNet 18), and the feature information is a 1×512 feature matrix). The feature information is input into the classification module, and the classification module outputs a distance matrix. Based on the function argmax that finds the maximum independent variable, the label with the highest probability is obtained as the classification result of the image to be identified.
[0094] The following example illustrates how computer devices can identify images in the first domain based on a trained prediction model.
[0095] For example, see Figure 5 The first domain is network communication, and the first sample set includes samples labeled as network topology diagram, system architecture diagram, and statistical graph. The computer inputs the first sample set into the trained prediction model, and the feature extraction module in the trained prediction model outputs feature matrix 1 of the network topology diagram, feature matrix 2 of the system architecture diagram, and feature matrix 3 of the statistical graph.
[0096] The computer device inputs the image of the first region to be identified into the trained prediction model, and the feature extraction module in the trained prediction model outputs the feature matrix of the image to be identified.
[0097] The classification module in the trained prediction model calculates the Mahalanobis distance between feature matrix 1 of the network topology graph and feature matrix 4 of the image to be identified, resulting in distance matrix 1; the Mahalanobis distance between feature matrix 2 of the system architecture graph and feature matrix 4 of the image to be identified, resulting in distance matrix 2; and the Mahalanobis distance between feature matrix 3 of the statistical graph and feature matrix 4 of the image to be identified, resulting in distance matrix 3. The classification module uses the argmax function to determine the optimal distance (the label with the highest probability) among the three distance matrices. If the optimal distance is obtained according to distance matrix 1, the classification result of the image to be identified is the network topology graph.
[0098] Understandably, the above examples only use three types of labels and are not limited to these in practice.
[0099] In the above schemes S101 to S103, a feature transformation layer corresponding to the convolution group is added to the feature extraction module. At least one feature transformation layer is activated. When the convolution group corresponding to any feature transformation layer outputs a feature set, any feature transformation layer can reduce the absolute value of the skewness of the feature set. This causes the weight of features closer to the extreme values (i.e., features that originally had a greater impact on the model) to decrease, and the weight of features farther from the extreme values (i.e., features that originally had a smaller impact on the model) to increase. The feature distribution is smoother and more inclined to a normal distribution. Features that originally had a smaller impact on the model can now have a greater impact on the model, making the model output results more accurate and improving the training accuracy of the model.
[0100] See Figure 6 This is a structural diagram of a model training device provided in an embodiment of this application. The device includes modules / units / technical means for executing the methods performed by computer devices in the above-described method embodiments.
[0101] For example, the device 600 includes:
[0102] The acquisition module 601 is used to acquire a first prediction model. The first prediction model includes a feature extraction module and a classification module. The feature extraction module includes multiple convolutional groups and multiple feature transformation layers. The multiple convolutional groups and the multiple feature transformation layers correspond one-to-one. Each convolutional group is used to extract features of samples based on one dimension to obtain a feature set corresponding to each convolutional group. The feature transformation layer corresponding to each convolutional group is used to update the feature set corresponding to each convolutional group. The absolute value of the skewness of the updated feature set is less than the absolute value of the skewness of the feature set before the update.
[0103] The processing module 602 is used to wake up at least one of the plurality of feature transformation layers, the plurality of feature transformation layers including the at least one feature transformation layer; to train the first prediction model based on a first sample set to obtain a trained prediction model, wherein the samples in the first sample set belong to a first domain, and the trained prediction model is used to identify images in the first domain.
[0104] As one possible product form of the aforementioned device, see [link to product description]. Figure 7 This application also provides an electronic device 700, comprising:
[0105] At least one processor 701; and a communication interface 703 communicatively connected to the at least one processor 701; the at least one processor 701 causes the electronic device 700 to perform the method steps performed by any device in the above method embodiments through the communication interface 703 by executing instructions stored in the memory 702.
[0106] Optionally, the memory 702 is located outside the electronic device 700.
[0107] Optionally, the electronic device 700 includes the memory 702, which is connected to the at least one processor 701, and stores instructions executable by the at least one processor 701. (Appendix) Figure 7 The dashed line indicates that memory 702 is optional for electronic device 700.
[0108] The processor 701 and the memory 702 can be coupled through an interface circuit or integrated together; no restriction is imposed here.
[0109] This application embodiment does not limit the specific connection medium between the processor 701, memory 702, and communication interface 703. This application embodiment... Figure 7 The processor 701, memory 702, and communication interface 703 are connected via a bus 704. Figure 7 The connections between other components are shown in bold and are for illustrative purposes only, not as limiting information. The bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, Figure 7 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0110] It should be understood that the processor mentioned in the embodiments of this application can be implemented in hardware or software. When implemented in hardware, the processor can be a logic circuit, integrated circuit, etc. When implemented in software, the processor can be a general-purpose processor, implemented by reading software code stored in memory.
[0111] For example, the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0112] It should be understood that the memory mentioned in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate Synchronous DRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct RAM (DR RAM).
[0113] It should be noted that when the processor is a general-purpose processor, DSP, ASIC, FPGA, or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, the memory (storage module) can be integrated into the processor.
[0114] It should be noted that the memories described herein are intended to include, but are not limited to, these and any other suitable types of memories.
[0115] As another possible product form, this application embodiment also provides a computer-readable storage medium for storing instructions that, when executed, cause a computer to perform the method steps performed by the first device in the above method example.
[0116] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0117] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0118] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0119] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0120] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A model training method, characterized in that, include: A first prediction model is obtained, which includes a feature extraction module and a classification module. The feature extraction module includes multiple convolutional groups and multiple feature transformation layers. The multiple convolutional groups and the multiple feature transformation layers correspond one-to-one. Each convolutional group is used to extract features of samples based on one dimension to obtain a feature set corresponding to each convolutional group. The feature transformation layer corresponding to each convolutional group is used to update the feature set corresponding to each convolutional group. The absolute value of the skewness of the updated feature set is less than the absolute value of the skewness of the feature set before the update. At least one of the plurality of feature transformation layers is activated, wherein the plurality of feature transformation layers includes the at least one feature transformation layer; The first prediction model is trained based on the first sample set to obtain a trained prediction model. The samples in the first sample set belong to the first domain, and the trained prediction model is used to identify images in the first domain. Each of the plurality of feature transformation layers updates the feature set corresponding to the convolutional group of each feature transformation layer according to the following formula: ;in, For the updated features, Let i be the feature in the feature set corresponding to the convolutional group of each feature transformation layer, and i be the index of the feature. The feature transformation layer is in a dormant state. The feature transformation layer is in a wake-up state. As a preset constant, For variables.
2. The method as described in claim 1, characterized in that, The process of obtaining the first prediction model includes: The second prediction model is trained based on the second sample set to obtain the first prediction model; the second prediction model includes the feature extraction module and the classification module, and the multiple feature transformation layers in the second prediction model are in a dormant state; the number of samples in the first sample set is less than the number of samples in the second sample set.
3. The method as described in claim 1, characterized in that, The at least one feature transformation layer is related to the domain type of the first domain.
4. The method as described in claim 3, characterized in that, The step of waking up at least one of the plurality of feature transformation layers includes: Based on the correspondence between the sample's domain and the feature conversion layer, as well as the domain type of the first domain, the activation of at least one feature conversion layer is determined.
5. The method as described in claim 1, characterized in that, The method further includes: Receive a wake-up command, wherein the wake-up command includes an identifier of the at least one feature conversion layer; The step of waking up at least one of the plurality of feature transformation layers includes: The at least one feature conversion layer is activated according to the wake-up command.
6. The method as described in claim 1, characterized in that, The first sample set includes at least one labeled sample, the label being used to indicate the true classification result of the sample; The step of training the first prediction model based on the first sample set includes: The first sample set is input into the first prediction model to obtain at least one classification result of the first sample set, wherein the at least one classification result corresponds one-to-one with the at least one sample; The loss value is determined based on the label of the at least one sample and the at least one classification result; Update the variable with the goal of minimizing the loss value. .
7. A model training device, characterized in that, include: An acquisition module is used to acquire a first prediction model. The first prediction model includes a feature extraction module and a classification module. The feature extraction module includes multiple convolutional groups and multiple feature transformation layers. The multiple convolutional groups and the multiple feature transformation layers correspond one-to-one. Each convolutional group is used to extract features of samples based on one dimension to obtain a feature set corresponding to each convolutional group. The feature transformation layer corresponding to each convolutional group is used to update the feature set corresponding to each convolutional group. The absolute value of the skewness of the updated feature set is less than the absolute value of the skewness of the feature set before the update. The processing module is used to wake up at least one of the plurality of feature transformation layers, the plurality of feature transformation layers including the at least one feature transformation layer; to train the first prediction model based on a first sample set to obtain a trained prediction model, wherein the number of samples in the first sample set is less than a preset number, the samples in the first sample set belong to a first domain, and the trained prediction model is used to identify images in the first domain. Each of the plurality of feature transformation layers updates the feature set corresponding to the convolutional group of each feature transformation layer according to the following formula: ;in, For the updated features, Let i be the feature in the feature set corresponding to the convolutional group of each feature transformation layer, and i be the index of the feature. The feature transformation layer is in a dormant state. The feature transformation layer is in a wake-up state. As a preset constant, For variables.
8. An electronic device, characterized in that, include: At least one processor; And a memory and a communication interface that are communicatively connected to the at least one processor; The memory stores instructions executable by the at least one processor, which, by executing the instructions stored in the memory, causes the electronic device to perform the method as described in any one of claims 1-6 through the communication interface.
9. A computer-readable storage medium, characterized in that, It stores a computer program executable by a computer device, which, when run on the computer device, causes the computer device to perform the steps of the method according to any one of claims 1-6.