Image recognition task execution method and device, equipment and medium

By adjusting and filtering the weight matrix of the image recognition model, more suitable pruning weights are generated, which solves the efficiency and accuracy problems of traditional pruning methods on resource-constrained devices, and achieves more efficient and accurate image recognition.

CN120071017APending Publication Date: 2025-05-30SHANDONG INSPUR SCI RES INST CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510290892.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-12
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

Due to the huge parameters of the deep image recognition model, it is difficult to complete the image recognition task in real time and efficiently on resource-constrained devices. The traditional fixed-scale pruning method has limitations when processing weights, and may mistakenly prune the weights corresponding to key features, resulting in a decrease in recognition accuracy.

Method used

By obtaining the current weight matrix, adjusting its column weights to generate multiple candidate weight matrices, dividing it into block matrices, and filtering out the target weight matrix based on the weight difference value, processing the target weight matrix based on the target pruning ratio to obtain the pruning weight, and updating the image recognition model to perform the recognition task.

Benefits of technology

The calculation efficiency and accuracy of image recognition are improved, the error deletion of key feature weights is avoided, and the weight that contributes a lot to the recognition is retained, so that the model can run efficiently on resource-constrained devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120071017A_ABST
    Figure CN120071017A_ABST
Patent Text Reader

Abstract

The invention discloses an image recognition task execution method and device, equipment and a medium, and relates to the technical field of image processing, and the method comprises the steps: obtaining a current weight matrix in a process of executing an image recognition task through employing an image recognition model based on a neural network, and adjusting the column weight of the current weight matrix, generating a plurality of candidate weight matrixes; the current weight matrix stores association strength information of each image feature; dividing each candidate weight matrix into a plurality of block matrixes, and screening out a target weight matrix from the plurality of candidate weight matrixes based on a weight difference value among the plurality of block matrixes; processing the target weight matrix based on the target pruning proportion to obtain a pruning weight from the target weight matrix; and updating the image recognition model by using the pruning weight, and executing the image recognition task by using the updated image recognition model. According to the invention, the calculation efficiency of image recognition is improved, and the accuracy of image recognition is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to a method, device, equipment and medium for executing an image recognition task. Background Art

[0002] With the rapid development of deep learning technology, deep image recognition models have achieved remarkable results in a wide range of fields, including image recognition, natural language processing, and speech recognition. In particular, deep neural networks can accurately identify objects, scenes, and features within images, providing powerful technical support for applications such as security monitoring, autonomous driving, and medical imaging diagnosis.

[0003] However, these deep image recognition models typically contain a massive number of parameters, which makes the models extremely large and requires significant computational and storage resources to process image data. This severely limits their application on resource-constrained devices (such as mobile terminals and embedded devices), making it difficult for these devices to efficiently and effectively perform image recognition tasks in real time. To address this challenge, model sparsification techniques have emerged. Fixed-ratio pruning is a common sparsification method. This approach groups the weights in the model into fixed groups and selects the larger weights to retain. This significantly reduces the size of the weight matrix after pruning, theoretically improving the computational speed of image recognition.

[0004] However, the traditional fixed-ratio pruning scheme has obvious limitations when dealing with weights. In the image recognition process, the weight distribution corresponding to image features is complex and diverse. When there are multiple large values ​​in a group of adjacent elements, the scheme may mistakenly prune the elements with larger weights, and these large weight elements may correspond to key features in the image, such as the outline of the object, important texture, etc.; on the contrary, when a group of elements are all small, some smaller elements are retained, and these smaller weight elements may not contribute much to image recognition. Taking 4:2 pruning as an example, when there are multiple large values ​​among the four adjacent elements, weight elements that play an important role in the key features of the image may be pruned; and when the four elements are all small, two smaller, insignificant elements are retained, which directly leads to a significant reduction in the accuracy of the pruned model in image recognition. Therefore, the above technical problems urgently need to be solved by those skilled in the art. Summary of the Invention

[0005] In view of this, the purpose of the present invention is to provide a method, apparatus, device and medium for performing image recognition tasks, which can improve the computational efficiency of image recognition while improving the accuracy of image recognition. The specific scheme is as follows:

[0006] In a first aspect, the present application discloses a method for performing an image recognition task, comprising:

