A data processing method and apparatus
By minimizing the information difference between the student neural network and the teacher neural network, the accuracy of the compressed visual detection model is improved, solving the problem of model accuracy degradation on resource-limited platforms and achieving efficient target detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2023-05-29
- Publication Date
- 2026-05-26
AI Technical Summary
Existing transformer-based object detectors suffer from large parameter counts and high computational costs when deployed on resource-constrained platforms, leading to decreased model accuracy, especially with a sharp performance drop when quantized to ultra-low bits.
By obtaining the first query from the student neural network and the second query from the teacher neural network, the student model is updated using the methods of maximizing information entropy and minimizing conditional entropy to reduce the information difference between the student and teacher models and improve the accuracy of the compressed model.
It improves the accuracy of the compressed visual inspection model, reduces computation and storage requirements, and is suitable for deployment on resource-constrained platforms.
Smart Images

Figure CN116861968B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence, and more particularly to a data processing method and apparatus thereof. Background Technology
[0002] Object detection aims to locate and classify visual objects from input images. Early work typically employed convolutional neural networks to process region features of the input image. More recently, transformer-based object detectors have been proposed, where object detection is treated as an ensemble prediction task and can be trained end-to-end. These greatly simplify the object detection task, eliminating the need for tedious adjustments to manually designed components, such as anchor size and scale. While object detectors possess impressive capabilities, they often involve a large number of parameters and floating-point operations (FLOPs). For example, in the ResNet-50-based object detector (DETR-R50), 39.8M parameters consumed 159MB of memory and 86GFLOPs of computation. The significant memory and computational demands during inference limit the deployment of these models on resource-constrained platforms.
[0003] To achieve efficient online inference, numerous works have attempted to compress and accelerate neural networks, including compact network design, network pruning, low-order decomposition, quantization, and knowledge distillation. Quantization and pruning are particularly suitable for deployment on AI chips, reducing the number of network parameters and activation values, thus enabling efficient inference. However, the parameters of the model change significantly before and after compression, leading to a decrease in model accuracy. Performance degrades drastically, especially when quantized to very low bits (4 bits or lower). Summary of the Invention
[0004] This application provides a data processing method that can improve the model accuracy of compressed visual inspection models.
[0005] In a first aspect, this application provides a data processing method, the method comprising: obtaining a first query corresponding to a first neural network and a second query corresponding to a second neural network; the first query being a query obtained by maximizing the information entropy of the query corresponding to the first neural network; the first neural network being a model obtained by compressing the second neural network; the first neural network and the second neural network being used for target detection; determining a first loss based on the first query and the second query; the first loss indicating minimizing the information difference between the second query and the first query; and updating the first neural network and the first query based on the first loss.
[0006] This application improves the accuracy of the compressed model by minimizing the information gap between the student model and the teacher model's query.
[0007] For example, the first neural network can be a model obtained by quantizing the second neural network, or it can be a smaller and faster network obtained by pruning, redesigning, etc.
[0008] In one possible implementation, the first neural network is obtained by quantizing the second neural network with 2, 3, or 4 bits.
[0009] In one possible implementation, the method further includes: performing target detection on the target image based on the first query and the first neural network to obtain information of M first detection boxes; obtaining the ground truth value of the detection result corresponding to the target image, the ground truth value of the detection result including multiple second detection boxes; determining M1 first detection boxes from the M first detection boxes based on the positional relationship between the first detection boxes and the second detection boxes, each of the M1 first detection boxes corresponding to a second detection box, and the positional relationship between each of the M1 first detection boxes and the corresponding second detection box satisfies a first preset condition, the first preset condition being related to the overlap between the regions where the detection boxes are located; the first query is the query corresponding to the M1 first detection boxes.
[0010] In one possible implementation, the method further includes: performing target detection on the target image based on the second query and the second neural network to obtain information on N third detection boxes; determining M1 third detection boxes from the N third detection boxes based on the positional relationship between each first detection box and the third detection box in the M1 first detection boxes, wherein each first detection box in the M1 first detection boxes corresponds to a second detection box, and the positional relationship between each first detection box in the M1 first detection boxes and the corresponding third detection box satisfies a second preset condition, the second preset condition being related to the overlap between the regions where the detection boxes are located; and the second query being the query corresponding to the M1 third detection boxes.
[0011] Minimizing conditional entropy requires a one-to-one match between the detection results of the student model and the teacher model, meaning that each detection box output by the student model needs to be mapped one-to-one with the detection box output by the teacher model. To determine the correspondence between the detection results of the student model and the teacher model, we can first determine the correspondence between the student model's detection results and the ground truth values of the image detection results.
[0012] Due to the discreteness of algorithm matching and the randomness of model training, ground-truth matching (i.e., matching the student model's output with the ground-truth of the image detection results) becomes a dynamic and unstable process. For example, the ground-truth of the image detection results may include 5 detection boxes, while the student model's detection results may include 8 detection boxes. This application proposes a foreground-aware query matching method to address this problem. Specifically, the ground-truth of the image detection results is matched with the detection results output by the student model. Detection boxes that match the ground-truth of the image detection results (e.g., detection boxes whose positional relationships meet preset conditions) are determined from the student model's output detection results. A one-to-one correspondence is established between the determined detection boxes and the ground-truth of the image detection results, that is, the detection boxes with more accurate foreground perception capabilities are selected from the student model's output detection boxes.
[0013] In one possible implementation, the information of the first detection box and the third detection box includes the position, size, and category of the image content of the detection box.
[0014] In one possible implementation, the first query is obtained by adjusting the distribution of the query corresponding to the first neural network to a preset type of distribution.
[0015] In one possible implementation, the distribution of the preset type is a Gaussian distribution.
[0016] In one possible implementation, the information difference is represented by the L2 norm or conditional entropy.
[0017] In one possible implementation, the first neural network includes a first backbone network, a first encoder, and a first decoder; the second neural network includes a second backbone network, a second encoder, and a second decoder.
[0018] The step of performing target detection on the target image based on the first query and the first neural network includes:
[0019] Based on the target image, a first intermediate output is obtained through the first backbone network and the first encoder;
[0020] The first decoder processes the first query and the first intermediate output.
[0021] The step of performing target detection on the target image based on the second query and the second neural network includes:
[0022] Based on the target image, a second intermediate output is obtained through the second backbone network and the second encoder;
[0023] The second decoder processes the second query and the second intermediate output.
[0024] Secondly, this application provides a data processing method, the method comprising:
[0025] Acquire images;
[0026] The image is subjected to target detection using the updated first neural network and the updated first query obtained as in any of the first aspects, and a processing result is obtained.
[0027] Thirdly, this application provides a data processing apparatus, the apparatus comprising:
[0028] The acquisition module is used to acquire a first query corresponding to a first neural network and a second query corresponding to a second neural network; the first query is a query obtained by maximizing the information entropy of the query corresponding to the first neural network; the first neural network is a model obtained by compressing the second neural network; the first neural network and the second neural network are used for target detection;
[0029] The processing module is configured to determine a first loss based on the first query and the second query; the first loss indicates minimizing the information difference between the second query and the first query;
[0030] Update the first neural network and the first query based on the first loss.
[0031] In one possible implementation, the first neural network is obtained by quantizing the second neural network with 2, 3, or 4 bits.
[0032] In one possible implementation, the processing module is further configured to:
[0033] Based on the first query and the first neural network, target detection is performed on the target image to obtain information on M first detection boxes;
[0034] Obtain the ground value of the detection result corresponding to the target image, wherein the ground value of the detection result includes multiple second detection boxes;
[0035] Based on the positional relationship between the first detection box and the second detection box, M1 first detection boxes are determined from the M first detection boxes. Each of the M1 first detection boxes corresponds to a second detection box, and the positional relationship between each of the M1 first detection boxes and the corresponding second detection box satisfies a first preset condition. The first preset condition is related to the degree of overlap between the areas where the detection boxes are located.
[0036] The first query is the query corresponding to the M1 first detection boxes.
[0037] In one possible implementation, the processing module is further configured to:
[0038] Based on the second query and the second neural network, target detection is performed on the target image to obtain information of N third detection boxes;
[0039] Based on the positional relationship between each first detection frame and the third detection frame in the M1 first detection frames, M1 third detection frames are determined from the N third detection frames. Each first detection frame in the M1 first detection frames corresponds to a second detection frame, and the positional relationship between each first detection frame in the M1 first detection frames and the corresponding third detection frame satisfies a second preset condition. The second preset condition is related to the degree of overlap between the areas where the detection frames are located.
[0040] The second query is the query corresponding to the M1 third detection boxes.
[0041] In one possible implementation, the information of the first detection box and the third detection box includes the position, size, and category of the image content of the detection box.
[0042] In one possible implementation, the first query is obtained by adjusting the distribution of the query corresponding to the first neural network to a preset type of distribution.
[0043] In one possible implementation, the distribution of the preset type is a Gaussian distribution.
[0044] In one possible implementation, the information difference is represented by the L2 norm or conditional entropy.
[0045] In one possible implementation, the first neural network includes a first backbone network, a first encoder, and a first decoder; the second neural network includes a second backbone network, a second encoder, and a second decoder.
[0046] The processing module is specifically used for:
[0047] Based on the target image, a first intermediate output is obtained through the first backbone network and the first encoder;
[0048] The first decoder processes the first query and the first intermediate output.
[0049] Based on the target image, a second intermediate output is obtained through the second backbone network and the second encoder;
[0050] The second decoder processes the second query and the second intermediate output.
[0051] Fourthly, this application provides a data processing apparatus, the apparatus comprising:
[0052] The acquisition module is used to acquire images;
[0053] The processing module is used to perform target detection on the image using the updated first neural network and the updated first query obtained as in the first aspect, and to obtain a processing result.
[0054] Fifthly, embodiments of this application provide a data processing apparatus, which may include a memory, a processor, and a bus system, wherein the memory is used to store a program, and the processor is used to execute the program in the memory to perform the methods described in the first aspect above and any optional methods thereof, or the methods described in the second aspect above and any optional methods thereof.
[0055] In a sixth aspect, embodiments of this application provide a computer-readable storage medium storing a computer program that, when run on a computer, causes the computer to perform the methods described in the first aspect and any optional methods thereof, or the methods described in the second aspect and any optional methods thereof.
[0056] In a seventh aspect, embodiments of this application provide a computer program that, when run on a computer, causes the computer to perform the methods described in the first aspect and any optional methods thereof, or the methods described in the second aspect and any optional methods thereof.
[0057] Eighthly, this application provides a chip system including a processor for supporting an execution device or training device in implementing the functions involved in the foregoing aspects, such as transmitting or processing data involved in the foregoing methods; or, information. In one possible design, the chip system further includes a memory for storing program instructions and data necessary for the execution device or training device. This chip system may be composed of chips or may include chips and other discrete devices. Attached Figure Description
[0058] Figure 1A A structural diagram illustrating the main framework of artificial intelligence;
[0059] Figures 1B to 1D This is a schematic diagram of the application framework of this application;
[0060] Figure 2 This is a schematic diagram of the application framework of this application;
[0061] Figure 3 This is a schematic diagram of the application framework of this application;
[0062] Figure 4 This is a schematic diagram of the application framework of this application;
[0063] Figure 5A This is an illustration of one application scenario of this application;
[0064] Figures 5B to 5E This is a schematic diagram of a network structure according to this application;
[0065] Figure 6 A flowchart illustrating a data processing method provided in an embodiment of this application;
[0066] Figure 7 A flowchart illustrating an embodiment of this application;
[0067] Figure 8 A schematic diagram of the structure of a data processing apparatus provided in an embodiment of this application;
[0068] Figure 9 A schematic diagram of the structure of the execution device provided in the embodiments of this application;
[0069] Figure 10 A schematic diagram of the structure of the training device provided in the embodiments of this application;
[0070] Figure 11 This is a schematic diagram of a chip structure provided in an embodiment of this application. Detailed Implementation
[0071] The embodiments of the present invention will now be described with reference to the accompanying drawings. The terminology used in the embodiments section is for illustrative purposes only and is not intended to limit the scope of the invention.
[0072] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0073] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.
[0074] First, the overall workflow of an artificial intelligence system is described, as shown in Figure 1. Figure 1 is a structural diagram of the main framework of artificial intelligence. The framework is then elaborated on from two dimensions: the "Intelligent Information Chain" (horizontal axis) and the "IT Value Chain" (vertical axis). The "Intelligent Information Chain" reflects a series of processes from data acquisition to processing. For example, it could be the general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, and intelligent execution and output. In this process, data undergoes a condensation process of "data—information—knowledge—wisdom." The "IT Value Chain" reflects the value that artificial intelligence brings to the information technology industry, from the underlying infrastructure of human intelligence and information (provided and processed by technology) to the industrial ecosystem of the system.
[0075] (1) Infrastructure
[0076] Infrastructure provides computing power to support artificial intelligence systems, enabling communication with the external world and providing support through a basic platform. This communication occurs through sensors; computing power is provided by intelligent chips (hardware acceleration chips such as CPUs, NPUs, GPUs, ASICs, and FPGAs); and the basic platform includes distributed computing frameworks and related platform guarantees and support, which may include cloud storage and computing, interconnected networks, etc. For example, sensors communicate with the outside world to acquire data, and this data is provided to intelligent chips in the distributed computing system provided by the basic platform for computation.
[0077] (2) Data
[0078] The data at the next layer of infrastructure is used to represent the data sources in the field of artificial intelligence. The data involves graphics, images, voice, text, and IoT data from traditional devices, including business data from existing systems and sensor data such as force, displacement, liquid level, temperature, and humidity.
[0079] (3) Data processing
[0080] Data processing typically includes methods such as data training, machine learning, deep learning, search, reasoning, and decision-making.
[0081] Among them, machine learning and deep learning can perform intelligent information modeling, extraction, preprocessing, and training on data, including symbolization and formalization.
[0082] Reasoning refers to the process in which, in a computer or intelligent system, the machine thinks and solves problems by simulating human intelligent reasoning, based on reasoning control strategies and using formalized information. Typical functions include search and matching.
[0083] Decision-making refers to the process of making decisions based on intelligent information after reasoning, and it typically provides functions such as classification, sorting, and prediction.
[0084] (4) General ability
[0085] After the data processing mentioned above, the results of the data processing can be used to form some general capabilities, such as algorithms or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.
[0086] (5) Smart Products and Industry Applications
[0087] Intelligent products and industry applications refer to products and applications of artificial intelligence systems in various fields. They are the encapsulation of overall artificial intelligence solutions, productizing intelligent information decision-making and realizing practical applications. Their application areas mainly include: intelligent terminals, intelligent transportation, intelligent healthcare, autonomous driving, smart cities, etc.
[0088] This application can be applied to the field of image processing in the field of artificial intelligence. The following will take image processing as an example to introduce several application scenarios that have been implemented in products.
[0089] First, let's introduce the application scenarios of this application.
[0090] This application may be applied, but is not limited to, to applications with image processing capabilities (hereinafter referred to as image processing applications) or cloud services provided by cloud-side servers, which will be described in detail below:
[0091] I. Image processing applications:
[0092] The product form of this application embodiment can be an image processing application, specifically an application with image segmentation capabilities. Image processing applications can run on terminal devices or cloud-based servers.
[0093] In one possible implementation, image processing applications can perform tasks such as image segmentation or object detection based on the input image, and obtain processing results, which can be image segmentation results (masked regions) or detection results (e.g., including detection boxes and categories).
[0094] In one possible implementation, a user can open an image processing application installed on a terminal device and input an image. The image processing application can process the image using a neural network model trained by the method provided in this application embodiment and present the processing result to the user (the presentation method may include, but is not limited to, displaying, saving, uploading to the cloud, etc.).
[0095] In one possible implementation, a user can open an image processing application installed on a terminal device and input an image. The image processing application can then send the image to a cloud-based server. The cloud-based server processes the image using a neural network model trained by the method provided in this application embodiment and sends the processing result back to the terminal device. The terminal device can then present the processing result to the user (the presentation method may include, but is not limited to, displaying, saving, or uploading to the cloud).
[0096] The image processing application in this application will be described below, focusing on its functional architecture and the product architecture that implements its functions.
[0097] Reference Figure 1B , Figure 1B This is a schematic diagram of the functional architecture of the image processing application in the embodiments of this application:
[0098] In one possible implementation, such as Figure 1B As shown, the image processing application 102 can receive input parameters 101 (e.g., including an image) and generate a processing result 103. The image processing application 102 can be executed on at least one computer system (for example) and includes computer code that, when executed by one or more computers, causes the computers to perform the methods provided in the embodiments of this application.
[0099] Reference Figure 1C , Figure 1C This is a schematic diagram of the entity architecture for running an image processing application in this embodiment of the application:
[0100] See Figure 1C , Figure 1C A schematic diagram of a system architecture is shown. The system may include a terminal 100 and a server 200. The server 200 may include one or more servers (…). Figure 1C(The example includes a server), and the server 200 can provide the methods provided in the embodiments of this application to one or more terminals.
[0101] The terminal 100 may have an image processing application installed. The application and webpage can provide an interface. The terminal 100 can receive relevant parameters input by the user on the image processing interface and send the parameters to the server 200. The server 200 can obtain the processing result based on the received parameters and return the processing result to the terminal 100.
[0102] It should be understood that in some optional implementations, the terminal 100 can also complete the action of obtaining the processing result based on the received parameters on its own, without the need for the server to cooperate. This application embodiment is not limited to this.
[0103] The following description Figure 1C The product form of the mid-terminal 100;
[0104] The terminal 100 in this application embodiment can be a mobile phone, tablet computer, wearable device, vehicle device, augmented reality (AR) / virtual reality (VR) device, laptop computer, ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA), etc., and this application embodiment does not impose any restrictions on it.
[0105] Figure 1D A schematic diagram of an optional hardware structure for terminal 100 is shown.
[0106] refer to Figure 1D As shown, the terminal 100 may include a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160 (optional), a speaker 161 (optional), a microphone 162 (optional), a processor 170, an external interface 180, a power supply 190, and other components. Those skilled in the art will understand that... Figure 1D These are merely examples of terminals or multi-functional devices and do not constitute a limitation on terminals or multi-functional devices. They may include more or fewer components than shown in the illustration, or combine certain components, or use different components.
[0107] The input unit 130 can be used to receive input numerical or character information, and to generate key signal inputs related to user settings and function control of the portable multi-functional device. Specifically, the input unit 130 may include a touchscreen 131 (optional) and / or other input devices 132. The touchscreen 131 can collect touch operations performed by the user on or near it (such as operations performed by the user using fingers, knuckles, styluses, or any suitable object on or near the touchscreen), and drive the corresponding connection devices according to a pre-set program. The touchscreen can detect the user's touch actions, convert the touch actions into touch signals and send them to the processor 170, and can receive and execute commands sent by the processor 170; the touch signal includes at least touch point coordinate information. The touchscreen 131 can provide an input interface and an output interface between the terminal 100 and the user. In addition, various types of touchscreens, such as resistive, capacitive, infrared, and surface acoustic wave, can be used to implement the touchscreen. Besides the touchscreen 131, the input unit 130 may also include other input devices. Specifically, other input devices 132 may include, but are not limited to, one or more of the following: physical keyboard, function keys (such as volume control buttons, power buttons, etc.), trackball, mouse, joystick, etc.
[0108] The input device 132 can receive input images, etc.
[0109] The display unit 140 can be used to display information input by the user or information provided to the user, various menus of the terminal 100, interactive interfaces, file display, and / or playback of any multimedia file. In this embodiment, the display unit 140 can be used to display the interface of an image processing application, processing results, etc.
[0110] The memory 120 can be used to store instructions and data. The memory 120 may primarily include an instruction storage area and a data storage area. The data storage area can store various types of data, such as multimedia files and text. The instruction storage area can store software units such as operating systems, applications, and instructions required for at least one function, or subsets or extended sets thereof. It may also include non-volatile random access memory. It provides the processor 170 with hardware, software, and data resources for managing the computing device, supporting control software and applications. It is also used for storing multimedia files, as well as storing running programs and applications.
[0111] The processor 170 is the control center of the terminal 100. It connects various parts of the terminal 100 via various interfaces and lines. By running or executing instructions stored in the memory 120 and calling data stored in the memory 120, it performs various functions and processes data of the terminal 100, thereby controlling the terminal device as a whole. Optionally, the processor 170 may include one or more processing units; preferably, the processor 170 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 170. In some embodiments, the processor and memory can be implemented on a single chip; in some embodiments, they can also be implemented separately on independent chips. The processor 170 can also be used to generate corresponding operation control signals, send them to the corresponding components of the computing processing device, read and process data in the software, especially read and process data and programs in the memory 120, so that the various functional modules therein perform corresponding functions, thereby controlling the corresponding components to act according to the instructions.
[0112] The memory 120 can be used to store software code related to the data processing method, and the processor 170 can execute the steps of the chip's data processing method, and can also schedule other units (such as the above-mentioned input unit 130 and display unit 140) to achieve the corresponding functions.
[0113] The radio frequency unit 110 (optional) can be used for receiving and transmitting signals during information transmission or calls. For example, it can receive downlink information from the base station and process it for the processor 170; additionally, it can transmit uplink data to the base station. Typically, the RF circuit includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier (LNA), a duplexer, etc. Furthermore, the radio frequency unit 110 can also communicate wirelessly with network devices and other devices. This wireless communication can use any communication standard or protocol, including but not limited to Global System for Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.
[0114] In this embodiment of the application, the radio frequency unit 110 can send an image to the server 200 and receive the processing result sent by the server 200.
[0115] It should be understood that the radio frequency unit 110 is optional and can be replaced with other communication interfaces, such as a network port.
[0116] The terminal 100 also includes a power supply 190 (such as a battery) that supplies power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system.
[0117] Terminal 100 also includes an external interface 180, which can be a standard Micro USB interface or a multi-pin connector, which can be used to connect terminal 100 to other devices for communication or to connect a charger to charge terminal 100.
[0118] Although not shown, terminal 100 may also include a flash, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with various functions, etc., which will not be described in detail here. Some or all of the methods described below can be applied to, for example... Figure 1D In the terminal 100 shown.
[0119] The following description Figure 1C The product form of the mid-range server 200;
[0120] Figure 2 A structural diagram of a server 200 is provided, as follows: Figure 2 As shown, server 200 includes bus 201, processor 202, communication interface 203, and memory 204. Processor 202, memory 204, and communication interface 203 communicate with each other via bus 201.
[0121] Bus 201 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 2 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0122] The processor 202 can be any one or more of the following processors: central processing unit (CPU), graphics processing unit (GPU), microprocessor (MP), or digital signal processor (DSP).
[0123] Memory 204 may include volatile memory, such as random access memory (RAM). Memory 204 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0124] The memory 204 can be used to store software code related to the data processing method, and the processor 202 can execute the steps of the chip's data processing method, and can also schedule other units to achieve corresponding functions.
[0125] It should be understood that the aforementioned terminal 100 and server 200 can be centralized or distributed devices. The processors (e.g., processor 170 and processor 202) in the aforementioned terminal 100 and server 200 can be hardware circuits (such as application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), general-purpose processors, digital signal processors (DSPs), microprocessors or microcontrollers, etc.) or combinations of these hardware circuits. For example, the processor can be a hardware system with instruction execution capabilities, such as a CPU or DSP, or a hardware system without instruction execution capabilities, such as an ASIC or FPGA, or a combination of the aforementioned hardware systems without instruction execution capabilities and hardware systems with instruction execution capabilities.
[0126] It should be understood that the steps related to the model inference process in the embodiments of this application involve AI-related operations. When performing AI operations, the instruction execution architecture of the terminal device and server is not limited to the processor-memory architecture described above. The following section will further explain... Figure 3 The system architecture provided in the embodiments of this application will be described in detail.
[0127] Figure 3 This is a schematic diagram of the system architecture provided for an embodiment of this application. Figure 3 As shown, the system architecture 500 includes an execution device 510, a training device 520, a database 530, a client device 540, a data storage system 550, and a data acquisition system 560.
[0128] The execution device 510 includes a calculation module 511, an I / O interface 512, a preprocessing module 513, and a preprocessing module 514. The calculation module 511 may include a target model / rule 501, while the preprocessing modules 513 and 514 are optional.
[0129] The execution device 510 can be a terminal device or a server that runs the aforementioned image processing applications.
[0130] The data acquisition device 560 is used to acquire training samples. Training samples can be multiple images, etc. After acquiring the training samples, the data acquisition device 560 stores these training samples in the database 530.
[0131] The training device 520 can maintain training samples in the database 530 to obtain the target model / rule 501 from the neural network to be trained.
[0132] It should be understood that the training device 520 can perform a pre-training process on the neural network to be trained based on the training samples maintained in the database 530, or fine-tune the model based on the pre-training.
[0133] It should be noted that in practical applications, the training samples maintained in database 530 may not all come from the data acquisition device 560; they may also be received from other devices. Furthermore, it should be noted that training device 520 may not necessarily train the target model / rule 501 entirely based on the training samples maintained in database 530; it may also obtain training samples from the cloud or other sources for model training. The above description should not be construed as limiting the embodiments of this application.
[0134] The target model / rule 501 trained using training device 520 can be applied to different systems or devices, such as... Figure 3 The execution device 510 shown can be a terminal, such as a mobile phone terminal, tablet computer, laptop computer, augmented reality (AR) / virtual reality (VR) device, vehicle terminal, etc., or it can be a server, etc.
[0135] Specifically, the training device 520 can transfer the trained model to the execution device 510.
[0136] exist Figure 3 In the execution device 510, an input / output (I / O) interface 512 is configured for data interaction with external devices. Users can input data (such as images in this embodiment) into the I / O interface 512 through the client device 540.
[0137] Preprocessing modules 513 and 514 are used to preprocess the input data received from the I / O interface 512. It should be understood that preprocessing modules 513 and 514 may be absent, or only one preprocessing module may be used. When preprocessing modules 513 and 514 are absent, the calculation module 511 can be used directly to process the input data.
[0138] During the preprocessing of input data by the execution device 510, or during the calculation module 511 of the execution device 510 performing calculations and other related processes, the execution device 510 can call data, code, etc. in the data storage system 550 for corresponding processing, or store the data, instructions, etc. obtained from the corresponding processing into the data storage system 550.
[0139] Finally, the I / O interface 512 provides the processing result to the client device 540, thereby providing it to the user.
[0140] exist Figure 3 In the illustrated scenario, the user can manually provide input data, which can be done through the interface provided by I / O interface 512. Alternatively, the client device 540 can automatically send input data to I / O interface 512. If user authorization is required for the client device 540 to automatically send input data, the user can set the corresponding permissions in the client device 540. The user can view the output results of the execution device 510 on the client device 540, which can be presented in various forms such as display, sound, or animation. The client device 540 can also act as a data acquisition terminal, collecting the input data and output results of the input I / O interface 512 as shown in the figure, and storing them as new sample data in database 530. Alternatively, data can be collected directly from the I / O interface 512 without going through the client device 540, using the input data and output results of the input I / O interface 512 as shown in the figure, and storing them as new sample data in database 530.
[0141] It is worth noting that, Figure 3 This is merely a schematic diagram of a system architecture provided in an embodiment of this application. The positional relationships between the devices, components, modules, etc., shown in the diagram do not constitute any limitation. For example, in Figure 3 In this context, the data storage system 550 is an external storage device relative to the execution device 510. However, in other cases, the data storage system 550 may also be placed within the execution device 510. It should be understood that the aforementioned execution device 510 may be deployed within the client device 540.
[0142] From the inference side of the model:
[0143] In this embodiment, the computing module 511 of the execution device 520 can obtain the code stored in the data storage system 550 to implement the steps related to the model reasoning process in this embodiment.
[0144] In this embodiment of the application, the computing module 511 of the execution device 520 may include hardware circuits (such as application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), general-purpose processors, digital signal processors (DSPs), microprocessors or microcontrollers, etc.) or combinations of these hardware circuits. For example, the training device 520 may be a hardware system with instruction execution capabilities, such as a CPU or DSP, or a hardware system without instruction execution capabilities, such as an ASIC or FPGA, or a combination of the aforementioned hardware systems without instruction execution capabilities and hardware systems with instruction execution capabilities.
[0145] Specifically, the computing module 511 of the execution device 520 can be a hardware system with the function of executing instructions. The steps related to the model inference process provided in this application embodiment can be software code stored in the memory. The computing module 511 of the execution device 520 can obtain the software code from the memory and execute the obtained software code to implement the steps related to the model inference process provided in this application embodiment.
[0146] It should be understood that the computing module 511 of the execution device 520 can be a combination of a hardware system without the function of executing instructions and a hardware system with the function of executing instructions. Some steps related to the model reasoning process provided in the embodiments of this application can also be implemented by the hardware system in the computing module 511 of the execution device 520 without the function of executing instructions, which is not limited here.
[0147] From the training side of the model:
[0148] In this embodiment of the application, the training device 520 can access the memory ( Figure 3 (Not shown in the diagram, but can be integrated into the training device 520 or deployed separately from the training device 520) The code stored in the diagram can be used to implement the steps related to model training in the embodiments of this application.
[0149] In this embodiment of the application, the training device 520 may include hardware circuits (such as application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), general-purpose processors, digital signal processors (DSPs), microprocessors or microcontrollers, etc.) or combinations of these hardware circuits. For example, the training device 520 may be a hardware system with instruction execution capabilities, such as a CPU or DSP, or a hardware system without instruction execution capabilities, such as an ASIC or FPGA, or a combination of the aforementioned hardware systems without instruction execution capabilities and hardware systems with instruction execution capabilities.
[0150] It should be understood that the training device 520 can be a combination of a hardware system without the function of executing instructions and a hardware system with the function of executing instructions. Some steps related to the training of the neutralization model provided in the embodiments of this application can also be implemented by the hardware system in the training device 520 without the function of executing instructions, which is not limited here.
[0151] II. Image processing cloud services provided by the server:
[0152] In one possible implementation, the server can provide image processing services to the client side through an application programming interface (API).
[0153] In this process, the terminal device can send relevant parameters (such as images) to the server through the API provided by the cloud. The server can obtain the processing results based on the received parameters and return the processing results to the terminal.
[0154] The description of the terminal and server can be found in the above embodiments, and will not be repeated here.
[0155] like Figure 4 The process of using an image processing cloud service provided by a cloud platform is shown.
[0156] 1. Activate and purchase content moderation services.
[0157] 2. Users can download the software development kit (SDK) corresponding to the content moderation service. Cloud platforms usually provide multiple development versions of the SDK for users to choose from according to their development environment needs, such as JAVA version SDK, Python version SDK, PHP version SDK, Android version SDK, etc.
[0158] 3. After downloading the corresponding version of the SDK to their local machine according to their needs, users can import the SDK project into their local development environment, configure and debug it in the local development environment, and develop other functions in the local development environment to form an application that integrates image processing capabilities.
[0159] 4. When an image processing application is used, it can trigger an image processing API call when image processing is required. When the application triggers the image processing function, it sends an API request to the running instance of the image processing service in the cloud environment. The API request carries the image, and the running instance in the cloud environment processes the image to obtain the processing result.
[0160] 5. The cloud environment returns the processing result to the application, thereby completing one method call provided in this embodiment of the application.
[0161] III. Cloud services for model compression provided by the server:
[0162] In one possible implementation, the server can provide model compression services to the client side via an application programming interface (API).
[0163] In this process, the terminal device can send relevant parameters (such as images, neural networks to be compressed) to the server through the API provided by the cloud. The server can obtain the compressed neural network based on the received parameters and return the compressed neural network to the terminal.
[0164] The description of the terminal and server can be found in the above embodiments, and will not be repeated here.
[0165] For example, the data processing method provided in the embodiments of this application can be applied to ADAS / ADS visual perception systems.
[0166] like Figure 5AAs shown, ADAS and ADS require real-time detection of multiple types of 2D objects, including: dynamic obstacles (pedestrians, cyclists, tricycles, cars, trucks, buses), static obstacles (traffic cones, traffic sticks, fire hydrants, motorcycles, bicycles), and traffic signs (traffic signs, guide signs, billboards, red / yellow / green / black traffic lights, road signs). Furthermore, to accurately determine the area occupied by dynamic obstacles in 3D space, 3D estimation of the dynamic obstacles is also required, outputting 3D bounding boxes. To fuse data with LiDAR, it is necessary to acquire the mask of dynamic obstacles, thereby filtering out the laser point clouds hitting the dynamic obstacles; for precise parking space determination, it is necessary to simultaneously detect four key points of the parking space; for mapping and localization, it is necessary to detect the key points of static targets. The model trained using the technical solution provided in the embodiments of this application can perform all or some of the above functions within the model.
[0167] Since the embodiments of this application involve a large number of neural network applications, for ease of understanding, the relevant terms and concepts such as neural networks involved in the embodiments of this application will be introduced below.
[0168] (1) Neural Network
[0169] A neural network can be composed of neural units, which can be defined as a computational unit that takes xs (i.e., input data) and an intercept of 1 as input. The output of this computational unit can be:
[0170]
[0171] Where s = 1, 2, ..., n, where n is a natural number greater than 1, Ws is the weight of xs, and b is the bias of the neural unit. f is the activation function of the neural unit, used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into an output signal. The output signal of this activation function can be used as the input of the next convolutional layer, and the activation function can be the sigmoid function. A neural network is a network formed by connecting multiple of the above-mentioned individual neural units together, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the features of the local receptive field, which can be a region composed of several neural units.
[0172] (2) A convolutional neural network (CNN) is a deep neural network with a convolutional structure. A CNN contains a feature extractor consisting of convolutional layers and subsampling layers, which can be viewed as a filter. A convolutional layer refers to the layer of neurons in a CNN that performs convolutional processing on the input signal. In a convolutional layer of a CNN, a neuron can be connected to only some of the neurons in its neighboring layers. A convolutional layer typically contains several feature planes, each composed of rectangularly arranged neural units. Neural units on the same feature plane share weights, which are the convolutional kernel. Shared weights can be understood as the way features are extracted being independent of their location. The convolutional kernel can be formalized as a matrix of random size, and during the training process of the CNN, the kernel can learn reasonable weights. Furthermore, the direct benefit of shared weights is reducing the connections between layers in the CNN, while also reducing the risk of overfitting.
[0173] CNN is a very common type of neural network. Below, we will combine... Figure 5B This section focuses on a detailed explanation of the structure of CNNs. As mentioned in the basic concept introduction above, a Convolutional Neural Network (CNN) is a deep neural network with a convolutional structure. It is a deep learning architecture, which refers to learning at multiple levels of abstraction through machine learning algorithms. As a deep learning architecture, CNN is a feed-forward artificial neural network, in which each neuron can respond to the input image.
[0174] like Figure 5BAs shown, the convolutional neural network (CNN) 200 may include an input layer 210, a convolutional / pooling layer 220 (where the pooling layer is optional), and a fully connected layer 230.
[0175] Convolutional / pooling layers 220:
[0176] Convolutional layers:
[0177] like Figure 5B The convolutional / pooling layer 220 shown may include layers as in Examples 221-226. For instance, in one implementation, layer 221 is a convolutional layer, layer 222 is a pooling layer, layer 223 is a convolutional layer, layer 224 is a pooling layer, layer 225 is a convolutional layer, and layer 226 is a pooling layer; in another implementation, layers 221 and 222 are convolutional layers, layer 223 is a pooling layer, layers 224 and 225 are convolutional layers, and layer 226 is a pooling layer. That is, the output of the convolutional layer can be used as the input to a subsequent pooling layer, or as the input to another convolutional layer to continue the convolution operation.
[0178] The following section will use convolutional layer 221 as an example to introduce the internal working principle of a convolutional layer.
[0179] Convolutional layer 221 can include multiple convolution operators, also known as kernels. In image processing, a convolution operator acts as a filter to extract specific information from the input image matrix. Essentially, a convolution operator can be a weight matrix, which is usually predefined. During the convolution operation, the weight matrix typically processes the input image pixel by pixel (or two pixels by two pixels, depending on the stride) along the horizontal direction, thus extracting specific features from the image. The size of the weight matrix should be related to the image size. It's important to note that the depth dimension of the weight matrix is the same as the depth dimension of the input image; during convolution, the weight matrix extends to the entire depth of the input image. Therefore, convolution with a single weight matrix produces a single-depth convolutional output. However, in most cases, a single weight matrix is not used; instead, multiple weight matrices of the same size (rows × columns) are applied—multiple identical matrices. The outputs of each weight matrix are stacked to form the depth dimension of the convolutional image; this dimension can be understood as being determined by the "multiple" mentioned above. Different weight matrices can be used to extract different features from an image. For example, one weight matrix can be used to extract image edge information, another weight matrix can be used to extract specific colors of the image, and yet another weight matrix can be used to blur unwanted noise in the image. These multiple weight matrices have the same size (rows × columns), and the feature maps extracted by these multiple weight matrices of the same size also have the same size. The extracted feature maps of the same size are then merged to form the output of the convolution operation.
[0180] The weight values in these weight matrices need to be obtained through extensive training in practical applications. The weight matrices formed by the weight values obtained through training can be used to extract information from the input image, thereby enabling the convolutional neural network 200 to make correct predictions.
[0181] When a convolutional neural network 200 has multiple convolutional layers, the initial convolutional layers (e.g., 221) tend to extract more general features, which can also be called low-level features. As the depth of the convolutional neural network 200 increases, the features extracted by later convolutional layers (e.g., 226) become more and more complex, such as high-level semantic features. Features with higher semantic levels are more suitable for the problem to be solved.
[0182] Pooling layer:
[0183] Because it is often necessary to reduce the number of training parameters, pooling layers are often introduced periodically after convolutional layers, such as... Figure 5BLayers 221-226 in example 220 can be a convolutional layer followed by a pooling layer, or multiple convolutional layers followed by one or more pooling layers. In image processing, the sole purpose of pooling layers is to reduce the spatial size of the image. Pooling layers can include average pooling and / or max pooling operators to sample the input image to obtain a smaller image size. The average pooling operator calculates the average value of pixel values within a specific range as the result of average pooling. The max pooling operator takes the pixel with the largest value within a specific range as the result of max pooling. Furthermore, just as the size of the weight matrix in a convolutional layer should be related to the image size, the operators in a pooling layer should also be related to the image size. The size of the output image after processing by the pooling layer can be smaller than the size of the input image of the pooling layer. Each pixel in the output image of the pooling layer represents the average or maximum value of the corresponding sub-region of the input image of the pooling layer.
[0184] Fully connected layer 230:
[0185] After processing by the convolutional / pooling layers 220, the convolutional neural network 200 is still insufficient to output the required information. As mentioned earlier, the convolutional / pooling layers 220 only extract features and reduce the parameters introduced by the input image. However, to generate the final output information (the required class information or other relevant information), the convolutional neural network 200 needs to utilize fully connected layers 230 to generate one or a set of outputs representing the required number of classes. Therefore, the fully connected layers 230 can include multiple hidden layers (such as...). Figure 5B As shown in 231, 232 to 23n), the parameters contained in these multi-layer hidden layers can be pre-trained based on relevant training data for specific task types. For example, the task type may include image recognition, image classification, image super-resolution reconstruction, etc.
[0186] After the multiple hidden layers in the fully connected layer 230, the final layer of the entire convolutional neural network 200 is the output layer 240. This output layer 240 has a loss function similar to the classification cross-entropy, specifically used to calculate the prediction error. Once the entire convolutional neural network 200 has propagated forward (e.g., ... Figure 5B Propagation from 210 to 240 degrees is considered forward propagation, while backward propagation (e.g.) is completed. Figure 5B The propagation from 240 to 210 (backpropagation) will begin to update the weight values and biases of the layers mentioned above, in order to reduce the loss of the convolutional neural network 200 and the error between the output of the convolutional neural network 200 through the output layer and the ideal result.
[0187] It should be noted that, as Figure 5BThe convolutional neural network 200 shown is merely an example of a convolutional neural network. In specific applications, convolutional neural networks can also exist in the form of other network models, for example, including only... Figure 5B As shown in the network structure, for example, the convolutional neural network used in the embodiments of this application may only include an input layer 210, a convolutional / pooling layer 220, and an output layer 240.
[0188] It should be noted that, as Figure 5B The convolutional neural network 100 shown is merely an example of a convolutional neural network. In specific applications, convolutional neural networks can also exist in the form of other network models, such as... Figure 5C The multiple convolutional / pooling layers shown are implemented in parallel, and the extracted features are all input into the fully connected layer 230 for processing.
[0189] (3) Deep Neural Networks
[0190] Deep Neural Networks (DNNs), also known as multilayer neural networks, can be understood as neural networks with many hidden layers, though there's no specific metric for "many." DNNs can be categorized into three layers based on their position: input layers, hidden layers, and output layers. Generally, the first layer is the input layer, the last layer is the output layer, and the layers in between are hidden layers. All layers are fully connected, meaning that any neuron in the i-th layer is connected to any neuron in the (i+1)-th layer. Although DNNs appear complex, the operation of each layer is actually quite simple, resembling a linear relationship as follows: in, It is the input vector. It is the output vector. α is the offset vector, W is the weight matrix (also called coefficients), and α() is the activation function. Each layer is simply an adjustment of the input vector. The output vector is obtained through such a simple operation. Because DNNs have many layers, the coefficients W and the offset vector... The number of these parameters is therefore quite large. The definitions of these parameters in a DNN are as follows: Taking the coefficient W as an example: Assuming a three-layer DNN, the linear coefficient from the 4th neuron in the second layer to the 2nd neuron in the third layer is defined as... The superscript 3 represents the layer number where coefficient W resides, while the subscript corresponds to the output third layer index 2 and the input second layer index 4. In summary, the coefficients from the k-th neuron in layer L-1 to the j-th neuron in layer L are defined as follows: It's important to note that the input layer does not have a W parameter. In deep neural networks, more hidden layers allow the network to better represent complex real-world situations. Theoretically, the more parameters a model has, the higher its complexity and "capacity," meaning it can perform more complex learning tasks. Training a deep neural network is essentially the process of learning the weight matrix, with the ultimate goal of obtaining the weight matrix of all layers in the trained deep neural network (a weight matrix formed by the vectors W from many layers).
[0191] (4) Loss Function
[0192] In training a deep neural network, to ensure the output closely approximates the desired predicted value, we compare the network's prediction with the target value. Based on the difference, we update the weight vector of each layer (usually pre-configuring parameters before the initial update). For example, if the prediction is too high, the weight vector is adjusted to predict a lower value. This adjustment continues until the deep neural network predicts the target value or a value very close to it. Therefore, we need to predefine "how to compare the difference between the predicted and target values," which is the loss function or objective function. These are important equations used to measure the difference between the predicted and target values. Taking the loss function as an example, a higher output value (loss) indicates a greater difference, and training the deep neural network becomes a process of minimizing this loss.
[0193] (5) Backpropagation algorithm
[0194] Convolutional neural networks can employ backpropagation (BP) to correct the parameters in the initial super-resolution model during training, thereby reducing the reconstruction error loss. Specifically, forward propagation of the input signal to the output generates an error loss; this error loss information is then propagated back to update the parameters in the initial super-resolution model, leading to convergence of the error loss. The backpropagation algorithm is an error-loss-driven backpropagation process aimed at obtaining the optimal parameters of the super-resolution model, such as the weight matrix.
[0195] (6) Model quantization:
[0196] In the field of artificial intelligence model acceleration, quantization refers to compression techniques that use a bit width of less than 32 bits to represent weight data and feature map data in neural networks. The lower the compressed bit width, the more memory space, latency, and power consumption can be saved in actual deployment. Model quantization is generally divided into two types: post-trained quantization (PTQ) and quantization-aware training (QAT). The former only requires a small amount of unlabeled calibration dataset to complete the quantization process of a pre-trained floating-point model and is often used for compression with a higher bit width. The latter requires a complete dataset for training, simulating quantization operations during training so that the quantized model can further converge to the optimum. It is often used for accuracy recovery after the quantized model has suffered significant losses.
[0197] (7) Full precision: Parameters in the network model whose numerical type is 32-bit floating point.
[0198] (8) Anchor: Anchor boxes, which are commonly used in object detection, are fixed reference boxes. A set of fixed reference boxes at different scales and locations are preset to cover almost all locations and scales. Each reference box is responsible for detecting targets with an intersection-union ratio greater than a threshold (preset training value, usually 0.5 or 0.7).
[0199] (9) Knowledge distillation: The knowledge distillation (KD) method can use the knowledge learned by the large model to guide the training of the small model, so that the small model has the same performance as the large model, but the number of parameters is greatly reduced, thereby realizing model compression and acceleration. This is the application of knowledge distillation and transfer learning in model optimization.
[0200] (10) Teacher model: a large model with full precision that has been trained.
[0201] (11) Student model: It can be a model obtained by pruning and quantizing the teacher model, or it can be a model designed manually with the same framework as the teacher model.
[0202] (12) Transformer layer
[0203] The neural network includes an embedding layer and at least one transformer layer. The at least one transformer layer can be N transformer layers (N being an integer greater than 0). Each transformer layer includes sequentially adjacent attention layers, add and normalize layers, feed-forward layers, and add and normalize layers. In the embedding layer, the current input is embedded to obtain multiple embedding vectors. In the attention layer, P input vectors are obtained from the layer above the first transformer layer. Using any first input vector among the P input vectors as the center, intermediate vectors corresponding to the first input vector are obtained based on the correlation between each input vector within a preset attention window and the first input vector. This process determines P intermediate vectors corresponding to the P input vectors. In the pooling layer, the P intermediate vectors are merged into Q output vectors, where the multiple output vectors obtained from the last transformer layer are used as feature representations of the current input.
[0204] Reference Figure 5D , Figure 5D This is a schematic diagram of a transformer model. It needs to be understood. Figure 5D The structure shown is merely an example; the number of neural network layers can be adjusted as needed. The embedding layer processes the input, yielding multiple feature vectors. A core feature of the transformer model is its unique attention mechanism. When processing natural language, such as a sentence, the transformer model uses this mechanism to assign different attention coefficients to each word vector in the sentence, thus more comprehensively considering the influence of the context on each word. The embedding layer can encode N embedding vectors Xl based on the node features and their positions in the current sequence. The attention layer is connected to the embedding layer, taking the N embedding vectors as input vectors. Based on the correlation between the N input vectors, it synthesizes them to obtain N output vectors, which are then fed to subsequent transformer layers. The transformer layer takes the output of the previous layer as its input vector and performs similar operations as the previous transformer layer.
[0205] Reference Figure 5E , Figure 5E This is a schematic diagram of a transformer layer structure, wherein the transformer layer may include sequentially adjacent multi-head attention layers (or simply attention layers), addition and normalization (add&norm) layers, feed forward net (FFN) layers, and addition and normalization layers.
[0206] The multi-head attention layer obtains N input vectors Xl from the layer above it. These N input vectors Xl can be represented as a matrix X. The multi-head attention layer employs a self-attention mechanism, transforming each vector based on the correlation between them to obtain N output vectors, which can also be represented as a matrix Y. It can be understood that when this multi-head attention layer is directly connected to the embedding layer, for example... Figure 5E In a transformer layer directly connected to the embedding layer, the input vector it receives is the embedding vector output by the embedding layer; when this multi-head attention layer is a multi-head attention layer included in subsequent transformer layers, for example... Figure 5E A multi-head attention layer, which is directly connected to the previous transformer layer, receives the input vector as the output vector of the previous transformer layer. A multi-head attention layer can include multiple attention heads (e.g., ...). Figure 5E The following are Head 1, Head 2, ..., Head N shown in the figure.
[0207] (13) Attention mechanism
[0208] Attention mechanisms mimic the internal processes of biological observation—aligning internal experience with external senses to increase the precision of observation in specific areas. They enable the rapid sifting of high-value information from a large volume of data using limited attentional resources. Attention mechanisms can quickly extract important features from sparse data and are therefore widely used in natural language processing tasks, particularly machine translation. Self-attention mechanisms, an improvement on attention mechanisms, reduce reliance on external information and are better at capturing the internal correlations of data or features. The core idea of attention mechanisms can be rewritten as follows:
[0209] In this formula, Lx = ||Source|| represents the length of the Source. The meaning is that the elements in the Source are imagined as a series of data pairs. Given a Query element in the Target, the similarity or relevance between the Query and each Key is calculated to obtain the weight coefficient of the Value corresponding to each Key. Then, the Values are weighted and summed to obtain the final Attention value. Therefore, the Attention mechanism essentially performs a weighted sum of the Values of the elements in the Source, while the Query and Key are used to calculate the weight coefficients of their corresponding Values. Conceptually, Attention can be understood as selectively filtering a small amount of important information from a large amount of information and focusing on this important information, ignoring most of the unimportant information. The focusing process is reflected in the calculation of the weight coefficients; the larger the weight, the more focused it is on its corresponding Value. That is, the weight represents the importance of the information, and the Value is the corresponding information. Self-attention can be understood as intra attention. The attention mechanism occurs between the elements of the Target (Query) and all elements of the Source. Self-attention refers to the attention mechanism that occurs between elements within the Source or between elements within the Target. It can also be understood as the attention calculation mechanism in the special case where Target = Source. The specific calculation process is the same, only the calculation object changes.
[0210] Object detection aims to locate and classify visual objects from input images. Early work typically employed convolutional neural networks to process region features of the input image. More recently, transformer-based object detectors have been proposed, where object detection is treated as an ensemble prediction task and can be trained end-to-end. These greatly simplify the object detection task, eliminating the need for tedious adjustments to manually designed components, such as anchor size and scale. While object detectors possess impressive capabilities, they often involve a large number of parameters and floating-point operations (FLOPs). For example, in the ResNet-50-based object detector (DETR-R50), 39.8M parameters consumed 159MB of memory and 86GFLOPs of computation. The significant memory and computational demands during inference limit the deployment of these models on resource-constrained platforms.
[0211] To achieve efficient online inference, a large body of work has attempted to compress and accelerate neural networks, including compact network design, network pruning, low-order decomposition, quantization, and knowledge distillation. Quantization and pruning are particularly suitable for deployment on AI chips, reducing the number of network parameters and activation values, thus enabling efficient inference. However, the parameters of the model change significantly before and after quantization, leading to a decrease in model accuracy. Performance drops sharply, especially when quantized to very low bits (4 bits or lower).
[0212] To solve the above problems, refer to Figure 6 , Figure 6 This is a flowchart illustrating a data processing method provided in an embodiment of this application, such as... Figure 6 As shown in the embodiment of this application, a data processing method may include steps 601 to 603, which are described in detail below.
[0213] 601. Obtain the first query corresponding to the first neural network and the second query corresponding to the second neural network; the first query is the query obtained by maximizing the information entropy of the query corresponding to the first neural network; the first neural network is a model obtained by compressing the second neural network; the first neural network and the second neural network are used for target detection.
[0214] In one possible implementation, the neural network model for object detection may include a feature extraction network (e.g., including a backbone network and an encoder) and a decoder, wherein the decoder may take as input a feature representation (obtained by processing the image through the feature extraction network) and multiple query vectors to obtain at least one image detection result (including a detection box and a corresponding category), and one query vector may correspond to one image detection result.
[0215] In this embodiment, a neural network to be compressed (second neural network) and a neural network after compression of the second neural network (first neural network) can be obtained. This application can use the second neural network as a teacher network and the first neural network as a student model. Knowledge distillation is used to update the first neural network and its corresponding multiple query vectors, thereby improving the model accuracy of the first neural network.
[0216] In one possible implementation, the first neural network is obtained by quantizing the second neural network with 2, 3, or 4 bits.
[0217] In one possible implementation, when performing knowledge distillation on the first neural network, a trade-off between performance and compression can be achieved by minimizing the mutual information contained in the intermediate layers of the teacher network and the student model and maximizing the expected output. For example, respectively... and Let's use these to represent the second neural network and the first neural network.
[0218] For example, the loss of knowledge distillation can be constructed as:
[0219]
[0220] in, and Let represent the queries for the teacher model and the student model, respectively; β and γ are Lagrange multipliers. For the parameters of the student model; I(·) returns the mutual information between the two input variables. Minimize the first term I(X; E) S ), representing the input and visual features E S Mutual information between them is used to extract task-oriented cues. Maximize the second term I(E) S ,q S ;y GT This represents the mutual information between the extracted visual features and the real data labels, enabling better target detection. These two aspects can be achieved through common network training and detection loss constraints, such as coordinate regression and category classification.
[0221] As for the third item It attempts to address the information distortion problem of the student model's query by introducing the teacher model's query as prior knowledge. To achieve this goal, the third formula can be mathematically expanded and restated as follows:
[0222]
[0223] Where H represents information entropy, and self-information H(q) S The conditional entropy needs to be maximized. It needs to be minimized. Maximizing and minimizing both simultaneously is quite difficult; therefore, the above formula can be reformulated as a bi-level optimization problem, solved by alternately optimizing these two terms, as defined below:
[0224]
[0225]
[0226] This objective involves two sub-problems: obtaining the current optimal query through inner-level optimization. Furthermore, knowledge transfer from the teacher model to the student model is achieved through upper-level optimization. The optimization of these two problems can be implemented during the forward and backward propagation processes, respectively.
[0227] In one possible implementation, the query of the student model can be optimized during forward propagation by adjusting its distribution to a preset type. In this embodiment, the first query (i.e., the query of the student model) is obtained by adjusting the distribution of the query corresponding to the first neural network to a preset type. Here, the preset type distribution can be the distribution (or an approximate distribution) of the query corresponding to the teacher model; for example, the preset type distribution can be a Gaussian distribution.
[0228] The above optimization of the query corresponding to the student model can be called inner-level optimization. The following is a specific illustration of inner-level optimization:
[0229] According to the definition of self-information, H(q) S This can be expanded as follows:
[0230]
[0231] The query distribution in the teacher model tends to follow a Gaussian distribution, so the inner layer optimization problem can be solved by aligning the distribution. To do this, query q can be calculated. S The average value μ(q) S ) and variance σ(q) S The query distribution is as follows: Then, the self-information of the query in the student model can be written as follows:
[0232]
[0233] when At that time, the above objectives Reaching its maximum value: Furthermore, due to biases in the query data of the student model, its mean and variance may be inaccurate. To address this issue, concepts from batch normalization can be used to add a learnable shift parameter. and scale parameter Scale and translate the query. Optimize the query for the student model as follows:
[0234]
[0235] At this point, the maximum self-information of the query in the student model is Therefore, in the forward propagation, the optimized query can be obtained using the above formula. Next, further outer-layer optimization is performed (that is, the knowledge transfer from the teacher model to the student model is completed).
[0236] In one possible implementation, the first neural network includes a first backbone network, a first encoder, and a first decoder. During forward propagation, a first intermediate output can be obtained based on the target image through the first backbone network and the first encoder. The first decoder then processes the first query and the first intermediate output. The first processing result may include a detection box and the category corresponding to the image content within the detection box.
[0237] Minimizing conditional entropy requires a one-to-one match between the detection results of the student model and the teacher model, meaning that each detection box output by the student model needs to be mapped one-to-one with the detection box output by the teacher model. To determine the correspondence between the detection results of the student model and the teacher model, we can first determine the correspondence between the student model's detection results and the ground truth values of the image detection results.
[0238] Due to the discreteness of algorithm matching and the randomness of model training, ground-truth matching (i.e., matching the student model's output with the ground-truth of the image detection results) becomes a dynamic and unstable process. For example, the ground-truth of the image detection results may include 5 detection boxes, while the student model's detection results may include 8 detection boxes. This application proposes a foreground-aware query matching method to address this problem. Specifically, the ground-truth of the image detection results is matched with the detection results output by the student model. Detection boxes that match the ground-truth of the image detection results (e.g., detection boxes whose positional relationships meet preset conditions) are determined from the student model's output detection results. A one-to-one correspondence is established between the determined detection boxes and the ground-truth of the image detection results, that is, the detection boxes with more accurate foreground perception capabilities are selected from the student model's output detection boxes.
[0239] For example, the maximum overlap ratio can be found as:
[0240]
[0241] Where GloU(·) is the generalized intersection-union ratio, and each G i This reflects the overlap between the bounding boxes predicted by the student model and the ground truth bounding boxes of the i-th detection result. Then, high-quality student bounding boxes are retained.
[0242]
[0243] Here, T is a threshold used to control the proportion of distilled queries. After removing empty queries, the set of detection boxes for the student model can be obtained:
[0244]
[0245] In one possible implementation, target detection can be performed on the target image based on the first query and the first neural network to obtain information on M first detection boxes. Only some of the M first detection boxes may correspond to the detection boxes included in the ground truth of the detection result. Specifically, the ground truth of the detection result corresponding to the target image can be obtained, and the ground truth of the detection result includes multiple second detection boxes. Based on the positional relationship between the first and second detection boxes, M1 first detection boxes are determined from the M first detection boxes. Each of the M1 first detection boxes corresponds to a second detection box, and the positional relationship between each first detection box and its corresponding second detection box satisfies a first preset condition, which is related to the overlap between the regions where the detection boxes are located (e.g., the overlap may be greater than a threshold).
[0246] In one possible implementation, the first query is the query corresponding to the M1 first detection boxes.
[0247] In one possible implementation, the second neural network includes a second backbone network, a second encoder, and a second decoder; a second intermediate output can be obtained based on the target image through the second backbone network and the second encoder; the second query and the second intermediate output are processed by the second decoder. Specifically, the detection boxes output by each student model that establishes a matching relationship with the ground truth can be matched one-to-one with the detection boxes output by the teacher model, and the output of the teacher model after matching can be the second processing result described above.
[0248] In one possible implementation, the positional relationship between each detection box output by the teacher model and the detection boxes output by each student model (detection boxes that are matched with the ground truth) can be determined, and an association relationship can be established between detection boxes whose positional relationship meets a preset condition.
[0249] In one possible implementation, target detection can be performed on the target image based on the second query and the second neural network to obtain information on N third detection boxes; based on the positional relationship between each first detection box and the third detection box in the M1 first detection boxes, M1 third detection boxes are determined from the N third detection boxes, each first detection box in the M1 first detection boxes corresponds to a second detection box, and the positional relationship between each first detection box and the corresponding third detection box in the M1 first detection boxes satisfies a second preset condition, which is related to the overlap between the regions where the detection boxes are located (for example, it can be the region with the largest overlap).
[0250] In one possible implementation, the obtained second query is the query corresponding to the M1 third detection boxes.
[0251] Using the above method, a correspondence can be established between the detection results output by the student model and the detection results output by the teacher model. Similarly, based on the correspondence between the detection results, the correspondence between the queries of the student model and the queries of the teacher model can be determined (that is, the one-to-one correspondence between each query in the first query and each query in the second query). Then, a loss can be constructed based on the queries with corresponding relationships.
[0252] 602. Determine a first loss based on the first query and the second query; the first loss indicates minimizing the information difference between the second query and the first query.
[0253] Step 602 can also be called upper-level optimization. In upper-level optimization, the information difference between the student model and the teacher model can be minimized. Optionally, the information difference can be represented by the L2 norm or the conditional entropy, which is a distance function.
[0254] For example, it can be used Represents the ground-truth label, where N gt It is the number of prospects. and Let represent the category and bounding box of the i-th object, respectively. For the student model, each query is associated with one object. Therefore, we can obtain N objects for the teacher model (teacher) and the student model (student), denoted as ... and
[0255] For the query of the j-th student model, the corresponding query of the teacher model is:
[0256]
[0257] Due to differences in network structure, query sequences exhibit differences in importance and order. The above method enables matching based on importance.
[0258] Finally, after correction, the outer layer optimization problem becomes:
[0259]
[0260] The above formula is difficult to optimize; therefore, it can be solved by minimizing... and The optimal solution is obtained by using the L2 norm between the two values; therefore, the loss function of distribution-corrected distillation can be written as:
[0261]
[0262] In one possible implementation, a second loss can be constructed based on the difference between the ground truth of the image detection results and the information of the first detection box with a corresponding relationship.
[0263] For example, the overall training loss function of the model can be referred to in the following formula, where It is a common detection loss for tasks such as coordinate regression, where λ is a trade-off hyperparameter:
[0264]
[0265] 603. Update the first neural network and the first query based on the first loss.
[0266] This application provides a data processing method, comprising: obtaining a first query corresponding to a first neural network and a second query corresponding to a second neural network; the first query is a query obtained by maximizing the information entropy of the query corresponding to the first neural network; the first neural network is a model obtained by compressing the second neural network; the first neural network and the second neural network are used for object detection; determining a first loss based on the first query and the second query; the first loss indicates minimizing the information difference between the second query and the first query; and updating the first neural network and the first query based on the first loss. This application improves the model accuracy of the compressed model by minimizing the information gap between the query queries of the student model and the teacher model, thereby minimizing the information gap between the student model and the teacher model.
[0267] In this embodiment, the information bottleneck optimization problem of the student model is modeled as a two-layer optimization model, and a two-layer distribution correction distillation module is proposed. In the inner layer optimization, guided by Gaussian distribution, the student model's queries are distributed and aligned (DA) to maximize the self-information of the student queries. In the outer layer optimization, a novel foreground-aware query matching (FQM) method is introduced to filter out low-quality student queries. By performing precise one-to-one query matching between students and teachers, the conditional entropy between student and teacher queries is minimized, effectively transferring teacher information into the student model. Through training optimization, the technical solution of this embodiment can effectively improve the accuracy of the student model.
[0268] A schematic diagram of the process of an embodiment of this application can be shown as follows: Figure 7 As shown, a method called Distribution Corrected Distillation (DRD) is proposed to correct the query information of the student model to the query information corresponding to the teacher model, thereby eliminating the distribution difference of the compressed query information and solving the information distortion problem of the attention mechanism in the model compression process.
[0269] Specifically, a full-precision model is used as the teacher model, and a compressed model is used as the student model. The information bottleneck optimization problem of the student model is modeled as a two-layer optimization model. The two-layer optimization problem includes an inner layer optimization that maximizes the self-information of student queries and an outer layer optimization that minimizes the conditional entropy between student and teacher queries, thereby eliminating the distributional differences of queries between the student and teacher models. In the inner layer optimization, a Gaussian distribution is used as the guiding distribution, and the self-information of student queries is maximized by aligning the query distribution during forward propagation. In the outer layer optimization, a novel foreground-aware query matching method is introduced to filter out low-quality student queries and perform precise one-to-one query matching between students and teachers, minimizing the gap between student and teacher queries to effectively transfer teacher information to the student model. In the inner layer optimization, the mean and variance of student model queries are calculated. Based on the known distribution of queries, the optimal query value when the self-information entropy of student queries is maximized can be obtained. At the same time, since there is a certain bias in the query data, the idea of batch normalization is adopted to add learnable scale and shift parameters to correct the optimal student query. In the outer layer optimization, it is necessary to minimize the information gap between student and teacher queries, which requires a one-to-one match between student and teacher queries. However, due to the discreteness of algorithm matching and the randomness of model training, ground-truth matching becomes a dynamic and unstable process. Therefore, the ground truth detection results of the image are matched with the detection results output by the student model, and the detection results output by the student model that are higher than a set threshold are retained. Then, the sets of student and teacher objects can be obtained, completing the one-to-one matching of student and teacher objects. The embodiments of this application use distribution alignment and foreground-aware query matching methods to solve the two-layer optimization problem, effectively solving the problem of information distortion after compression of the multi-head attention module in the baseline model.
[0270] The beneficial effects of the embodiments of this application will be described below with reference to specific experiments:
[0271] This application's embodiments train Q-DETR based on two mainstream models, DETR and SMCA-DETR. The quantized student backbone network is pre-trained using the ImageNet ILSVRC12 dataset. Using the AdamW optimizer, with an initial learning rate of 1e-4, weight decay of 1e-4, and a batch size of 16, Q-DETR is trained on the VOC and COCO datasets for 300 / 500 epochs respectively, with the learning rate divided by 10 at 200 / 400 epochs. Q-SMCA-DETR is trained on the VOC / COCO datasets for 50 epochs respectively, with the learning rate multiplied by 0.1 at 40 epochs. SMCA-DETR-R101 with a full-precision DETR-R101 and VGG16 backbone is selected as the teacher model.
[0272] First, extensive comparative experiments were conducted based on the full-precision DETR model and the baseline quantization model to verify the effectiveness of the module proposed in this application's embodiments. Furthermore, numerous comparative experiments were performed to compare the detection accuracy of this application's embodiments with baseline and LSQ methods under the same framework on different bit networks.
[0273] Table 1
[0274]
[0275] The results of the proposed method in the object detection task are shown in Table 1. As can be seen from Table 1, the distribution alignment (DA, which is the inner and outer optimization process described above) and foreground-aware query matching (FQM, the matching method between the query of the student model and the query of the teacher model) proposed in this application can improve detection accuracy when used alone, and their combined use further significantly improves model performance. For example, compared to the 2-bit baseline model, using DA alone results in higher accuracy. 50 Increased by 1.9% when using FQM alone, AP 50 This represents a 5.2% improvement. With the combination of DA and FQM, the performance improvement reaches 6.7%.
[0276] Table 2
[0277]
[0278] Extensive experiments were conducted on the VOC dataset using the DETR-R50 and SMCA-DETR-R50 networks, and compared with 2 / 3 / 4-bit baselines and LSQ based on the same framework. The results are shown in Table 2, demonstrating the performance advantage of the Q-DETR proposed in this application. Compared with the 2 / 3 / 4-bit quantization baseline and LSQ, DETR-R50 / SMCA-DETR-R50 outperforms the models in the three bit ranges by 6.3%-5.3%-4.7% and 6.3%-5.1%-3.8%, respectively.
[0279] Reference Figure 8 , Figure 8 This is a schematic diagram of the structure of a data processing apparatus provided in an embodiment of this application, such as... Figure 8 As shown in the figure, an embodiment of this application provides a data processing apparatus 800, comprising:
[0280] The acquisition module 801 is used to acquire a first query corresponding to a first neural network and a second query corresponding to a second neural network; the first query is a query obtained by maximizing the information entropy of the query corresponding to the first neural network; the first neural network is a model obtained by compressing the second neural network; the first neural network and the second neural network are used for target detection;
[0281] The description of the acquisition module 801 can be found in the description of step 601 in the above embodiments, and will not be repeated here.
[0282] Processing module 802 is configured to determine a first loss based on the first query and the second query; the first loss indicates minimizing the information difference between the second query and the first query;
[0283] Update the first neural network and the first query based on the first loss.
[0284] The description of the processing module 802 can be found in the descriptions of steps 602 and 603 in the above embodiments, and will not be repeated here.
[0285] In one possible implementation, the first neural network is obtained by quantizing the second neural network with 2, 3, or 4 bits.
[0286] In one possible implementation, the processing module is further configured to:
[0287] Based on the first query and the first neural network, target detection is performed on the target image to obtain information on M first detection boxes;
[0288] Obtain the ground value of the detection result corresponding to the target image, wherein the ground value of the detection result includes multiple second detection boxes;
[0289] Based on the positional relationship between the first detection box and the second detection box, M1 first detection boxes are determined from the M first detection boxes. Each of the M1 first detection boxes corresponds to a second detection box, and the positional relationship between each of the M1 first detection boxes and the corresponding second detection box satisfies a first preset condition. The first preset condition is related to the degree of overlap between the areas where the detection boxes are located.
[0290] The first query is the query corresponding to the M1 first detection boxes.
[0291] In one possible implementation, the processing module is further configured to:
[0292] Based on the second query and the second neural network, target detection is performed on the target image to obtain information of N third detection boxes;
[0293] Based on the positional relationship between each first detection frame and the third detection frame in the M1 first detection frames, M1 third detection frames are determined from the N third detection frames. Each first detection frame in the M1 first detection frames corresponds to a second detection frame, and the positional relationship between each first detection frame in the M1 first detection frames and the corresponding third detection frame satisfies a second preset condition. The second preset condition is related to the degree of overlap between the areas where the detection frames are located.
[0294] The second query is the query corresponding to the M1 third detection boxes.
[0295] In one possible implementation, the information of the first detection box and the third detection box includes the position, size, and category of the image content of the detection box.
[0296] In one possible implementation, the first query is obtained by adjusting the distribution of the query corresponding to the first neural network to a preset type of distribution.
[0297] In one possible implementation, the distribution of the preset type is a Gaussian distribution.
[0298] In one possible implementation, the information difference is represented by the L2 norm or conditional entropy.
[0299] In one possible implementation, the first neural network includes a first backbone network, a first encoder, and a first decoder; the second neural network includes a second backbone network, a second encoder, and a second decoder.
[0300] The processing module is specifically used for:
[0301] Based on the target image, a first intermediate output is obtained through the first backbone network and the first encoder;
[0302] The first decoder processes the first query and the first intermediate output.
[0303] Based on the target image, a second intermediate output is obtained through the second backbone network and the second encoder;
[0304] The second decoder processes the second query and the second intermediate output.
[0305] The following describes an execution device provided in an embodiment of this application. Please refer to [link / reference]. Figure 9 , Figure 9 This is a schematic diagram of an execution device provided in an embodiment of this application. The execution device 900 can specifically be a virtual reality (VR) device, a mobile phone, a tablet, a laptop, a smart wearable device, a monitoring data processing device, or a server, etc., and is not limited thereto. Specifically, the execution device 900 includes: a receiver 901, a transmitter 902, a processor 903, and a memory 904 (wherein the execution device 900 may have one or more processors 903). Figure 9 (Taking a processor as an example), processor 903 may include application processor 9031 and communication processor 9032. In some embodiments of this application, receiver 901, transmitter 902, processor 903 and memory 904 may be connected via a bus or other means.
[0306] Memory 904 may include read-only memory and random access memory, and provides instructions and data to processor 903. A portion of memory 904 may also include non-volatile random access memory (NVRAM). Memory 904 stores processor and operation instructions, executable modules, or data structures, or subsets thereof, or extended sets thereof, wherein the operation instructions may include various operation instructions for implementing various operations.
[0307] Processor 903 controls the operation of the execution device. In specific applications, the various components of the execution device are coupled together through a bus system, which may include not only the data bus, but also power buses, control buses, and status signal buses. However, for clarity, all buses are referred to as the bus system in the diagram.
[0308] The methods disclosed in the embodiments of this application can be applied to or implemented by the processor 903. The processor 903 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 903 or by instructions in software form. The processor 903 can be a general-purpose processor, a digital signal processor (DSP), a microprocessor, or a microcontroller, and may further include an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The processor 903 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 904, and processor 903 reads the information from memory 904 and, in conjunction with its hardware, completes the steps of the above method.
[0309] Receiver 901 can be used to receive input digital or character information, and to generate signal inputs related to the settings and function control of the execution device. Transmitter 902 can be used to output digital or character information through the first interface; transmitter 902 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; transmitter 902 may also include a display device such as a display screen.
[0310] This application also provides a training device; please refer to [link / reference]. Figure 10 , Figure 10This is a schematic diagram of a training device provided in an embodiment of this application. Specifically, the training device 1000 is implemented by one or more servers. The training device 1000 can vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 1010 (e.g., one or more processors) and memory 1032, and one or more storage media 1030 (e.g., one or more mass storage devices) for storing application programs 1042 or data 1044. The memory 1032 and storage media 1030 can be temporary or persistent storage. The program stored in the storage media 1030 may include one or more modules (not shown in the diagram), each module may include a series of instruction operations on the training device. Furthermore, the CPU 1010 may be configured to communicate with the storage media 1030 and execute the series of instruction operations in the storage media 1030 on the training device 1000.
[0311] The training device 1000 may also include one or more power supplies 1026, one or more wired or wireless network interfaces 1050, one or more input / output interfaces 1058; or one or more operating systems 1041, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0312] In this embodiment, the central processing unit 1010 is used to perform actions related to model training in the above embodiments.
[0313] This application also provides a computer program product that, when run on a computer, causes the computer to perform steps as performed by the aforementioned execution device, or causes the computer to perform steps as performed by the aforementioned training device.
[0314] This application also provides a computer-readable storage medium storing a program for signal processing, which, when run on a computer, causes the computer to perform steps as performed by the aforementioned execution device, or causes the computer to perform steps as performed by the aforementioned training device.
[0315] The execution device, training device, or terminal device provided in this application embodiment can specifically be a chip. The chip includes a processing unit and a communication unit. The processing unit can be, for example, a processor, and the communication unit can be, for example, an input / output interface, pins, or circuits. The processing unit can execute computer execution instructions stored in the storage unit to cause the chip within the execution device to execute the data processing method described in the above embodiments, or to cause the chip within the training device to execute the data processing method described in the above embodiments. Optionally, the storage unit can be a storage unit within the chip, such as a register or cache. Alternatively, the storage unit can be a storage unit located outside the chip within the wireless access device, such as a read-only memory (ROM) or other types of static storage devices capable of storing static information and instructions, such as random access memory (RAM).
[0316] For details, please refer to Figure 11 , Figure 11 This is a schematic diagram of a chip provided in an embodiment of this application. The chip can be represented as a neural network processor (NPU) 1100. The NPU 1100 is mounted as a coprocessor on the host CPU, and tasks are assigned by the host CPU. The core part of the NPU is the arithmetic circuit 1103, which is controlled by the controller 1104 to extract matrix data from the memory and perform multiplication operations.
[0317] In some implementations, the arithmetic circuit 1103 internally includes multiple processing engines (PEs). In some implementations, the arithmetic circuit 1103 is a two-dimensional pulsating array. The arithmetic circuit 1103 can also be a one-dimensional pulsating array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 1103 is a general-purpose matrix processor.
[0318] For example, suppose we have an input matrix A, a weight matrix B, and an output matrix C. The arithmetic circuit retrieves the corresponding data of matrix B from the weight memory 1102 and caches it in each PE of the arithmetic circuit. The arithmetic circuit retrieves the data of matrix A from the input memory 1101 and performs matrix operations with matrix B. The partial result or the final result of the obtained matrix is stored in the accumulator 1108.
[0319] Unified memory 1106 is used to store input and output data. Weight data is directly transferred to weight memory 1102 via Direct Memory Access Controller (DMAC) 1105. Input data is also transferred to unified memory 1106 via DMAC.
[0320] BIU stands for Bus Interface Unit, which is used for interaction between the AXI bus and the DMAC and the Instruction Fetch Buffer (IFB) 1109.
[0321] The Bus Interface Unit (BIU) 1110 is used by the instruction fetch memory 1109 to fetch instructions from external memory, and also by the memory access controller 1105 to fetch the original data of the input matrix A or the weight matrix B from external memory.
[0322] The DMAC is mainly used to move input data from external memory DDR to unified memory 1106, or to weight data to weight memory 1102, or to input data to input memory 1101.
[0323] The vector computation unit 1107 includes multiple processing units that, when needed, further process the output of the computation circuit 1103, such as vector multiplication, vector addition, exponential operations, logarithmic operations, size comparisons, etc. It is mainly used for computation in non-convolutional / fully connected layers of neural networks, such as batch normalization, pixel-level summation, and upsampling of feature planes.
[0324] In some implementations, vector computation unit 1107 can store the processed output vector in unified memory 1106. For example, vector computation unit 1107 can apply a linear function, or a nonlinear function, to the output of computation circuit 1103, such as linear interpolation of feature planes extracted by convolutional layers, or, for example, a vector of accumulated values, to generate activation values. In some implementations, vector computation unit 1107 generates normalized values, pixel-level summed values, or both. In some implementations, the processed output vector can be used as activation input to computation circuit 1103, for example, for use in subsequent layers of the neural network.
[0325] The instruction fetch buffer 1109 connected to the controller 1104 is used to store the instructions used by the controller 1104;
[0326] Unified memory 1106, input memory 1101, weight memory 1102, and instruction fetch memory 1109 are all on-chip memories. External memory is proprietary to this NPU hardware architecture.
[0327] The processor mentioned above can be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits used to control the execution of the above program.
[0328] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.
[0329] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0330] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.
[0331] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
Claims
1. A data processing method, characterized in that, The method includes: Obtain the first query corresponding to the first neural network and the second query corresponding to the second neural network; the first query is the query obtained by maximizing the information entropy of the query corresponding to the first neural network; the first neural network is a model obtained by compressing the second neural network; the first neural network and the second neural network are used for target detection; the first query is the query corresponding to M1 first detection boxes out of M first detection boxes; the M first detection boxes are obtained by performing target detection on the target image based on the first query and the first neural network; the positional relationship between each first detection box in the M1 first detection boxes and the corresponding second detection boxes in the multiple second detection boxes satisfies a first preset condition, the first preset condition The overlap between the regions where the detection boxes are located is related to the degree of overlap; the plurality of second detection boxes belong to the ground truth of the detection result corresponding to the target image; the second query is the query corresponding to M1 third detection boxes; the M1 third detection boxes are determined from N third detection boxes according to the positional relationship between each first detection box and the third detection box in the M1 first detection boxes; the information of the N third detection boxes is obtained by performing target detection on the target image according to the second query and the second neural network; each first detection box in the M1 first detection boxes corresponds to a second detection box, and the positional relationship between each first detection box in the M1 first detection boxes and the corresponding third detection box satisfies a second preset condition, the second preset condition being related to the degree of overlap between the regions where the detection boxes are located; A first loss is determined based on the first query and the second query; the first loss indicates how to minimize the information difference between the second query and the first query. Update the first neural network and the first query based on the first loss.
2. The method according to claim 1, characterized in that, The first neural network is obtained by quantizing the second neural network with 2, 3, or 4 bits.
3. The method according to claim 1 or 2, characterized in that, The information of the first detection box and the third detection box includes the position, size, and category of the image content of the detection box.
4. The method according to claim 1 or 2, characterized in that, The first query is obtained by adjusting the distribution of the query corresponding to the first neural network to a preset type of distribution.
5. The method according to claim 4, characterized in that, The preset type of distribution is a Gaussian distribution.
6. The method according to claim 1 or 2, characterized in that, The information differences are represented by the L2 norm or conditional entropy.
7. The method according to claim 1 or 2, characterized in that, The first neural network includes a first backbone network, a first encoder, and a first decoder; the second neural network includes a second backbone network, a second encoder, and a second decoder. The step of performing target detection on the target image based on the first query and the first neural network includes: Based on the target image, a first intermediate output is obtained through the first backbone network and the first encoder; The first decoder processes the first query and the first intermediate output. The step of performing target detection on the target image based on the second query and the second neural network includes: Based on the target image, a second intermediate output is obtained through the second backbone network and the second encoder; The second decoder processes the second query and the second intermediate output.
8. A data processing method, characterized in that, The method includes: Acquire images; The image is subjected to target detection using the updated first neural network and the updated first query obtained as described in any one of claims 1 to 7, and the processing result is obtained.
9. A data processing apparatus, characterized in that, The device includes: The acquisition module is used to acquire a first query corresponding to a first neural network and a second query corresponding to a second neural network; the first query is a query obtained by maximizing the information entropy of the query corresponding to the first neural network; the first neural network is a model obtained by compressing the second neural network; the first neural network and the first neural network are used for target detection; the first query is the query corresponding to M1 first detection boxes out of M first detection boxes; the M first detection boxes are obtained by performing target detection on the target image based on the first query and the first neural network; the positional relationship between each first detection box in the M1 first detection boxes and the corresponding second detection boxes in the plurality of second detection boxes satisfies a first preset condition, the first preset condition... The conditions are related to the overlap between the regions where the detection boxes are located; the plurality of second detection boxes belong to the true value of the detection result corresponding to the target image; the second query is the query corresponding to M1 third detection boxes; the M1 third detection boxes are determined from N third detection boxes according to the positional relationship between each first detection box and the third detection box in the M1 first detection boxes; the information of the N third detection boxes is obtained by performing target detection on the target image according to the second query and the second neural network; each first detection box in the M1 first detection boxes corresponds to a second detection box, and the positional relationship between each first detection box in the M1 first detection boxes and the corresponding third detection box satisfies a second preset condition, the second preset condition being related to the overlap between the regions where the detection boxes are located; The processing module is configured to determine a first loss based on the first query and the second query; the first loss indicates minimizing the information difference between the second query and the first query; Update the first neural network and the first query based on the first loss.
10. The apparatus according to claim 9, characterized in that, The first neural network is obtained by quantizing the second neural network with 2, 3, or 4 bits.
11. The apparatus according to claim 9 or 10, characterized in that, The information of the first detection box and the third detection box includes the position, size, and category of the image content of the detection box.
12. The apparatus according to claim 9 or 10, characterized in that, The first query is obtained by adjusting the distribution of the query corresponding to the first neural network to a preset type of distribution.
13. The apparatus according to claim 12, characterized in that, The preset type of distribution is a Gaussian distribution.
14. The apparatus according to claim 9 or 10, characterized in that, The information differences are represented by the L2 norm or conditional entropy.
15. The apparatus according to claim 9 or 10, characterized in that, The first neural network includes a first backbone network, a first encoder, and a first decoder; the second neural network includes a second backbone network, a second encoder, and a second decoder. The processing module is specifically used for: Based on the target image, a first intermediate output is obtained through the first backbone network and the first encoder; The first decoder processes the first query and the first intermediate output. Based on the target image, a second intermediate output is obtained through the second backbone network and the second encoder; The second decoder processes the second query and the second intermediate output.
16. A data processing apparatus, characterized in that, The device includes: The acquisition module is used to acquire images; The processing module is configured to perform object detection on the image using the updated first neural network and the updated first query obtained as described in any one of claims 1 to 7, and obtain a processing result.
17. A computer storage medium, characterized in that, The computer storage medium stores one or more instructions that, when executed by one or more computers, cause the one or more computers to perform the operation of the method according to any one of claims 1 to 7.
18. A computer program product, characterized in that, Includes computer-readable instructions that, when executed on a computer device, cause the computer device to perform the method as described in any one of claims 1 to 7.
19. A system comprising at least one processor and at least one memory; the processor and the memory are connected via a communication bus and communicate with each other. The at least one memory is used to store code; The at least one processor is used to execute the code to perform the method as described in any one of claims 1 to 7.