Neural network model processing method, electronic device and readable storage medium

By merging the multi-branch processing units and fusion parameters of the neural network model on the server, the problem of slow running speed and reduced accuracy caused by insufficient hardware performance of the terminal device is solved, and efficient operation on the terminal device is achieved.

WO2024193697A1PCT designated stage expired Publication Date: 2024-09-26HUAWEI TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/083321
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-23
Filing Date
2024-03-22
Publication Date
2024-09-26

AI Technical Summary

Technical Problem

Due to the weak hardware performance of the terminal device, the neural network model deployed on the terminal device runs slowly, and adjusting the model to improve the speed will reduce the accuracy.

Method used

After training the neural network model on the server, merge the multi-branch processing units into a single-branch processing unit, and fuse multiple parameters into one fusion parameter, which is used to configure the merged processing unit to ensure that it runs on the terminal device. accuracy and speed.

Benefits of technology

By merging processing units and fusion parameters, high accuracy can be maintained on the terminal device, the running speed can be increased, and the hardware requirements can be reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024083321_26092024_PF_FP
    Figure CN2024083321_26092024_PF_FP
Patent Text Reader

Abstract

The present application relates to the technical field of artificial intelligence, and discloses a neural network model processing method, an electronic device and a readable storage medium. The method comprises: a first electronic device acquires a first neural network model to be processed, wherein the first neural network model comprises M first processing units, the M first processing units can perform parallel processing on data, and M is greater than or equal to 2; the first electronic device combines the M first processing units of the first neural network into S second processing units to obtain a second neural network, wherein S is less than M; and the first electronic device sends a second neural network model to a second electronic device. Multi-branch processing units in the trained first neural network model are adjusted and combined into single-branch processing units, so that the precision of the deployed second neural network model is ensured; moreover, the second neural network model having single-branch processing units has lower requirements on the hardware of a terminal device and runs faster after being deployed on the terminal device.
Need to check novelty before this filing date? Find Prior Art

Description

Neural network model processing method, electronic device and readable storage medium

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on March 23, 2023, with application number 202310332748.0 and application name “Processing method of neural network model, electronic device and readable storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of artificial intelligence technology, and in particular to a processing method, electronic device, and readable storage medium for a neural network model. Background Art

[0003] Currently, with the development of artificial intelligence (AI) technology in areas such as image processing and speech recognition, more and more applications based on artificial intelligence neural network models (also known as AI models) are being deployed on terminal devices. As shown in Figure 1, server 3 can train a neural network model and deploy it on terminal device 2. User 1 can use the camera application on terminal device 2 to capture an image containing multiple people (i.e., the input data is an image). Then, using an image application based on a neural network model, the target person (AI removes passersby) is segmented from the captured image and saved as another image.

[0004] The server has strong hardware performance, and usually after completing the training of the neural network model on the server, the neural network model is deployed to the electronic device on the terminal side. As shown in Figure 2, server 3 deploys the trained neural network model 100 to terminal device 2 to obtain a neural network model 100a, including: a classification loss unit 1001 and a distillation loss unit 1002. It can be seen that server 3 has not adjusted the neural network model 100a, and the structures of the two neural network models are roughly the same. Since the hardware performance of terminal device 2 is weaker than that of server 3, the speed of running the neural network model 100a on terminal device 2 will be slower. If the neural network model 100a is to be adjusted, such as reducing the processing units in the neural network model 100a, etc., the accuracy of the neural network model 100a will be reduced.

[0005] Summary of the Invention

[0006] In order to solve the above-mentioned defects, the present application proposes a processing method of a neural network model, an electronic device and a readable storage medium.

[0007] In a first aspect, the present application provides a method for processing a neural network model, comprising:

[0008] The first electronic device obtains a first neural network model to be processed. Among them, the first neural network model includes M first processing units, and the M first processing units can process data in parallel, where M is greater than or equal to 2;

[0009] The first electronic device combines the M first processing units of the first neural network into S second processing units to obtain a second neural network, where S is less than M;

[0010] The first electronic device sends the second neural network model to the second electronic device.

[0011] In this application, the first electronic device here can be a server, and the second electronic device can be a terminal device. The first neural network here can be a neural network model trained on the server. The M first processing units of the first neural network can include: N distillation loss units, K groups of convolutional units and normalization units, and T groups of convolutional units and multiple normalization units. Here, the K groups of convolutional units can be 3x3 convolutional kernels, and the T groups of convolutional units can be 1x1 convolutional kernels. The S second processing units of the second neural network model can include: at least one distillation loss unit, at least one group of convolutional units (3x3 convolutional kernels) and normalization units. Each of the M first processing units is configured with a first parameter, and each of the S second processing units is configured with a second parameter. The first electronic device can adjust the first parameter to the second parameter according to the number of the first processing unit and the second processing unit. In the case of P = M, the M first parameters of all the first processing units can be adjusted to the S second parameters; in the case of P < M, the P first parameters of some of the first processing units can be adjusted to the S second parameters.

[0012] It can be seen that before deploying the first neural network model on the terminal device, the multi-branch processing units in the trained first neural network model can be adjusted and combined into single-branch processing units, and the multiple first parameters corresponding to the multi-branch processing units can be fused and calculated. For example, the multiple parameters can be summed, averaged, weighted averaged, etc. to determine a second parameter (fusion parameter), and the merged single-branch processing unit is configured with the fusion parameter. It can be seen that the merged processing unit configured with the fusion parameter can cover the processing capabilities of the multiple processing units before merging, ensuring the accuracy of the deployed second neural network model. Compared with the first neural network model with multi-branch processing units, the second neural network model with single-branch processing units has lower hardware requirements for the terminal device and faster running speed after being deployed on the terminal device.