[0007] In the process of performing an image recognition task using a neural network-based image recognition model, obtaining a current weight matrix and adjusting column weights of the current weight matrix to generate a plurality of candidate weight matrices; wherein the current weight matrix stores association strength information of each image feature;

[0008] Dividing each of the candidate weight matrices into a plurality of block matrices, and screening a target weight matrix from the plurality of candidate weight matrices based on weight differences between the plurality of block matrices;

[0009] Processing the target weight matrix based on the target pruning ratio to obtain pruning weights from the target weight matrix;

[0010] The image recognition model is updated using the pruning weights, and the image recognition task is performed using the updated image recognition model.

[0011] Optionally, the selecting a target weight matrix from the plurality of candidate weight matrices based on the weight differences between the plurality of block matrices includes:

[0012] If the weight difference between the multiple block matrices is greater than a preset threshold, the corresponding candidate weight matrix is ​​eliminated; if the weight difference between the multiple block matrices is not greater than the preset threshold, the corresponding candidate weight matrix is ​​retained to obtain the target weight matrix.

[0013] Optionally, adjusting the column weights of the current weight matrix to generate multiple candidate weight matrices includes:

[0014] Select any two columns of weights from the current weight matrix, swap the positions of the any two columns, and then determine the matrix obtained after the swap as the candidate weight matrix.

[0015] Optionally, processing the target weight matrix based on the target pruning ratio to obtain pruning weights from the target weight matrix includes:

[0016] Using a binary matrix obtained based on the target pruning ratio, multiplying the target weight matrix to obtain a result matrix, and obtaining the maximum weight of each row weight in the result matrix;

[0017] The weight corresponding to each of the maximum weights in the target weight matrix is ​​determined as the pruning weight.

[0018] Optionally, after updating the image recognition model using the pruning weights and performing the image recognition task using the updated image recognition model, the method further includes:

[0019] Obtaining a task execution result of the image recognition task; wherein the task execution result includes a rate of change of a loss function value of the image recognition model and an accuracy of an output result;

[0020] A target adjustment coefficient is determined according to the task execution result, and the pruning weight is adjusted by the target adjustment coefficient so as to re-update the image recognition model.

[0021] Optionally, determining a target adjustment coefficient according to the task execution result includes:

[0022] If the rate of decrease of the loss function value is less than a first threshold, setting the target adjustment coefficient to a first coefficient value;

[0023] If the decreasing rate of the loss function value is not less than the first threshold, the target adjustment coefficient is set to a second coefficient value; wherein the first coefficient value is greater than the second coefficient value.

[0024] Optionally, determining a target adjustment coefficient according to the task execution result includes:

[0025] If the accuracy of the output result is not less than the second threshold, keeping the pruning weight unchanged;

[0026] If the accuracy of the output result is less than the second threshold, the target adjustment coefficient is set to a third coefficient value.

[0027] In a second aspect, the present application discloses an image recognition task execution device, comprising:

[0028] an adjustment module for obtaining a current weight matrix and adjusting column weights of the current weight matrix to generate a plurality of candidate weight matrices during the process of performing an image recognition task using a neural network-based image recognition model; wherein the current weight matrix stores information on the strength of association of each image feature;

[0029] a screening module, configured to divide each candidate weight matrix into a plurality of block matrices, and screen a target weight matrix from the plurality of candidate weight matrices based on weight differences between the plurality of block matrices;

[0030] a pruning module, configured to process the target weight matrix based on a target pruning ratio to obtain pruning weights from the target weight matrix;

[0031] An execution module is used to update the image recognition model using the pruning weights and perform the image recognition task using the updated image recognition model.

[0032] In a third aspect, the present application discloses an electronic device, comprising:

[0033] Memory, used to store computer programs;

[0034] A processor is used to execute the computer program to implement the aforementioned disclosed method for executing the image recognition task.

[0035] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned disclosed image recognition task execution method is implemented.

