Neural network model structure adjustment method and device and related equipment

By screening and adjusting the network layer of neural network model with high importance, the problem of high computing resource consumption during neural network model structure adjustment is solved, and the recognition efficiency and resource utilization are improved.

CN119129684APending Publication Date: 2024-12-13北京中关村科金技术有限公司
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411020414.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-29
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

At present, when it is necessary to adjust the network layer structure of the neural network model, the consumption of computing resources is large, resulting in waste of resources and inefficiency.

Method used

By obtaining the target importance score of each network layer, the high-importance network layer is selected for structural adjustment, and these adjusted network layers are used for target object recognition, thereby reducing the consumption of computing resources and improving identification efficiency.

Benefits of technology

It effectively reduces the need for all network layer structure adjustments of neural network models, improves the efficiency of target object recognition, and significantly reduces the consumption of computing and storage resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119129684A_ABST
    Figure CN119129684A_ABST
Patent Text Reader

Abstract

The invention provides a neural network model structure adjustment method and device and related equipment, and the method comprises the steps: obtaining a target importance score of each network layer in M network layers of a target neural network model, obtaining M target importance scores, the target importance scores being used for representing the importance degree of the network layers in the target neural network model, the target importance score is calculated according to the weight matrix of the network layer and the L2 norm of the activation value, and the L2 norm of the activation value is determined according to the input vector of the target neural network model; arranging the M target importance scores according to a preset sequence; determining N network layers of which the target importance scores are greater than a preset value from the sorted M target importance scores; and adjusting the structures of the N network layers, and performing target object identification by using a target neural network model comprising the N network layers after the structures are adjusted. In this way, consumption of computing resources is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the fields of natural language processing, computer vision, artificial intelligence and deep learning technology, and in particular to a method, apparatus and related equipment for adjusting the structure of a neural network model. Background Art

[0002] With the development of deep learning technology, neural network models have achieved remarkable results in many fields. However, neural network models usually include a large number of parameters, resulting in high consumption of computing resources and storage resources. It can be seen that when the structure of the network layer of the neural network model needs to be adjusted, the consumption of computing resources is relatively large. Summary of the invention

[0003] The embodiments of the present application provide a neural network model structure adjustment method, apparatus and related equipment to solve the current problem of large consumption of computing resources when the structure of the network layer of the neural network model needs to be adjusted.

[0004] To solve the above problems, this application is implemented as follows:

[0005] In a first aspect, an embodiment of the present application provides a method for adjusting a neural network model structure, comprising:

[0006] Obtaining a target importance score for each of the M network layers of the target neural network model to obtain M target importance scores, wherein the target importance score is used to indicate the importance of the network layer in the target neural network model, and the target importance score is calculated based on the weight matrix of the network layer and the L2 norm of the activation value, and the L2 norm of the activation value is determined based on the input vector of the target neural network model;

[0007] Arrange the M target importance scores in a preset order;

[0008] From the sorted M target importance scores, determine N network layers whose target importance scores are greater than a preset value;

[0009] Adjusting the structures of the N network layers, and using the target neural network model including the N network layers after the structures are adjusted to perform target object recognition;

[0010] Wherein, M and N are both positive integers, and N is less than M.

[0011] In a second aspect, an embodiment of the present application provides a neural network model structure adjustment device, comprising:

[0012] A first acquisition module is used to obtain a target importance score of each network layer in the M network layers of the target neural network model to obtain M target importance scores, wherein the target importance score is used to indicate the importance of the network layer in the target neural network model, and the target importance score is calculated based on the weight matrix of the network layer and the L2 norm of the activation value, and the L2 norm of the activation value is determined based on the input vector of the target neural network model;

[0013] An arrangement module, used to arrange the M target importance scores in a preset order;

[0014] A first determination module is used to determine N network layers whose target importance scores are greater than a preset value from the sorted M target importance scores;

[0015] An adjustment module, used to adjust the structure of the N network layers, and use the target neural network model including the N network layers after the structure is adjusted to perform target object recognition;

[0016] Wherein, M and N are both positive integers, and N is less than M.

