Method and apparatus for obtaining neural network model

CN116029353BActive Publication Date: 2026-10-16BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111248541.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-26
Publication Date
2026-10-16
Estimated Expiration
2041-10-26

AI Technical Summary

Technical Problem

然而,神经网络模型的模型参数之间往往有非常强的依赖关系,对模型参数改变会对神经网络模型的精度具有很大的影响

Benefits of technology

[0033] The method for obtaining a neural network model provided in this embodiment of the invention first constructs an initial network model of the target neural network model, then uses the initial network model as the initial input for n rounds of model parameter quantization, and obtains the quantization result of the nth round of model parameter quantization as the target neural network model. Since the mth round of model parameter quantization includes: training based on the quantization result of the (m-1)th round of model parameter quantization to obtain an intermediate model of the mth round of model parameter quantization, and converting the bit width of the model parameters that meet preset conditions in the intermediate model of the mth round of model parameter quantization to a second bit width, and obtaining the quantization result of the mth round of model parameter quantization, the method for obtaining a neural network model provided in this embodiment of the invention can gradually quantize the model parameters of the neural network model during the neural network training process, thereby reducing the accuracy loss of the neural network model. Therefore, the method for obtaining a neural network model provided in this embodiment of the invention can reduce the disk space occupied by the neural network model while avoiding serious impact on the accuracy of the neural network model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116029353B_ABST
    Figure CN116029353B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a neural network model obtaining method and device, and relate to the technical field of neural network models. The method comprises: constructing an initial network model of a target neural network model, the initial network model comprising a plurality of model parameters with a first bit width; performing n rounds of model parameter quantization on the initial network model as initial input; the mth round of model parameter quantization comprises: training the quantization result of the (m-1)th round based on sample data to obtain an intermediate model of the mth round, and converting the bit width of the model parameters of the intermediate model of the mth round that meet a preset condition to a second bit width to obtain the quantization result of the mth round; n and m are integers greater than 1, and n >= m; the second bit width is less than the first bit width; and the quantization result of the nth round is obtained as the target neural network model. Embodiments of the present application are used to reduce the disk space occupied by the neural network model while avoiding a serious impact on the accuracy of the neural network model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of neural network model technology, and in particular to a method and apparatus for obtaining a neural network model. Background Technology

[0002] Neural network models typically consume a significant amount of disk space, with the majority of that space used to store the model parameters. For example, the AlexNet model file exceeds 200MB, and most of the storage space is dedicated to storing its millions of parameters. This high disk space consumption significantly limits the application of neural network models on mobile devices; therefore, reducing the disk space required by neural network models has become a hot research topic in this field.

[0003] Existing technologies propose reducing the disk space occupied by neural network models by quantizing the model parameters after training. Specifically, this involves converting high-bit-width model parameters to low-bit-width parameters after training to reduce the disk space occupied by each individual parameter. However, neural network parameters often have strong dependencies, and changes to these parameters can significantly impact the model's accuracy. Directly converting all model parameters from high-bit-width to low-bit-width after training can severely compromise accuracy, potentially leading to insufficient precision to meet business requirements. Therefore, reducing disk space occupied by neural network models without significantly affecting accuracy is a pressing issue. Summary of the Invention

[0004] In view of this, the present invention provides a method and apparatus for obtaining a neural network model, which reduces the disk space occupied by the neural network model while avoiding serious impact on the accuracy of the neural network model.

[0005] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:

[0006] In a first aspect, embodiments of the present invention provide a method for obtaining a neural network model, comprising:

[0007] An initial network model for constructing the target neural network model, wherein the initial network model includes multiple model parameters with a bit width equal to the first bit width;

[0008] The initial network model is used as the initial input for n rounds of model parameter quantization; wherein, the m-th round of model parameter quantization includes: training based on the quantization result of the (m-1)-th round of model parameter quantization to obtain an intermediate model of the m-th round of model parameter quantization, and converting the bit width of the model parameters that meet the preset conditions in the intermediate model of the m-th round of model parameter quantization into a second bit width to obtain the quantization result of the m-th round of model parameter quantization; n and m are both integers greater than 1, and n≥m; the second bit width is less than the first bit width;

