Data compression method, data decompression method, device and electronic equipment

By applying a compressed network model and an arithmetic encoder to encode intermediate results in the neural network, the problem of low compression efficiency in the prior art is solved, and the operation efficiency of neural network algorithms on micro-terminal devices is improved.

CN113810058BActive Publication Date: 2025-02-11伟光有限公司(CN)
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111094531.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-17
Publication Date
2025-02-11
Estimated Expiration
2041-09-17

AI Technical Summary

Technical Problem

The prior art compresses the intermediate results of neural networks, and the compression efficiency is low, resulting in the application of neural network algorithms with extremely high operating speed requirements on micro-terminal devices being limited.

Method used

By obtaining the data to be compressed, the intermediate compression result and its probability distribution parameters are obtained using the compressed network model, and the intermediate compression result and the data to be compressed are encoded in combination with the arithmetic encoder to generate the compression result.

Benefits of technology

The efficiency of data compression is improved, so that the data is compressed based on the probability distribution characteristics of the data to be compressed and the probability distribution parameters obtained by the compressed network model, which is suitable for running efficient neural network algorithms on micro-terminal devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113810058B_ABST
    Figure CN113810058B_ABST
Patent Text Reader

Abstract

This application discloses a data compression method, a data decompression method, an apparatus, and an electronic device. The method includes: acquiring data to be compressed; obtaining an intermediate compression result of the data to be compressed, a first probability distribution parameter corresponding to the probability distribution of the intermediate compression result, and a second probability distribution parameter corresponding to the probability distribution of the data to be compressed through a compression network model; encoding the intermediate compression result based on an arithmetic encoder and the first probability distribution parameter to obtain a first code; and encoding the data to be compressed based on the arithmetic encoder and the second probability distribution parameter to obtain a second code, wherein the second code is the compression result of the data to be compressed. This method allows compression of the data to be compressed based on the probability distribution characteristics of the data to be compressed and the second probability distribution parameter corresponding to the probability distribution of the data to be compressed obtained from the compression network model, thereby improving compression efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data compression, and more specifically, to a data compression method, a data decompression method, a device and an electronic device. Background Art

[0002] With the advancement of deep learning technology, more and more deep learning algorithms are being deployed on electronic devices such as mobile phones. In order to run neural network algorithms on electronic devices, NPU (Neural Processing Unit) is configured on the electronic devices. However, the storage requirements of some intermediate results of the neural network are too large to be completely temporarily stored in the NPU. The intermediate results need to be written to DDR (Double Data Rate), and then read from DDR to NPU when needed. However, due to the limited bandwidth of DDR, the reading and writing of large amounts of data will produce a large delay, which greatly restricts the application of neural network algorithms with extremely high speed requirements on micro terminal devices. In this context, compressing the intermediate results of neural networks has become a research hotspot.

[0003] However, the related compression algorithms still have the problem of low compression efficiency. Summary of the invention

[0004] In view of the above problems, the present application proposes a data compression method, a data decompression method, a device and an electronic device to improve the above problems.

[0005] In a first aspect, the present application provides a data compression method, which is applied to an electronic device, and the method includes: obtaining data to be compressed; obtaining an intermediate compression result of the data to be compressed, a first probability distribution parameter corresponding to the probability distribution of the intermediate compression result, and a second probability distribution parameter corresponding to the probability distribution of the data to be compressed through a compression network model; encoding the intermediate compression result based on an arithmetic encoder and the first probability distribution parameter to obtain a first code, and encoding the data to be compressed based on the arithmetic encoder and the second probability distribution parameter to obtain a second code, wherein the second code is the compression result of the data to be compressed.

[0006] In a second aspect, the present application provides a data decompression method, which is applied to an electronic device, and the method includes: obtaining information to be decoded, the information to be decoded includes a first probability distribution parameter, a first code and a second code, the second code is the data to be decompressed; inputting the first probability distribution parameter and the first code into an arithmetic decoder to obtain a first decoding; inputting the first decoding result into a decompression network model to obtain a second probability distribution parameter, the decompression network model is an upsampling network, and the upsampling network is an upsampling network in a compression network model corresponding to the decompression network model; inputting the second probability distribution parameter and the second code into an arithmetic decoder to obtain a second decoding, the second decoding being the decompression result of the data to be decompressed.

[0007] In a third aspect, the present application provides a data compression device that runs on an electronic device, the device comprising: a data acquisition unit for acquiring data to be compressed; a parameter acquisition unit for obtaining an intermediate compression result of the data to be compressed, a first probability distribution parameter corresponding to the probability distribution of the intermediate compression result, and a second probability distribution parameter corresponding to the probability distribution of the data to be compressed through a compression network model; a data compression unit for encoding the intermediate compression result based on an arithmetic encoder and the first probability distribution parameter to obtain a first code, and encoding the data to be compressed based on the arithmetic encoder and the second probability distribution parameter to obtain a second code, wherein the second code is the compression result of the data to be compressed.

