Image data processing method, device and terminal equipment
By introducing a convolution calculation module and a data compression module into the neural network model, the input data is de-zeroed and compressed and used directly for subsequent calculations, which solves the problem of slow calculation speed of the neural network and improves processing efficiency and accuracy.
Patent Information
- Application Number
- CN202010014406.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-01-07
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2040-01-07
AI Technical Summary
Neural networks have slow calculation speeds when processing big data, resulting in slower data transmission and calculations, and may even cause errors in calculation results.
By introducing the convolution calculation module and data compression module into the neural network model, the input data is first subjected to zeroing processing and convolution calculation to obtain the initial feature map data, and then the data is dezeroed and compressed to obtain the target feature map data, which can be directly It is used for subsequent calculations, which avoids the step of decompressing and then calculating in the existing technology.
It improves the calculation speed of the neural network, reduces the amount of data calculation and processing time, and avoids the occurrence of calculation errors.
Smart Images

Figure CN113159267B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of data processing, and in particular relates to an image data processing method, device and terminal equipment. Background Art
[0002] A neural network is a computing module that mimics the structure and function of a biological neural network and is used to estimate or approximate a function. With the development of neural networks, neural networks have been widely used in computer vision, natural language processing, and other fields.
[0003] When neural networks process big data, such as super-resolution image processing, due to the large amount of data, neural networks need to store, transmit and calculate a large amount of data, resulting in slow data transmission and data calculation speeds, and even erroneous calculation results. Therefore, improving the calculation speed of neural networks is a problem that needs to be solved at present. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides an image data processing method, apparatus and terminal device to solve the problem of slow calculation speed of neural network in the prior art.
[0005] In a first aspect, an embodiment of the present application provides an image data processing method, the method is used for a neural network model, the neural network model includes: a convolution calculation module and a data compression module;
[0006] The method comprises:
[0007] Inputting the input data of the convolution layer into the convolution calculation module, the convolution calculation module performs convolution calculation on the input data, and outputs the initial feature map data of the convolution layer to the data compression module, wherein the input data includes the data after the initial image data is processed by zero removal or the data after the initial feature map data of the previous convolution layer is processed by zero removal;
[0008] The data compression module performs zero removal processing on the initial feature map data and outputs corresponding target feature map data.
[0009] In a second aspect, an embodiment of the present application provides an image data processing device, including:
[0010] The neural network model and the external controller, wherein the external controller is connected to the neural network model, and the external controller transmits the input data to the neural network model.
[0011] In a third aspect, an embodiment of the present application provides a terminal device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the image data processing method described in any one of the first aspects above when executing the computer program.
[0012] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and wherein the computer program, when executed by a processor, implements the image data processing method described in any one of the first aspects above.
[0013] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product runs on a terminal device, the terminal device executes the image data processing method described in any one of the above-mentioned first aspects.
[0014] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the present application receives the input data after the convolution layer zero-removing processing and performs convolution calculation on the input data to obtain the initial feature map data of the convolution layer, and finally performs zero-removing compression on the initial feature map data to obtain the target feature map data. The present application can directly process the input data after the zero-removing processing, and then compress the calculated initial feature map data before performing subsequent calculations. Compared with the method in the prior art that first decompresses the compressed data and then performs data calculations, the present application directly uses the data after the zero-removing processing for subsequent calculations, thereby improving the calculation speed of the neural network.
[0015] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0017] Figure 1 is a schematic diagram of the structure of a neural network model provided by an embodiment of the present invention;
[0018] Figure 2 is a flowchart of an image data processing method provided by an embodiment of the present invention;
[0019] Figure 3 The embodiment of the present invention provides Figure 2A schematic flow chart of the method for calculating the initial feature map data in step 101;
[0020] Figure 4 The embodiment of the present invention provides Figure 3 Specific flow diagram of the method for obtaining target weight data in step 1012 Figure 1 ;
[0021] Figure 5 The embodiment of the present invention provides Figure 3 Specific flow diagram of the method for obtaining target weight data in step 1012 Figure 2 ;
[0022] Figure 6 The embodiment of the present invention provides Figure 1 A flow chart of a method for performing data zero removal processing in step 102;
[0023] Figure 7 is a structural schematic diagram of an image data processing device provided by an embodiment of the present invention;
[0024] Figure 8 is a schematic diagram of the structure of a terminal device provided in an embodiment of the present application;
[0025] Fig. 9 It is a block diagram of a partial structure of a computer provided in one embodiment of the present application. DETAILED DESCRIPTION
[0026] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0027] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0028] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0029] In order to speed up the processing of neural networks, one of the acceleration methods is to compress the data. There are existing solutions for compression calculation, such as Cambricon-x, Cnvlutin, DEEP COMPRESSION, EIE, Xiaowei Li, Eyeriss, etc. Since the compressed data will not be arranged in order, the order of the compressed data is chaotic. At present, when the neural network processes the compressed data, it needs to decompress the compressed data before processing, otherwise the neural network will have errors. Such a processing process reduces the speed of the neural network to process data.
[0030] Based on the above problems, the present application provides an image data processing method, apparatus and terminal device. For each convolution layer in the neural network, according to the algorithm corresponding to the current convolution layer, the initial image data is de-zeroed and input into the neural network model for calculation. When calculating the current convolution layer in a neural network with multiple convolution layers, the initial feature map data obtained by the previous convolution layer is de-zeroed and sent into the neural network model for calculation, which reduces the amount of data calculation and improves the running speed of data processing.
[0031] like Figure 1 As shown, the image data processing method of the present application is used for a neural network model 200, and the neural network model 200 includes: a convolution calculation module 210 and a data compression module 220, and the convolution calculation module 210 and the data compression module 220 are connected.
[0032] The convolution calculation module 210 includes: a data storage unit 212, a control unit 215, a calculation unit 217 and a weight storage unit 216, wherein the weight storage unit 216 stores the initial weight data of the neural network, the data storage unit 212 stores the input data of each convolution layer, the calculation unit 217 stores the preset algorithm corresponding to each convolution layer, and performs convolution calculation on the input data to obtain the initial feature map data;
[0033] The data compression module 220 performs zero removal processing on the initial feature map data to obtain target feature map data;
[0034] The control unit 215 controls the data transmission between the data storage unit 214, the calculation unit 217, the weight storage unit 216 and the data compression module 220 and the operation of each unit / module.
[0035] In this embodiment, the initial weight data may be the weight data of all convolutional layers in the neural network. The initial weight data may be pre-stored in a weight storage unit or may be transmitted to the weight storage unit from an external controller.
[0036] like Figure 1As shown, in a possible implementation, the convolution calculation module 210 may further include: a data interface unit 211, a data cache unit 212 and a control interface unit 213;
[0037] The data interface unit 211 obtains the initial weight data and input data stored in the external controller, and transmits the initial weight data and input data to the data cache unit 212; after the data cache unit 212 caches the initial weight data and input data, it transmits the initial weight data to the weight storage unit 216 for storage, and transmits the input data to the data storage unit 214 for storage;
[0038] The control interface unit 213 acquires a control signal from an external controller and transmits the control signal to the control unit 215 .
[0039] like Figure 1 As shown, in a possible implementation, the neural network model 200 may further include a data output module 230, which obtains target feature map data from the data compression module 220 and transmits the target feature map data to an external controller as input data for calculation of the next convolutional layer. When calculation of the next convolutional layer is required, the data storage unit 212 obtains the above target feature map data from the external controller for convolution calculation.
[0040] like Figure 1 As shown, in a possible implementation, the data storage unit 212 may include: a data cache subunit and a data distribution subunit, and the data cache subunit is connected to the data distribution subunit.
[0041] Figure 2 A schematic flow chart of the image data processing method provided by the present application is shown, referring to Figure 2 , the above image data processing method is described in detail as follows:
[0042] S101, inputting the input data of the convolution layer into the convolution calculation module, the convolution calculation module performs convolution calculation on the input data, and outputs the initial feature map data of the convolution layer to the data compression module, wherein the input data includes the data after the initial image data is de-zeroed or the data after the initial feature map data of the previous convolution layer is de-zeroed.
[0043] In this embodiment, since the neural network model is calculated layer by layer, in a neural network with multiple convolutional layers, when calculating the current convolutional layer, it is necessary to obtain the initial feature map data output by the previous convolutional layer after the zero-removing processing to perform convolution calculation, and obtain the initial feature map data of the current convolutional layer. When there is only one convolutional layer or the first convolutional layer, the input data is the initial image data of the image to be convolution processed after the zero-removing processing.
[0044] Specifically, the method for removing zeros from the initial image data may include:
[0045] S201, removing zero data in the initial image data to obtain non-zero data in the initial image data;
[0046] S202, obtaining data encoding of the non-zero data based on the row and column where the non-zero data is located in the initial image data;
[0047] S203, storing the non-zero data and the data code in correspondence with each other to obtain data after zero removal processing.
[0048] It should be noted that the method of performing zero removal processing on the initial feature map data output by the previous convolutional layer is the same as the process of performing zero removal processing on the initial image data, refer to S201 to S203.
[0049] like Figure 3 As shown, in a possible implementation, step S101 may specifically include:
[0050] S1011, the data storage unit receives and stores input data of the convolutional layer.
[0051] In this embodiment, in a neural network with multiple convolutional layers, the input data is the data obtained by removing zero from the initial feature map data of the previous convolutional layer. Existing, a set of data is obtained after each convolution, and the above data is stored as the feature map data after this convolution, and the feature map data obtained by this convolution will be used as the input data of the next convolutional layer to continue the convolution calculation until all the operation rules in the neural network are completed.
[0052] The input data of the convolutional layer is zero-removed data. Zero-removal processing can reduce the amount of data, increase the transmission speed, and speed up the calculation speed.
[0053] S1012, the control unit obtains a preset algorithm from the calculation unit, and obtains target weight data corresponding to the input data from the initial weight data based on the preset algorithm.
[0054] In this embodiment, since the data in the initial weight data is relatively small, the compression or non-compression of the initial weight data has little effect on the processing speed. Therefore, the initial weight data can be the weight data after zeroing processing or the weight data without zeroing processing.
[0055] Specifically, in a neural network, weight data exists in the form of a kernel function and a matrix, and each data in the kernel function matrix is a weight. The compressed initial weight data is obtained by removing the zero data in the original weight data, so the original order of the weight data may change. Each weight in the compressed weight data will be numbered according to the rows and columns of the weight in the original matrix, so even if the weight data is compressed, the required weight can be accurately found according to the number; the uncompressed weight data is arranged in the matrix order, which is regular, and the weights are not numbered. However, since the weight data is not compressed, the weight data is still arranged in the original order, even if there is no number, the required weight can be found smoothly.
[0056] For example, if the initial weight data is not compressed, the weight data of a convolutional layer can be If the initial weight data is compressed, the original weight data After removing zeros, it can be recorded as [1:a 11 ,2:a 21 ,3:a 22 ], where a 11 Indicates that the position of 1 in the matrix is the first row and first column; a 21 Indicates that the position of 2 in the matrix is the second row and first column; a 22 It means that the position of 3 in the matrix is the second row and second column.
[0057] In a possible implementation, the preset algorithm includes: the sum of the products of the data encoding of each data in the input data that has not been processed with past zeros and the weight encoding of the corresponding weight data.
[0058] In this embodiment, the preset algorithm of the convolution layer is a calculation rule for calculating the output result of the convolution layer, such as a calculation formula. The preset algorithm of the convolution layer may include multiple calculation formulas. The preset algorithm in this application is set according to the process of convolution calculation, and the target weight data related to the input data can be found according to the preset algorithm.
[0059] The convolution calculation in the convolutional neural network is the result of multiplying two variables within a certain range and then summing them, where the two variables refer to an input value in the input data and the weight corresponding to the above input value, so the preset algorithm is set in accordance with the above convolution calculation rules. The structure of the preset algorithm can be composed of the sum of the products of the encodings of several input values and the weight encodings corresponding to the input values, where the encoding of the input value can be the row and column numbers of the input value in the input matrix without zeroing processing, and the weight encoding can be the row and column numbers of the weight value in the kernel function matrix, and several can be the number of weights in the kernel function.
[0060] According to the above preset algorithm, the target weight data corresponding to each input value in the input data can be obtained, that is, the input value required for the current convolution layer to perform convolution calculation and the weight value that needs to be multiplied by the input value. Since the input data is data after zero removal processing, it is only necessary to know the weight code corresponding to the input data, and index the weight value through the weight code. For the zero data in the input data before zero removal processing, there is no need to know the corresponding weight code, and there is no need to index the corresponding weight value. Similarly, there is no need to calculate zero data during convolution calculation, which reduces the amount of calculation and speeds up the calculation.
[0061] As an example: The general convolution calculation process is: If the uncompressed input data is a 3*3 matrix The kernel function is a 2*2 matrix Each data in the kernel function is a weight, and the step size of the convolution calculation is 1, so the convolution algorithm is:
[0062]
[0063] The result of the convolution calculation is: The above formula C is the preset algorithm of a convolutional layer.
[0064] Therefore, the preset algorithm is based on the configuration setting of the neural network. According to the preset algorithm, the data encoding of the input data used in the calculation formula and the weight encoding of the weight data can be obtained. If the input value of the required input data is known, the corresponding weight encoding can be known through the data encoding, and then the weight value can be indexed through the weight encoding.
[0065] like Figure 4 As shown, in a possible implementation, the input data includes: second non-zero data and second data codes corresponding to each of the second non-zero data; step S1012 may specifically include:
[0066] S10121, based on the corresponding position of the second data code in the preset algorithm, obtaining a second weight code corresponding to the second non-zero data calculation in the preset algorithm;
[0067] S10122: Based on the second weight code, index the target weight data corresponding to the second weight code in the initial weight data.
[0068] In this embodiment, since the preset algorithms are composed of the sum of the products of the data encoding of the input value and the weight encoding of the weight data corresponding to the input value, the corresponding weight encoding can be obtained by knowing the data encoding of the input value, and the weight value corresponding to the weight encoding can be indexed among all weights to obtain the weight value required for calculation.
[0069] As an example: Input data [1:a 11 ,2:a 13 ,2:a 22 ,3:a 23 ,4:a 31 ,1:a 32 ], 1, 2, 2, 3, 4, 1 in the input data is the second non-zero data, a 11 、a 13 、a 22 、a 23 、a 31 and a 32 Encode the second data; the preset algorithm is: b in the preset algorithm 11 …b 22 is the weight code; the weight data of the current convolutional layer in the initial weight data is Based on the preset algorithm C 11 =a 11 b 11 +a 12 b 12 +a 21 b 21 +a 22 b 22 , we can get the first data code a in the input data 11 The corresponding second weight code is b 11 , a 22 The corresponding second weight code is b 22 , since C does not exist in the current input data 11 Calculate the required a 12 and a 21 , indicating a 12 and a 21 The value of is zero, which has been removed during the zero removal process, so there is no need to query a 12 and a 21 The weight value corresponding to the part is used to calculate C 11 There is no need to calculate a 12 and a 21 part.
[0070] Index to b in the initial weight data 11 The value of b is 1, 22 The value of C is 3, then 11 =1+6=7, C 12 , C 21 and C 22 The calculation process is similar to C 11 The calculation process is the same as that of C 12 =0+4+9=13, C 21 =8+3=11, C 22 =2+2=4.
[0071] like Figure 5 As shown, in a possible implementation, the input data includes: third non-zero data and third data codes corresponding to each of the third non-zero data; step S1012 may specifically include:
[0072] S10123, distributing the third non-zero data to corresponding positions in the preset algorithm according to the third data encoding of each of the third non-zero data;
[0073] S10124, determining a third weight code corresponding to each third non-zero data based on a position of the third non-zero data in the preset algorithm;
[0074] S10125. Based on the third weight code, index the target weight data corresponding to the third weight code in the initial weight data.
[0075] In this embodiment, the third non-zero data can be distributed to the corresponding position in the preset algorithm according to the third data encoding in the preset algorithm, and then the third weight encoding of the corresponding position can be known according to which third data encoding position in the preset algorithm has an input value, and the target weight data can be indexed in the initial weight data according to the third weight encoding.
[0076] As an example: the current input data [1:a 11 ,2:a 13 ,2:a 22 ,3:a 23 ,4:a 31 ,1:a 32 ], 1, 2, 2, 3, 4, 1 in the input data is the third non-zero data, a 11 、a 13 、a 22 、a 23 、a 31 and a 32 Encode the third data; the preset algorithm is: b in the preset algorithm 11…b 22 is the weight code; the weight data of the current convolutional layer in the initial weight data is Based on the preset algorithm C 11 =1*b 11 +a 12 b 12 +a 21 b 21 +2*b 22 From the above formula, we can get the third weight code of the position corresponding to 1 as b 11 , the third weight code of the corresponding position of 2 is b 22 , C 11 Calculate the required a 12 and a 21 There is no value at the position, indicating that a does not exist in the current input data. 12 and a 21 The value of a 12 and a 21 The value of is zero, which has been removed during the zero removal process. 11 No need to 12 and a 21 part of the calculation.
[0077] Index to b in the initial weight data 11 The value of b is 1, 22 The value of C is 3, then 11 =1+6=7, C 12 , C 21 and C 22 The calculation process is similar to C 11 The calculation process is the same as that of C 11 The calculation process.
[0078] S1013, the calculation unit determines the initial feature map data of the convolutional layer based on the preset algorithm, the target weight data and the input data.
[0079] In a possible implementation, if the input data includes: second non-zero data and second data codes corresponding to each of the second non-zero data, step S1013 may specifically include:
[0080] Each data in the initial feature map data is determined according to the sum of the products of the second non-zero data and the corresponding target weight data.
[0081] In a possible implementation, if the input data includes: third non-zero data and third data codes corresponding to each of the third non-zero data, step S1013 may specifically include:
[0082] Each data in the initial feature map data is determined according to the sum of the products of the third non-zero data and the corresponding target weight data.
[0083] In this embodiment, the preset algorithm of the convolution layer may include multiple calculation formulas, the result of each calculation formula is a number in the initial feature map data, and the calculation results of all the calculation formulas together constitute the initial feature map data, wherein the initial feature map data can be one group of data, or two or more groups of data, and the number of data groups of the initial feature map data is determined by the structural setting of the neural network. The convolution layer in the neural network has several groups of kernel functions, and the initial feature map data output after the convolution calculation has several groups of data.
[0084] Specifically, each data in the initial feature map data is determined according to the sum of the products of the non-zero data and the corresponding target weight data, and the results calculated by all preset algorithms constitute the initial feature map data.
[0085] For example: if the input data is [1:a 11 ,1:a 12 ,2:a 13 ,1:a 21 ,2:a 22 ,3:a 23 ,4:a 31 ,1:a 32 ,1:a 33 ], the weight data of the current convolutional layer is The default algorithm is:
[0086]
[0087] The initial feature map data is: If there are two sets of kernel functions, the input data needs to be operated on the two sets of kernel functions respectively to obtain two sets of initial feature map data.
[0088] In the embodiment of the present application, since the input data is data after zero removal processing, when querying the weight data required in the preset algorithm, it is only necessary to find the target weight data corresponding to the input data. There is no need to query the weight data corresponding to the zero data in the input data that has not been processed with past zeros. When calculating the convolution calculation through the preset algorithm, it is only necessary to calculate the sum of the products of the non-zero data and the corresponding weight data. The product of the zero data in the input data that has not been compressed with past zeros and the weight data corresponding to the zero data does not need to be calculated. This can greatly reduce the amount of data processing and speed up the convolution calculation.
[0089] S102, the data compression module performs zero removal processing on the initial feature map data and outputs corresponding target feature map data.
[0090] like Figure 6 As shown, in a possible implementation, the initial feature map data includes feature data arranged in a matrix, and the feature data includes zero data and non-zero data; step S102 may specifically include:
[0091] S1021, removing zero data in the initial feature map data to obtain first non-zero data in the initial feature map data;
[0092] S1022, obtaining a corresponding first data code based on a position of the first non-zero data in the initial feature map data;
[0093] S1023, store the first non-zero data and the first data encoding correspondingly to obtain the target feature map data.
[0094] In this embodiment, if there is zero data in the initial feature map data, the zero data is removed and only the non-zero data in the initial feature map data is retained.
[0095] Specifically, the initial feature map data can be one group of data or two or more groups of data. For example, when the input data is an image, the image is divided into three channels of RGB, so there are three groups of inputs, and each group of input data exists in the form of a matrix; when the number of groups of initial feature map data obtained after convolution of the input data is the same as the number of kernel functions in the current convolution layer, there will be as many groups of initial feature map data output by the current convolution layer as there are groups of kernel functions.
[0096] As an example, the initial feature map data can have three sets of data, namely and The above three sets of data are collectively recorded as the initial feature map data of the current convolution layer. In addition, if there is a kernel function in the first convolution layer, each set of data is calculated with the kernel function respectively, and after the calculation of the first convolution layer, a set of initial feature map data will be output.
[0097] In this embodiment, since the initial feature map data are all in the form of a matrix, they are also calculated according to the position of the data in the matrix and the corresponding weight when used. Therefore, when encoding the non-zero data in the initial feature map data, the non-zero data is encoded according to the rows and columns in the initial feature map matrix, and one data corresponds to one code, which is convenient for future search and use.
[0098] In this embodiment, one non-zero data corresponds to one data code, and the non-zero data and the corresponding data code are stored correspondingly, or it can be associated storage, and all the non-zero data in the initial feature map data and the data code corresponding to the non-zero data are stored as target feature map data, and the target feature map data is used as the input data of the next convolution layer to perform calculations on the next convolution layer.
[0099] As an example, an initial feature map data of the convolutional layer is The zero removal compression of the initial feature map data includes:
[0100] First, the initial feature map data is Remove zeros, and the non-zero data obtained is [1,2,2,3,4,1];
[0101] Second, according to the rows and columns of the non-zero data in the initial feature map data, [1,2,2,3,4,1] are encoded, and the resulting data encodings are a 11 ,a 13 ,a 22 ,a 23 ,a 31 ,a 32 .
[0102] Third, store each non-zero data and the corresponding code of the non-zero data in correspondence to obtain the target feature map data [1:a 11 ,2:a 13 ,2:a 22 ,3:a 23 ,4:a 31 ,1:a 32 ].
[0103] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0104] Corresponding to the neural network calculation method described in the above embodiment, Figure 7 A structural block diagram of an image data processing device 300 provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0105] Reference Figure 7 , the image data processing device 300 may include: an external controller 310 and the neural network model 200, the external controller 310 is connected to the neural network model 200, and the external controller 310 transmits the input data to the neural network model 200; the external controller 310 includes: a main processor and a memory, the main processor is connected to the memory, and the neural network model 200 includes: a convolution calculation module 210 and a data compression module 220;
[0106] A convolution calculation module 210, configured to obtain input data of a convolution layer and perform convolution calculation on the input data, and output initial feature map data of the convolution layer to the data compression module 220, wherein the input data includes data after zero removal of the initial image data or data after zero removal of the initial feature map data of the previous convolution layer;
[0107] The data compression module 220 is used to perform zero removal processing on the initial feature map data.
[0108] In a possible implementation, the initial feature map data includes feature data arranged in a matrix, and the feature data includes zero data and non-zero data;
[0109] The data compression module 220 can be specifically used for:
[0110] Removing zero data in the initial feature map data to obtain first non-zero data in the initial feature map data;
[0111] Based on the position of the first non-zero data in the initial feature map data, obtain a corresponding first data code;
[0112] The first non-zero data and the first data encoding are stored correspondingly to obtain the target feature map data.
[0113] In a possible implementation, the convolution calculation module 210 may specifically include:
[0114] A data storage unit 214, used to receive and store the input data of the convolution layer;
[0115] A control unit 215 is configured to obtain a preset algorithm from the calculation unit, and obtain target weight data corresponding to the input data from the initial weight data based on the preset algorithm;
[0116] The calculation unit 217 is used to determine the initial feature map data of the convolution layer based on the preset algorithm, the target weight data and the input data.
[0117] In a possible implementation manner, the input data includes: second non-zero data and second data codes corresponding to each of the second non-zero data;
[0118] The control unit 215 may be specifically used for:
[0119] Based on the corresponding position of the second data code in the preset algorithm, obtaining a second weight code corresponding to the second non-zero data calculation in the preset algorithm;
[0120] Based on the second weight code, the target weight data corresponding to the second weight code is indexed in the initial weight data.
[0121] In a possible implementation manner, the input data includes: third non-zero data and third data codes corresponding to each of the third non-zero data;
[0122] The control unit 215 may be specifically used for:
[0123] Distributing the third non-zero data to corresponding positions in the preset algorithm according to the third data encoding of each third non-zero data;
[0124] Determine, based on the position of the third non-zero data in the preset algorithm, a third weight code corresponding to each of the third non-zero data;
[0125] Based on the third weight code, the target weight data corresponding to the third weight code is indexed in the initial weight data.
[0126] In a possible implementation, the preset algorithm includes: the sum of the products of the data encoding of each data in the input data that has not been processed with past zeros and the weight encoding of the corresponding weight data.
[0127] In a possible implementation, the calculation unit 217 may be specifically configured to:
[0128] Each data in the initial feature map data is determined according to the sum of the products of the second non-zero data or the third non-zero data and the corresponding target weight data.
[0129] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0130] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0131] The present application also provides a terminal device, see Figure 8 The terminal device 400 may include: at least one processor 410, a memory 420, and a computer program stored in the memory 420 and executable on the at least one processor 410. When the processor 410 executes the computer program, the steps in any of the above-mentioned method embodiments are implemented, for example Figure 2 Steps S101 to S102 in the illustrated embodiment. Alternatively, when the processor 410 executes the computer program, the functions of each module / unit in the above-mentioned device embodiments are implemented, for example Figure 7 Functionality of the neural network model 200 is shown.
[0132] Exemplarily, the computer program may be divided into one or more modules / units, one or more modules / units are stored in the memory 420, and executed by the processor 410 to complete the present application. The one or more modules / units may be a series of computer program segments capable of completing specific functions, and the program segments are used to describe the execution process of the computer program in the terminal device 400.
[0133] Those skilled in the art will understand that Figure 8 It is only an example of a terminal device and does not constitute a limitation on the terminal device. It may include more or fewer components than shown in the figure, or correspond to storing certain components, or different components, such as input and output devices, network access devices, buses, etc.
[0134] The processor 410 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0135] The memory 420 may be an internal storage unit of the terminal device, or an external storage device of the terminal device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. The memory 420 is used to store the computer program and other programs and data required by the terminal device. The memory 420 may also be used to temporarily store data that has been output or is to be output.
[0136] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0137] The image data processing method provided in the embodiment of the present application can be applied to terminal devices such as computers, tablet computers, laptop computers, netbooks, personal digital assistants (PDAs), etc. The embodiment of the present application does not impose any restrictions on the specific type of terminal devices.
[0138] Take the terminal device as a computer as an example. Fig. 9 FIG. 1 is a block diagram showing a partial structure of a computer provided in an embodiment of the present application. Fig. 9The computer includes: a communication circuit 510, a memory 520, an input unit 530, a display unit 540, an audio circuit 550, a wireless fidelity (WiFi) module 560, a processor 570, a power supply 580 and other components.
[0139] Combine the following Fig. 9 A detailed introduction to the various components of the computer:
[0140] The communication circuit 510 can be used for receiving and sending signals during the process of sending and receiving information or making calls. In particular, after receiving the image sample sent by the image acquisition device, it is sent to the processor 570 for processing; in addition, the image acquisition instruction is sent to the image acquisition device. Generally, the communication circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA), a duplexer, etc. In addition, the communication circuit 510 can also communicate with the network and other devices through wireless communication. The above-mentioned wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (Global System of Mobile communication, GSM), General Packet Radio Service (General Packet Radio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access, CDMA), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), Long Term Evolution (Long Term Evolution, LTE)), email, Short Messaging Service (SMS), etc.
[0141] The memory 520 can be used to store software programs and modules. The processor 570 executes various functional applications and data processing of the computer by running the software programs and modules stored in the memory 520. The memory 520 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the computer (such as audio data, a phone book, etc.), etc. In addition, the memory 520 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0142] The input unit 530 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the computer. Specifically, the input unit 530 may include a touch panel 531 and other input devices 532. The touch panel 531, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 531 or near the touch panel 531 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 531 may include a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 570, and can receive and execute the command sent by the processor 570. In addition, the touch panel 531 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 531, the input unit 530 may also include other input devices 532. Specifically, other input devices 532 may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, etc.
[0143] The display unit 540 can be used to display information input by the user or information provided to the user and various menus of the computer. The display unit 540 may include a display panel 541. Optionally, the display panel 541 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch panel 531 may cover the display panel 541. When the touch panel 531 detects a touch operation on or near it, it is transmitted to the processor 570 to determine the type of touch event. Subsequently, the processor 570 provides a corresponding visual output on the display panel 541 according to the type of touch event. Although in Fig. 9 In the embodiment, the touch panel 531 and the display panel 541 are used as two independent components to implement the input and output functions of the computer, but in some embodiments, the touch panel 531 and the display panel 541 can be integrated to implement the input and output functions of the computer.
[0144] The audio circuit 550 can provide an audio interface between the user and the computer. The audio circuit 550 can convert the received audio data into an electrical signal, transmit it to the speaker, and the speaker converts it into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 550 and converted into audio data, and then the audio data is output to the processor 570 for processing, and then sent to another computer through the communication circuit 510, or the audio data is output to the memory 520 for further processing.
[0145] WiFi is a short-range wireless transmission technology. Computers can help users send and receive emails, browse web pages, and access streaming media through WiFi module 560, which provides users with wireless broadband Internet access. Fig. 9 A WiFi module 560 is shown, but it is understandable that it is not an essential component of the computer and can be omitted as needed without changing the essence of the invention.
[0146] The processor 570 is the control center of the computer. It uses various interfaces and lines to connect various parts of the entire computer. It executes various functions of the computer and processes data by running or executing software programs and / or modules stored in the memory 520, and calling data stored in the memory 520, so as to monitor the computer as a whole. Optionally, the processor 570 may include one or more processing units; preferably, the processor 570 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 570.
[0147] The computer also includes a power supply 580 (such as a battery) for supplying power to various components. Preferably, the power supply 580 can be logically connected to the processor 570 through a power management system, so that the power management system can manage charging, discharging, power consumption and other functions.
[0148] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in each embodiment of the above-mentioned image data processing method can be implemented.
[0149] An embodiment of the present application provides a computer program product. When the computer program product runs on a mobile terminal, the mobile terminal can implement the steps in each embodiment of the above-mentioned image data processing method when executing the computer program product.
[0150] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium can at least include: any entity or device that can carry the computer program code to the camera / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0151] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0152] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0153] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0154] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0155] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for processing image data, It is characterized in that The method is used for a neural network model, which includes: a convolution calculation module and a data compression module; The method comprises: Inputting the input data of the convolution layer into the convolution calculation module, the convolution calculation module performs convolution calculation on the input data, and outputs the initial feature map data of the convolution layer to the data compression module, wherein the input data includes the data after the initial image data is processed by zero removal or the data after the initial feature map data of the previous convolution layer is processed by zero removal; The data compression module performs zero removal processing on the initial feature map data and outputs corresponding target feature map data; The initial feature map data includes feature data arranged in a matrix, and the feature data includes zero data and non-zero data; The data compression module performs zero removal processing on the initial feature map data and outputs corresponding target feature map data, including: Removing zero data in the initial feature map data to obtain first non-zero data in the initial feature map data; Based on the position of the first non-zero data in the initial feature map data, obtain a corresponding first data code; The first non-zero data and the first data encoding are stored correspondingly to obtain the target feature map data.
2. The image data processing method according to claim 1, It is characterized in that The convolution calculation module includes: a data storage unit, a control unit, a calculation unit and a weight storage unit, and the weight storage unit stores the initial weight data of the neural network; The step of inputting the input data of the convolution layer into the convolution calculation module, wherein the convolution calculation module performs convolution calculation on the input data and outputs the initial feature map data of the convolution layer to the data compression module comprises: The data storage unit receives and stores the input data of the convolutional layer; The control unit acquires a preset algorithm from the calculation unit, and obtains target weight data corresponding to the input data from the initial weight data based on the preset algorithm; The calculation unit determines initial feature map data of the convolutional layer based on the preset algorithm, the target weight data and the input data.
3. The image data processing method according to claim 2, It is characterized in that The input data includes: second non-zero data and second data codes corresponding to each of the second non-zero data; The control unit acquires a preset algorithm from the calculation unit, and obtains target weight data corresponding to the input data from the initial weight data based on the preset algorithm, including: Based on the corresponding position of the second data code in the preset algorithm, obtaining a second weight code corresponding to the second non-zero data calculation in the preset algorithm; Based on the second weight code, the target weight data corresponding to the second weight code is indexed in the initial weight data.
4. The image data processing method according to claim 3, It is characterized in that The input data includes: third non-zero data and third data codes corresponding to each of the third non-zero data; The control unit acquires a preset algorithm from the calculation unit, and obtains target weight data corresponding to the input data from the initial weight data based on the preset algorithm, including: Distributing the third non-zero data to corresponding positions in the preset algorithm according to the third data encoding of each third non-zero data; Determine, based on the position of the third non-zero data in the preset algorithm, a third weight code corresponding to each of the third non-zero data; Based on the third weight code, the target weight data corresponding to the third weight code is indexed in the initial weight data.
5. The image data processing method according to claim 3 or 4, It is characterized in that The preset algorithm includes: the sum of the products of the data codes of each data in the input data without past zero processing and the weight codes of the corresponding weight data.
6. The image data processing method according to claim 5, It is characterized in that The calculation unit determines the initial feature map data of the convolution layer based on the preset algorithm, the target weight data and the input data, including: Each data in the initial feature map data is determined according to the sum of the products of the second non-zero data or the third non-zero data and the corresponding target weight data.
7. An image data processing device, It is characterized in that include: The neural network model and the external controller described in any one of claims 1 to 6 above, wherein the external controller is connected to the neural network model, and the external controller transmits the input data to the neural network model.
8. A terminal device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the image data processing method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the image data processing method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Data processing method, device and system based on neural network and storage medium
CN108875924A
A method for measuring that difference between a video consecutive frame and its convolution characteristic graph
CN109389588A
Neural network model processing method, device and terminal
CN109409518A
A sparse convolutional neural network accelerator and an implementation method
CN109635944A
Accelerated quantized multiply-and-add operations
US20190294413A1