[0013] In a possible implementation of the foregoing first aspect, the first electronic device combines and processes the M first processing units of the first neural network into S second processing units to obtain a second neural network, including:

[0014] Obtaining first parameters of P first processing units among the M first processing units, where P is less than or equal to M;

[0015] The first parameters of the P first processing units are combined into second parameters, and the S second processing units are configured using the second parameters, where the value of S is 1.

[0016] In a possible implementation of the first aspect, the merging includes at least one of summing, averaging, or weighted averaging the first parameters.

[0017] In a possible implementation of the first aspect, the P first processing units include P data processing units, and the P data processing units are used to perform feature processing on the data to obtain a prediction result; or

[0018] The P first processing units include P distillation loss units, and the loss unit is used to determine the difference between the predicted result output by the data processing unit of the first neural network model and the actual result.

[0019] In the present application, the process of merging the first parameters of P data processing units into S second parameters may include: determining the first parameters corresponding to the P data processing units included in the first neural network model by the following formula: Conv(x)=W K (x)+b K

[0020] Among them, W K represents the weight of the data processing unit, b K represents the bias of the data processing unit, and x represents the data input to the data processing unit;

[0021] By setting x=Conv(x)=W K (x)+b K Substitute the following formula into BN(x)=γ(xu) / σ+β

[0022] Among them, γ represents accuracy, u represents mean error, σ represents variance, and β represents bias;

[0023] We get BN(Conv(x))=γ*W K (x) / σ+γ(b K -u) / σ+β

[0024] Among them, W a =γ*W K / σ represents the weight of the fused data processing unit, γ(b K -u) / σ+β represents the bias of the fused data processing unit.

[0025] This application also includes:

[0026] The second parameters corresponding to the S data processing units included in the second neural network model are determined by the following formula:

[0027] in, represents the weight of the data processing unit, Indicates the offset of the data processing unit.

[0028] In the present application, the process of merging the first parameters of P distillation loss units into S second parameters may include:

[0029] The first parameter corresponding to the P distillation loss units included in the first neural network model is determined by the following formula:

[0030] O(x)=W N (x)+b N

[0031] Among them, W N represents the weight of the distillation loss unit, b N represents the bias of the distillation loss unit, and x represents the data input to the distillation loss unit.

[0032] In the present application, the second parameter of the S distillation loss units included in the second neural network model is determined by the following formula:

[0033] in, represents the weight of the distillation loss unit, Represents the bias of the distillation loss unit.

[0034] In the present application, the number of data processing units and distillation loss units can be the same or different.

[0035] In a possible implementation of the first aspect above, the first neural network model includes a convolutional neural network model, and the data processing unit includes a convolution layer or a pooling layer.

[0036] In a possible implementation of the first aspect above, the first electronic device includes a server, and the second electronic device includes a terminal device.

[0037] In a possible implementation of the first aspect above, the terminal device includes at least one of the following: a mobile phone, a tablet computer, and a smart watch.

[0038] In a possible implementation of the first aspect above, the first neural network model or the second neural network model is used to implement at least one of the following functions: image recognition, text recognition, and speech recognition.

[0039] In a second aspect, the present application provides an electronic device for processing a neural network, comprising: a memory for storing instructions executed by one or more processors of the electronic device, and a processor, which is one of the processors of the electronic device, for executing the processing method of the neural network model of the first aspect.

[0040] In a third aspect, the present application provides a computer-readable storage medium having instructions stored thereon, which, when executed on a computer, causes the computer to execute the processing method of the neural network model of the first aspect.

[0041] In a fourth aspect, the present application provides a computer program product, comprising: a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium contains a processing method for executing the neural network model of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] FIG1 is a diagram illustrating an application scenario of an application using a neural network model according to an embodiment of the present application;

[0043] FIG2 is a schematic diagram of deploying a neural network model on a terminal device according to an embodiment of the present application;

[0044] FIG3 is a schematic diagram illustrating deploying a trained neural network model on a terminal device according to an embodiment of the present application;

[0045] FIG4 is a schematic diagram of a processing unit for adjusting and merging multiple branches of a neural network model into a single branch according to an embodiment of the present application;

[0046] FIG5 is an architecture diagram of a server for training a neural network model according to an embodiment of the present application;

[0047] FIG6 is an architecture diagram of a terminal device for deploying a neural network model according to an embodiment of the present application;

[0048] FIG7 is a flow chart of a method for processing a neural network model according to an embodiment of the present application;

[0049] FIG8 is a schematic diagram of a multi-branch structure formed by convolution units and normalization units in a data processing layer of a neural network model according to an embodiment of the present application;

[0050] FIG9 is a schematic diagram of a multi-branch structure formed by a distillation loss unit in a loss layer of a neural network model shown in an embodiment of the present application;

[0051] FIG10 is a schematic diagram of a scenario in which a user uses a terminal device to capture an image of a person, as shown in an embodiment of the present application;

[0052] FIG11 is a schematic diagram of a data processing layer in a neural network model according to an embodiment of the present application;

[0053] FIG12 is a schematic diagram of a data processing layer in a neural network model according to an embodiment of the present application;