[0017] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a memory, a processor, and a program stored in the memory and executable on the processor; the processor is used to read the program in the memory to implement the steps in the method described in the first aspect above.

[0018] In a fourth aspect, an embodiment of the present application further provides a readable storage medium for storing a program, which, when executed by a processor, implements the steps in the method described in the first aspect above.

[0019] In a fifth aspect, an embodiment of the present application further provides a computer program product, comprising computer instructions, which, when executed by a processor, implement the steps in the method described in the first aspect above.

[0020] In an embodiment of the present application, the target importance score of each network layer in the M network layers of the target neural network model can be obtained, and N network layers with target importance scores greater than a preset value can be screened out according to the target importance scores, and only the structure of the above N network layers needs to be adjusted. In this way, there is no need to adjust the structure of all network layers in the target neural network model, thereby reducing the consumption of computing resources. At the same time, the target neural network model including the N network layers after the structure is adjusted can be used to identify the target object, thereby improving the recognition efficiency of the target object. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. 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 paying any creative labor.

[0022] Figure 1 It is one of the flow charts of the neural network model structure adjustment method provided in the embodiment of the present application;

[0023] Figure 2 This is the second flowchart of the neural network model structure adjustment method provided in the embodiment of the present application;

[0024] Figure 3 is a schematic diagram of the structure of a neural network model structure adjustment device provided in an embodiment of the present application;

[0025] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0027] The terms "first", "second" etc. in the embodiments of the present application are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. In addition, the terms "include" and "have" and any variation thereof are intended to cover non-exclusive inclusions, for example, the process, method, system, product or equipment comprising a series of steps or units need not be limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment. In addition, "and / or" is used in the present application to represent at least one of connected objects, such as A and / or B and / or C, representing the inclusion of separate A, separate B, separate C, and A and B all exist, B and C all exist, A and C all exist, and 7 situations that A, B and C all exist.

[0028] See also Figure 1 , Figure 1 Schematic diagram of the process of adjusting the structure of the neural network model provided in the embodiment of the present application. Figure 1 As shown, the neural network model structure adjustment method may include the following steps:

[0029] Step 101, obtain a target importance score for each of the M network layers of the target neural network model to obtain M target importance scores, wherein the target importance score is used to indicate the importance of the network layer in the target neural network model, and the target importance score is calculated based on the L2 norm of the weight matrix and activation value of the network layer.

[0030] Among them, the specific manner in which the L2 norm of the activation value is determined according to the input vector of the target neural network model is not limited here. Optionally, the L2 norm of the activation value is the square root of the sum of squares of all elements of the input vector of the target neural network model; and optionally, the L2 norm of the activation value is the product of the application scenario coefficient and the target value, and the target value can be the square root of the sum of squares of all elements of the input vector of the target neural network model, wherein the input vector can be related to the execution task of the target neural network model, that is, the input vector can be a vector obtained by vector extraction of the execution task, and the application scenario coefficient can correspond to the execution task one by one, and the application scenario coefficient is different for different execution tasks. For example: when the execution task is to recognize a specific object in a sentence, the application scenario coefficient can be a first value, and when the execution task is a specific object in an image, the application scenario coefficient can be a second value, the first value can be less than the second value, or the first value can be greater than the second value, which is not limited here.

[0031] Among them, the specific type of the target neural network model is not limited here. Optionally, the target neural network model can be a large language model (such as a transformer model (Transformer model)), or the target neural network model can also be a large language model (Large Language Models, LLMs) model.

[0032] Among them, the target importance score is used to indicate the importance of the network layer in the target neural network model, that is, the higher the importance of a certain network layer in the target neural network model, the larger the value of the target importance score corresponding to the network layer. Similarly, when the importance of a certain network layer in the target neural network model is lower, the value of the target importance score corresponding to the network layer is smaller, that is, the values ​​of the target importance scores corresponding to different network layers may be different.

[0033] Among them, the specific method of calculating the target importance score according to the weight matrix of the network layer and the L2 norm of the activation value can be found in the specific description of the subsequent implementation method, and will not be repeated here.