[0009] The quantization result of the nth round of model parameter quantization is used as the target neural network model.

[0010] As an optional implementation of this invention, the step of converting the bit width of the model parameters that meet the preset conditions in the intermediate model parameters of the m-th round of model parameter quantization into a second bit width includes:

[0011] Obtain the model parameter set, which includes all model parameters with a bit width of the first bit width in the intermediate model of the m-th round of model parameter quantization;

[0012] Obtain the absolute value of each model parameter in the model parameter set;

[0013] The bit width of a preset number of model parameters with the smallest absolute value in the model parameter set is converted into a second bit width.

[0014] As an optional implementation of this invention, the preset quantity is the ratio of the total number of model parameters of the initial network model to n.

[0015] As an optional implementation of this invention, the method further includes:

[0016] In the process of training the model parameters based on the quantization results of the (m-1)th round of model parameter quantization and obtaining the intermediate model of the mth round of model parameter quantization, the fixed bit width is converted into the second bit width model parameters.

[0017] As an optional implementation of this invention, the model parameter of the first bit width is a single-precision floating-point type model parameter; the model parameter of the second bit width is an integer type model parameter.

[0018] As an optional implementation of this invention, the sample data includes multiple sample speech and text information corresponding to each sample speech;

[0019] The target neural network model is a neural network model used to output corresponding text information based on the input speech to be recognized.

[0020] Secondly, embodiments of the present invention provide a device for acquiring a neural network model, comprising:

[0021] A building unit is used to build an initial network model of the target neural network model, wherein the initial network model includes multiple model parameters with a bit width of the first bit.

[0022] The processing unit is configured to perform n rounds of model parameter quantization using the initial network model as initial input; wherein, the m-th round of model parameter quantization includes: training the quantization result of the (m-1)-th round of model parameter quantization based on sample data to obtain an intermediate model of the m-th round of model parameter quantization, and converting the bit width of the model parameters that meet the preset conditions in the intermediate model of the m-th round of model parameter quantization into a second bit width to obtain the quantization result of the m-th round of model parameter quantization; n and m are both integers greater than 1, and n≥m; the second bit width is less than the first bit width;

[0023] The acquisition unit is used to acquire the quantization result of the nth round of model parameter quantization as the target neural network model.

[0024] As an optional implementation of this invention, the processing unit is specifically used to obtain a model parameter set, which includes all model parameters with a bit width of the first bit width in the model parameters of the intermediate model of the m-th round of model parameter quantization; obtain the absolute value of each model parameter in the model parameter set; and convert the bit width of a preset number of model parameters with the smallest absolute value in the model parameter set into a second bit width.

[0025] As an optional implementation of this invention, the preset quantity is the ratio of the total number of model parameters of the initial network model to n.

[0026] As an optional implementation of the present invention, the processing unit is specifically used to convert the fixed bit width to the second bit width model parameters during the process of training the quantization result of the (m-1)th round of model parameter quantization based on sample data and obtaining the intermediate model of the mth round of model parameter quantization.

[0027] As an optional implementation of this invention, the model parameter of the first bit width is a single-precision floating-point type model parameter; the model parameter of the second bit width is an integer type model parameter.

[0028] As an optional implementation of this invention, the sample data includes multiple sample speech and text information corresponding to each sample speech;

[0029] The target neural network model is a neural network model used to output corresponding text information based on the input speech to be recognized.

[0030] Thirdly, embodiments of the present invention provide an electronic device, including: a memory and a processor, wherein the memory is used to store a computer program; and the processor is used to, when the computer program is invoked, cause the electronic device to implement the method for obtaining a neural network model as described in the first aspect or any optional embodiment of the first aspect.

[0031] Fourthly, embodiments of the present invention provide a computer-readable storage medium that, when executed by a computing device, causes the computing device to implement the method for obtaining a neural network model as described in the first aspect or any optional embodiment of the first aspect.