[0054] Figure 13 is a schematic diagram of the convolution unit and attention unit processing data shown in an embodiment of the present application. DETAILED DESCRIPTION

[0055] In order to make the objectives, embodiments and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0056] In order to solve the problem that the accuracy of the neural network model deployed on the terminal device is reduced after reducing the processing units in the neural network model trained on the server. The embodiment of the present application proposes a processing method for a neural network model. During the model training process, a multi-branch processing unit is configured for the neural network model on the server, the neural network model is trained using input data (training data), and the parameters of each processing unit in the neural network model are determined. The parameters can represent the processing capacity of the processing unit. Before the neural network model is deployed on the terminal device, the multi-branch processing units in the trained neural network model can be adjusted and merged into a single-branch processing unit. In some embodiments, multiple parameters corresponding to the multi-branch processing units can also be fused and calculated, for example, by summing, averaging, weighted averaging, etc. of the multiple parameters to determine a fusion parameter, and using the fusion parameter to configure the merged single-branch processing unit. It can be seen that the merged processing unit configured with the fusion parameter can cover the processing capacity of the multiple processing units before the merger, thereby ensuring the accuracy of the neural network model after deployment. Compared with the multi-branch processing unit, the neural network model with a single-branch processing unit has lower requirements on the hardware of the terminal device and runs faster after being deployed on the terminal device.

[0057] In some embodiments, Figure 3 is a schematic diagram of a neural network model 100c obtained by deploying the trained neural network model 100b on the terminal device 2 shown in an embodiment of the present application. In the embodiment shown in Figure 3, the neural network model 100b may include a classification loss 1001b and N distillation loss units 1002b, where N can be a natural number greater than 1, for example, the value of N can be 4.

[0058] Backbone network 101b is used to extract features from input data. For example, for image data, backbone network 101b can convert the image data into feature vectors as prediction results. Feature vectors are used to represent various information included in the image data, such as people, vehicles, animals, etc. The backbone network can also be called an encoder network.

[0059] Classification loss unit 1001b is used to evaluate the performance of neural network model 100b in classifying input data. Classification loss can be calculated by comparing the difference between the neural network model's predictions and the actual results. Classification loss can be implemented using classification loss functions, including cross-entropy loss and squared loss. For example, a digit recognition application configured with a neural network model needs to classify handwritten digits. The output of the neural network model is a vector containing 10 elements, each element representing the probability distribution of the digits 0-9. For example, if the handwritten digit is 2 and its corresponding actual result is [0, 0, 1, 0, 0, 0, 0, 0, 0], if the model's prediction result is [0.05, 0.1, 0.9, 0.01, 0.02, 0.02, 0.01, 0.01, 0.01, 0.01], the difference between the actual result and the predicted result is the classification loss.

[0060] Distillation loss unit 1002b is used to represent the generalization performance of neural network model 100b. Generalization performance here refers to the ability of neural network model 100b to adapt to new samples. In other words, neural network model 100b can also provide correct prediction results for new data that does not have the same input data pattern. For example, consider a digit recognition application configured with a neural network model that needs to classify handwritten digits. The output of the neural network model is a vector containing 10 elements, each element representing the probability distribution of the digits 0-9. For example, if the handwritten digit is 1, the corresponding actual result is [0, 0.7, 0, 0, 0, 0, 0.2, 0, 0.1], indicating that there is a 0.7 probability of digit 1, a 0.2 probability of digit 7, and a 0.1 probability of digit 9. If the model's prediction result is [0.05, 0.9, 0.1, 0.01, 0.02, 0.02, 0.01, 0.01, 0.01], the difference between the actual result and the predicted result is the distillation loss. It can be seen that compared with the classification loss unit, the distribution of actual results corresponding to the distillation loss unit is wider, and changing the number of distillation loss units in the loss layer 103 can change the generalization performance of the neural network model 100.

[0061] Continuing to refer to Figure 3, before the trained neural network model is deployed on the terminal device, the neural network model 100b can be adjusted to the neural network model 100c, wherein the neural network model 100c can output the prediction result of a single-branch distillation loss unit (not shown), wherein the parameters of the distillation loss unit are the fusion parameters corresponding to the parameters of the N distillation loss units 1002b of the neural network model 100b.

[0062] In some embodiments, Figure 4 shows a schematic diagram of a processing unit that can adjust and merge multiple branches into a single branch. In the embodiment shown in Figure 4, the processing unit of the neural network model during the model training process may include K groups of convolution units 1021b and multiple normalization units 1022b, where K can be a natural number greater than 1. For example, the value of K can be 6.

[0063] The convolution unit 1021b is used to extract features from the input data to obtain feature data (feature vector). For example, when the convolution unit 1021b is a 3x3 convolution kernel, the convolution unit 1021b can extract local features of size 3x3 from the input data.

[0064] The normalization unit 1022b can be called batch normalization (BN), which is used to reduce the data offset problem between each unit (node) in the neural network model, making the output of the neural network model more stable.

[0065] The neural network model may also include a single-branch linear unit 1023b for transforming the dimension of the feature data (feature vector) as a prediction result. The linear unit 1023b may include multiple 1x1 convolution kernel subunits and activation function subunits. The 1x1 convolution kernel subunits are used to transform the feature data into multiple vectors to reduce the dimension of the feature data and improve processing efficiency. The activation function subunit, namely the Rectified Linear Activation Function (ReLU), is used to linearly transform the feature data, for example, to clip the negative part of the feature data to 0 and keep the positive part unchanged.