[0036] It can be seen that the present application proposes a method for performing an image recognition task, comprising: in the process of performing an image recognition task using an image recognition model based on a neural network, obtaining a current weight matrix and adjusting the column weights of the current weight matrix to generate multiple candidate weight matrices; wherein the current weight matrix stores the correlation strength information of each image feature; dividing each candidate weight matrix into multiple block matrices, and based on the weight difference between the multiple block matrices, screening a target weight matrix from the multiple candidate weight matrices; processing the target weight matrix based on the target pruning ratio to obtain pruning weights from the target weight matrix; updating the image recognition model using the pruning weights, and performing the image recognition task using the updated image recognition model. It can be seen that the present application first obtains the current weight matrix and adjusts the column weights of the current weight matrix to generate multiple candidate weight matrices, thereby greatly enriching the diversity of the weight matrix and creating conditions for mining weight configurations that are more suitable for image recognition tasks. Further, each candidate weight matrix is ​​divided into multiple block matrices, and based on the weight difference between the block matrices, the target weight matrix is ​​screened from the numerous candidate weight matrices. Subsequently, the target weight matrix is ​​processed according to the target pruning ratio to obtain the pruning weights. Compared with traditional fixed-ratio pruning, the present application can accurately determine the pruning weights based on the selected better target weight matrix, effectively avoiding blind pruning. In this way, the accidental deletion of key feature weight elements is reduced, and the weights that contribute more to image recognition are retained. Finally, the image recognition model is updated using the obtained pruning weights, and the updated model is used to perform image recognition tasks. Since the updated model uses weights that have been optimized, screened, and reasonably pruned, the accuracy of image recognition is significantly improved, while unnecessary computing resource consumption is reduced, so that the model can run more efficiently on resource-constrained devices. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0038] Figure 1 This is a flow chart of a method for executing an image recognition task disclosed in this application;

[0039] Figure 2 This is a schematic diagram of column weight adjustment disclosed in this application;

[0040] Figure 3 A weight calculation schematic diagram disclosed in this application;

[0041] Figure 4 A schematic diagram of the comparison of results disclosed in this application;

[0042] Figure 5 A schematic diagram of the overall architecture for executing an image recognition task disclosed in this application;

[0043] Figure 6 This is a schematic diagram of the structure of an image recognition task execution device disclosed in this application;

[0044] Figure 7 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION

[0045] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0046] Traditional fixed-ratio pruning schemes have significant limitations when handling weights. During image recognition, the distribution of weights corresponding to image features is complex and diverse. When a group of adjacent elements contains multiple large values, traditional fixed-ratio pruning schemes may mistakenly prune the elements with larger weights, which may correspond to key features in the image. Conversely, when a group of elements is generally small, some smaller elements are retained, which may not contribute much to image recognition.

[0047] To this end, an embodiment of the present application proposes an image recognition task execution scheme that can improve the computational efficiency of image recognition while improving the accuracy of image recognition.

[0048] Embodiments of the present application disclose a method for performing an image recognition task. Refer to Figure 1 as shown, including:

[0049] Step S11: During the process of performing an image recognition task using a neural network-based image recognition model, obtain the current weight matrix, and adjust the column weights of the current weight matrix to generate multiple candidate weight matrices; wherein, the current weight matrix stores the association strength information of each image feature.

[0050] In this embodiment, select any two columns of weights from the current weight matrix, exchange the positions of the two columns of weights, and determine the matrix obtained after the exchange as the candidate weight matrix. Specifically, within the column index range of the current weight matrix, randomly select two different column index values to determine any two columns of weights whose positions need to be exchanged. Assume that the column index range of the current weight matrix is from 0 to n - 1, and two different index values i and j (0 ≤ i < n, 0 ≤ j < n and i ≠ j) are obtained through a random number generator. Further, perform a position exchange operation on the selected two columns of weights. Specifically, first take out the weight data of the i-th column in sequence and place the weight data of the j-th column in the original position of the i-th column, and then place the previously taken out weight data of the i-th column in the j-th column position, thus completing the position exchange of the two columns of weights. Finally, determine the matrix obtained after the column weight exchange operation as a candidate weight matrix. Since the two columns randomly selected each time are different, by repeating the above operation, multiple candidate weight matrices can be generated. These candidate weight matrices provide a rich selection for subsequent screening of better weight configurations, which helps to挖掘出更适配当前图像识别任务的权重矩阵形式,从而提升图像识别模型的性能。