[0034] Step 102: Arrange the M target importance scores in a preset order.

[0035] The specific content of the preset order is not limited here. Optionally, the preset order can be an order from large to small; and optionally, the preset order can also be an order from small to large.

[0036] Step 103: Determine N network layers whose target importance scores are greater than a preset value from the sorted M target importance scores.

[0037] Among them, optionally, when the preset order is from large to small, multiple network layers whose target importance scores are greater than the preset value can be determined first, and then the network layers corresponding to the first N target importance scores are determined among the multiple network layers whose target importance scores are greater than the preset value, and the network layers corresponding to the above-mentioned first N target importance scores are determined as the N network layers whose target importance scores are greater than the preset value.

[0038] Alternatively, screening may be performed directly from the sorted M target importance scores to obtain N network layers whose target importance scores are greater than a preset value.

[0039] It should be noted that, since the target importance scores of the N network layers are greater than the preset value, the above N network layers can be understood as the N network layers with higher importance among the M network layers, that is, the above N network layers can be called top_k network layers of importance, that is, the value of N can be k.

[0040] Step 104: adjust the structure of the N network layers, and use the target neural network model including the N network layers after the structure adjustment to identify the target object; wherein M and N are both positive integers, and N is less than M.

[0041] Among them, adjusting the structure of N network layers may include adjusting the weight matrix of the network layer. For example, a certain network layer may include at least one of the following weight matrices: p_proj, k_proj, v_proj, o_proj, gate_pro, up_proj and down_proj. Specifically, at least one of the above weight matrices may be adjusted to achieve the purpose of reducing the consumption of computing resources and storage resources of the N network layers.

[0042] In addition, adjusting the structure of the N network layers may also include reducing the number of parameters of the network layers, which can also achieve the purpose of reducing the consumption of computing resources and storage resources of the N network layers.

[0043] Among them, the target object recognition is performed using the target neural network model including N network layers after the structure is adjusted. It can be understood that: the target object can be a specific object in a sentence or a specific object in an image. In this way, since the target neural network model including N network layers after the structure is adjusted consumes less computing resources, it can quickly recognize the target object, thereby improving the target object recognition efficiency.

[0044] In an embodiment of the present application, through steps 101 to 104, the target importance score of each network layer in the M network layers of the target neural network model can be obtained, and N network layers with target importance scores greater than a preset value can be screened out according to the target importance scores, and only the structure of the above N network layers needs to be adjusted. In this way, there is no need to adjust the structure of all network layers in the target neural network model, thereby reducing the consumption of computing resources. At the same time, using the target neural network model including the N network layers after the structure is adjusted to identify the target object can also improve the recognition efficiency of the target object.

[0045] It should be noted that the N network layers determined in the above manner are determined based on the target importance score. In this way, the weight importance coefficients of the target neural network model are integrated and dynamically updated (that is, the weight matrix is ​​integrated), so that the N network layers with higher importance of the target neural network model can be more accurately located.

[0046] In addition, compared with the method of adjusting all network layer structures in the target neural network model, the embodiment of the present application can reduce the interference of weight matrices with less importance, thereby making the adjustment of the structures of N network layers more accurate; at the same time, only the important N network layers in the target neural network model are trained and adjusted, which can significantly reduce the training calculation and storage requirements of the target neural network model while improving the performance of the target neural network model, thereby improving the training and reasoning efficiency of the target neural network model in a resource-constrained environment.

[0047] It should be noted that the specific method of calculating the target importance score based on the L2 norm of the weight matrix and activation value of the network layer is not limited here. Optionally, the sum of the L2 norm of the weight matrix and activation value of the network layer can be calculated, and the sum of the L2 norm of the weight matrix and activation value of the network layer can be determined as the target importance score.

[0048] As an optional implementation manner, before obtaining the target importance score of each network layer in the M network layers of the target neural network model and obtaining the M target importance scores, the method further includes:

[0049] Obtaining the loss function, the L2 norm of the activation value and the weight matrix corresponding to the target neural network model;

[0050] A weight optimization gradient is calculated according to the loss function and the weight matrix, and a scoring parameter is calculated according to the L2 norm of the activation value and the absolute value of the weight matrix;