[0066] In some embodiments, T groups of convolution units 1024b and multiple normalization units 1025b are added to the multi-branch structure formed by K groups of convolution units 1021b and multiple normalization units 1022b. Here, T can be a natural number greater than or equal to 1, for example, the value of T can be 1. The convolution unit 1024b here can be a 1x1 convolution kernel, which is used to transform feature data into multiple vectors to reduce the dimension of the feature data and improve processing efficiency. Continuing to refer to FIG4, before the trained neural network model is deployed on the terminal device, the K groups of convolution units 1021b and multiple normalization units 1022b and the T groups of convolution units 1024b and multiple normalization units 1025b can be adjusted and merged into a single-branch convolution unit 1021c and normalization unit 1022c. The parameters of the convolution unit 1021c are the fusion parameters corresponding to the parameters of the K groups of convolution units 1021b and multiple normalization units 1022b. The linear unit 1023c here can be the same as the linear unit 1023b. The specific process of determining the fusion calculation of the fusion parameters will be described in detail in the interactive process of the processing method of the neural network model shown in FIG8.

[0067] FIG5 is an architecture diagram of a server 3 for training a neural network model according to an embodiment of the present application. The server 3 may include a processor 500, an internal memory 510, a power management module 520, and a communication module 530. The server 3 may include an application server, a cloud server, and the like.

[0068] The processor 500 may include one or more processing units, for example, the processor 500 may include a central processing unit (CPU). The processor 500 is used to train the neural network model stored in the internal memory 510 and adjust the neural network model before deploying it on the terminal device. For example, it can be used to adjust and merge the multi-branch processing units in the trained neural network model into a single-branch processing unit to obtain a target neural network model.

[0069] The internal memory 50 can be used to store computer executable program code, which includes instructions. The internal memory 510 can include a program storage area and a data storage area. The program storage area can store a neural network model and training data.

[0070] The power management module 520 is used to supply power to the processor 500 and the internal memory 510 .

[0071] The communication module 530 is used to communicate with at least one terminal device and send the adjusted neural network model to the terminal device.

[0072] FIG6 is an architecture diagram of a terminal device 2 for deploying a neural network model, as shown in an embodiment of the present application. The terminal device 2 herein may include a mobile phone, a tablet computer, a wearable device, an in-vehicle device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), or other device with a display screen. The embodiment of the present application does not impose any restrictions on the specific type of the terminal device.

[0073] The terminal device 2 may include a processor 600, an external memory interface 620, an internal memory 621, a universal serial bus (USB) interface 630, a charging management module 640, a power management module 641, a battery 642, an antenna 1, an antenna 2, a mobile communication module 650, a wireless communication module 660, an audio module 670, a speaker 670A, a receiver 670B, a microphone 670C, an earphone interface 670D, a sensor module 680, a button 690, a motor 691, an indicator 692, a camera 693, a display screen 694, and a subscriber identification module (SIM) card interface 695, etc. The sensor module 680 may include a pressure sensor 680A, a gyroscope sensor 680B, an air pressure sensor 680C, a magnetic sensor 680D, an acceleration sensor 680E, a distance sensor 680F, a proximity light sensor 680G, a fingerprint sensor 680H, a temperature sensor 680J, a touch sensor 680K, an ambient light sensor 680L, a bone conduction sensor 680M, etc.

[0074] It is understood that the structures illustrated in the embodiments of the present application do not constitute specific limitations on the terminal device. In other embodiments of the present application, the terminal device may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0075] The processor 600 may include one or more processing units, for example: the processor 600 may include a central processing unit (CPU), a microprocessor (MCU), an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc.

[0076] The processor can generate operation control signals based on instruction opcodes and timing signals to complete the control of instruction fetching and execution.

[0077] The processor 600 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 600 is a cache memory. The memory may store instructions or data that the processor 600 has just used or is cyclically using.

[0078] The wireless communication function of the terminal device can be implemented through antenna 1, antenna 2, mobile communication module 650, wireless communication module 660, modem processor and baseband processor.

[0079] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the terminal device can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.

[0080] The mobile communication module 650 can provide wireless communication solutions including 2G / 3G / 4G / 5G applied to the terminal device. In some embodiments, at least some functional modules of the mobile communication module 650 can be set in the same device as at least some modules of the processor 600.

[0081] In some embodiments, antenna 1 of the terminal device is coupled to mobile communication module 650, and antenna 2 is coupled to wireless communication module 660, so that the terminal device can communicate with the network and other devices through wireless communication technology.

[0082] The external memory interface 620 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the terminal device. The external memory card communicates with the processor 600 through the external memory interface 620 to implement data storage functions. For example, files such as music and videos can be stored on the external memory card.

[0083] The internal memory 621 can be used to store computer executable program code, which includes instructions. The internal memory 621 may include a program storage area and a data storage area. The processor 600 executes various functional applications and data processing of the terminal device by running the instructions stored in the internal memory 621 and / or the instructions stored in the memory provided in the processor. In some embodiments, the internal memory 621 can store a neural network model.

[0084] The SIM card interface 795 is used to connect a SIM card.

[0085] Each method implementation method of the present application can be implemented in software, magnetic components, firmware, etc.

[0086] Program code can be applied to input instructions to perform the functions described herein and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.

[0087] Program code can be implemented with a high-level programming language or an object-oriented programming language to communicate with the processing system. Where necessary, program code can also be implemented with assembly language or machine language. In fact, the mechanism described herein is not limited to the scope of any particular programming language. In either case, the language can be a compiled language or an interpreted language.