[0051] Step S12: Divide each candidate weight matrix into multiple block matrices, and screen out the target weight matrix from the multiple candidate weight matrices based on the weight difference between the multiple block matrices.

[0052] In this embodiment, if the weight difference between the multiple block matrices is greater than a preset threshold, the corresponding candidate weight matrix is excluded; if the weight difference between the multiple block matrices is not greater than the preset threshold, the corresponding candidate weight matrix is retained to obtain the target weight matrix.

[0053] It should be noted that there is an unclear expression "挖掘出更适配当前图像识别任务的权重矩阵形式" in the original text, and I have tried my best to translate it while keeping the original meaning as much as possible. You may need to check and correct it according to the actual situation.Taking a candidate weight matrix as an example, suppose it is divided into two block matrices, denoted as block matrix A and block matrix B. After the division is completed, the weight sums of block matrix A and block matrix B are calculated separately. All weights in block matrix A are summed to obtain a total, denoted as SA. Similarly, all weights in block matrix B are summed to obtain another total, denoted as SB. The absolute value of the difference between SA and SB, i.e., |SA - SB|, is denoted as the weight difference between the two block matrices. In this embodiment, a weight difference of 10 is used as a preset threshold to screen candidate weight matrices. If the calculated weight difference |SA - SB| between block matrix A and block matrix B is greater than 10, the corresponding candidate weight matrix is ​​eliminated. This is because an excessively large weight difference indicates that the weight distribution between block matrix A and block matrix B in the candidate weight matrix is ​​too unbalanced, which is not conducive to the model's stable extraction and recognition of image features. Conversely, if the calculated weight difference |SA - SB| between block matrix A and block matrix B is no greater than 10, the candidate weight matrix is ​​retained. All generated candidate weight matrices are screened in this way, and the candidate weight matrices that are finally retained are determined as target weight matrices. These target weight matrices are more likely to provide a good weight configuration for the image recognition model because the weight differences between their block matrices are relatively stable and the distribution is more balanced, which is more likely to help the model achieve better performance in image recognition tasks. Figure 2 As shown, for candidate weight matrix 1 and candidate weight matrix 2, the weight difference between the two block matrices is no more than 10, so candidate weight matrix 1 and candidate weight matrix 2 are both determined as target weight matrices.

[0054] Step S13: processing the target weight matrix based on the target pruning ratio to obtain pruning weights from the target weight matrix.

[0055] In this embodiment, a binary matrix obtained based on the target pruning ratio is used to multiply the target weight matrix to obtain a result matrix, and the maximum weight of each row of weights in the result matrix is ​​obtained. Then, the weight corresponding to each maximum weight in the target weight matrix is ​​determined as the pruning weight.

[0056] See also Figure 3 and Figure 4 , the above process is explained by taking the target weight matrix as candidate weight matrix 2 as an example. In order to simplify the explanation process, one of the block matrices of candidate weight matrix 2 is used as an example for demonstration. Figure 3The first matrix in is one of the block matrices of the candidate weight matrix 2, the second matrix is ​​a binary matrix, and the second matrix is ​​the result matrix. The maximum value of the second row in the result matrix is ​​14, and 14 is obtained by multiplying the second row (2568) of the block matrix with the last column (0011) of the second matrix. Since the last column of the second matrix is ​​0011, the last two weights of 2568 are taken as pruning weights. Further, Figure 4 The yellow part in is all the pruning weights obtained after the overall operation.

[0057] Step S14: using the pruning weights to update the image recognition model, and using the updated image recognition model to perform the image recognition task.

[0058] To further improve the accuracy of image recognition, this embodiment adjusts the pruning weights according to the target adjustment coefficient, updates the image recognition model using the adjusted weights, and performs the image recognition task using the updated image recognition model. The following describes how to determine the target adjustment coefficient:

[0059] Obtain the task execution results for the image recognition task, which include the rate of change of the image recognition model's loss function value and the accuracy of the output results. Determine the target adjustment coefficient based on the task execution results. Adjust the pruning weights by multiplying the target adjustment coefficient by each pruning weight in the weight matrix.