[0051] The target importance score is calculated based on the weight optimization gradient and the scoring parameter.

[0052] Among them, the loss function corresponding to the target neural network model can correspond one-to-one to the target neural network model, that is, the target neural network model is different, and thus the corresponding loss function is also different.

[0053] Among them, the L2 norm of the activation value is the square root of the sum of squares of all elements of the input vector of the target neural network model, that is, the L2 norm of the activation value can be a parameter used to measure the size of the input vector, and the above size can be the length or the size of the corresponding data amount.

[0054] In the implementation mode of the present application, the target importance score is calculated based on the weight optimization gradient and the scoring parameter, so that the diversity and flexibility of the target importance score calculation method can be further enhanced; at the same time, the weight optimization gradient is calculated based on the loss function and the weight matrix, and the scoring parameter is calculated based on the L2 norm of the activation value and the absolute value of the weight matrix, thereby further improving the accuracy of the target importance score calculation result.

[0055] It should be noted that the specific method of calculating the target importance score based on the weight optimization gradient and the scoring parameter is not limited here. Optionally, the weight optimization gradient and the scoring parameter can be directly added to obtain the target importance score.

[0056] As an optional implementation manner, the step of calculating the target importance score according to the weight optimization gradient and the scoring parameter includes:

[0057] Calculating a first product of the weight optimization gradient and a first preset coefficient, and calculating a second product of the scoring parameter and a second preset coefficient;

[0058] The sum of the first product and the second product is determined as the target importance score.

[0059] In an implementation manner of the present application, a first product of the weight optimization gradient and a first preset coefficient is calculated, and a second product of the scoring parameter and a second preset coefficient is calculated; the sum of the first product and the second product is determined as the target importance score. In this way, by adjusting the values ​​of the first preset coefficient and the second preset coefficient, the calculation weights of the weight optimization gradient and the scoring parameter in calculating the target importance score can be adjusted, which can further increase the flexibility of the target importance score calculation method.

[0060] The above implementation is illustrated below with a specific example: the loss function can be represented by L, and the specific content of the loss function is not limited here. For example, the loss function can be a cross entropy loss function, and the weight optimization gradient can be represented by I ij Represented, and the calculation method of weight optimization gradient can be seen in the following statement:

[0061]

[0062] Among them, W ij represents the weight matrix, and Represents the gradient of the loss function L to the weight matrix, that is, the weight optimization gradient I ij It can represent the rate of change of the loss function when the weight matrix changes, i and j represent the serial number of the network layer and the weight matrix included in the network layer, respectively; for example: when the target neural network model is llama, i is the number of network layers included in the target neural network model (for example, it can be one layer among 0-39 layers), and j is the serial number of the weight matrix included in the network layer of the target neural network model (for example, the weight matrix can be distributed in the following order: p_proj, k_proj, v_proj, o_proj, gate_pro, up_proj, down_proj).

[0063] Among them, the scoring parameters can be calculated as follows:

[0064] S ij =|W ij |·||X j ||2;

[0065] Among them, S ij Used to represent the scoring parameter, |W ij | is used to represent the absolute value of the weight matrix, ‖X j ‖2 is used to represent the L2 norm of the activation value.

[0066] The sum of the first product and the second product is determined as the target importance score, which can be calculated as follows:

[0067] R ij =αIij +βS ij ;

[0068] Among them, R ij Used to represent the target importance score, αI ij is used to represent the first product, α is used to represent the first preset coefficient, βS ij is used to represent the second product, and β is used to represent the second preset coefficient.

[0069] It should be noted that the method for determining the first preset coefficient and the second preset coefficient is not limited here. Optionally, the first preset coefficient and the second preset coefficient may be predetermined coefficients, that is, the first preset coefficient and the second preset coefficient may be coefficients determined in advance according to the user's input instructions.

[0070] As an optional implementation manner, before calculating the first product of the weight optimization gradient and the first preset coefficient and calculating the second product of the scoring parameter and the second preset coefficient, the method further includes:

[0071] Obtaining a preset optimization algorithm and an optimization objective function corresponding to the input vector;

[0072] The first preset coefficient and the second preset coefficient are determined according to the preset optimization algorithm and the optimization objective function.

[0073] The preset optimization algorithm is not limited here. Optionally, the preset optimization algorithm may include at least one of the following algorithms: grid optimization, random search, Bayesian optimization, etc.

[0074] Among them, the optimization objective function can correspond to the input vector one by one, that is, different input vectors have different optimization objective functions, and the input vector can be related to the execution task of the target neural network model, that is, the input vector can be a vector obtained by vector extraction of the execution task.

[0075] In the implementation manner of the present application, the first preset coefficient and the second preset coefficient are determined according to a preset optimization algorithm and an optimization objective function. In this way, the first preset coefficient and the second preset coefficient can be continuously optimized, thereby improving the accuracy of the determination results of the first preset coefficient and the second preset coefficient.

[0076] It should be noted that the method for determining the optimization objective function is not limited here. Optionally, the optimization objective function can correspond one-to-one to the target neural network model, that is, the optimization objective function is a predetermined function.

[0077] As an optional implementation manner, before obtaining the preset optimization algorithm and the optimization objective function corresponding to the input vector, the method further includes:

[0078] Determine a neural network sub-model composed of the N network layers;

[0079] The input vector is input into the neural network sub-model to calculate the optimization objective function.

[0080] Among them, the neural network sub-model composed of N network layers can be a partial structure in the target neural network model.

[0081] In the implementation manner of the present application, the diversity and flexibility of the method for determining the optimization objective function can be further enhanced.

[0082] As an optional implementation manner, the adjusting the structure of the N network layers includes:

[0083] Determine the matrix to be updated;

[0084] Decomposing the matrix to be updated into the product of at least two target matrices, the rank of the target matrix being smaller than the rank of the matrix to be updated;

[0085] The weight matrix of each network layer in the N network layers is adjusted by multiplying the at least two target matrices.

[0086] The matrix to be updated can be understood as a matrix used to update the weight matrices of N network layers, and the specific content of the matrix to be updated is not limited here.

[0087] In the implementation mode of the present application, since the rank of the target matrix is ​​smaller than the rank of the matrix to be updated, the target matrix is ​​a low-rank matrix relative to the matrix to be updated. Thus, by decomposing the matrix to be updated into the product of at least two low-rank matrices, the number of parameters of N network layers can be reduced, thereby reducing the consumption of computing resources and storage resources, and thus improving the training and reasoning efficiency of the entire target neural network model.

[0088] It should be noted that the manner of adjusting the structure of the N network layers in this implementation can be understood as a low-rank adaptation (LoRA) fine-tuning manner, and specific reference can be made to the following expressions:

[0089] W′=W+ΔW=W+AB;

[0090] Among them, W′ is used to represent the weight matrix of N network layers after the structure is adjusted, W is used to represent the weight matrix of N network layers before the structure is adjusted, ΔW is used to represent the matrix to be updated, A and B represent two target matrices respectively, and AB represents the product of the two target matrices.

[0091] The above implementation is described below with a specific example:

[0092] The first preset coefficient and the second preset coefficient may be determined in the following manner:

[0093] min α,β E[F(α,β)];

[0094] Among them, E is used to represent the preset optimization algorithm, F is used to represent the optimization objective function, and the above method is used to represent the iterative optimization of α and β according to the principle of minimizing the loss, so that the final determined values ​​of α and β are the first preset coefficient and the second preset coefficient respectively.

[0095] The optimization objective function F can be calculated as follows:

[0096]

[0097] in, Used to indicate weight importance (R ij ) is the top_k model (i.e., the neural network sub-model consisting of N network layers), and x and y can represent different labels corresponding to the input vector.

[0098] It should be noted that the value of N can be adjusted according to the number of parameters, computing resources and training time of the target neural network model.