[0008] In a fourth aspect, the present application provides a data decompression device, which runs on an electronic device, and the device includes: a data acquisition unit, used to obtain information to be decoded, the information to be decoded includes a first probability distribution parameter, a first code and a second code, and the second code is the data to be decompressed; a data decompression unit, used to input the first probability distribution parameter and the first code into an arithmetic decoder to obtain a first decoding; input the first decoding result into a decompression network model to obtain a second probability distribution parameter, the decompression network model is an upsampling network, and the upsampling network is an upsampling network in a compression network model corresponding to the decompression network model; input the second probability distribution parameter and the second code into the arithmetic decoder to obtain a second decoding, and the second decoding is the decompression result of the data to be decompressed.

[0009] In a fifth aspect, the present application provides an electronic device comprising one or more processors and a memory; one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the above-mentioned method.

[0010] In a sixth aspect, the present application provides a computer program product, comprising a computer program / instructions, characterized in that the computer program / instructions implement the steps of the above method when executed by a processor.

[0011] In a seventh aspect, the present application provides a computer-readable storage medium, in which program code is stored, wherein the above method is executed when the program code is run.

[0012] The present application provides a data compression method, a data decompression method, a device and an electronic device. After obtaining the data to be compressed, an intermediate compression result of the data to be compressed, a first probability distribution parameter corresponding to the probability distribution of the intermediate compression result and a second probability distribution parameter corresponding to the probability distribution of the data to be compressed are obtained through a compression network model. The intermediate compression result is encoded based on an arithmetic encoder and the first probability distribution parameter to obtain a first code. The data to be compressed is encoded based on an arithmetic encoder and the second probability distribution parameter to obtain a second code, and the second code is the compression result of the data to be compressed. In the above manner, the data to be compressed can be compressed based on the probability distribution characteristics of the data to be compressed and the second probability distribution parameter corresponding to the probability distribution of the data to be compressed obtained by the compression network model, thereby improving the compression efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0014] Figure 1 A flow chart of a data compression method proposed in an embodiment of the present application is shown;

[0015] Figure 2 Shows this application Figure 1 A flowchart of an embodiment of S120;

[0016] Figure 3 A schematic diagram of a compression network model proposed in this application is shown;

[0017] Figure 4 A schematic diagram of a downsampling module proposed in the present application is shown;

[0018] Figure 5 A schematic diagram of an upsampling module proposed in the present application is shown;

[0019] Figure 6A schematic diagram of an arithmetic coding proposed in the present application is shown;

[0020] Figure 7 A flow chart of a data compression method proposed in another embodiment of the present application is shown;

[0021] Figure 8 A flow chart of a data compression method proposed in another embodiment of the present application is shown;

[0022] Fig. 9 A flow chart of a data decompression method proposed in an embodiment of the present application is shown;

[0023] Fig.10 A schematic diagram of arithmetic decoding proposed in the present application is shown;

[0024] Fig.11 A schematic diagram of a decompression network model proposed in this application is shown;

[0025] Fig.12 A schematic diagram showing an application scenario of a data compression and decompression method proposed in the present application is shown;

[0026] Fig.13 A structural block diagram of a data compression device proposed in an embodiment of the present application is shown;

[0027] Fig.14 A structural block diagram of a data decompression device proposed in an embodiment of the present application is shown;

[0028] Fig.15 A structural block diagram of an electronic device proposed in this application is shown;

[0029] Fig.16 It is a storage unit of an embodiment of the present application for storing or carrying a program code for implementing a parameter acquisition method according to an embodiment of the present application. DETAILED DESCRIPTION

[0030] 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. 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.

[0031] With the advancement of deep learning technology, more and more deep learning algorithms are being deployed on electronic devices such as mobile phones. In order to run neural network algorithms on electronic devices, NPU (Neural Processing Unit) is configured on the electronic devices. However, the storage requirements of some intermediate results of the neural network are too large to be completely temporarily stored in the NPU. The intermediate results need to be written to DDR (Double Data Rate) first, and then read from DDR into the NPU when needed. However, due to the limited bandwidth of DDR, the reading and writing of large amounts of data will produce a large delay, which greatly restricts the application of neural network algorithms with extremely high speed requirements on micro terminal devices. In this context, compressing the intermediate results of neural networks has become a research hotspot.

[0032] The inventors discovered during their research on related compression methods that currently commonly used compression algorithms compress data mainly based on the number of repetitions of the data, which may lead to the problem of low compression efficiency.

[0033] Therefore, the inventors have proposed a data compression method, a data decompression method, a device and an electronic device in the present application. After obtaining the data to be compressed, an intermediate compression result of the data to be compressed, a first probability distribution parameter corresponding to the probability distribution of the intermediate compression result and a second probability distribution parameter corresponding to the probability distribution of the data to be compressed are obtained through a compression network model. The intermediate compression result is encoded based on an arithmetic encoder and the first probability distribution parameter to obtain a first code. The data to be compressed is encoded based on an arithmetic encoder and the second probability distribution parameter to obtain a second code, and the second code is the compression result of the data to be compressed. In the above manner, the data to be compressed can be compressed based on the probability distribution characteristics of the data to be compressed and the second probability distribution parameter corresponding to the probability distribution of the data to be compressed obtained by the compression network model, thereby improving the compression efficiency.

[0034] See also Figure 1 The present application provides a data compression method, which is applied to an electronic device, and the method comprises:

[0035] S110: Obtain data to be compressed.

[0036] The data to be compressed is data to be compressed. Furthermore, when the data compression method provided by the embodiment of the present application is applied in different scenarios, the data to be compressed may correspond to different scenarios.