[0088] One or more aspects of at least one embodiment may be implemented by representative instructions stored on a computer-readable storage medium. The instructions represent various logic within a processor, and when read by a machine, the instructions cause the machine to fabricate logic for executing the technical solutions described herein. These representations, known as "IP cores," may be stored on a tangible computer-readable storage medium and supplied to multiple customers or manufacturing facilities to be loaded into manufacturing machines that actually manufacture the logic or processor.

[0089] The processing method provided by the embodiment of the present application is described in detail below based on the schematic diagram shown in Figure 7. The method shown in Figure 7 can be implemented by the processors of the server 3 and the terminal device 2 executing relevant instructions.

[0090] Referring to FIG7 , the processing method may include the following steps:

[0091] S701: Server 3 obtains input data.

[0092] For example, the input data here can be training data for training a neural network model. In some embodiments, assuming that the neural network model is used for the smart cursor cutout function of an image application on terminal device 2, the input data can be foreground image data and background image data of an image of unknown category with a label, denoted as Dataset I. To prepare Dataset I, a set of samples containing foreground and background images can be prepared in advance and divided into two parts, for example: a foreground dataset and a background dataset.

[0093] In some embodiments, the dataset I here can be implemented by manually segmenting or using computer vision technology to process existing images (including images in public datasets or datasets in specific fields). The public dataset here can be ImageNet1k, which can contain 1,000 categories, more than 1 million images, and 50,000 test images. Once the segmentation is completed, each image needs to be assigned a label indicating whether the image is foreground or background. When preparing dataset I, the following factors can also be considered:

[0094] Amount of data: The dataset should contain enough samples so that the neural network model can learn enough features to improve the classification accuracy.

[0095] Data quality: The images in the dataset can be high-quality (high-resolution) images with good clarity and contrast, so that the images can be accurately segmented into foreground and background.

[0096] Data diversity: The images in the dataset should cover different types of foregrounds and backgrounds, so that the neural network model can learn different types of samples and improve the generalization performance of the neural network model.

[0097] S702: Server 3 configures a first preset number of multi-branch convolution units and normalization units for the neural network model.

[0098] For example, server 3 may configure a convolution unit and a normalization unit for the data processing layer of the neural network model according to a first preset number. The convolution unit may be used to extract image features. The normalization unit may be a regularization technique that can be used to prevent overfitting of the output results of the convolution unit. By configuring the normalization unit for the convolution unit, the output results of each convolution unit can be standardized, thereby accelerating the training of the neural network model and improving the generalization performance of the neural network.

[0099] In some embodiments, the first preset number here can be represented by K, and K can be a natural number greater than 1. For example, K can be 6. At this time, 6 groups of convolution units and normalization units can form a multi-branch architecture, that is, multiple parallel convolution units are added to the neural network model so that different features can be extracted from the input data at the same time. It can be understood that the 6 here is exemplary, and other values ​​can also be used in the embodiments of the present application, without limitation. As the value of K is different, the number of branches formed by the convolution units and normalization units in the neural network model is also different.

[0100] Reference is made below to FIG8 , which shows a multi-branch structure formed by convolution units and normalization units in a data processing layer of a neural network model according to an embodiment of the present application.

[0101] As shown in FIG8 , when the value of K is 6, the neural network model may include six branches consisting of convolution units and normalization units, namely, branches 1 to 6, receiving input data 1 and input data 2. The convolution units and normalization units in each branch may include respective parameters.

[0102] For example, a convolution unit can be obtained by formula (1): Conv(x) = W K (x)+b K Indicates, where x represents the input data, for example: feature vector, W K represents the weight, b K Represents bias. The weight here is used to indicate the possibility that the input data belongs to a certain category. The bias is a constant used to adjust W K (x) to prevent the value from being too large or too small, that is, exceeding the normal value range.

[0103] For example, a normalization unit can be obtained by formula (2): BN(x) = γ K (xu K ) / σ K +β K Indicates that, where x represents the input data, γ K Indicates precision, u K represents the mean difference, σ K represents the variance, β K The output of the convolution unit can be limited to a certain range, for example, [0, 1], that is, between 0 and 1.

[0104] Continuing with Figure 8 , the convolution unit in branches 1 through 6 can be a 3x3 convolution kernel. In some embodiments, a parallel branch 0 can be provided for branches 1 through 6. Branch 0 can also consist of a convolution unit and a normalization unit. The convolution unit in branch 0 can be a 1x1 convolution kernel. The 1x1 convolution kernel can be used in conjunction with the 3x3 convolution kernel to simultaneously process the input data, transforming the input data into multiple vectors to reduce the dimensionality of the input data and improve processing efficiency.

[0105] S703: Server 3 configures a second preset number of multi-branch distillation loss units corresponding to the neural network model.

[0106] Exemplarily, the server 3 may configure a distillation loss unit for the loss layer of the neural network model according to a second preset number.

[0107] In some embodiments, the second preset number here can be represented by N, which can be a natural number greater than 1. For example, N can be 4. In this case, 4 groups of distillation loss units can form a multi-branch architecture, that is, multiple parallel distillation loss units are added to the neural network model so that the predicted results of the neural network model can be compared with the actual results at the same time to obtain the difference. It can be understood that the 4 here is exemplary, and other values ​​can also be used in the embodiments of the present application, and this is not limited. As the value of N is different, the number of branches formed by the distillation loss unit in the neural network model is also different.