[0060] On the one hand, if the decrease rate of the loss function value is less than the first threshold, the target adjustment coefficient is set to the first coefficient value; if the decrease rate of the loss function value is not less than the first threshold, the target adjustment coefficient is set to the second coefficient value; wherein, the first coefficient value is greater than the second coefficient value.

[0061] When the rate of decrease of the loss function value of the model is less than a pre-set first threshold, it indicates that the difference between the predicted value and the true value of the model is shrinking slowly during the optimization process. In order to accelerate the convergence of the model and improve the model performance, it is necessary to increase the intensity of the adjustment of the model parameters. To this end, this embodiment sets the target adjustment coefficient to the first coefficient value. For example, when the condition that the rate of decrease of the loss function value is less than the first threshold is met, the target adjustment coefficient is set to the ratio of the original total weight to the pruned total weight (the ratio of the original total weight to the pruned total weight is greater than 1), and the target adjustment coefficient is multiplied by each pruned weight in the weight matrix to increase the pruned weight. In this way, during the subsequent operation of the model, calculations will be performed based on these adjusted, larger pruned weights, prompting the model to optimize faster in the direction of reducing the loss function value and accelerating the convergence speed.

[0062] If the rate of decrease of the loss function value of the model is not less than the first threshold, it means that the current optimization strategy of the model is relatively effective and can reduce the difference between the predicted value and the true value at a reasonable speed. At this time, in order to avoid problems such as instability or overfitting of the model caused by excessive adjustment, it is necessary to appropriately reduce the intensity of adjustment of the model parameters. In this embodiment, the target adjustment coefficient is set to the second coefficient value, and the first coefficient value is greater than the second coefficient value. For example, the second coefficient value can be set to a fixed value less than 1, such as 0.8 (this is just an example, and the actual value needs to be determined based on the model characteristics and experimental results). Similarly, the pruning weight is reduced by multiplying each pruning weight in the weight matrix by the target adjustment coefficient. In this way, under the premise of ensuring stable convergence of the model, the pruning weight is moderately adjusted to continuously optimize the model performance and prevent the existing good performance of the model from being destroyed due to excessive adjustment.

[0063] On the other hand, if the output result accuracy is not less than the second threshold, the pruning weight is kept unchanged; if the output result accuracy is less than the second threshold, the target adjustment coefficient is set to a third coefficient value; wherein the third coefficient value is greater than the second coefficient value.

[0064] Assuming the second threshold is set at 85%, when the image recognition model's output accuracy is calculated to be 90%, or at least 85%, the model's current performance has reached or exceeded the expected accuracy level. To maintain the model's current good performance, no additional adjustments to the pruning weights are required; the pruning weights remain unchanged. When the output accuracy falls below the second threshold, the model needs to be adjusted to improve performance. Assuming the second threshold remains at 85%, if the model's output accuracy is calculated to be 80%, which is less than 85%, the target adjustment coefficient is set to a third coefficient value. For example, the third coefficient value is set to 1.2 (the actual value should be determined based on model characteristics and extensive experimentation, and must ensure that this value effectively improves model performance). After determining the third coefficient value, each pruning weight in the weight matrix is ​​multiplied by this coefficient to increase the pruned weight. This process continues in this manner. By adjusting the model weight configuration in this way, the accuracy of the output results can be improved in subsequent image recognition tasks, optimizing model performance.

[0065] The following describes the method for executing the image recognition task described in this application through specific embodiments:

[0066] In order to overcome the shortcomings of the existing 4:2 pruning scheme, this application proposes a sparse pruning optimization scheme based on 4:2 structure sparsification. This scheme can more effectively retain important weights while removing unimportant weights, thereby achieving model sparsification while maintaining model accuracy and improving the model's operational efficiency and practicality. In order to achieve the desired function, the overall architecture of this application is as follows Figure 5As shown, it includes a sequence adjustment module, a weight multiplication and addition module, a solution selection module, a result comparison module, a pruning execution module, and a weight fine-tuning module. To better illustrate this application, the following is a specific example:

[0067] 1. After the sequence adjustment module obtains the weight matrix, it calculates its total eigenvalue (the sum of all elements in the matrix) and block eigenvalue (the sum of elements in units of 4 columns). Figure 2 Taking the weight matrix on the left as an example, the total weight is 142, and the block weights are 74 and 68, respectively. Next, the matrix is ​​rearranged column by column, and the block eigenvalues ​​of each rearranged matrix are calculated. Rearranged matrices with block eigenvalue differences greater than 10 are then removed to prevent uneven distribution of adjusted elements from affecting pruning accuracy.