[0032] Fifthly, embodiments of the present invention provide a computer program product that, when run on a computer, enables the computer to implement the method for obtaining a neural network model as described in the first aspect or any optional implementation of the first aspect.

[0033] The method for obtaining a neural network model provided in this embodiment of the invention first constructs an initial network model of the target neural network model, then uses the initial network model as the initial input for n rounds of model parameter quantization, and obtains the quantization result of the nth round of model parameter quantization as the target neural network model. Since the mth round of model parameter quantization includes: training based on the quantization result of the (m-1)th round of model parameter quantization to obtain an intermediate model of the mth round of model parameter quantization, and converting the bit width of the model parameters that meet preset conditions in the intermediate model of the mth round of model parameter quantization to a second bit width, and obtaining the quantization result of the mth round of model parameter quantization, the method for obtaining a neural network model provided in this embodiment of the invention can gradually quantize the model parameters of the neural network model during the neural network training process, thereby reducing the accuracy loss of the neural network model. Therefore, the method for obtaining a neural network model provided in this embodiment of the invention can reduce the disk space occupied by the neural network model while avoiding serious impact on the accuracy of the neural network model. Attached Figure Description

[0034] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0035] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0036] Figure 1 One of the flowcharts for obtaining a neural network model provided in an embodiment of the present invention;

[0037] Figure 2 The second step of the method for obtaining a neural network model provided in the embodiments of the present invention is illustrated in the flowchart below.

[0038] Figure 3 A schematic diagram of a neural network model acquisition device provided in an embodiment of the present invention;

[0039] Figure 4 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0040] To better understand the above-mentioned objectives, features, and advantages of the present invention, the solutions of the present invention will be further described below. It should be noted that, unless otherwise specified, the embodiments of the present invention and the features thereof can be combined with each other.

[0041] Many specific details are set forth in the following description in order to provide a full understanding of the invention, but the invention may also be practiced in other ways different from those described herein; obviously, the embodiments in the specification are only some embodiments of the invention, and not all embodiments.

[0042] In the embodiments of the present invention, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present invention should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner. Furthermore, in the description of the embodiments of the present invention, unless otherwise stated, "a plurality of" means two or more.

[0043] The terms "first" and "second," etc., used in the specification and claims of this invention are used to distinguish the objects being synchronized, rather than to describe a specific order of the objects. For example, "first bit width" and "second bit width" are used to distinguish different bit widths, rather than to describe a specific order of the bit widths.

[0044] This invention provides a method for obtaining a neural network model, referring to... Figure 1As shown, the method for obtaining this neural network model includes the following steps:

[0045] S11. Construct the initial network model of the target neural network model.

[0046] The initial network model includes multiple model parameters, each with a bit width equal to the first bit width.

[0047] That is, to build an initial neural network model that can be trained on sample data to obtain the target neural network model.

[0048] Optionally, the target neural network model in the embodiments of the present invention can be a deep learning neural network model.

[0049] Optionally, the first bit-width model parameter is a single-precision floating-point type model parameter. Since single-precision floating-point type data occupies 32 bits of storage space, when the first bit-width model parameter is a single-precision floating-point type model parameter, the first bit width is 32.

[0050] S12. Use the initial network model as the initial input for n rounds of model parameter quantization.

[0051] The process of quantizing model parameters in the m-th round includes: training the model parameters based on the quantization results of the (m-1)-th round based on sample data to obtain an intermediate model for the m-th round of model parameter quantization; and converting the bit width of the model parameters that meet the preset conditions in the intermediate model for the m-th round of model parameter quantization into a second bit width to obtain the quantization result for the m-th round of model parameter quantization; where n and m are both integers greater than 1, and n ≥ m; and the second bit width is less than the first bit width.

[0052] For example, the implementation process of step S12 (using the initial network model as the initial input for n rounds of model parameter quantization) will be explained below with n=20 as an example.

[0053] The first round of model parameter quantization includes:

[0054] First, the initial network model will be trained based on the sample data to obtain the intermediate model for the first round of model parameter quantization.