[0108] Reference is made below to FIG9 , which shows a multi-branch structure formed by a distillation loss unit in a loss layer of a neural network model shown in an embodiment of the present application.

[0109] As shown in FIG9 , when the value of N is 4, the neural network model may include four branches consisting of distillation loss units, namely, branches 1 to 4, which receive prediction result 1 and prediction result 2 as input data. The distillation loss unit in each branch may include its own parameters. For example, a distillation loss unit may be calculated by formula (1): O(x) = W N (x)+b N Indicates, where x represents the input data, for example: feature vector, W N Represents the weight, denoted as W b , b N Indicates the bias, denoted as b b .

[0110] Continuing to refer to FIG10 , a parallel branch 0 may be further provided for branches 1 to 4 , and branch 0 may be composed of a classification loss unit.

[0111] S704: Server 3 uses the input data to train the neural network model.

[0112] Exemplarily, after the server 3 completes the configuration of the neural network model, the neural network model is trained using data set I, the output result obtained is compared with the actual result (true result) corresponding to the label, the loss (difference) is calculated, and the model parameters of the neural network model are reversely updated using the obtained loss. This step is repeated until the preset number of training times is reached.

[0113] In some embodiments, during the training process, using dataset 1 including foreground image data and background image data as an example, the image data in dataset 1 is used as input to obtain output results. The difference (loss) between each output result and the actual result corresponding to the label is calculated, and the model parameters of the neural network model are updated using a backpropagation algorithm to minimize the loss. Server 3 may repeat this process until a preset number of training times is reached or the loss reaches a preset value.

[0114] In some embodiments, after server 3 completes training a neural network model, it can be saved for future use. Server 3 can achieve this by saving the structure and model parameters of the neural network model to a file so that it can be reloaded when the neural network model is needed. When saving the neural network model, server 3 can also save some metadata (such as the network architecture, model parameters, etc.).

[0115] S705: Server 3 adjusts the distillation loss unit, convolution unit, and normalization unit of the trained neural network model into a single-branch target convolution unit and target distillation loss unit to obtain a target neural network model.

[0116] Exemplarily, server 3 can adjust the multi-branch distillation loss unit, convolution unit and normalization unit in the trained neural network model to a single branch, that is, a single-branch target distillation loss unit is configured in the loss layer of the adjusted target neural network model, and a single-branch target convolution unit is configured in the data processing layer.

[0117] S706: The server 3 re-parameterizes the parameters of the multi-branch convolution units and normalization units corresponding to the first preset number into first fusion parameters.

[0118] Exemplarily, taking the value of the first preset number K as 6 as an example, the parameter reparameterization here can be to fuse the parameters of the convolution units and normalization units in the seven branches in the data processing layer of the neural network model (including the convolution units and normalization units in branch 0) into one parameter, that is, the first fusion parameter, and use the first fusion parameter to configure the target convolution unit of the data processing layer of the target neural network model.

[0119] In some embodiments, taking branch 1 shown in FIG8 as an example, the convolution unit is implemented by Conv(x)=W K (x)+b K The normalization unit is represented by the formula BN(x)=γ(xu) / σ+β, and the convolution unit and the normalization unit in each branch are fused. Since the normalization unit is used to process the output of the convolution unit, Conv(x)=W K (x)+b K Substituting the input x into the normalization unit, we get BN(Conv(x))=γ(W K (x)+b K -u) / σ+β, and after sorting, we get formula (3) BN(Conv(x))=γ*W K (x) / σ+γ(b K -u) / σ+β. It can be seen that formula (3) is equivalent to the formula of a convolution unit, where γ*W K / σ represents weight, denoted as W a ,γ(b K -u) / σ+β represents the bias, denoted as b a .

[0120] In some embodiments, for branch 0 in FIG9 , the convolution unit and the normalization unit in branch 0 also need to be fused. The 1x1 convolution kernel here needs to be converted into a convolution kernel, and the convolution kernel needs to be padded with 0s around it so that the original 1x1 convolution kernel is in the center of the 3x3 convolution kernel. The parameters of the convolution units and normalization units of the seven branches are obtained in sequence, and the parameters are summed up to obtain the first fusion parameters for configuring the target convolution unit. For example, the first fusion parameter may include and in, That is, the parameters of the fused multi-branch convolutional unit and normalization unit are summed.

[0121] S707: The server 3 re-parameterizes the parameters of the multi-branch distillation loss units corresponding to the second preset number into second fusion parameters.

[0122] Exemplarily, taking the value of the second preset number N as 4 as an example, the parameter reparameterization here can be to fuse the parameters of the distillation loss units in the four branches in the loss layer of the neural network model (excluding the classification loss unit in branch 0) into one parameter, that is, the second fusion parameter, and use the first fusion parameter to configure the target distillation loss unit of the data processing layer of the target neural network model.

[0123] In some embodiments, taking branch 1 shown in FIG9 as an example, the distillation loss unit is O(x)=WN (x)+b N Indicates that the parameters of the distillation loss units of the four branches are obtained in turn, and the parameters are summed up to obtain the second fusion parameters for configuring the target convolution unit. For example: the second fusion parameters may include and in, Where i = 1, 2, 3..N means to average the parameters of the fused multi-branch convolutional unit and normalization unit.

[0124] S708: Server 3 uses the first fusion parameter and the second fusion parameter to configure the target convolution unit and the target distillation loss unit of the target neural network model.