[0037] Optionally, the data to be compressed may be an intermediate result of a neural network. Exemplarily, the intermediate result may be an intermediate feature extracted by the neural network, a hyperparameter of a hidden layer of the neural network, or the like.

[0038] Optionally, the data to be compressed may be an image, a weight of a neural network model, etc.

[0039] S120: Obtaining, through a compression network model, an intermediate compression result of the data to be compressed, a first probability distribution parameter corresponding to the probability distribution of the intermediate compression result, and a second probability distribution parameter corresponding to the probability distribution of the data to be compressed.

[0040] The first probability distribution parameter may be used to reflect the probability distribution state of the intermediate compression result, and the second probability distribution parameter may be used to reflect the probability distribution state of the data to be compressed.

[0041] Optionally, the probability distribution of the data to be compressed and the intermediate compression result can be a Gaussian distribution, the first probability distribution parameters are the mean and variance of the Gaussian distribution of the intermediate compression result, and the second probability distribution parameters are the mean and variance of the Gaussian distribution of the data to be compressed.

[0042] As a method, the compression network model includes a downsampling network and an upsampling network. Figure 2 As shown, obtaining the intermediate compression result of the data to be compressed, the first probability distribution parameter corresponding to the probability distribution of the intermediate compression result, and the second probability distribution parameter corresponding to the probability distribution of the data to be compressed by the compression network model includes:

[0043] S121: Input the data to be compressed into the downsampling network to obtain the intermediate compression result output by the downsampling network and the first probability distribution parameter.

[0044] S122: Input the intermediate compression result to the upsampling network to obtain the second probability distribution parameter output by the upsampling network.

[0045] like Figure 3 As shown, a schematic diagram of the structure of a compression network model is shown. Figure 3 The compression network model shown in includes two parts: a downsampling network and an upsampling network. The downsampling network may have three downsampling modules (Downsampling), and the upsampling network may include three upsampling modules (Upsampling).

[0046] like Figure 4 As shown, each downsampling module can have a 3*3 convolution, an activation function (Leaky_Relu), and a 2*2 flat pooling. Figure 5As shown in the figure, each upsampling module can have a 3*3 deconvolution and an activation function (Leaky_Relu). The strides of the convolution and deconvolution can be 2, and the padding can be the same padding. This way, each time the data to be compressed is padded, the length and width dimensions will be exactly 1 / 2 of the length before the padding. In the subsequent decoding process, the padded data of the data to be compressed will be discarded.

[0047] For example, Figure 3 As shown, the data to be compressed is the intermediate feature F extracted by the neural network. The intermediate feature F is input into the compression network model. After passing through the downsampling network part, the intermediate compression result Z of the intermediate feature F and the first probability distribution parameters Z:Mu and Z:Sigma can be obtained. Then Z passes through the upsampling network part to obtain the second probability distribution parameters F:Mu and F:Sigma.

[0048] Among them, for the convenience of calculation, Z can be obtained by rounding the partial output of the downsampling network, and can represent the compressed information related to the F distribution. The probability distribution parameters Z:Mu and Z:Sigma of Z can be obtained after the training of the compressed network model. It can be understood that because Z can represent the compressed information related to the F distribution, the distribution of Z is simpler than the distribution of F. Therefore, fixed probability distribution parameters can be used to describe Z, that is, the probability distribution parameters Z:Mu and Z:Sigma of Z are fixed values, and this value remains unchanged after the training of the compressed network model is completed.

[0049] By inputting the data to be compressed into the compression network model to obtain an intermediate compression result of the data to be compressed, and then obtaining a second probability distribution parameter corresponding to the probability distribution of the data to be compressed from the intermediate compression result, the second probability distribution parameter corresponding to the probability distribution of the data to be compressed can be made more accurate, and the probability distribution parameter of the data to be compressed is obtained based on the data to be compressed through the compression network model, that is, the compression network model can adaptively obtain the probability distribution parameters corresponding to the data to be compressed.

[0050] As another way, in order to obtain a more accurate compression network model, the above compression network model can be improved. Such improvements can be: increasing the size of the convolution kernel, for example, changing the size of the above convolution and deconvolution (3×3) to 5×5, which can increase the receptive field of the compression network model and learn more information; increasing the complexity of the compression network model, for example, stacking more convolution layers in each upsampling and downsampling module, and for another example, increasing the number of upsampling and downsampling modules in the upsampling and downsampling network.

[0051] It is understandable that when the structure of the compressed network model is more complex, the compressed network model will be overparameterized, further reducing the computational efficiency of the compressed network model. In order to cope with high real-time computing scenarios, the compressed network model can also be pruned. For example, the trained compressed network model can be subjected to channel pruning, which is mainly performed through the following two steps: (1) Channel selection: This can be accomplished through LASSO regression, that is, adding the L1 norm to the loss function to constrain the weights. From the perspective of objective function optimization, the L1 norm can make most of the weights 0, making the weights in the channel sparse, so that the sparse channels can be pruned; (2) Feature map reconstruction, which can be implemented based on linear least squares, so that the change of the output feature map before and after pruning is as small as possible.