[0099] In order to more fully illustrate the above embodiment, a specific embodiment is used as an example below. The specific steps can be found in Figure 2 In the steps shown in , the model layer and structure weight importance scores can be understood as the target importance scores of the network layers, the layers and structures of the weight importance scores top_k are N network layers, LLM can be understood as the target neural network model, the domain task instructions can be understood as the quality related to the input vector, and the LoRA plug-in model can be understood as the target neural network model of N network layers after the structure is adjusted.

[0100] See also Figure 3 , Figure 3 : is a structural diagram of a neural network model structure adjustment device provided in an embodiment of the present application. The neural network model structure adjustment device 300 includes:

[0101] The first acquisition module 301 is used to obtain the target importance score of each network layer in the M network layers of the target neural network model, and obtain M target importance scores, wherein the target importance score is used to represent the importance of the network layer in the target neural network model, and the target importance score is calculated according to the weight matrix of the network layer and the L2 norm of the activation value, and the L2 norm of the activation value is determined according to the input vector of the target neural network model;

[0102] An arrangement module 302 is used to arrange the M target importance scores in a preset order;

[0103] A first determination module 303 is used to determine N network layers whose target importance scores are greater than a preset value from the sorted M target importance scores;

[0104] An adjustment module 304 is used to adjust the structure of the N network layers, and use the target neural network model including the N network layers after the structure is adjusted to perform target object recognition;

[0105] Wherein, M and N are both positive integers, and N is less than M.

[0106] As an optional implementation, the neural network model structure adjustment device 300 further includes:

[0107] A second acquisition module is used to obtain the loss function corresponding to the target neural network model, the L2 norm of the activation value and the weight matrix;

[0108] A first calculation module, used to calculate a weight optimization gradient according to the loss function and the weight matrix, and to calculate a scoring parameter according to the L2 norm of the activation value and the absolute value of the weight matrix;

[0109] The second calculation module is used to calculate the target importance score according to the weight optimization gradient and the scoring parameter.

[0110] As an optional implementation, the second calculation module includes:

[0111] A calculation submodule, used for calculating a first product of the weight optimization gradient and a first preset coefficient, and calculating a second product of a scoring parameter and a second preset coefficient;

[0112] The first determination submodule is used to determine the sum of the first product and the second product as the target importance score.

[0113] As an optional implementation, the neural network model structure adjustment device 300 further includes:

[0114] A third acquisition module is used to obtain a preset optimization algorithm and an optimization objective function corresponding to the input vector;

[0115] The second determination module is used to determine the first preset coefficient and the second preset coefficient according to the preset optimization algorithm and the optimization objective function.

[0116] As an optional implementation, the neural network model structure adjustment device 300 further includes:

[0117] A third determination module is used to determine the neural network sub-model composed of the N network layers;

[0118] The third calculation module is used to input the input vector into the neural network sub-model to calculate the optimization objective function.

[0119] As an optional implementation, the adjustment module 304 includes:

[0120] A second determination submodule is used to determine the matrix to be updated;

[0121] A decomposition submodule, used for decomposing the matrix to be updated into the product of at least two target matrices, the rank of the target matrix is ​​smaller than the rank of the matrix to be updated;

[0122] An adjustment submodule is used to adjust the weight matrix of each network layer in the N network layers by multiplying the at least two target matrices.

[0123] The neural network model structure adjustment device 300 can realize the embodiment of the present application Figure 1 The various processes of the method embodiment and the same beneficial effects are achieved, and will not be described again here to avoid repetition.

[0124] The present application also provides an electronic device. Figure 4 , the electronic device may include a processor 401, a memory 402, and a program 4021 stored in the memory 402 and executable on the processor 401. When the program 4021 is executed by the processor 401, Figure 1 Any steps in the corresponding method embodiments and achieving the same beneficial effects will not be repeated here.

[0125] A person skilled in the art can understand that all or part of the steps of implementing the above-mentioned embodiment method can be completed by hardware related to program instructions, and the program can be stored in a readable medium. The present application also provides a readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned Figure 1 Any steps in the corresponding method embodiments can achieve the same technical effect and will not be repeated here to avoid repetition.

[0126] The storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0127] The present application also provides a computer program product, including computer instructions, which can achieve the above-mentioned Figure 1 Any steps in the corresponding method embodiments can achieve the same technical effect and will not be repeated here to avoid repetition.