[0055] Next, the bit width of the model parameters that meet the preset conditions in the intermediate model of the first round of model parameter quantization is converted into a second bit width to obtain the quantization result of the first round of model parameter quantization. At this point, the first round of model parameter quantization is complete.

[0056] The second round of model parameter quantization includes:

[0057] First, the quantization results of the first round of model parameter quantization are used to train the model to obtain the intermediate model for the second round of model parameter quantization.

[0058] Next, the bit width of the model parameters that meet the preset conditions in the intermediate model of the second round of model parameter quantization is converted into a second bit width to obtain the quantization result of the second round of model parameter quantization. At this point, the second round of model parameter quantization is complete.

[0059] The process of quantizing model parameters in rounds 3 to 20 is similar to that in round 2, including:

[0060] First, the quantization results of the previous round of model parameter quantization are used to train the model to obtain the intermediate model for the current round of model parameter quantization.

[0061] Secondly, the bit width of the model parameters that meet the preset conditions in the intermediate model parameters of the current round of model parameter quantization is converted into the second bit width to obtain the quantization result of the current round of model parameter quantization.

[0062] Optionally, the second bit-width model parameter is an integer type model parameter.

[0063] Optionally, the second bit width is 5. That is, each model parameter with the second bit width requires 5 bits of storage space.

[0064] When the first bit width of the model parameter is a single-precision floating-point type model parameter and the second bit width is 5, each model parameter needs to occupy 32 bits before quantization. After converting to the second bit width model parameter, 32 bits can store at least 6 model parameters. Therefore, converting all model parameters to the second bit width can reduce the storage space occupied by the target neural network model by at least 6 times.

[0065] It should also be noted that floating-point calculations require significant computing resources (CPU resources / GPU resources). The above embodiments convert the model parameters of the neural network model from floating-point type model parameters to integer type model parameters. Therefore, the above embodiments can also reduce the computing resources consumed by the neural network model and shorten the computation latency of the neural network model.

[0066] S13. Obtain the quantization result of the nth round of model parameter quantization as the target neural network model.

[0067] That is, the quantization result of the last round of model parameter quantization is used as the quantized neural network model corresponding to the target neural network model, and then output and saved.

[0068] The method for obtaining a neural network model provided in this embodiment of the invention first constructs an initial network model of the target neural network model, then uses the initial network model as the initial input for n rounds of model parameter quantization, and obtains the quantization result of the nth round of model parameter quantization as the target neural network model. Since the mth round of model parameter quantization includes: training based on the quantization result of the (m-1)th round of model parameter quantization to obtain an intermediate model of the mth round of model parameter quantization, and converting the bit width of the model parameters that meet preset conditions in the intermediate model of the mth round of model parameter quantization to a second bit width, and obtaining the quantization result of the mth round of model parameter quantization, the method for obtaining a neural network model provided in this embodiment of the invention can gradually quantize the model parameters of the neural network model during the neural network training process, thereby reducing the accuracy loss of the neural network model. Therefore, the method for obtaining a neural network model provided in this embodiment of the invention can reduce the disk space occupied by the neural network model while avoiding serious impact on the accuracy of the neural network model.

[0069] As an extension and refinement of the above embodiments, this invention provides another method for obtaining a neural network model, referring to... Figure 2 As shown, the method for obtaining this neural network model includes the following steps:

[0070] S201. Construct the initial network model of the target neural network model.

[0071] The initial network model includes multiple model parameters, each with a bit width equal to the first bit width.

[0072] S202. Train the initial network model based on the sample data to obtain the intermediate model for the first round of model parameter quantization.

[0073] That is, by training and updating the model parameters of the initial network model using sample data, an intermediate model with the first round of model parameter quantization is obtained.

[0074] As an optional implementation of this invention, the sample data includes multiple sample speech and text information corresponding to each sample speech;

[0075] The target neural network model is a neural network model used to output corresponding text information based on the input speech to be recognized.

[0076] For example, the implementation method of the target neural network model outputting corresponding text information based on the input speech to be recognized includes:

[0077] First, the speech to be recognized is divided into multiple speech segments. Second, the probability of each text corresponding to each speech segment is obtained. Finally, the text with the highest probability corresponding to each speech segment is combined into the text information corresponding to the speech to be recognized and output.

[0078] S203. Obtain the set of model parameters corresponding to the intermediate model of the first round of model parameter quantization.

[0079] The model parameter set includes all model parameters of the intermediate model obtained from the first round of model parameter quantization that have a bit width of the first bit. Specifically, since the bit width of all model parameters of the intermediate model obtained from the first round of model parameter quantization is the first bit, S203 is to obtain all model parameters of the intermediate model obtained from the first round of model parameter quantization.

[0080] S204. Obtain the absolute value of each model parameter in the model parameter set corresponding to the intermediate model of the first round of model parameter quantization.

[0081] S205. Convert the bit width of the preset number of model parameters with the smallest absolute value in the model parameter set corresponding to the intermediate model of the first round of model parameter quantization into the second bit width, and obtain the quantization result of the first round of model parameter quantization.

[0082] Optionally, the preset quantity is the ratio of the total number of model parameters of the initial network model to n.

[0083] For example, when the total number of model parameters in the initial network model is Q and n = 20, the bit width of the preset number of model parameters with the smallest absolute value in the model parameter set corresponding to the intermediate model of the first round of model parameter quantization is converted into the second bit width. That is, the bit width of the Q / n model parameters with the smallest absolute value in the model parameter set corresponding to the intermediate model of the first round of model parameter quantization is converted into the second bit width, or the bit width of the 5% of model parameters with the smallest absolute value in the model parameter set corresponding to the intermediate model of the first round of model parameter quantization is converted into the second bit width.

[0084] S206. Train the model based on the quantization results of the first round of model parameter quantization using sample data to obtain the intermediate model for the second round of model parameter quantization.

[0085] As an optional implementation of the present invention, the neural network model quantization method provided in the present invention further includes:

[0086] In the process of training the model parameters based on the quantization results of the (m-1)th round of model parameter quantization and obtaining the intermediate model of the mth round of model parameter quantization, the fixed bit width is converted into the second bit width model parameters.

[0087] That is, during the training of the model based on sample data, the model parameters that have been converted to the second bit width will no longer be updated, and only the model parameters with the first bit width will be updated.

[0088] S207. Obtain the set of model parameters corresponding to the intermediate model in the second round of model parameter quantization.

[0089] The model parameter set includes all model parameters with a bit width of the first bit width from the intermediate model parameters of the second round of model parameter quantization.

[0090] As mentioned above, when the preset quantity is 5% of the total number of model parameters in the initial network model, the model parameter set corresponding to the intermediate model in the second round of model parameter quantization includes the remaining 95% of the model parameters.

[0091] S208. Convert the bit width of the preset number of model parameters with the smallest absolute value in the model parameter set corresponding to the intermediate model of the second round of model parameter quantization into the second bit width, and obtain the quantization result of the second round of model parameter quantization.

[0092] As mentioned above, when the preset quantity is 5% of the total number of model parameters in the initial network model, 10% of the model parameters in the quantization result of the second round of model parameter quantization are model parameters with the second bit width, and 90% are model parameters with the first bit width.

[0093] When the preset quantity is the ratio of the total number of model parameters in the initial network model to n, the quantization result of the previous round of model parameter quantization is used as the input for the current round of model parameter quantization, and the model parameter quantization steps S206 to S208 above are repeated for n-1 rounds. In each round of model parameter quantization, the second-bit-width model parameters in the quantization result increase by 1 / n. In the nth round of model parameter quantization result, the proportion of the second-bit-width model parameters is 100%, and the proportion of the first-bit-width model parameters is 0. All model parameters are converted to second-bit-width model parameters.

[0094] S209. Obtain the quantization result of the nth round of model parameter quantization as the target neural network model.