[0052] It should be noted that the compression network model can be obtained by combining multiple improvement methods. For example, the size of the convolution kernel and the number of up-sampling and down-sampling modules in the up-sampling and down-sampling networks can be increased at the same time. Exemplarily, the number of up-sampling and down-sampling modules in the up-sampling and down-sampling networks can be increased to 5, and the size of the convolution kernel in each up-sampling and down-sampling module becomes 5×5.

[0053] S130: Encode the intermediate compression result based on the arithmetic encoder and the first probability distribution parameters to obtain a first code, and encode the data to be compressed based on the arithmetic encoder and the second probability distribution parameters to obtain a second code, where the second code is a compression result of the data to be compressed.

[0054] For example, Figure 6 As shown, the intermediate compression result is Z, the first probability distribution parameters are Z:Mu, Z:Sigma, and Z, Z:Mu, and Z:Sigma are input into the arithmetic encoder to obtain the first code, that is, the encoding result CZ of Z. The data to be compressed is F, and the second probability distribution parameters are F:Mu, F:Sigma. F, F:Mu, and F:Sigma are input into the arithmetic encoder to obtain the second code, that is, the encoding result CF of F, wherein CF is the compression result of F.

[0055] The present embodiment provides a data compression method, after obtaining the data to be compressed, obtains the intermediate compression result of the data to be compressed, the first probability distribution parameter corresponding to the probability distribution of the intermediate compression result, and the second probability distribution parameter corresponding to the probability distribution of the data to be compressed through a compression network model, encodes the intermediate compression result based on an arithmetic encoder and the first probability distribution parameter to obtain a first code, encodes the data to be compressed based on an arithmetic encoder and the second probability distribution parameter to obtain a second code, and the second code is the compression result of the data to be compressed. Through the above manner, the data to be compressed can be compressed based on the probability distribution characteristics of the data to be compressed and the second probability distribution parameter corresponding to the probability distribution of the data to be compressed obtained by the compression network model, thereby improving the compression efficiency.

[0056] See also Figure 7 , the present application provides a data compression method, the method comprising:

[0057] S210: Training the compression network model to be trained by using a compression loss function to obtain the compression network model.

[0058] The compression loss function is used to minimize the sum of the mean values ​​of the storage space required for the data to be compressed and the multiple sub-data of the intermediate compression result.

[0059] As a method, the compression loss function includes a first loss function and a second loss function, wherein the first loss function is used to minimize the average value of the storage space required by the multiple sub-data of the intermediate compression result, and the second loss function is used to minimize the average value of the storage space required by the multiple sub-data of the data to be compressed. Optionally, the calculation formula of the compression loss function can be:

[0060] Loss = -(BPP F +BPP Z )

[0061] Among them, the BPP of this formula is Z is the first loss function, the BPP in this formula F is the second loss function.

[0062] Among them, the calculation formula of the first loss function can be:

[0063]

[0064] The Z in the calculation formula of the first loss function represents the intermediate compression result generated by inputting the data to be compressed into the compression network model. The intermediate compression result can represent the compressed information related to the distribution of the data to be compressed. The intermediate compression result contains multiple sub-data, each of which is represented by Z i, where each sub-data has a probability distribution parameter Z corresponding to the data i :Mu i and Z i : Sigma i . It can be seen from this that Z i The probability value of the probability value is a logarithm operation with a base of 2 to obtain the sub-data Z i How many bits are needed to represent it, where the size of the bit number corresponds to the sub-data Z i The size of the storage space required, if the sub-data Z i The more bits are needed, the more i The more storage space is needed; if the sub-data Z i The fewer bits are needed, the better the sub-data Z i By summing and averaging the number of bits required for each sub-data in the intermediate compression result Z, the average value of the storage space required for multiple sub-data of the intermediate compression result Z can be expressed.

[0065] Among them, the calculation formula of the second loss function can be:

[0066]

[0067] In the calculation formula of the second loss function, F represents the data to be compressed, and the data to be compressed includes multiple sub-data, each of which is represented by F i , where each sub-data has a probability distribution parameter F corresponding to the data i :Mu i and F i : Sigma i . It can be seen from this that F i The probability value of the probability value is obtained by performing a logarithmic operation with a base of 2 on the probability value. i How many bits are needed to represent it, where the size of the number of bits corresponds to the sub-data F i The size of the storage space required, if the sub-data F i The more bits are needed, the smaller the sub-data F i The more storage space is needed; if the sub-data F i The fewer bits are needed, the better the sub-data F i By summing and averaging the number of bits required for each sub-data in the data to be compressed F, the average value of the storage space required for multiple sub-data of the data to be compressed F can be expressed.

[0068] It should be noted that because the sub-data Z i 、F i The probability is very small and is infinitely close to 0, so when calculating the sub-data Z of the intermediate compression result i The sub-data F of the data to be compressed i When the probability is i 、F i An interval near , and the probability value of this interval is used as the sub-data Z i 、F i For example, the probability integral of the interval [Fi-0.5, Fi+0.5] is selected as the probability of Fi.

[0069] S220: Obtain data to be compressed.

[0070] S230: Obtaining, through a compression network model, an intermediate compression result of the data to be compressed, a first probability distribution parameter corresponding to the probability distribution of the intermediate compression result, and a second probability distribution parameter corresponding to the probability distribution of the data to be compressed.