[0068] 2. After the initial screening, multiple candidate weight matrices are sent to the weight multiplication and addition module together with their corresponding total weights. The weight multiplication and addition module receives multiple candidate weight matrices, such as Figure 2 As shown on the right. These matrices are combined with the binary matrix composed of the 4-choose-2 selection method ( Figure 3 The middle matrix, where each column represents a solution (e.g., the first column {1, 1, 0, 0} means retaining the first two elements and discarding the last two elements), performs multiplication and addition operations to obtain a 4×6 matrix result under six choices.

[0069] 3. The solution selection module compares all possible pruning results, such as Figure 3 In the second row of the result matrix, the maximum result is 14, and the pruning scheme corresponding to the sixth column is selected. The column selection matrix {0, 0, 1, 1} indicates that the last two elements are retained.

[0070] 4. The result comparison module receives all the optimal pruning solutions of the candidate weight matrix group and performs the final screening. Figure 4 As shown in Figure 3, for the sparsified matrix, the weight of the rearranged matrix after pruning is 107, which is 12 higher than the 95 before pruning, closer to the total weight of the original matrix, and improves the pruning accuracy.

[0071] 5. The pruning execution module receives the optimal pruning solution selected by the result comparison module and performs the actual pruning operation, obtaining a new weight matrix that is half the size of the original weight matrix. The host uses the pruned result matrix as the new feature matrix and performs convolution calculations with other input matrices.

[0072] 6. The weight fine-tuning module multiplies the fine-tuning parameter (i.e., target adjustment parameter) calculated under the adaptive mechanism by each element of the weight matrix, making the result closer to the total weight of the original matrix. This ensures that the pruned model maintains high accuracy while reducing the number of weight matrix units and improving computational efficiency.

[0073] The core advantage of this application lies in its innovative sequence adjustment technology, which is the key to achieving efficient sparse pruning. Through the sequence adjustment module, the weight matrix can be optimized before pruning, thereby improving the accuracy and performance of the pruned model. Sequence adjustment can more effectively retain important weights while removing unimportant weights to ensure that the model can more accurately identify and retain key features in the subsequent weight multiplication and pruning process. This adjustment mechanism allows the model to retain the weights that have a significant impact on performance while reducing the number of parameters, thereby avoiding a significant drop in accuracy while maintaining model sparsity. In addition, the design of this application can quickly adjust fine-tuning parameters by dynamically adjusting the weight sequence, thereby further reducing the loss of accuracy after pruning. Through the collaborative work of these modules, this application can reduce the number of model weights, improve computational efficiency, and maintain the accuracy performance of the pruned model as much as possible. This optimization scheme is of great significance for realizing efficient deep learning model applications on resource-constrained devices.

[0074] It can be seen that the present application proposes a method for performing an image recognition task, comprising: in the process of performing an image recognition task using an image recognition model based on a neural network, obtaining a current weight matrix and adjusting the column weights of the current weight matrix to generate multiple candidate weight matrices; wherein the current weight matrix stores the correlation strength information of each image feature; dividing each candidate weight matrix into multiple block matrices, and based on the weight difference between the multiple block matrices, screening a target weight matrix from the multiple candidate weight matrices; processing the target weight matrix based on the target pruning ratio to obtain pruning weights from the target weight matrix; updating the image recognition model using the pruning weights, and performing the image recognition task using the updated image recognition model. It can be seen that the present application first obtains the current weight matrix and adjusts the column weights of the current weight matrix to generate multiple candidate weight matrices, thereby greatly enriching the diversity of the weight matrix and creating conditions for mining weight configurations that are more suitable for image recognition tasks. Further, each candidate weight matrix is ​​divided into multiple block matrices, and based on the weight difference between the block matrices, the target weight matrix is ​​screened from the numerous candidate weight matrices. Subsequently, the target weight matrix is ​​processed according to the target pruning ratio to obtain the pruning weights. Compared with traditional fixed-ratio pruning, the present application can accurately determine the pruning weights based on the selected better target weight matrix, effectively avoiding blind pruning. In this way, the accidental deletion of key feature weight elements is reduced, and the weights that contribute more to image recognition are retained. Finally, the image recognition model is updated using the obtained pruning weights, and the updated model is used to perform image recognition tasks. Since the updated model uses weights that have been optimized, screened, and reasonably pruned, the accuracy of image recognition is significantly improved, while unnecessary computing resource consumption is reduced, so that the model can run more efficiently on resource-constrained devices.

[0075] Accordingly, the present application also discloses an image recognition task execution device, see Figure 6 As shown, the device includes:

[0076] An adjustment module 11 is configured to obtain a current weight matrix and adjust column weights of the current weight matrix to generate a plurality of candidate weight matrices during the process of performing an image recognition task using a neural network-based image recognition model; wherein the current weight matrix stores information on the association strength of each image feature;

[0077] A screening module 12 is configured to divide each candidate weight matrix into a plurality of block matrices, and screen a target weight matrix from the plurality of candidate weight matrices based on weight differences between the plurality of block matrices;

[0078] a pruning module 13, configured to process the target weight matrix based on a target pruning ratio to obtain pruning weights from the target weight matrix;

[0079] The execution module 14 is configured to update the image recognition model using the pruning weights and execute the image recognition task using the updated image recognition model.

[0080] Among them, for more specific working processes of the above modules, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.

[0081] It can be seen that the present application proposes a method for performing an image recognition task, comprising: in the process of performing an image recognition task using an image recognition model based on a neural network, obtaining a current weight matrix and adjusting the column weights of the current weight matrix to generate multiple candidate weight matrices; wherein the current weight matrix stores the correlation strength information of each image feature; dividing each candidate weight matrix into multiple block matrices, and based on the weight difference between the multiple block matrices, screening a target weight matrix from the multiple candidate weight matrices; processing the target weight matrix based on the target pruning ratio to obtain pruning weights from the target weight matrix; updating the image recognition model using the pruning weights, and performing the image recognition task using the updated image recognition model. It can be seen that the present application first obtains the current weight matrix and adjusts the column weights of the current weight matrix to generate multiple candidate weight matrices, thereby greatly enriching the diversity of the weight matrix and creating conditions for mining weight configurations that are more suitable for image recognition tasks. Further, each candidate weight matrix is ​​divided into multiple block matrices, and based on the weight difference between the block matrices, the target weight matrix is ​​screened from the numerous candidate weight matrices. Subsequently, the target weight matrix is ​​processed according to the target pruning ratio to obtain the pruning weights. Compared with traditional fixed-ratio pruning, the present application can accurately determine the pruning weights based on the selected better target weight matrix, effectively avoiding blind pruning. In this way, the accidental deletion of key feature weight elements is reduced, and the weights that contribute more to image recognition are retained. Finally, the image recognition model is updated using the obtained pruning weights, and the updated model is used to perform image recognition tasks. Since the updated model uses weights that have been optimized, screened, and reasonably pruned, the accuracy of image recognition is significantly improved, while unnecessary computing resource consumption is reduced, so that the model can run more efficiently on resource-constrained devices.

[0082] Furthermore, an embodiment of the present application also provides an electronic device. Figure 7 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram should not be considered as any limitation to the scope of application of the present application.

[0083] Figure 7 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a display screen 23, an input / output interface 24, a communication interface 25, a power supply 26, and a communication bus 27. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps of the image recognition task execution method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0084] In this embodiment, the power supply 26 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 25 can create a data transmission channel between the electronic device 20 and the external device. The communication protocol it follows is any communication protocol that can be applied to the technical solution of this application and is not specifically limited here; the input and output interface 24 is used to obtain external input data or output data to the outside world. Its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0085] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, a magnetic disk, or an optical disk, etc. The resources stored thereon can include a computer program 221, which can be stored in a temporary or permanent manner. In addition to including a computer program capable of performing the image recognition task execution method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 221 can further include a computer program capable of performing other specific tasks.