[0125] For example, the target convolution unit of the target neural network model can be obtained by formula (4), Indicates that, Represents weight and Denotes the bias. The target distillation loss unit of the target neural network model can be obtained by formula (5) Indicates that, Represents weight and Indicates bias.

[0126] S709: Server 3 sends the adjusted target neural network model to terminal device 2.

[0127] Exemplarily, the server 3 can send the adjusted target neural network model to the terminal device 2. Taking the target neural network model as an example of the smart cursor cutout function of the image application of the terminal device 2, the terminal device 2 can use the target neural network model to configure the image application to improve the efficiency of the image application in cutout.

[0128] In some embodiments, after the target neural network model is deployed on the terminal device 2, the user can use an application based on the target neural network model. Figure 10 shows an embodiment of the present application, in which a user uses a terminal device to capture an image of a person, selects the person in the image, and the terminal device's image application cuts out the person.

[0129] As shown in FIG10 , the terminal device 2 can first acquire an image. Here, the image 1001 can be an image captured by the user through the camera of the terminal device 2 or an image selected from the local album of the terminal device 2. The image application of the terminal device 2 can open the image 1001. In some embodiments, the image application of the terminal device 2 can also perform RGB domain normalization processing on the image 1001. The user can perform a frame operation on the image 1001 and select a region of interest 1002 on the image 1001. After the terminal device 2 receives the user's operation, the image application based on the neural network model can perform saliency segmentation on the region of interest 1002. That is, the image application can use the pre-trained and adjusted neural network model to identify the region of interest 1002 on the image 1001 to obtain a salient target. That is, the person 1003 is segmented from the region of interest 1002 and saved as image 1004. In some embodiments, because the neural network model used in the image can already distinguish between person 1003 and the background or foreground in region of interest 1002, the resulting image 1004 may contain only person 1003 without the background or foreground in image 1001. The user can copy image 1004 to a PPT or Word document for display and application.

[0130] In some embodiments, the target neural network model can also be applied to applications that support speech recognition or text recognition.

[0131] The above FIG7 describes the first preset number K and the second preset number N used by the server to configure the neural network model. The values ​​of K and N here can be determined by performing an ablation experiment on the neural network model during the training process of the neural network model. The ablation experiment can be used to determine the best results for the values ​​of K and N. The value of K can be fixed first, and the value of N can be adjusted to optimize the performance parameters of the neural network model, thereby obtaining the best result for the value of N. Then, based on the best result of the value of N, N is fixed, and the value of K is adjusted to optimize the performance parameters of the neural network model, thereby obtaining the best result for the value of K. Table 1 shows the correspondence between the values ​​of K and N determined by ablation experiments and the performance parameters of the neural network model in an embodiment of the present application. It can be seen that the model name can represent the name of the neural network model, and "Model 1" here represents the neural network model being trained by the server. The first preset number K and the second preset number N here respectively represent the number of branches consisting of convolution units and normalization units of the neural network model being trained and the number of branches consisting of distillation loss units. The performance parameters can represent the accuracy of the neural network model. Referring to Table 1, during the server training of the neural network model, the values ​​of K and N are continuously adjusted. When K=6 and N=4, the performance parameters of the neural network model reach the optimal level.

[0132] Table 1

[0133] The values ​​in Table 1 above are all exemplary. In some embodiments, the values ​​in Table 1 can also take any other values, which is not limited in the embodiments of the present application.

[0134] FIG11 is a schematic diagram of a data processing layer in a neural network model 100 shown in an embodiment of the present application. In the embodiment shown in FIG11 , the data processing layer may include a convolution unit 1121, a normalization unit 1122, and a linear unit 1123, wherein the convolution unit 1121 is used to extract features from the input data to obtain feature data (feature vectors). The normalization unit 1122 here can be called batch normalization (BN). It is used to reduce the data offset problem between the various units (nodes) in the neural network model and make the output of the neural network model more stable.

[0135] The activation function subunit in the linear unit 1123, i.e., the Rectified Linear Activation Function (ReLU), is used to perform a linear transformation on the feature data, for example, clipping the negative part of the feature data to 0 and keeping the positive part unchanged.

[0136] Compared to Figure 11, Figure 12 is a schematic diagram of a data processing layer in a neural network model 100 shown in an embodiment of the present application. In the embodiment shown in Figure 12, the data processing layer may include a self-attention unit 1221, a layer normalization unit 1222, and a linear unit 1223. Among them, the self-attention unit 1221 is a module for calculating feature data at each position in the input data. It is commonly used in the field of language processing and can determine the relationship between words at different positions in the input sentence. Compared with the convolution unit 1121, the self-attention unit 1221 has a larger number of parameters and a slower data processing speed.

[0137] Layer normalization unit 1222 can be called layer normalization (LN), and can also be used to reduce the data offset problem between each unit (node) in the neural network model, making the output of the neural network model more stable. However, the data processing speed of layer normalization unit 1222 is slower than batch normalization (BN). The activation function subunit in linear unit 1223, namely, Gaussian error linear unit (Gauss linear activation function, GeLU), also has a slower data processing speed than ReLU.

[0138] Figure 13 is a schematic diagram of a data processing scenario using a convolution unit and a self-attention unit, as shown in an embodiment of the present application. In the embodiment shown in Figure 13, the self-attention unit can be used to determine the local positional relationships of various objects included in an image 1301 and capture local representations 1302 corresponding to the local positions. The convolution unit 1303 is used to directly capture the local representations from the input data 1304 to obtain the output results.