[0071] S240: Encode the intermediate compression result based on the arithmetic encoder and the first probability distribution parameters to obtain a first code, and encode the data to be compressed based on the arithmetic encoder and the second probability distribution parameters to obtain a second code, where the second code is a compression result of the data to be compressed.

[0072] It should be noted that the training process of the compressed network model in S210 can be implemented on a computer workstation, which is a high-performance computer with powerful data calculation and graphics and image processing capabilities; S220~S240 can be implemented on electronic devices, such as mobile phones, computers, etc.

[0073] The data compression method provided by the present embodiment can compress the data to be compressed based on the probability distribution characteristics of the data to be compressed and the second probability distribution parameter corresponding to the probability distribution of the data to be compressed obtained by the compression network model, thereby improving the compression efficiency. In addition, in the present embodiment, the compression network model is trained by using a compression loss function adapted to the compression network model, thereby improving the accuracy of the compression network model.

[0074] See also Figure 8 The present application provides a data compression method, which is applied to an electronic device, and the method comprises:

[0075] S310: Obtain data to be compressed.

[0076] S320: Obtaining, through a compression network model, an intermediate compression result of the data to be compressed, a first probability distribution parameter corresponding to the probability distribution of the intermediate compression result, and a second probability distribution parameter corresponding to the probability distribution of the data to be compressed.

[0077] S330: Encode the intermediate compression result based on the arithmetic encoder and the first probability distribution parameters to obtain a first code, and encode the data to be compressed based on the arithmetic encoder and the second probability distribution parameters to obtain a second code, where the second code is a compression result of the data to be compressed.

[0078] S340: Concatenate the first code and the second code to obtain a third code, and store the third code.

[0079] The third code can be obtained by simply concatenating the first code and the second code. For example, the first code is AAAAAA, the second code is BBBBBB, and the third code is AAAAAABBBBBB.

[0080] It can be understood that, in order to facilitate subsequent decompression operations, a flag bit can be set for the third code, and the flag bit can indicate that: before the flag bit is the first code, and after the flag bit is the second code.

[0081] The data compression method provided by the present embodiment can compress the data to be compressed based on the probability distribution characteristics of the data to be compressed and the second probability distribution parameter corresponding to the probability distribution of the data to be compressed obtained by the compression network model, thereby improving the compression efficiency. In addition, in the present embodiment, compared with the method of storing the first code and the second code separately, the third code is obtained by splicing the first code and the second code, and the method of storing the third code can be more convenient to manage.

[0082] See also Fig. 9 The present application provides a data decompression method, which is applied to an electronic device, and the method comprises:

[0083] S410: Obtain information to be decoded, where the information to be decoded includes a first probability distribution parameter, a first code, and a second code, where the second code is data to be decompressed.

[0084] The first probability distribution parameter is a parameter corresponding to the probability distribution of the decoding result of the first code. Exemplarily, the decoding result of the first code is Gaussian distributed, and the first probability distribution parameter includes a mean and a variance.

[0085] As a method, obtaining the information to be decoded can be achieved by obtaining a first probability distribution parameter, a first code, and a second code.

[0086] As another way, the information to be decoded can be obtained by obtaining the first probability distribution parameter and the third code, and splitting the third code to obtain the first code and the second code. Among them, the third code can split the first code and the second code by a flag bit, and the flag bit can indicate: before the flag bit is the first code, and after the flag bit is the second code. For example, the third code is AAAAAABBBBBB, and according to the flag bit, the third code can be split into: the first code AAAAAA, the second code BBBBBB.

[0087] S420: Input the first probability distribution parameter and the first code into an arithmetic decoder to obtain a first decoding.

[0088] For example, Fig.10 As shown, the first probability distribution parameters are Z:Mu, Z:Sigma, the first code is CZ, and Z:Mu, Z:Sigma and CZ are input into the arithmetic decoder to obtain the first decoding Z.

[0089] S430: Input the first decoding into a decompression network model to obtain second probability distribution parameters, wherein the decompression network model is an upsampling network, and the upsampling network is an upsampling network in a compression network model corresponding to the decompression network model.

[0090] The second probability distribution parameter is a parameter corresponding to the probability distribution of the decoding result of the second code, that is, the second probability distribution parameter is a parameter corresponding to the probability distribution of the data to be decompressed. Exemplarily, if the data to be decompressed is Gaussian distributed, the second probability distribution parameter includes a mean and a variance.

[0091] For example, Fig.11 As shown, the first decoding is Z, and inputting Z into the upsampling network can obtain the second probability distribution parameters F:Mu and F:Sigma.

[0092] S440: Input the second probability distribution parameter and the second code into an arithmetic decoder to obtain a second decoding, where the second decoding is a decompression result of the data to be decompressed.

[0093] For example, Fig.10 As shown, the second probability distribution parameters are F:Mu, F:Sigma, and the second code is CF. F:Mu, F:Sigma and CF are input into the arithmetic decoder to obtain the second decoding F, which is the decompression result.