[0086] Furthermore, an embodiment of the present application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned disclosed image recognition task execution method is implemented.

[0087] For the specific steps of this method, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.

[0088] The various embodiments in this application are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part.

[0089] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0090] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0091] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.

[0092] The above is a detailed introduction to the image recognition task execution method, device, equipment, and storage medium provided by this application. Specific examples are used in this article to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method of this application and its core idea; at the same time, for general technical personnel in this field, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on this application.

Claims

1. A method for executing an image recognition task, characterized in that: include: In the process of performing an image recognition task using a neural network-based image recognition model, a current weight matrix is ​​obtained, and column weights of the current weight matrix are adjusted to generate a plurality of candidate weight matrices; wherein the current weight matrix stores association strength information of each image feature; Dividing each of the candidate weight matrices into a plurality of block matrices, and selecting a target weight matrix from the plurality of candidate weight matrices based on weight differences between the plurality of block matrices; Processing the target weight matrix based on the target pruning ratio to obtain pruning weights from the target weight matrix; The image recognition model is updated using the pruning weights, and the image recognition task is performed using the updated image recognition model.

2. The image recognition task execution method according to claim 1, characterized in that: The step of selecting a target weight matrix from a plurality of candidate weight matrices based on the weight differences between the plurality of block matrices comprises: If the weight difference between the multiple block matrices is greater than a preset threshold, the corresponding candidate weight matrix is ​​eliminated; if the weight difference between the multiple block matrices is not greater than the preset threshold, the corresponding candidate weight matrix is ​​retained to obtain the target weight matrix.

