Image recognition method, device, electronic device and storage medium
By weighting the parameters of the branches of the stacked basic units in the convolutional neural network and fusing the convolution kernel, the problem of the undifferentiated importance of each branch in the multi-branch structure is solved, and the accuracy and computational efficiency of image recognition are improved.
Patent Information
- Application Number
- CN202210395806.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-15
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2042-04-15
AI Technical Summary
In existing image recognition models, the importance of each branch of the multi-branch structure is not differentiated, resulting in low recognition accuracy.
By fusing the weighted parameters and convolution layer parameters of the branches of each stacked basic unit in the convolutional neural network, setting the same weighted parameters, and expanding the convolution kernel to equal area for fusion, the deployment process is simplified and the model feature extraction capability is improved.
This improves the accuracy of image recognition, reduces the computational complexity and memory usage on the inference side, and simplifies the deployment process.
Smart Images

Figure CN114758191B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and more specifically, to an image recognition method and device, an electronic device, and a computer-readable storage medium. Background Art
[0002] With the continuous development of artificial intelligence (AI), AI has gradually been applied to our daily lives. Deep learning is one of the most prominent technologies in the field of AI. The key to deep neural networks lies in the design of the network model structure. Generally speaking, the most direct way to improve network performance is to increase the depth and width of the neural network. Depth refers to the number of network layers, and width refers to the number of neurons (channels) in each layer. Following these two design principles, currently commonly used network model structures include multi-branch network model designs, such as the residual-addition structure of ResNet, the multi-branch concatenation structure of Inception, and automated network search structure designs based on NAS (Neural Architecture Search) learning. While these network structures improve model recognition accuracy, the complexity of the model structure increases the difficulty of deployment on the inference side, and they suffer from disadvantages such as slow execution speed and low memory utilization.
[0003] In related technologies, such as Figure 1 As shown, the RepVGG (structural re-parameterization Visual Geometry Group) architecture is used. On the training side, network complexity is increased by designing 3x3, 1x1, and directly connected multi-branch structures to improve network performance. On the inference side, model parameter fusion is used to simplify inference deployment and achieve model acceleration. However, although this model uses a multi-branch structure to connect each node, it does not distinguish the importance of each branch, resulting in low accuracy when applied to image recognition.
[0004] Therefore, how to improve the accuracy of image recognition is a technical problem that needs to be solved by those skilled in the art. Summary of the Invention
[0005] The purpose of this application is to provide an image recognition method, device, electronic device and computer-readable storage medium to improve the accuracy of image recognition.
[0006] To achieve the above objectives, the present application provides an image recognition method, comprising:
[0007] Obtaining a training image and determining a category label corresponding to the training image;
[0008] Obtaining a training image and determining a category label corresponding to the training image;
[0009] The convolutional neural network model parameters are trained using the training images and corresponding category labels to obtain a trained convolutional neural network; wherein the convolutional neural network includes a plurality of stacked basic units connected in series, each of the stacked basic units includes a plurality of branches connected in parallel, and the model parameters include at least weighting parameters and convolution layer parameters corresponding to each of the branches;
[0010] Fusing the weighted parameters and convolutional layer parameters corresponding to each branch in each stacked basic unit in the trained convolutional neural network to obtain fusion parameters corresponding to each branch in each stacked basic unit;
[0011] Deploying a target convolutional neural network based on the trained convolutional neural network and the fusion parameters corresponding to each branch in each of the stacked basic units;
[0012] Acquire a target image and input the target image into the target convolutional neural network for image recognition.
[0013] Wherein, the weighted parameters of corresponding branches in different stacked basic units in the convolutional neural network are the same;
[0014] Accordingly, the model parameters of the convolutional neural network are trained using the training images and the corresponding category labels to obtain a trained convolutional neural network, including:
[0015] Constructing a training convolutional neural network; wherein the training convolutional neural network includes n stacked basic units connected in series, where n is a positive integer less than a preset value, each stacked basic unit includes a plurality of branches connected in parallel, and weighted parameters of corresponding branches in different stacked basic units are the same;
[0016] Using the training images and corresponding category labels to train weighted parameters corresponding to different branches in the training convolutional neural network;
[0017] Using the weighted parameters corresponding to different branches in the training convolutional neural network obtained through training as the weighted parameters corresponding to different branches in the convolutional neural network;
[0018] The convolutional layer parameters corresponding to different branches in the convolutional neural network are trained using the training images and the corresponding category labels to obtain a trained convolutional neural network.
[0019] Wherein, deploying a target convolutional neural network based on the trained convolutional neural network and the fusion parameters corresponding to each branch in each of the stacked basic units includes:
[0020] Performing convolution kernel fusion on multiple branches in each stacked basic unit in the trained convolutional neural network to obtain a fused target convolutional neural network;
[0021] The fusion parameters at the corresponding position of each branch in each of the stacked basic units are fused to obtain the fusion parameters at the corresponding position of the fused convolution kernel in each stacked basic unit in the target convolutional neural network.
[0022] The convolution kernels of multiple branches in each stacked basic unit in the convolutional neural network are fused to obtain a fused target convolutional neural network, including:
[0023] Selecting a reference convolution kernel in each stacked basic unit in the convolutional neural network; wherein the reference convolution kernel is the maximum convolution kernel in all branches of the stacked basic unit;
[0024] Expanding the convolution kernels of all branches in each of the stacked basic units into convolution kernels having an area equal to that of the reference convolution kernel in the corresponding stacked basic unit;
[0025] The expanded convolution kernels of all branches in each of the stacked basic units are fused to obtain a fused target convolutional neural network.
[0026] Wherein, the branch includes a convolution kernel branch and / or a direct residual connection branch;
[0027] The step of expanding the convolution kernels of all branches in each of the stacked basic units into convolution kernels having an area equal to that of the reference convolution kernel in the corresponding stacked basic unit comprises:
[0028] Determine a target convolution kernel in a convolution kernel branch in each of the stacked basic units, whose convolution kernel area is smaller than the convolution kernel area of the reference convolution kernel in the corresponding stacked basic unit, and expand the target convolution kernel into a convolution kernel having an area equal to that of the reference convolution kernel in the corresponding stacked basic unit by zero-padding;
[0029] And / or, the center value of the convolution kernel on the output channel of the direct residual connection branch in each of the stacked basic units is filled with a non-zero value and the other parts are filled with zero values, so as to expand the direct residual connection branch into a convolution kernel with an area equal to that of the reference convolution kernel in the stacked basic unit to which it belongs.
[0030] The model parameters also include batch normalization layer parameters corresponding to each branch;
[0031] Accordingly, the weighted parameters and convolution layer parameters corresponding to each branch in each stacked basic unit in the trained convolutional neural network are fused to obtain the fusion parameters corresponding to each branch in each stacked basic unit, including:
[0032] Fusing the weighted parameters corresponding to each branch in each stacked basic unit in the trained convolutional neural network into the convolutional layer parameters to obtain the fused convolutional layer parameters corresponding to each branch;
[0033] The fused convolution layer parameters corresponding to each branch in each of the stacked basic units are fused with the batch normalization layer parameters to obtain the fused parameters corresponding to each branch in each of the stacked basic units.
[0034] The convolution layer parameters include convolution kernel weight parameters and bias unit parameters;
[0035] Accordingly, the weighted parameters corresponding to each branch in each stacked basic unit in the trained convolutional neural network are fused into the convolutional layer parameters to obtain the fused convolutional layer parameters corresponding to each branch, including:
[0036] The product of the weighted parameter corresponding to each branch in each stacked basic unit in the trained convolutional neural network and the convolution kernel weight parameter is used as the fused convolution kernel weight parameter corresponding to each branch;
[0037] The product of the weighted parameter corresponding to each branch in each stacked basic unit in the trained convolutional neural network and the bias unit parameter is used as the fused bias unit parameter corresponding to each branch;
[0038] Accordingly, the fused convolution layer parameters corresponding to each branch in each of the stacked basic units are fused with the batch normalization layer parameters to obtain the fused parameters corresponding to each branch in each of the stacked basic units, including:
[0039] Using a first fusion formula, the fused convolution kernel weight parameters corresponding to each branch in each of the stacked basic units are fused with the batch normalization layer parameters to obtain a first fusion parameter corresponding to each branch in each of the stacked basic units;
[0040] Using a second fusion formula, the fused bias unit parameters corresponding to each branch in each of the stacked basic units are fused with the batch normalization layer parameters to obtain a second fusion parameter corresponding to each branch in each of the stacked basic units;
[0041] Among them, the first fusion formula is: The second fusion formula is:
[0042] in, is the convolution kernel weight parameter after fusion corresponding to the nth branch, is the bias unit parameter after fusion corresponding to the nth branch, μ (n) , σ (n) , β (n) and γ (n) is the batch normalization layer parameter corresponding to the nth branch, ∈ is the adjustment parameter, is the first fusion parameter corresponding to the nth branch, is the second fusion parameter corresponding to the nth branch.
[0043] The step of fusing the fusion parameters at the corresponding position of each branch in each of the stacked basic units to obtain the fusion parameters at the corresponding position of the fused convolution kernel in each stacked basic unit in the target convolutional neural network includes:
[0044] The fusion parameters at the corresponding position of each branch in each of the stacked basic units are summed as the fusion parameters at the corresponding position of the fused convolution kernel in each stacked basic unit in the target convolutional neural network.
[0045] To achieve the above objectives, the present application provides an image recognition device, comprising:
[0046] An acquisition module, configured to acquire a training image and determine a category label corresponding to the training image;
[0047] A training module, configured to train the model parameters of a convolutional neural network using the training images and corresponding category labels to obtain a trained convolutional neural network; wherein the convolutional neural network includes a plurality of stacked basic units connected in series, each of the stacked basic units includes a plurality of branches connected in parallel, and the model parameters include at least weighting parameters and convolution layer parameters corresponding to each of the branches;
[0048] A fusion module, configured to fuse the weighted parameters and convolutional layer parameters corresponding to each branch in each of the stacked basic units in the trained convolutional neural network to obtain fusion parameters corresponding to each branch in each of the stacked basic units;
[0049] A deployment module is used to deploy a target convolutional neural network based on the fusion parameters corresponding to each branch in each of the stacked basic units on the basis of the trained convolutional neural network;
[0050] The recognition module is used to obtain a target image and input the target image into the target convolutional neural network for image recognition.
[0051] To achieve the above objectives, the present application provides an electronic device, comprising:
[0052] memory for storing computer programs;
[0053] A processor is used to implement the steps of the above-mentioned image recognition method when executing the computer program.
[0054] To achieve the above objectives, the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned image recognition method are implemented.
[0055] From the above scheme, it can be seen that an image recognition method provided by the present application includes: obtaining a training image and determining the category label corresponding to the training image; using the training image and the corresponding category label to train the model parameters of the convolutional neural network to obtain a trained convolutional neural network; wherein the convolutional neural network includes a plurality of stacked basic units in series, each of the stacked basic units includes a plurality of branches in parallel, and the model parameters include at least weighted parameters and convolutional layer parameters corresponding to each of the branches; the weighted parameters and convolutional layer parameters corresponding to each branch in each stacked basic unit in the trained convolutional neural network are fused to obtain the fusion parameters corresponding to each branch in each stacked basic unit; based on the trained convolutional neural network, a target convolutional neural network is deployed based on the fusion parameters corresponding to each branch in each stacked basic unit; a target image is obtained, and the target image is input into the target convolutional neural network for image recognition.
[0056] The image recognition method provided in this application sets different weighting parameters for different branches in each stacked basic unit of a convolutional neural network. By learning these weighting parameters, different convolution calculations are selectively weighted. This method can effectively improve the ability to extract model features, improve the information extraction capability of the convolutional neural network, and increase the accuracy of image recognition performed by the convolutional neural network. This application also discloses an image recognition device, an electronic device, and a computer-readable storage medium, which can also achieve the above technical effects.
[0057] It should be understood that the foregoing general description and the following detailed description are merely illustrative and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings required for the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. The drawings are used to provide a further understanding of the present disclosure and constitute part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure, but do not constitute a limitation of the present disclosure. In the drawings:
[0059] Figure 1 Schematic diagram of a RepVGG structure in related art;
[0060] Figure 2 is a flow chart of an image recognition method according to an exemplary embodiment;
[0061] Figure 3 is a flow chart of another image recognition method according to an exemplary embodiment;
[0062] Figure 4 is a schematic diagram of a method for constructing a target neural convolutional network according to an exemplary embodiment;
[0063] Figure 5 is a schematic diagram of another method for constructing a target neural convolutional network according to an exemplary embodiment;
[0064] Figure 6 is a schematic diagram of another method for constructing a target neural convolutional network according to an exemplary embodiment;
[0065] Figure 7a FIG1 is a schematic diagram showing memory usage before fusion according to an exemplary embodiment;
[0066] Figure 7b is a schematic diagram showing memory usage after fusion according to an exemplary embodiment;
[0067] Figure 8 1 is a schematic diagram of the training and inference ends in an image classification task according to an exemplary embodiment;
[0068] Figure 9 is a structural diagram of an image recognition device according to an exemplary embodiment;
[0069] Figure 10 The figure is a structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0070] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application. In addition, in the embodiments of the present application, "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0071] The embodiment of the present application discloses an image recognition method, which improves the accuracy of image recognition.
[0072] See also Figure 2 , according to an exemplary embodiment, a flowchart of an image recognition method is shown, such as Figure 2 Shown, including:
[0073] S101: Acquire a training image and determine a category label corresponding to the training image;
[0074] S102: Using the training image and the corresponding category label, train the model parameters of the convolutional neural network to obtain a trained convolutional neural network; wherein the convolutional neural network includes a plurality of stacked basic units connected in series, each of the stacked basic units includes a plurality of branches connected in parallel, and the model parameters include at least weighting parameters and convolution layer parameters corresponding to each branch;
[0075] The purpose of this embodiment is to perform image recognition on the target image. In the specific implementation, a training image is obtained, its corresponding category label is determined, and the convolutional neural network is trained using the training image and the corresponding category label. The convolutional neural network includes a plurality of stacked basic units in series, each stacked basic unit includes a plurality of parallel branches, different branches correspond to different weighting parameters, each branch includes a convolution layer, and of course can also include a batch normalization layer (BN layer). The size and shape of the convolution kernels of the convolution layers in different branches can be the same or different, and this embodiment does not specifically limit this. The trainable model parameters of the convolutional neural network include at least the weighted parameters and convolution layer parameters corresponding to each branch. If a batch normalization layer is included in the branch, the model parameters also include the batch normalization layer parameters corresponding to the branch. The convolution layer parameters can include convolution kernel weight parameters and bias unit parameters (bias parameters).
[0076] During training, use L train and L val Represents the loss of training and validation sets, and the goal is to find an optimal set of weighting parameters α w , so that it can minimize the loss function L of the validation set val, and the model convolutional layer parameters W are also followed by minimizing the training set loss L train The specific training process can refer to the bidirectional optimization problem of DARTS (neural network search, differentiable architecture search) method, which includes the following steps: (1) fix the weight parameter α w In the case of , the convolutional neural network is trained and updated by minimizing the loss constraint of the training set; (2) when the convolutional layer parameter W is fixed, the weighted parameter α is learned by minimizing the loss constraint of the validation set. w Learn and update; (3) Finally, the optimal model parameters of the convolutional neural network are obtained through alternating learning. The model parameters ensure that the loss error of the training set and the validation set is minimized.
[0077] It can be understood that since the number of stacked basic units contained in the convolutional neural network is large, the training speed of the convolutional neural network will be affected. In order to improve the training speed of the convolutional neural network, as a preferred embodiment, the weighted parameters of the corresponding branches in different stacked basic units in the convolutional neural network are the same; accordingly, the model parameters of the convolutional neural network are trained using the training image and the corresponding category label to obtain a trained convolutional neural network, including: constructing a training convolutional neural network; wherein the training convolutional neural network includes n stacked basic units in series, n is a positive integer less than a preset value, each of the stacked basic units includes multiple branches in parallel, and the weighted parameters of the corresponding branches in different stacked basic units are the same; using the training image and the corresponding category label to train the weighted parameters corresponding to different branches in the training convolutional neural network; using the weighted parameters corresponding to different branches in the training convolutional neural network obtained by training as the weighted parameters corresponding to different branches in the convolutional neural network; using the training image and the corresponding category label to train the convolution layer parameters corresponding to different branches in the convolutional neural network to obtain a trained convolutional neural network. In a specific implementation, a training convolutional neural network with a structure similar to the above-mentioned convolutional neural network is constructed, the difference being that the training convolutional neural network contains fewer stacked basic units, that is, the training convolutional neural network includes n stacked basic units connected in series, where n is a positive integer less than a preset value. During the training process, the training convolutional neural network is first trained using the training image and the corresponding category label. The weighted parameters corresponding to the different branches in each stacked basic unit can be obtained by referring to the above-mentioned bidirectional optimization training process. Since the number of stacked basic units contained in the training convolutional neural network is small, the training speed can be improved. It should be noted that in order to further improve the training speed, the number of branches contained in different stacked basic units can be set to be the same, and the weighted parameters of the corresponding branches can be the same, that is, the structure of each stacked basic unit is exactly the same. For example, each stacked basic unit contains three branches, and the corresponding weighted parameters are α, β, and γ, respectively. Then, the convolutional layer parameters corresponding to different branches in the convolutional neural network are trained while the weighted parameters corresponding to different branches are fixed to obtain a trained convolutional neural network.
[0078] S103: fusing the weighted parameters and convolutional layer parameters corresponding to each branch in each stacked basic unit in the trained convolutional neural network to obtain fusion parameters corresponding to each branch in each stacked basic unit;
[0079] In this step, based on the multi-branch network structure in each stacked basic unit, the model parameters of each branch are fused. The parameter fusion may include the fusion of weighted parameters and convolution layer parameters, and may also include the fusion of batch normalization layer parameters.
[0080] As a feasible implementation method, this step includes: fusing the weighted parameters corresponding to each branch in each of the stacked basic units in the trained convolutional neural network into the convolutional layer parameters to obtain the fused convolutional layer parameters corresponding to each of the branches; fusing the fused convolutional layer parameters corresponding to each branch in each of the stacked basic units with the batch normalization layer parameters to obtain the fused parameters corresponding to each branch in each of the stacked basic units.
[0081] In the specific implementation, the weighted parameters of each branch, such as α, β, and γ values, are first fused into the convolution layer parameters, and then the fused convolution layer parameters are fused with the batch normalization layer parameters to obtain the fusion parameters corresponding to each branch.
[0082] It can be understood that the convolution layer parameters include convolution kernel weight parameters and bias unit parameters. Accordingly, the weighted parameters corresponding to each branch in each of the stacked basic units in the trained convolutional neural network are fused into the convolution layer parameters to obtain the fused convolution layer parameters corresponding to each branch, including: taking the product of the weighted parameters corresponding to each branch in each of the stacked basic units in the trained convolutional neural network and the convolution kernel weight parameters as the fused convolution kernel weight parameters corresponding to each branch; taking the product of the weighted parameters corresponding to each branch in each of the stacked basic units in the trained convolutional neural network and the bias unit parameters as the fused bias unit parameters corresponding to each branch. correspondingly, fusing the fused convolution layer parameters corresponding to each branch in each of the stacked basic units with the batch normalization layer parameters to obtain the fused parameters corresponding to each branch in each of the stacked basic units, including: using a first fusion formula to fuse the fused convolution kernel weight parameters corresponding to each branch in each of the stacked basic units with the batch normalization layer parameters to obtain the first fused parameters corresponding to each branch in each of the stacked basic units; using a second fusion formula to fuse the fused bias unit parameters corresponding to each branch in each of the stacked basic units with the batch normalization layer parameters to obtain the second fused parameters corresponding to each branch in each of the stacked basic units;
[0083] Among them, the first fusion formula is: The second fusion formula is:
[0084] in, is the convolution kernel weight parameter after fusion corresponding to the nth branch, is the bias unit parameter after fusion corresponding to the nth branch, μ (n) , σ (n) , β (n) and γ(n) is the batch normalization layer parameter corresponding to the nth branch, ∈ is the adjustment parameter, is the first fusion parameter corresponding to the nth branch, is the second fusion parameter corresponding to the nth branch.
[0085] S104: deploying a target convolutional neural network based on the trained convolutional neural network and the fusion parameters corresponding to each branch in each of the stacked basic units;
[0086] S105: Acquire a target image, and input the target image into the target convolutional neural network for image recognition.
[0087] In a specific implementation, after fusing the parameters of each branch in each stacked basic unit in the trained convolutional neural network, a target convolutional neural network can be obtained. The target convolutional neural network is used to perform image recognition on the target image, that is, to determine the category of the target image.
[0088] The image recognition method provided in the embodiment of the present application sets different weighting parameters for different branches in each stacked basic unit in the convolutional neural network, and selectively weights different convolution calculations through learning the weighting parameters, which can effectively improve the ability to extract model features, improve the information extraction ability of the convolutional neural network, and improve the accuracy of image recognition by the convolutional neural network.
[0089] The embodiment of this application discloses an image recognition method. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. Specifically:
[0090] See also Figure 3 , a flowchart of another image recognition method according to an exemplary embodiment is shown, such as Figure 3 Shown, including:
[0091] S201: Acquire a training image and determine a category label corresponding to the training image;
[0092] S202: Using the training image and the corresponding category label to train the model parameters of the convolutional neural network to obtain a trained convolutional neural network; wherein the convolutional neural network includes a plurality of stacked basic units connected in series, each of the stacked basic units includes a plurality of branches connected in parallel, and the model parameters include weighting parameters corresponding to each branch, convolution layer parameters, and batch normalization layer parameters;
[0093] S203: fusing the weighted parameters, convolutional layer parameters, and batch normalization layer parameters corresponding to each branch in each stacked basic unit in the trained convolutional neural network to obtain fused parameters corresponding to each branch in each stacked basic unit;
[0094] S204: fusing convolution kernels of multiple branches in each stacked basic unit in the trained convolutional neural network to obtain a fused target convolutional neural network;
[0095] In this embodiment, convolution kernels of each branch in each stacked basic unit in the convolutional neural network are fused, that is, multiple convolution kernels in each branch are fused into one convolution kernel.
[0096] As a feasible implementation method, this step includes: selecting a reference convolution kernel in each stacked basic unit in the convolutional neural network; wherein the reference convolution kernel is the maximum convolution kernel in all branches in the stacked basic unit; expanding the convolution kernels of all branches in each of the stacked basic units into convolution kernels with an area equal to the reference convolution kernel in the corresponding stacked basic unit; fusing the expanded convolution kernels of all branches in each of the stacked basic units to obtain a fused target convolutional neural network.
[0097] In the specific implementation, for each stacked basic unit, the sizes of the convolution kernels in each branch are compared, the largest convolution kernel is selected as the reference convolution kernel of the stacked basic unit, and then the remaining convolution kernels are expanded to convolution kernels with the same area as the largest convolution kernel. The convolution kernel expansion includes the expansion of the convolution kernel area and the expansion of the convolution kernel parameters. Figure 4 As shown in the figure, Convlayer is a convolution layer, and BN layer is a batch normalization layer. Assuming the maximum convolution kernel is MxM', the second branch convolution kernel NxN' and other convolution kernels are all expanded to MxM' convolution kernels. The convolution kernel can be of any size and shape.
[0098] It should be noted that the branches in the stacked basic units can be convolution kernel branches or direct residual connection branches. For the convolution kernel branches, the expansion process of the convolution kernel includes: determining a target convolution kernel whose convolution kernel area in the convolution kernel branch in each of the stacked basic units is smaller than the convolution kernel area of the reference convolution kernel in the stacked basic unit to which it belongs, and expanding the target convolution kernel into a convolution kernel with an area equal to that of the reference convolution kernel in the stacked basic unit to which it belongs by filling with zero values. For the direct residual connection branches, the expansion process includes: filling the convolution kernel center value on the output channel of the direct residual connection branch in each of the stacked basic units with a non-zero value and filling the other parts with zero values, so as to expand the direct residual connection branch into a convolution kernel with an area equal to that of the reference convolution kernel in the stacked basic unit to which it belongs.
[0099] S205: Fusing the fusion parameters at the corresponding position of each branch in each of the stacked basic units to obtain the fusion parameters at the corresponding position of the fused convolution kernel in each stacked basic unit in the target convolutional neural network;
[0100] In a specific implementation, the fusion parameters at the corresponding position of each branch in each of the stacked basic units are summed up as the fusion parameters at the corresponding position of the fused convolution kernel in each stacked basic unit in the target convolutional neural network.
[0101] S206: Acquire a target image, and input the target image into the target convolutional neural network for image recognition.
[0102] It can be seen that this embodiment fuses the convolution kernels of each branch in each stacked basic unit in the target convolutional neural network, simplifies the deployment process of the target convolutional neural network, accelerates the calculation process of image recognition, and reduces memory usage during the image recognition process.
[0103] The following describes an application embodiment provided by this application. First, the network model structure training and learning are carried out. In a stacked basic unit, there are multiple branches, each branch uses a different convolution kernel for calculation, and the multiple branches are fused into one branch as the input of the next basic unit through the sum operation. Figure 5 For example, in a stacked basic unit, we designed three convolution branches, namely 5x5, 3x3, and 1x1, and set different weighting parameters for each branch. Therefore, during the model training process, the model parameters that need to be learned by the basic unit are: branch weight parameters (such as Figure 5 α, β, γ in ), convolution layer parameters, and BN parameters. Assume that the input channel C1 of the convolution kernel is equal to the output channel C2, C1=C2=2. W(5), W(3), and W(1) represent the convolution kernel weight parameters of 5x5, 3x3, and 1x1 convolution kernels, respectively. W(5)∈RC2xC1x5x5, W(3)∈RC2xC1x3x3, and W(1)∈RC2xC1x1x1. b(5), b(3), and b(1) represent the bias parameters of each branch, respectively.
[0104] In the first step of merging the network model structure, the weighted parameters are first merged, and the weighted parameters of each branch are multiplied by the convolution kernel weight parameters of the corresponding branch to obtain the new convolution kernel weight parameters W of each branch. (5)new =α×W (5) 、W (3)new =β×W (3) 、W (1)new =γ×W (1) , and the bias parameter b of each branch (5)new =α×b(5) 、b (3)new =β×b (3) 、b (1)new =γ×b (1) Then, the BN layer is integrated into the convolution kernel parameters according to the BN parameters of each branch. The specific fusion process is as follows:
[0105]
[0106]
[0107] in, is the convolution kernel weight parameter after fusion corresponding to the nth branch, is the bias parameter after fusion corresponding to the nth branch, μ (n) , σ (n) , β (n) and γ (n) is the BN parameter corresponding to the nth branch, ∈ is the adjustment parameter, is the first fusion parameter corresponding to the nth branch, is the second fusion parameter corresponding to the nth branch, n=1, 3, 5.
[0108] In the second step of convolution kernel parameter expansion, the largest convolution kernel in each branch is selected as the reference convolution kernel, and the remaining convolution kernels are expanded into convolution kernel patterns with the same area as the largest convolution kernel. Figure 5 The largest convolution kernel is 5x5, so with 5x5 as the basic convolution kernel, 3x3 and 1x1 are expanded to 5x5 convolution kernels respectively. The expansion diagram is as follows Figure 5 As shown in the second step, the extended part of the convolution kernel is filled with 0 values. Figure 6 As shown, Figure 6 There are three branches in the network, namely 3x3 convolution branch, 1x3 convolution branch, and a direct residual connection branch. Taking 3x3 as the reference convolution kernel size, the 1x3 convolution kernel is expanded. The expansion process is the same as Figure 5 Similarly, the convolution kernel is padded with a value of 0. For the directly connected residual branch, the center of the convolution kernel on each output channel is padded with a non-zero value, and the rest are padded with a value of 0. For example, with 2 input and output channels, the first convolution kernel center point in the first channel is padded with a non-zero value, while the second convolution kernel center point in the second channel is padded with a non-zero value, and the rest are padded with a value of 0. When the directly connected residual branch does not have a batch normalization parameter or a weighting parameter, the non-zero value is 1.
[0109] The third step is to perform convolution kernel fusion, which combines the convolution kernel parameters of multiple branches into one convolution kernel. The specific operation process is as follows:
[0110]
[0111] b all =b (1) +b (2) +...+b (n)
[0112] in, is the convolution kernel weight parameter at position (i, j) in the nth branch, and the convolution kernel weight parameters at the corresponding position are added together as the convolution kernel weight parameter at the corresponding position after fusion. b (n) is the bias parameter of the nth branch. The bias parameter value merges the bias values of n branches into a set of bias values b all .
[0113] The fourth step is to deploy the inference side. Based on the model structure after convolutional fusion, the inference side is deployed.
[0114] It can be seen that in this embodiment, firstly, based on the weighted network model structure, different convolution calculations are selected and weighted by learning weighted parameters, which can effectively improve the ability to extract model features and improve the model information extraction performance. Secondly, through the branch fusion operation within each basic unit, when deployed on the inference end, it can effectively reduce memory usage. In the inference calculation process, if Figure 7a As shown in the figure, before fusion, the three computing branches will use 3 times the memory to store the intermediate results during the calculation process. After processing by the network model structure optimization method proposed in this embodiment, as shown in the figure, Figure 7b As shown in the figure, only 1 times of memory space is needed to store the intermediate results before and after the convolution calculation. The more branches the model has, the more effective this method is. Finally, the branch fusion operation within each basic unit will effectively accelerate the convolution calculation. Figure 7a As shown in , there are three branches, one of which is the residual branch. Therefore, during the convolution calculation process, two convolution calculations are required. After processing by the network model structure optimization method proposed in this embodiment, as shown in Figure 7b As shown, only one convolution calculation is required, which directly reduces the amount of calculation on the inference side. The faster the model branches, the more the method reduces the amount of calculation.
[0115] It should be noted that the target convolutional neural network provided in this embodiment can be applied to the construction of various deep neural networks such as image classification and image detection. Taking image classification as an example, a deep neural network model is built based on the basic unit designed by the present invention for the training and reasoning of the image classification model. For the convenience of expression, the stacked basic unit designed by this application is recorded as a Block, and the internal network structure of each Block is as follows: Figure 8Shown on the left.
[0116] During image classification training, the detailed internal structure of each block is shown in the basic module on the left side of Figure 7. Multiple blocks can be used to build the basic network of the image classification model. The number of blocks can be set based on the difficulty of the network task. For example, when training image classification based on Cifar, the number of blocks can be set to 16, but when training based on the large-scale ImageNet image database, the number of blocks may need to be set to 25 or more. This is just an example, and the specific setting should be evaluated and determined based on the difficulty of the final task. After the image classification network is obtained, it is deployed on the inference side. During the deployment process, each block can be optimized to a 5x5 convolution kernel to speed up the inference side calculations while reducing computing resources.
[0117] An image recognition device provided in an embodiment of the present application is introduced below. The image recognition device described below and the image recognition method described above can be referenced to each other.
[0118] See also Figure 9 , a structural diagram of an image recognition device according to an exemplary embodiment is shown as follows. Figure 9 As shown, including:
[0119] An acquisition module 901 is configured to acquire a training image and determine a category label corresponding to the training image;
[0120] A training module 902 is configured to train the model parameters of a convolutional neural network using the training images and corresponding category labels to obtain a trained convolutional neural network; wherein the convolutional neural network includes a plurality of stacked basic units connected in series, each of the stacked basic units includes a plurality of branches connected in parallel, and the model parameters include at least weighting parameters and convolution layer parameters corresponding to each branch;
[0121] A fusion module 903 is configured to fuse the weighted parameters and convolutional layer parameters corresponding to each branch in each stacked basic unit in the trained convolutional neural network to obtain a fusion parameter corresponding to each branch in each stacked basic unit;
[0122] A deployment module 904 is configured to deploy a target convolutional neural network based on the trained convolutional neural network and the fusion parameters corresponding to each branch in each of the stacked basic units;
[0123] The recognition module 905 is used to obtain a target image and input the target image into the target convolutional neural network for image recognition.
[0124] The image recognition device provided in the embodiment of the present application sets different weighting parameters for different branches in each stacked basic unit in the convolutional neural network, and selectively weights different convolution calculations through learning the weighting parameters, which can effectively improve the ability to extract model features, improve the information extraction ability of the convolutional neural network, and improve the accuracy of image recognition by the convolutional neural network.
[0125] On the basis of the above embodiment, as a preferred implementation manner, the weighted parameters of corresponding branches in different stacked basic units in the convolutional neural network are the same; the training module 902 is specifically used to: construct a training convolutional neural network; wherein the training convolutional neural network includes n stacked basic units in series, n is a positive integer less than a preset value, each of the stacked basic units includes multiple branches in parallel, and the weighted parameters of corresponding branches in different stacked basic units are the same; the weighted parameters corresponding to different branches in the training convolutional neural network are trained using the training image and the corresponding category labels; the weighted parameters corresponding to different branches in the training convolutional neural network obtained through training are used as the weighted parameters corresponding to different branches in the convolutional neural network; the convolutional layer parameters corresponding to different branches in the convolutional neural network are trained using the training image and the corresponding category labels to obtain a trained convolutional neural network.
[0126] Based on the above embodiment, as a preferred implementation, the deployment module 904 includes:
[0127] A first fusion unit is used to fuse convolution kernels of multiple branches in each stacked basic unit in the trained convolutional neural network to obtain a fused target convolutional neural network;
[0128] The second fusion unit is used to fuse the fusion parameters at the corresponding position of each branch in each of the stacked basic units to obtain the fusion parameters at the corresponding position of the fused convolution kernel in each stacked basic unit in the target convolutional neural network.
[0129] Based on the above embodiment, as a preferred implementation, the first fusion unit includes:
[0130] A selection subunit is used to select a reference convolution kernel in each stacked basic unit in the convolutional neural network; wherein the reference convolution kernel is the maximum convolution kernel in all branches in the stacked basic unit;
[0131] an expansion subunit, configured to expand the convolution kernels of all branches in each of the stacked basic units into convolution kernels having an area equal to that of the reference convolution kernel in the corresponding stacked basic unit;
[0132] The fusion subunit is used to fuse the expanded convolution kernels of all branches in each of the stacked basic units to obtain a fused target convolutional neural network.
[0133] Based on the above embodiment, as a preferred implementation, the branch includes a convolution kernel branch and / or a direct residual connection branch;
[0134] The expansion subunit is specifically used to: determine a target convolution kernel in the convolution kernel branch in each of the stacked basic units, whose convolution kernel area is smaller than the convolution kernel area of the reference convolution kernel in the corresponding stacked basic unit, and expand the target convolution kernel into a convolution kernel with an area equal to that of the reference convolution kernel in the corresponding stacked basic unit by filling with zero values; and / or, fill the convolution kernel center value on the output channel of the direct residual connection branch in each of the stacked basic units with a non-zero value and fill the other parts with zero values, so as to expand the direct residual connection branch into a convolution kernel with an area equal to that of the reference convolution kernel in the corresponding stacked basic unit.
[0135] Based on the above embodiment, as a preferred implementation, the model parameters further include batch normalization layer parameters corresponding to each branch; the fusion module 903 includes:
[0136] A third fusion unit is used to fuse the weighted parameters corresponding to each branch in each of the stacked basic units in the trained convolutional neural network into the convolutional layer parameters to obtain the fused convolutional layer parameters corresponding to each of the branches;
[0137] The fourth fusion unit is used to fuse the fused convolution layer parameters corresponding to each branch in each of the stacked basic units with the batch normalization layer parameters to obtain the fusion parameters corresponding to each branch in each of the stacked basic units.
[0138] Based on the above embodiment, as a preferred implementation, the convolution layer parameters include convolution kernel weight parameters and bias unit parameters;
[0139] Correspondingly, the third fusion unit is specifically used to: use the product of the weighted parameter corresponding to each branch in each of the stacked basic units in the trained convolutional neural network and the convolution kernel weight parameter as the fused convolution kernel weight parameter corresponding to each branch; use the product of the weighted parameter corresponding to each branch in each of the stacked basic units in the trained convolutional neural network and the bias unit parameter as the fused bias unit parameter corresponding to each branch;
[0140] Correspondingly, the fourth fusion unit is specifically used to: use the first fusion formula to fuse the fused convolution kernel weight parameters corresponding to each branch in each of the stacked basic units with the batch normalization layer parameters to obtain the first fusion parameters corresponding to each branch in each of the stacked basic units; use the second fusion formula to fuse the fused bias unit parameters corresponding to each branch in each of the stacked basic units with the batch normalization layer parameters to obtain the second fusion parameters corresponding to each branch in each of the stacked basic units;
[0141] Among them, the first fusion formula is: The second fusion formula is:
[0142]
[0143] in, is the convolution kernel weight parameter after fusion corresponding to the nth branch, is the bias unit parameter after fusion corresponding to the nth branch, μ (n) , σ (n) , β (n) and γ (n) is the batch normalization layer parameter corresponding to the nth branch, ∈ is the adjustment parameter, is the first fusion parameter corresponding to the nth branch, is the second fusion parameter corresponding to the nth branch.
[0144] Based on the above embodiment, as a preferred implementation manner, the second fusion unit is specifically used to: sum the fusion parameters at the corresponding position of each branch in each of the stacked basic units as the fusion parameters at the corresponding position of the fused convolution kernel in each stacked basic unit in the target convolutional neural network.
[0145] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0146] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiment of the present application, the embodiment of the present application further provides an electronic device, Figure 10 FIG. 1 is a structural diagram of an electronic device according to an exemplary embodiment. Figure 10 As shown, the electronic equipment includes:
[0147] Communication interface 1, capable of exchanging information with other devices such as network devices;
[0148] The processor 2 is connected to the communication interface 1 to implement information exchange with other devices and is used to execute the image recognition method provided by one or more of the above technical solutions when running a computer program. The computer program is stored in the memory 3.
[0149] Of course, in actual application, the various components in the electronic device are coupled together through the bus system 4. It can be understood that the bus system 4 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 4 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 10 Various buses are labeled as bus system 4.
[0150] The memory 3 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.
[0151] It is understood that the memory 3 can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a magnetic disk memory or a magnetic tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus random access memory (DRRAM).The memory 3 described in the embodiments of the present application is intended to include but is not limited to these and any other suitable types of memories.
[0152] The method disclosed in the above-mentioned embodiment of the present application can be applied to processor 2 or implemented by processor 2. Processor 2 may be an integrated circuit chip with signal processing capabilities. During the implementation process, each step of the above-mentioned method can be completed by the integrated logic circuit of the hardware in processor 2 or instructions in the form of software. The above-mentioned processor 2 can be a general-purpose processor, DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 2 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application can be directly embodied as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in memory 3. Processor 2 reads the program in memory 3 and completes the steps of the above-mentioned method in combination with its hardware.
[0153] When the processor 2 executes the program, the corresponding processes in the various methods of the embodiments of the present application are implemented. For the sake of brevity, they are not repeated here.
[0154] In an exemplary embodiment, the present application also provides a storage medium, namely, a computer storage medium, specifically a computer-readable storage medium, such as a memory 3 storing a computer program. The computer program can be executed by a processor 2 to perform the steps of the aforementioned method. The computer-readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface storage, optical disk, or CD-ROM.
[0155] Those skilled in the art will understand that all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: mobile storage devices, ROM, RAM, disks or optical disks, etc. Various media that can store program codes.
[0156] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for enabling an electronic device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0157] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. An image recognition method, characterized in that: include: Obtaining a training image and determining a category label corresponding to the training image; The convolutional neural network model parameters are trained using the training images and the corresponding category labels to obtain a trained convolutional neural network; wherein the convolutional neural network includes a plurality of stacked basic units connected in series, each of the stacked basic units includes a plurality of branches connected in parallel, and the model parameters include at least weighted parameters corresponding to each branch, convolution layer parameters, and batch normalization layer parameters. Different stacked basic units contain the same number of branches, and the weighted parameters of the corresponding branches are the same. The convolution layer parameters include convolution kernel weight parameters and bias unit parameters. Fusing the weighted parameters and convolutional layer parameters corresponding to each branch in each stacked basic unit in the trained convolutional neural network to obtain fusion parameters corresponding to each branch in each stacked basic unit; Deploying a target convolutional neural network based on the trained convolutional neural network and the fusion parameters corresponding to each branch in each of the stacked basic units; Acquire a target image, and input the target image into the target convolutional neural network for image recognition; The weighted parameters and convolution layer parameters corresponding to each branch in each stacked basic unit in the trained convolutional neural network are fused to obtain the fusion parameters corresponding to each branch in each stacked basic unit, including: The product of the weighted parameter corresponding to each branch in each stacked basic unit in the trained convolutional neural network and the convolution kernel weight parameter is used as the fused convolution kernel weight parameter corresponding to each branch; The product of the weighted parameter corresponding to each branch in each stacked basic unit in the trained convolutional neural network and the bias unit parameter is used as the fused bias unit parameter corresponding to each branch; Using a first fusion formula, the fused convolution kernel weight parameters corresponding to each branch in each of the stacked basic units are fused with the batch normalization layer parameters to obtain a first fusion parameter corresponding to each branch in each of the stacked basic units; Using a second fusion formula, the fused bias unit parameters corresponding to each branch in each of the stacked basic units are fused with the batch normalization layer parameters to obtain a second fusion parameter corresponding to each branch in each of the stacked basic units; Among them, the first fusion formula is: , the second fusion formula is: ; in, is the convolution kernel weight parameter after fusion corresponding to the nth branch, is the fused bias unit parameter corresponding to the nth branch, 、 、 and is the batch normalization layer parameter corresponding to the nth branch, To adjust the parameters, is the first fusion parameter corresponding to the nth branch, is the second fusion parameter corresponding to the nth branch.
2. The image recognition method according to claim 1, characterized in that: The method of training the model parameters of the convolutional neural network using the training images and the corresponding category labels to obtain a trained convolutional neural network includes: Constructing a training convolutional neural network; wherein the training convolutional neural network includes n stacked basic units connected in series, where n is a positive integer less than a preset value, each stacked basic unit includes a plurality of branches connected in parallel, and weighted parameters of corresponding branches in different stacked basic units are the same; Using the training images and corresponding category labels to train weighted parameters corresponding to different branches in the training convolutional neural network; Using the weighted parameters corresponding to different branches in the training convolutional neural network obtained through training as the weighted parameters corresponding to different branches in the convolutional neural network; The convolutional layer parameters corresponding to different branches in the convolutional neural network are trained using the training images and the corresponding category labels to obtain a trained convolutional neural network.
3. The image recognition method according to claim 1, wherein: Deploying a target convolutional neural network based on the trained convolutional neural network and the fusion parameters corresponding to each branch in each of the stacked basic units, including: Performing convolution kernel fusion on multiple branches in each stacked basic unit in the trained convolutional neural network to obtain a fused target convolutional neural network; The fusion parameters at the corresponding position of each branch in each of the stacked basic units are fused to obtain the fusion parameters at the corresponding position of the fused convolution kernel in each stacked basic unit in the target convolutional neural network.
4. The image recognition method according to claim 3, characterized in that: The convolution kernels of multiple branches in each stacked basic unit in the convolutional neural network are fused to obtain a fused target convolutional neural network, including: Selecting a reference convolution kernel in each stacked basic unit in the convolutional neural network; wherein the reference convolution kernel is the maximum convolution kernel in all branches of the stacked basic unit; Expanding the convolution kernels of all branches in each of the stacked basic units into convolution kernels having an area equal to that of the reference convolution kernel in the corresponding stacked basic unit; The expanded convolution kernels of all branches in each of the stacked basic units are fused to obtain a fused target convolutional neural network.
5. The image recognition method according to claim 4, characterized in that: The branches include convolution kernel branches and / or direct residual connection branches; The step of expanding the convolution kernels of all branches in each of the stacked basic units into convolution kernels having an area equal to that of the reference convolution kernel in the corresponding stacked basic unit comprises: Determine a target convolution kernel in a convolution kernel branch in each of the stacked basic units, whose convolution kernel area is smaller than the convolution kernel area of the reference convolution kernel in the corresponding stacked basic unit, and expand the target convolution kernel into a convolution kernel having an area equal to that of the reference convolution kernel in the corresponding stacked basic unit by zero-padding; And / or, the center value of the convolution kernel on the output channel of the direct residual connection branch in each of the stacked basic units is filled with a non-zero value and the other parts are filled with zero values, so as to expand the direct residual connection branch into a convolution kernel with an area equal to that of the reference convolution kernel in the stacked basic unit to which it belongs.
6. The image recognition method according to claim 3, characterized in that: The step of fusing the fusion parameters at the corresponding position of each branch in each of the stacked basic units to obtain the fusion parameters at the corresponding position of the fused convolution kernel in each stacked basic unit in the target convolutional neural network includes: The fusion parameters at the corresponding position of each branch in each of the stacked basic units are summed as the fusion parameters at the corresponding position of the fused convolution kernel in each stacked basic unit in the target convolutional neural network.
7. An image recognition device, characterized in that: include: An acquisition module, configured to acquire a training image and determine a category label corresponding to the training image; A training module, configured to train the model parameters of a convolutional neural network using the training images and corresponding category labels to obtain a trained convolutional neural network; wherein the convolutional neural network comprises a plurality of stacked basic units connected in series, each of the stacked basic units comprises a plurality of branches connected in parallel, the model parameters comprise at least weighted parameters corresponding to each of the branches, convolutional layer parameters, and batch normalization layer parameters, the number of branches contained in different stacked basic units being the same, and the weighted parameters of the corresponding branches being the same, and the convolutional layer parameters comprising convolution kernel weight parameters and bias unit parameters; A fusion module, configured to fuse the weighted parameters and convolutional layer parameters corresponding to each branch in each of the stacked basic units in the trained convolutional neural network to obtain fusion parameters corresponding to each branch in each of the stacked basic units; A deployment module is used to deploy a target convolutional neural network based on the fusion parameters corresponding to each branch in each of the stacked basic units on the basis of the trained convolutional neural network; A recognition module is used to obtain a target image and input the target image into the target convolutional neural network for image recognition; Among them, the fusion module is specifically used to: use the product of the weighted parameter corresponding to each branch in each of the stacked basic units in the trained convolutional neural network and the convolution kernel weight parameter as the fused convolution kernel weight parameter corresponding to each branch; use the product of the weighted parameter corresponding to each branch in each of the stacked basic units in the trained convolutional neural network and the bias unit parameter as the fused bias unit parameter corresponding to each branch; use the first fusion formula to fuse the fused convolution kernel weight parameter corresponding to each branch in each of the stacked basic units with the batch normalization layer parameter to obtain the first fusion parameter corresponding to each branch in each of the stacked basic units; use the second fusion formula to fuse the fused bias unit parameter corresponding to each branch in each of the stacked basic units with the batch normalization layer parameter to obtain the second fusion parameter corresponding to each branch in each of the stacked basic units; Among them, the first fusion formula is: , the second fusion formula is: ; in, is the convolution kernel weight parameter after fusion corresponding to the nth branch, is the fused bias unit parameter corresponding to the nth branch, 、 、 and is the batch normalization layer parameter corresponding to the nth branch, To adjust the parameters, is the first fusion parameter corresponding to the nth branch, is the second fusion parameter corresponding to the nth branch.
8. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the image recognition method according to any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the image recognition method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Pedestrian re-identification method and device, computer equipment and storage medium
CN112183295A