[0094] The present embodiment provides a data decompression method. After obtaining information to be decoded, the information to be decoded includes a first probability distribution parameter, a first code, and a second code, the second code is the data to be decompressed, the first probability distribution parameter and the first code are input into an arithmetic decoder to obtain a first decoding, the first decoding is input into a decompression network model to obtain a second probability distribution parameter, the decompression network model is an upsampling network, the upsampling network is an upsampling network in a compression network model corresponding to the decompression network model, the second probability distribution parameter and the second code are input into an arithmetic decoder to obtain a second decoding, and the second decoding is the decompression result of the data to be decompressed. Through the above method, based on the probability distribution characteristics of the data to be decompressed, the data to be decompressed can be decompressed by the information to be decoded and the second probability distribution parameter corresponding to the probability distribution of the data to be decompressed obtained by the decompression network model, so as to facilitate the subsequent call of the decompressed data.

[0095] In order to better understand the solutions of all embodiments of the present application, the data compression and decompression method of the present application is introduced below in combination with an application scenario.

[0096] See also Fig.12 , the application scenario can be composed of the following three parts: (1) NPU: can be used to input the data to be compressed into the compression and decompression module and receive the decompressed data output by the compression and decompression module; (2) Compression and decompression module: can be used to realize data compression and decompression, the module can have a compression network model, an arithmetic encoder, a decompression network model, and an arithmetic decoder, wherein the decompression network model can be the upsampling network part of the compression network model; (3) DDR: can be used to store the output results of the compression and decompression module.

[0097] In the data compression stage: NPU can input the data to be compressed into the compression network model in the compression and decompression module. The data to be compressed can be the intermediate result of the neural network, the image, the weight of the neural network model, etc., wherein the intermediate result can be the intermediate feature extracted by the neural network, the hyperparameter of the hidden layer of the neural network, etc. In the compression and decompression module, the intermediate result corresponding to the data to be compressed, the first probability distribution parameter corresponding to the intermediate result, and the second probability distribution parameter corresponding to the data to be compressed can be obtained through the compression network model in the compression and decompression module. The intermediate result and the first probability distribution parameter are input into the arithmetic encoder to obtain the first code, and the data to be compressed and the second probability distribution parameter are input into the arithmetic encoder to obtain the second code, which is the compression result. Afterwards, the first probability distribution parameter, the first code and the second code can be stored in the DDR, wherein the first code and the second code can be spliced ​​to obtain the third code, and then the third code is stored, and the third code can set a flag to distinguish the first code from the second code.

[0098] In the data decompression stage, DDR can input the first probability distribution parameter, the first code and the second code into the compression and decompression module, and the second code is the data to be decompressed. If the first code and the second code are spliced ​​into a third code and then stored in DDR, the third code can be first split into the first code and the second code through the flag bit. In the compression and decompression module, the first probability distribution parameter and the first code can be first input into the arithmetic decoder to obtain the first decoding; then the first decoding is input into the decompression network model to obtain the second probability distribution parameter, and the second probability parameter is a parameter corresponding to the probability distribution of the decoding result of the second code, that is, the second probability distribution parameter is a parameter corresponding to the probability distribution of the data to be decompressed. The second probability distribution parameter and the second code are input into the arithmetic decoder to obtain the second decoding, and the second decoding is the decompression result. The decompression result can be input into the NPU for subsequent calculations.

[0099] See also Fig.13 The present application provides a data compression device 600, which runs on an electronic device. The device 600 includes:

[0100] Data acquisition unit 610: used to acquire data to be compressed;

[0101] Parameter acquisition unit 620: used to obtain, through a compression network model, an intermediate compression result of the data to be compressed, a first probability distribution parameter corresponding to the probability distribution of the intermediate compression result, and a second probability distribution parameter corresponding to the probability distribution of the data to be compressed;

[0102] Data compression unit 630: used to encode the intermediate compression result based on the arithmetic encoder and the first probability distribution parameters to obtain a first code, and encode the data to be compressed based on the arithmetic encoder and the second probability distribution parameters to obtain a second code, wherein the second code is a compression result of the data to be compressed.

[0103] The compression network model includes a downsampling network and an upsampling network. Optionally, the parameter acquisition unit 620 is specifically used to input the data to be compressed into the downsampling network to obtain the intermediate compression result and the first probability distribution parameter output by the downsampling network; and input the intermediate compression result into the upsampling network to obtain the second probability distribution parameter output by the upsampling network.

[0104] The device 600 further includes:

[0105] Model training unit 640: used to train the compression network model to be trained through a compression loss function to obtain the compression network model, the compression loss function includes a first loss function and a second loss function, the first loss function is used to minimize the average of the storage space required for multiple sub-data of the intermediate compression result, and the second loss function is used to minimize the average of the storage space required for multiple sub-data of the data to be compressed.

[0106] The data storage unit 650 is configured to concatenate the first code and the second code to obtain a third code, and store the third code.

[0107] The present application provides a data compression device, which runs on an electronic device. After obtaining the data to be compressed, the device obtains the intermediate compression result of the data to be compressed, the first probability distribution parameter corresponding to the probability distribution of the intermediate compression result, and the second probability distribution parameter corresponding to the probability distribution of the data to be compressed through a compression network model. The intermediate compression result is encoded based on an arithmetic encoder and the first probability distribution parameter to obtain a first code. The data to be compressed is encoded based on an arithmetic encoder and the second probability distribution parameter to obtain a second code, and the second code is the compression result of the data to be compressed. In the above manner, the data to be compressed can be compressed based on the probability distribution characteristics of the data to be compressed and the second probability distribution parameter corresponding to the probability distribution of the data to be compressed obtained by the compression network model, thereby improving the compression efficiency.