3. The image recognition task execution method according to claim 1, characterized in that: The step of adjusting the column weights of the current weight matrix to generate a plurality of candidate weight matrices includes: Select any two columns of weights from the current weight matrix, exchange the positions of the any two columns, and then determine the matrix obtained after the exchange as the candidate weight matrix.

4. The method for executing an image recognition task according to claim 1, characterized in that: The processing of the target weight matrix based on the target pruning ratio to obtain pruning weights from the target weight matrix includes: Using a binary matrix obtained based on the target pruning ratio, multiplying the target weight matrix to obtain a result matrix, and obtaining the maximum weight of each row weight in the result matrix; The weight corresponding to each of the maximum weights in the target weight matrix is ​​determined as the pruning weight.

5. The method for executing an image recognition task according to any one of claims 1 to 4, characterized in that: After the image recognition model is updated by using the pruning weights and the image recognition task is performed by using the updated image recognition model, the method further includes: Obtaining the task execution result of the image recognition task; wherein the task execution result includes the loss function value change rate and output result accuracy of the image recognition model; A target adjustment coefficient is determined according to the task execution result, and the pruning weight is adjusted by the target adjustment coefficient so as to re-update the image recognition model.

6. The method for executing an image recognition task according to claim 5, characterized in that: Determining the target adjustment coefficient according to the task execution result includes: If the decreasing rate of the loss function value is less than a first threshold, setting the target adjustment coefficient to a first coefficient value; If the decreasing rate of the loss function value is not less than the first threshold, the target adjustment coefficient is set to a second coefficient value; wherein the first coefficient value is greater than the second coefficient value.

7. The method for executing an image recognition task according to claim 6, characterized in that: Determining the target adjustment coefficient according to the task execution result includes: If the accuracy of the output result is not less than the second threshold, keeping the pruning weight unchanged; If the accuracy of the output result is less than the second threshold, the target adjustment coefficient is set to a third coefficient value.

8. An image recognition task execution device, characterized in that: include: An adjustment module, used for obtaining a current weight matrix and adjusting the column weights of the current weight matrix to generate a plurality of candidate weight matrices in the process of performing an image recognition task using an image recognition model based on a neural network; wherein the current weight matrix stores the association strength information of each image feature; A screening module, used for dividing each of the candidate weight matrices into a plurality of block matrices, and screening a target weight matrix from the plurality of candidate weight matrices based on weight differences between the plurality of block matrices; A pruning module, configured to process the target weight matrix based on a target pruning ratio to obtain pruning weights from the target weight matrix; An execution module is used to update the image recognition model using the pruning weights and perform the image recognition task using the updated image recognition model.

9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the image recognition task execution method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: Used to store a computer program; wherein, when the computer program is executed by a processor, the image recognition task execution method as described in any one of claims 1 to 7 is implemented.