[0139] Although the description of this application will be introduced in conjunction with the preferred embodiment, this does not mean that the features of this application are limited to this embodiment. On the contrary, the purpose of introducing the invention in conjunction with the embodiment is to cover other options or modifications that may be extended based on the claims of this application. In order to provide a deep understanding of this application, the following description will contain many exemplary details. This application can also be implemented without using these details. In addition, in order to avoid confusion or blurring the focus of this application, some specific details will be omitted in the description. It should be noted that the embodiments in this application and the features in the embodiments can be combined with each other unless there is a conflict.

[0140] Furthermore, various operations will be described as multiple discrete operations in a manner that is most helpful in understanding the illustrative embodiments; however, the order of description should not be construed as implying that these operations are necessarily order dependent. In particular, these operations do not need to be performed in the order presented.

[0141] As used herein, the term "module" or "unit" may refer to, be or include: an application specific integrated circuit (ASIC), an electronic circuit, a (shared, dedicated or group) processor and / or memory that executes one or more software or firmware programs, a combinational logic circuit and / or other suitable components that provide the described functionality.

[0142] In the accompanying drawings, some structural or method features are shown in a specific arrangement and / or order. However, it should be understood that such specific arrangement and / or order may not be required. In some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of structural or method features in a particular figure does not imply that such features are required in all embodiments, and in some embodiments, these features may not be included or may be combined with other features.

[0143] The various embodiments of the mechanisms disclosed in this application can be implemented in hardware, software, firmware, or a combination of these implementation methods. The embodiments of the present application can be implemented as a computer program or program code executed on a programmable system that includes multiple processors, a storage system (including volatile and non-volatile memory and / or storage elements), multiple input devices, and multiple output devices.

[0144] Such computer-readable storage media may include, but are not limited to, non-transitory tangible arrangements of articles manufactured or formed by a machine or apparatus, including storage media such as: a hard disk, any other type of disk, including a floppy disk, an optical disk, a compact disk read-only memory (CD-ROM), a compact disk rewritable (CD-RW), and a magneto-optical disk; semiconductor devices, such as read-only memory (ROM), random access memory (RAM) such as dynamic random access memory (DRAM) and static random access memory (SRAM), erasable programmable read-only memory (EPROM), flash memory, electrically erasable programmable read-only memory (EEPROM); phase change memory (PCM); a magnetic card or an optical card; or any other type of medium suitable for storing electronic instructions.

[0145] Therefore, embodiments of the present application also include non-transitory computer-readable storage media containing instructions or containing design data, such as hardware description language (HDL), which defines the structures, circuits, devices, processors and / or system features described in this application.

Claims

1. A processing method for a neural network model, It is characterized in that include: The first electronic device obtains a first neural network model to be processed, wherein the first neural network model includes M first processing units, the M first processing units are capable of processing data in parallel, and M is greater than or equal to 2; The first electronic device combines the M first processing units of the first neural network into S second processing units to obtain a second neural network, where S is less than M; The first electronic device sends the second neural network model to a second electronic device.

2. The method according to claim 1, It is characterized in that The first electronic device combines the M first processing units of the first neural network into S second processing units to obtain a second neural network, including: Obtaining first parameters of P first processing units among the M first processing units, where P is less than or equal to M; The first parameters of the P first processing units are combined into second parameters, and the S second processing units are configured using the second parameters, where the value of S is 1.

3. The method according to claim 2, It is characterized in that The merging includes at least one of summing, averaging or weighted averaging the first parameters.

4. The method according to claim 2, It is characterized in that The P first processing units include P data processing units, and the P data processing units are used to perform feature processing on the data to obtain a prediction result; or The P first processing units include P distillation loss units, and the loss units are used to determine the difference between the predicted results output by the data processing unit of the first neural network model and the actual results.

5. The method according to claim 1, It is characterized in that The first neural network model includes a convolutional neural network model, and the data processing unit includes a convolutional layer or a pooling layer.

6. The method according to claim 1, It is characterized in that The first electronic device includes a server, and the second electronic device includes a terminal device.

7. The method according to claim 6, It is characterized in that The terminal device includes at least one of the following: a mobile phone, a tablet computer and a smart watch.

8. The method according to claim 1, It is characterized in that The first neural network model or the second neural network model is used to implement at least one of the following functions: image recognition, text recognition and speech recognition.

9. An electronic device for processing a neural network, It is characterized in that include: one or more processors; One or more memories; the one or more memories store one or more programs, and when the one or more programs are executed by the one or more processors, the electronic device executes the processing method of the neural network model described in any one of claims 9 to 11.

10. A computer-readable storage medium, It is characterized in that The storage medium stores instructions, which, when executed on a computer, cause the computer to execute the method for processing a neural network model according to any one of claims 1 to 11.

11. A computer program product, It is characterized in that It includes a computer program / instruction, which, when executed by a processor, implements the processing method of the neural network model described in any one of claims 1 to 11.

Citation Information

Patent Citations

  • Neural network model processing method, electronic equipment and readable storage medium

    CN116451742A

  • Training method of convolutional neural network, and image processing method and apparatus

    CN108304921A

  • Neural network segmentation calculation method and device, storage medium and mobile terminal

    CN110298437A

  • Neural network generation method and device, data processing method and device, electronic equipment and medium

    CN114492754A