[0108] See also Fig.14 The present application provides a data decompression device 800, which runs on an electronic device. The device 800 includes:

[0109] A data acquisition unit 810 is used to acquire information to be decoded, where the information to be decoded includes a first probability distribution parameter, a first code, and a second code, where the second code is data to be decompressed;

[0110] The data decompression unit 820 is used to input the first probability distribution parameter and the first code into an arithmetic decoder to obtain a first decoding; input the first decoding result into a decompression network model to obtain a second probability distribution parameter, wherein the decompression network model is an upsampling network, and the upsampling network is an upsampling network in a compression network model corresponding to the decompression network model;

[0111] The second probability distribution parameter and the second code are input into an arithmetic decoder to obtain a second decoding, where the second decoding is a decompression result of the data to be decompressed.

[0112] Among them, optionally, the data acquisition unit 810 is specifically used to obtain the first probability distribution parameter and the third code; and split the third code to obtain the first code and the second code.

[0113] See also Fig.15 Based on the above data compression and decompression method and device, the embodiment of the present application also provides another electronic device 100 that can execute the above terminal control method. The electronic device 100 includes one or more (only one is shown in the figure) processors 102 and a memory 104 coupled to each other. The memory 104 stores a program that can execute the content of the above embodiment, and the processor 102 can execute the program stored in the memory 104.