[0095] The method for obtaining a neural network model provided in this embodiment of the invention first constructs an initial network model of the target neural network model, then uses the initial network model as the initial input for n rounds of model parameter quantization, and obtains the quantization result of the nth round of model parameter quantization as the target neural network model. Since the mth round of model parameter quantization includes: training based on the quantization result of the (m-1)th round of model parameter quantization to obtain an intermediate model of the mth round of model parameter quantization, and converting the bit width of the model parameters that meet preset conditions in the intermediate model of the mth round of model parameter quantization to a second bit width, and obtaining the quantization result of the mth round of model parameter quantization, the method for obtaining a neural network model provided in this embodiment of the invention can gradually quantize the model parameters of the neural network model during the neural network training process, thereby reducing the accuracy loss of the neural network model. Therefore, the method for obtaining a neural network model provided in this embodiment of the invention can reduce the disk space occupied by the neural network model while avoiding serious impact on the accuracy of the neural network model.

[0096] Based on the same inventive concept, as an implementation of the above method, this embodiment of the invention also provides a neural network model acquisition device. This device embodiment corresponds to the aforementioned method embodiment. For ease of reading, this device embodiment will not repeat the details of the aforementioned method embodiment one by one, but it should be clear that the neural network model acquisition device in this embodiment can correspondingly implement all the contents of the aforementioned method embodiment.

[0097] This invention provides a device for acquiring a neural network model. Figure 3 This is a schematic diagram of the structure of the device for acquiring the neural network model, as shown below. Figure 3 As shown, the neural network model acquisition device 300 includes:

[0098] The construction unit 31 is used to construct an initial network model of the target neural network model, wherein the initial network model includes multiple model parameters with a bit width of the first bit width;

[0099] Processing unit 32 is used to perform n rounds of model parameter quantization using the initial network model as initial input; wherein, the m-th round of model parameter quantization includes: training the quantization result of the (m-1)-th round of model parameter quantization based on sample data to obtain an intermediate model of the m-th round of model parameter quantization, and converting the bit width of the model parameters that meet the preset conditions in the intermediate model of the m-th round of model parameter quantization into a second bit width to obtain the quantization result of the m-th round of model parameter quantization; n and m are both integers greater than 1, and n≥m; the second bit width is less than the first bit width;

[0100] The acquisition unit 33 is used to acquire the quantization result of the nth round of model parameter quantization as the target neural network model.

[0101] As an optional implementation of this invention, the processing unit 32 is specifically used to obtain a model parameter set, which includes all model parameters with a bit width of the first bit width in the model parameters of the intermediate model of the m-th round of model parameter quantization; obtain the absolute value of each model parameter in the model parameter set; and convert the bit width of a preset number of model parameters with the smallest absolute value in the model parameter set into a second bit width.

[0102] As an optional implementation of this invention, the preset quantity is the ratio of the total number of model parameters of the initial network model to n.

[0103] As an optional implementation of the present invention, the processing unit 32 is specifically used to convert the fixed bit width to the second bit width model parameters during the process of training the quantization result of the (m-1)th round of model parameter quantization based on sample data and obtaining the intermediate model of the mth round of model parameter quantization.

[0104] As an optional implementation of this invention, the model parameter of the first bit width is a single-precision floating-point type model parameter; the model parameter of the second bit width is an integer type model parameter.

[0105] As an optional implementation of this invention, the sample data includes multiple sample speech and text information corresponding to each sample speech;

[0106] The target neural network model is a neural network model used to output corresponding text information based on the input speech to be recognized.

[0107] The neural network model acquisition device provided in this embodiment can execute the neural network model acquisition method provided in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described again here.

[0108] Based on the same inventive concept, embodiments of the present invention also provide an electronic device. Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention, such as... Figure 4 As shown, the electronic device provided in this embodiment includes a memory 41 and a processor 42. The memory 41 is used to store a computer program; the processor 42 is used to execute the neural network model acquisition method provided in the above embodiment when the computer program is invoked.

[0109] Based on the same inventive concept, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, enables the computing device to implement the method for obtaining a neural network model provided in the above embodiments.