[0128] The above is a preferred implementation of the embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles described in the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for adjusting the structure of a neural network model, characterized in that: include: Obtaining a target importance score for each of the M network layers of the target neural network model to obtain M target importance scores, wherein the target importance score is used to indicate the importance of the network layer in the target neural network model, and the target importance score is calculated based on the weight matrix of the network layer and the L2 norm of the activation value, and the L2 norm of the activation value is determined based on the input vector of the target neural network model; Arrange the M target importance scores in a preset order; From the sorted M target importance scores, determine N network layers whose target importance scores are greater than a preset value; Adjusting the structures of the N network layers, and using the target neural network model including the N network layers after the structures are adjusted to perform target object recognition; Wherein, M and N are both positive integers, and N is less than M.

2. The method according to claim 1, characterized in that Before obtaining the target importance score of each network layer in the M network layers of the target neural network model and obtaining the M target importance scores, the method further includes: Obtaining the loss function, the L2 norm of the activation value and the weight matrix corresponding to the target neural network model; A weight optimization gradient is calculated according to the loss function and the weight matrix, and a scoring parameter is calculated according to the L2 norm of the activation value and the absolute value of the weight matrix; The target importance score is calculated based on the weight optimization gradient and the scoring parameter.

3. The method according to claim 2, characterized in that The step of calculating the target importance score according to the weight optimization gradient and the scoring parameter includes: Calculating a first product of the weight optimization gradient and a first preset coefficient, and calculating a second product of the scoring parameter and a second preset coefficient; The sum of the first product and the second product is determined as the target importance score.

4. The method according to claim 3, characterized in that Before calculating the first product of the weight optimization gradient and the first preset coefficient and calculating the second product of the scoring parameter and the second preset coefficient, the method further includes: Obtaining a preset optimization algorithm and an optimization objective function corresponding to the input vector; The first preset coefficient and the second preset coefficient are determined according to the preset optimization algorithm and the optimization objective function.

5. The method according to claim 4, characterized in that Before obtaining the preset optimization algorithm and the optimization objective function corresponding to the input vector, the method further includes: Determine a neural network sub-model composed of the N network layers; The input vector is input into the neural network sub-model to calculate the optimization objective function.

6. The method according to any one of claims 1 to 5, characterized in that The adjusting the structures of the N network layers includes: Determine the matrix to be updated; Decomposing the matrix to be updated into the product of at least two target matrices, the rank of the target matrix being smaller than the rank of the matrix to be updated; The weight matrix of each network layer in the N network layers is adjusted by multiplying the at least two target matrices.

7. A neural network model structure adjustment device, characterized in that: include: A first acquisition module is used to obtain a target importance score of each network layer in the M network layers of the target neural network model to obtain M target importance scores, wherein the target importance score is used to indicate the importance of the network layer in the target neural network model, and the target importance score is calculated based on the weight matrix of the network layer and the L2 norm of the activation value, and the L2 norm of the activation value is determined based on the input vector of the target neural network model; An arrangement module, used to arrange the M target importance scores in a preset order; A first determination module is used to determine N network layers whose target importance scores are greater than a preset value from the sorted M target importance scores; An adjustment module, used to adjust the structure of the N network layers, and use the target neural network model including the N network layers after the structure is adjusted to perform target object recognition; Wherein, M and N are both positive integers, and N is less than M.

8. An electronic device comprising: A memory, a processor, and a program stored in the memory and executable on the processor; wherein the processor is used to read the program in the memory to implement the steps in the neural network model structure adjustment method as described in any one of claims 1 to 6.

9. A readable storage medium for storing a program, characterized in that: When the program is executed by a processor, the steps in the neural network model structure adjustment method as described in any one of claims 1 to 6 are implemented.

10. A computer program product, characterized in that It includes computer instructions, which, when executed by a processor, implement the steps in the neural network model structure adjustment method as described in any one of claims 1 to 6.

Citation Information

Cited By

  • Lightweight construction method of multi-task AI prediction model in low-altitude economic aviation field

    CN121659805A