[0114] Among them, the processor 102 may include one or more processing cores. The processor 102 uses various interfaces and lines to connect various parts within the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 104, and calling data stored in the memory 104. Optionally, the processor 102 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 102 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU), an embedded neural network processor (Neural Processing Unit, NPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing display content; the modem is used to process wireless communications; and the NPU is used to process massive multimedia data such as video and images. It is understandable that the above-mentioned modem may not be integrated into the processor 102, but may be implemented separately through a communication chip.

[0115] The memory 104 may include a random access memory (RAM), a read-only memory (Read-Only Memory), and a double data rate synchronous dynamic random access memory (Double Data Rate, DDR). The memory 104 may be used to store instructions, programs, codes, code sets, or instruction sets. The memory 104 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the terminal 100 during use.

[0116] Please refer to Fig.16 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable storage medium 1000 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.

[0117] The computer readable storage medium 1000 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 1000 includes a non-transitory computer-readable storage medium. The computer readable storage medium 800 has storage space for program code 1010 that performs any method step of the above method. These program codes can be read from or written to one or more computer program products. The program code 1010 can be compressed, for example, in an appropriate form.

[0118] In summary, the present application provides a data compression method, a data decompression method, a device and an electronic device. After obtaining the data to be compressed, an intermediate compression result of the data to be compressed, a first probability distribution parameter corresponding to the probability distribution of the intermediate compression result and a second probability distribution parameter corresponding to the probability distribution of the data to be compressed are obtained through a compression network model. The intermediate compression result is encoded based on an arithmetic encoder and the first probability distribution parameter to obtain a first code. The data to be compressed is encoded based on an arithmetic encoder and the second probability distribution parameter to obtain a second code, and the second code is the compression result of the data to be compressed. Through the above manner, the data to be compressed can be compressed based on the probability distribution characteristics of the data to be compressed and the second probability distribution parameter corresponding to the probability distribution of the data to be compressed obtained by the compression network model, thereby improving the compression efficiency.

[0119] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A data compression method, characterized in that: Applied to electronic equipment, the method comprises: Get the data to be compressed; Obtaining an intermediate compression result of the data to be compressed, a first probability distribution parameter corresponding to the probability distribution of the intermediate compression result, and a second probability distribution parameter corresponding to the probability distribution of the data to be compressed through a compression network model, wherein the compression network model includes a downsampling network and an upsampling network; The method of obtaining, by means of a compression network model, an intermediate compression result corresponding to the data to be compressed, a first probability distribution parameter corresponding to the probability distribution of the intermediate compression result, and a second probability distribution parameter corresponding to the probability distribution of the data to be compressed comprises: Inputting the data to be compressed into the downsampling network to obtain the intermediate compression result output by the downsampling network and the first probability distribution parameter; Inputting the intermediate compression result into the upsampling network to obtain the second probability distribution parameter output by the upsampling network; The intermediate compression result is encoded based on the arithmetic encoder and the first probability distribution parameters to obtain a first code, and the data to be compressed is encoded based on the arithmetic encoder and the second probability distribution parameters to obtain a second code, wherein the second code is a compression result of the data to be compressed.

2. The method according to claim 1, characterized in that The data to be compressed and the intermediate compression result both include a plurality of sub-data. Before obtaining the data to be compressed, the method further includes: The compression network model to be trained is trained by a compression loss function to obtain the compression network model, wherein the compression loss function includes a first loss function and a second loss function, wherein the first loss function is used to minimize the average of the storage space required for multiple sub-data of the intermediate compression result, and the second loss function is used to minimize the average of the storage space required for multiple sub-data of the data to be compressed.

3. The method according to claim 1, characterized in that After encoding the intermediate compression result based on the arithmetic encoder and the first probability distribution parameter to obtain a first code, and encoding the to-be-compressed data based on the arithmetic encoder and the second probability distribution parameter to obtain a second code, the method further includes: The first code and the second code are concatenated to obtain a third code, and the third code is stored.

4. A data decompression method, characterized in that: Applied to electronic equipment, the method comprises: Acquire information to be decoded, where the information to be decoded includes a first probability distribution parameter, a first code, and a second code, where the second code is data to be decompressed; The second code generation method includes: Get the data to be compressed; Obtaining an intermediate compression result of the data to be compressed, a first probability distribution parameter corresponding to the probability distribution of the intermediate compression result, and a second probability distribution parameter corresponding to the probability distribution of the data to be compressed through a compression network model, wherein the compression network model includes a downsampling network and an upsampling network; The method of obtaining, by means of a compression network model, an intermediate compression result corresponding to the data to be compressed, a first probability distribution parameter corresponding to the probability distribution of the intermediate compression result, and a second probability distribution parameter corresponding to the probability distribution of the data to be compressed comprises: Inputting the data to be compressed into the downsampling network to obtain the intermediate compression result output by the downsampling network and the first probability distribution parameter; Inputting the intermediate compression result into the upsampling network to obtain the second probability distribution parameter output by the upsampling network; Encoding the intermediate compression result based on the arithmetic encoder and the first probability distribution parameter to obtain a first code, and encoding the data to be compressed based on the arithmetic encoder and the second probability distribution parameter to obtain a second code; Inputting the first probability distribution parameter and the first code into an arithmetic decoder to obtain a first decoding; Input the first decoding into a decompression network model to obtain a second probability distribution parameter, wherein the decompression network model is an upsampling network, and the upsampling network is an upsampling network in a compression network model corresponding to the decompression network model; The second probability distribution parameter and the second code are input into an arithmetic decoder to obtain a second decoding, where the second decoding is a decompression result of the data to be decompressed.

5. The method according to claim 4, characterized in that The obtaining of information to be decoded comprises: Obtaining a first probability distribution parameter and a third code; The third code is split into a first code and a second code.

6. A device for compressing data, characterized in that: Running on an electronic device, the device comprises: A data acquisition unit, used for acquiring data to be compressed; A parameter acquisition unit, used for obtaining an intermediate compression result of the data to be compressed, a first probability distribution parameter corresponding to the probability distribution of the intermediate compression result, and a second probability distribution parameter corresponding to the probability distribution of the data to be compressed through a compression network model, wherein the compression network model includes a downsampling network and an upsampling network; obtaining the intermediate compression result corresponding to the data to be compressed, the first probability distribution parameter corresponding to the probability distribution of the intermediate compression result, and the second probability distribution parameter corresponding to the probability distribution of the data to be compressed through the compression network model, comprising: inputting the data to be compressed into the downsampling network to obtain the intermediate compression result and the first probability distribution parameter output by the downsampling network; inputting the intermediate compression result into the upsampling network to obtain the second probability distribution parameter output by the upsampling network; A data compression unit is used to encode the intermediate compression result based on the arithmetic encoder and the first probability distribution parameters to obtain a first code, and to encode the data to be compressed based on the arithmetic encoder and the second probability distribution parameters to obtain a second code, wherein the second code is a compression result of the data to be compressed.

7. A device for decompressing data, characterized in that: Running on an electronic device, the device comprises: A data acquisition unit is used to acquire information to be decoded, wherein the information to be decoded includes a first probability distribution parameter, a first code and a second code, wherein the second code is data to be decompressed; wherein the second code is generated in a manner including: acquiring data to be compressed; obtaining an intermediate compression result of the data to be compressed, a first probability distribution parameter corresponding to the probability distribution of the intermediate compression result and a second probability distribution parameter corresponding to the probability distribution of the data to be compressed through a compression network model, wherein the compression network model includes a downsampling network and an upsampling network; obtaining the intermediate compression result corresponding to the data to be compressed, the first probability distribution parameter corresponding to the probability distribution of the intermediate compression result and the second probability distribution parameter corresponding to the probability distribution of the data to be compressed through the compression network model includes: inputting the data to be compressed into the downsampling network to obtain the intermediate compression result and the first probability distribution parameter output by the downsampling network; inputting the intermediate compression result into the upsampling network to obtain the second probability distribution parameter output by the upsampling network; encoding the intermediate compression result based on an arithmetic encoder and the first probability distribution parameter to obtain a first code, and encoding the data to be compressed based on the arithmetic encoder and the second probability distribution parameter to obtain a second code; A data decompression unit, configured to input the first probability distribution parameter and the first code into an arithmetic decoder to obtain a first decoding; Inputting the first decoding result into a decompression network model to obtain a second probability distribution parameter, wherein the decompression network model is an upsampling network, and the upsampling network is an upsampling network in a compression network model corresponding to the decompression network model; The second probability distribution parameter and the second code are input into an arithmetic decoder to obtain a second decoding, where the second decoding is a decompression result of the data to be decompressed.

8. An electronic device, characterized in that: including one or more processors and memory; One or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1 to 5.

9. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of any method described in claims 1-5 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program code, wherein when the program code is run, the method according to any one of claims 1 to 5 is executed.

Citation Information

Patent Citations

  • Method and device for encoding and decoding data, and system

    CN111641826A

  • Encoding method and device, decoding method and device, electronic equipment and storage medium

    CN111641832A