[0110] Based on the same inventive concept, this embodiment of the invention also provides a computer program product, which, when run on a computer, enables the computing device to implement the method for obtaining the neural network model provided in the above embodiment.

[0111] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program code.

[0112] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.

[0113] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0114] Computer-readable media include both permanent and non-permanent, removable and non-removable storage media. Storage media can store information using any method or technology; the information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0115] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for obtaining a neural network model, characterized in that, include: An initial network model for constructing the target neural network model, wherein the initial network model includes multiple model parameters with a bit width equal to the first bit width; The initial network model is used as the initial input for n rounds of model parameter quantization; wherein, the m-th round of model parameter quantization includes: training the quantization result of the (m-1)-th round of model parameter quantization based on sample data to obtain the intermediate model of the m-th round of model parameter quantization, and converting the bit width of the model parameters that meet the preset conditions in the intermediate model of the m-th round of model parameter quantization into a second bit width to obtain the quantization result of the m-th round of model parameter quantization; n and m are both integers greater than 1, and n≥m; the second bit width is less than the first bit width, the sample data includes multiple sample speech and text information corresponding to each sample speech; the target neural network model is a neural network model used to output corresponding text information based on the input speech to be recognized; The quantization result of the nth round of model parameter quantization is used as the target neural network model.

2. The method according to claim 1, characterized in that, The step of converting the bit width of the model parameters that meet the preset conditions in the intermediate model parameters of the m-th round of model parameter quantization to a second bit width includes: Obtain the model parameter set, which includes all model parameters with a bit width of the first bit width in the intermediate model of the m-th round of model parameter quantization; Obtain the absolute value of each model parameter in the model parameter set; The bit width of a preset number of model parameters with the smallest absolute value in the model parameter set is converted into a second bit width.

3. The method according to claim 2, characterized in that, The preset quantity is the ratio of the total number of model parameters in the initial network model to n.

4. The method according to claim 1, characterized in that, The method further includes: In the process of training the model parameters based on the quantization results of the (m-1)th round of model parameter quantization and obtaining the intermediate model of the mth round of model parameter quantization, the fixed bit width is converted into the second bit width model parameters.

5. The method according to any one of claims 1-4, characterized in that, The model parameters of the first bit width are single-precision floating-point type model parameters; The second bit-width model parameter is an integer type model parameter.

6. The method according to any one of claims 1-4, characterized in that, The sample data includes multiple sample speech and the text information corresponding to each sample speech; The target neural network model is a neural network model used to output corresponding text information based on the input speech to be recognized.

7. A device for acquiring a neural network model, characterized in that, include: A building unit is used to build an initial network model of the target neural network model, wherein the initial network model includes multiple model parameters with a bit width of the first bit. The processing unit is configured to perform n rounds of model parameter quantization using the initial network model as initial input; wherein, the m-th round of model parameter quantization includes: training the quantization result of the (m-1)-th round of model parameter quantization based on sample data to obtain an intermediate model of the m-th round of model parameter quantization, and converting the bit width of the model parameters that meet the preset conditions in the intermediate model of the m-th round of model parameter quantization into a second bit width to obtain the quantization result of the m-th round of model parameter quantization; n and m are both integers greater than 1, and n≥m; the second bit width is less than the first bit width, the sample data includes multiple sample speech and text information corresponding to each sample speech; the target neural network model is a neural network model used to output corresponding text information based on the input speech to be recognized; The acquisition unit is used to acquire the quantization result of the nth round of model parameter quantization as the target neural network model.

8. An electronic device, characterized in that, include: A memory and a processor, the memory being used to store a computer program; the processor being used to cause the electronic device to implement the method for acquiring a neural network model according to any one of claims 1-6 when executing the computer program.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a computing device, causes the computing device to implement the method for obtaining a neural network model as described in any one of claims 1-6.

10. A computer program product, characterized in that, When the computer program product is run on a computer, the computer enables the computer to implement the method for obtaining a neural network model as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Neural network model quantification method and device based on label-free data

    CN110969251A