Data processing method and apparatus
By minimizing the information difference between the student model and the teacher model, and using prospect-aware query matching to optimize query distribution, the efficiency and accuracy problems of the object detection model when deploying on resource-limited platforms are solved, and efficient and accurate object detection is achieved .
Patent Information
- Application Number
- PCT/CN2024/094605
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-05-29
- Filing Date
- 2024-05-22
- Publication Date
- 2024-12-05
AI Technical Summary
When the existing object detection model is deployed on a resource-limited platform, due to the large number of parameters and high calculations, the inference efficiency is low, and the model accuracy decreases after quantization, especially when quantized to ultra-low levels.
By minimizing the information difference between the student model and the teacher model, using the methods of information entropy maximization and conditional entropy minimization, the query query of the student model is updated, the accuracy of the compressed model is improved, and the detection result correspondence is established through foreground-aware query matching Relationship, optimize query distribution to improve detection performance.
It effectively improves the accuracy of the compressed visual detection model, significantly improves the inference performance of the model on resource-limited platforms, reduces information distortion, and improves the accuracy of detection results.
Smart Images

Figure CN2024094605_05122024_PF_FP_ABST
Abstract
Description
A data processing method and device thereof
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on May 29, 2023, with application number 202310621628.2 and invention name “A data processing method and device thereof”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of artificial intelligence, and in particular to a data processing method and device thereof. Background Art
[0003] Object detection aims to locate and classify visual objects from an input image. In early work, this task was often achieved by combining convolutional neural networks to process regional features of the input image. Recently, transformer-based object detectors have been proposed, in which object detection is regarded as a collective prediction task and can be trained end-to-end. They greatly simplify the object detection task, and users do not need to perform tedious adjustments to hand-designed components, such as the size and scale of anchors. Although object detectors have excellent capabilities, they usually have a large number of parameters and floating-point operations (FLOPs). For example, in the object detector (DETR-R50) with ResNet-50 as the backbone network, the 39.8M parameters occupy 159MB of memory and consume 86GFLOPs of computation. The large amount of memory and computing power required during inference limits the deployment of the model on resource-limited platforms.
[0004] 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 and enabling efficient inference. However, the model parameters before and after compression vary significantly, resulting in a decrease in model accuracy. In particular, performance degrades dramatically when quantized to ultra-low bits (4 bits or lower).
[0005] Summary of the Invention
[0006] This application provides a data processing method that can improve the model accuracy of a compressed visual detection model.
[0007] In a first aspect, the present 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 first neural network are used for target 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.
[0008] This application minimizes the information gap between the student model and the teacher model by minimizing the information gap between the queries of the student model and the teacher model, thereby improving the model accuracy of the compression model.
[0009] For example, the first neural network can be a model obtained by quantizing the second neural network, or it can be a network that is smaller and faster than the second neural network obtained by pruning, structural redesign, etc.
[0010] In a possible implementation, the first neural network is obtained by quantizing the second neural network by 2, 3 or 4 bits.
[0011] In a possible implementation, the method further includes: performing target detection on the target image according to the first query and the first neural network to obtain information of M first detection frames; obtaining a true value of the detection result corresponding to the target image, the true value of the detection result including multiple second detection frames; determining M1 first detection frames from the M first detection frames according to the positional relationship between the first detection frame and the second detection frame, 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 second detection frame satisfies a first preset condition, and the first preset condition is related to the degree of overlap between the areas where the detection frames are located; the first query is the query corresponding to the M1 first detection frames.
[0012] In a possible implementation, the method further includes: performing target detection on the target image according to the second query and the second neural network to obtain information of N third detection frames; determining M1 third detection frames from the N third detection frames according to the positional relationship between each first detection frame and the third detection frame in the M1 first 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, and the second preset condition is related to the degree of overlap between the areas where the detection frames are located; the second query is the query corresponding to the M1 third detection frames.
[0013] Minimizing conditional entropy requires a one-to-one match between the detection results of the student model and the teacher model. This means that each detection box output by the student model must correspond 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 true value of the image detection results.
[0014] Due to the discreteness of algorithm matching and the randomness of model training, the matching of the true value ground-truth (that is, the matching between the output of the student model and the true value of the image detection result of the image) becomes a dynamic and unstable process. For example, the true value of the image detection result includes 5 detection frames, and the detection result of the student model includes 8 detection frames. The embodiment of the present application proposes foreground-aware query matching to solve this problem. Specifically, the true value of the image detection result is matched with the detection result output by the student model, and the detection frame that can be matched with the true value of the image detection result (for example, the detection frame whose position relationship meets the preset conditions) is determined from the detection result output by the student model, and a one-to-one correspondence is established between the determined detection frame and the true value of the image detection result, that is, the detection frame with more accurate foreground perception ability in the detection frame output by the student model is selected.
[0015] In a possible implementation, the information of the first detection frame and the third detection frame includes the position and size of the detection frame and the category corresponding to the image content of the detection frame.
[0016] In a possible implementation, the first query is obtained by adjusting the distribution of queries corresponding to the first neural network to a preset type of distribution.
[0017] In a possible implementation, the preset type of distribution is a Gaussian distribution.
[0018] In a possible implementation, the information difference is represented by L2 norm or conditional entropy.
[0019] 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;
[0020] The performing target detection on the target image according to the first query and the first neural network includes:
[0021] Obtain a first intermediate output according to the target image through the first backbone network and the first encoder;
[0022] Processing the first query and the first intermediate output through the first decoder;
[0023] The performing target detection on the target image according to the second query and the second neural network includes:
[0024] Obtain a second intermediate output according to the target image through the second backbone network and the second encoder;
[0025] The second query and the second intermediate output are processed by the second decoder.
[0026] In a second aspect, the present application provides a data processing method, the method comprising:
[0027] Acquire images;
[0028] Using the updated first neural network and the updated first query obtained in any one of the first aspects, target detection is performed on the image to obtain a processing result.
[0029] In a third aspect, the present application provides a data processing device, comprising:
[0030] an acquisition module, configured 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;
[0031] a processing module, configured to determine a first loss based on the first query and the second query, wherein the first loss indicates minimizing an information difference between the second query and the first query;
[0032] Update the first neural network and the first query according to the first loss.
[0033] In a possible implementation, the first neural network is obtained by quantizing the second neural network by 2, 3 or 4 bits.
[0034] In a possible implementation, the processing module is further configured to:
[0035] Performing target detection on the target image according to the first query and the first neural network to obtain information of M first detection boxes;
[0036] Obtaining a true value of a detection result corresponding to the target image, where the true value of the detection result includes a plurality of second detection frames;
[0037] Determine, based on a positional relationship between the first detection frame and the second detection frame, M1 first detection frames from the M first detection frames, where each first detection frame in the M1 first detection frames corresponds to a second detection frame, and a positional relationship between each first detection frame in the M1 first detection frames and the corresponding second detection frame satisfies a first preset condition, where the first preset condition is related to a degree of overlap between regions where the detection frames are located;
[0038] The first query is the query corresponding to the M1 first detection boxes.
[0039] In a possible implementation, the processing module is further configured to:
[0040] Performing target detection on the target image according to the second query and the second neural network to obtain information of N third detection boxes;
[0041] determining M1 third detection frames from the N third detection frames based on a positional relationship between each first detection frame in the M1 first detection frames and the third detection frame, wherein each first detection frame in the M1 first detection frames corresponds to a second detection frame, and a positional relationship between each first detection frame in the M1 first detection frames and the corresponding third detection frame satisfies a second preset condition, where the second preset condition is related to a degree of overlap between regions where the detection frames are located;
[0042] The second query is a query corresponding to the M1 third detection boxes.
[0043] In a possible implementation, the information of the first detection frame and the third detection frame includes the position and size of the detection frame and the category corresponding to the image content of the detection frame.
[0044] In a possible implementation, the first query is obtained by adjusting the distribution of queries corresponding to the first neural network to a preset type of distribution.
[0045] In a possible implementation, the preset type of distribution is a Gaussian distribution.
[0046] In a possible implementation, the information difference is represented by L2 norm or conditional entropy.
[0047] 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;
[0048] The processing module is specifically used to:
[0049] Obtain a first intermediate output according to the target image through the first backbone network and the first encoder;
[0050] Processing the first query and the first intermediate output through the first decoder;
[0051] Obtain a second intermediate output according to the target image through the second backbone network and the second encoder;
[0052] The second query and the second intermediate output are processed by the second decoder.
[0053] In a fourth aspect, the present application provides a data processing device, comprising:
[0054] An acquisition module, used for acquiring images;
[0055] A processing module is used to perform target detection on the image using the updated first neural network and the updated first query obtained in the first aspect to obtain a processing result.
[0056] In the fifth aspect, an embodiment of the present application provides a data processing device, which may include a memory, a processor, and a bus system, wherein the memory is used to store programs, and the processor is used to execute the programs in the memory to perform the first aspect and any optional method thereof, or the second aspect and any optional method thereof.
[0057] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer-readable storage medium is run on a computer, the computer executes the above-mentioned first aspect and any optional method thereof, or the above-mentioned second aspect and any optional method thereof.
[0058] In a seventh aspect, an embodiment of the present application provides a computer program which, when executed on a computer, enables the computer to execute the above-mentioned first aspect and any optional method thereof, or the above-mentioned second aspect and any optional method thereof.
[0059] In an eighth aspect, the present application provides a chip system comprising a processor for supporting an execution device or a training device in implementing the functions described in the aforementioned aspects, such as transmitting or processing data or information involved in the aforementioned methods. In one possible design, the chip system further comprises a memory for storing program instructions and data necessary for the execution device or the training device. The chip system may be comprised of a single chip or may include a chip and other discrete components. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] FIG1A is a schematic diagram of a structure of an artificial intelligence main framework;
[0061] Figures 1B to 1D are schematic diagrams of the application framework of this application;
[0062] Figure 2 is a schematic diagram of the application framework of this application;
[0063] Figure 3 is a schematic diagram of the application framework of this application;
[0064] Figure 4 is a schematic diagram of the application framework of this application;
[0065] FIG5A is a schematic diagram of an application scenario of the present application;
[0066] Figures 5B to 5E are schematic diagrams of a network structure of the present application;
[0067] FIG6 is a flowchart of a data processing method provided in an embodiment of the present application;
[0068] FIG7 is a schematic diagram of a process flow provided in an embodiment of the present application;
[0069] FIG8 is a schematic structural diagram of a data processing device provided in an embodiment of the present application;
[0070] FIG9 is a schematic diagram of a structure of an execution device provided in an embodiment of the present application;
[0071] FIG10 is a schematic diagram of a structure of a training device provided in an embodiment of the present application;
[0072] FIG11 is a schematic diagram of the structure of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0073] The following describes the embodiments of the present invention in conjunction with the accompanying drawings. The terms used in the embodiments of the present invention are only used to explain the specific embodiments of the present invention, and are not intended to limit the present invention.
[0074] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0075] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, and this is merely a way of distinguishing the objects of the same attributes when describing them in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0076] First, let's describe the overall workflow of an AI system. See Figure 1A, which shows a schematic diagram of the main AI framework. This AI framework will be explained from two perspectives: the "intelligent information chain" (horizontal axis) and the "IT value chain" (vertical axis). The "intelligent information chain" reflects the entire process 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. Throughout this process, data undergoes a condensed journey from "data-information-knowledge-wisdom." The "IT value chain," spanning the underlying infrastructure of human intelligence, information (provided and processed by technology), and the system's industrial ecosystem, reflects the value that AI brings to the information technology industry.
[0077] (1) Infrastructure
[0078] Infrastructure provides computing power for AI systems, enabling communication with the outside world and supporting this through a foundational platform. External communication occurs through sensors; computing power is provided by intelligent chips (CPUs, NPUs, GPUs, ASICs, FPGAs, and other hardware accelerators). The foundational platform includes a distributed computing framework and network-related platform guarantees and support, including cloud storage and computing, and interconnected networks. For example, sensors communicate with the outside world to acquire data, which is then fed into the intelligent chips within the distributed computing system provided by the foundational platform for computation.
[0079] (2) Data
[0080] Data above the infrastructure layer represents data sources for AI. This data includes graphics, images, voice, and text, as well as IoT data from traditional devices. This includes business data from existing systems and sensor data such as force, displacement, liquid level, temperature, and humidity.
[0081] (3) Data processing
[0082] Data processing generally includes data training, machine learning, deep learning, search, reasoning, decision-making, etc.
[0083] Among them, machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, and training.
[0084] Reasoning refers to the process of simulating human intelligent reasoning in computers or intelligent systems, using formalized information to perform machine thinking and solve problems based on reasoning control strategies. Typical functions are search and matching.
[0085] Decision-making refers to the process of making decisions after intelligent information is reasoned, and usually provides functions such as classification, sorting, and prediction.
[0086] (4) General ability
[0087] After the data has undergone the data processing mentioned above, some general capabilities can be further formed based on the results of the data processing, such as algorithms or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.
[0088] (5) Smart products and industry applications
[0089] Smart products and industry applications refer to the products and applications of artificial intelligence systems in various fields. They are the encapsulation of the overall artificial intelligence solution, which productizes intelligent information decision-making and realizes practical application. Its application areas mainly include: smart terminals, smart transportation, smart medical care, autonomous driving, smart cities, etc.
[0090] This application can be applied to the field of image processing in the field of artificial intelligence. Taking image processing as an example, the following will introduce multiple application scenarios that have been implemented in products.
[0091] First, the application scenario of this application is introduced.
[0092] This application can be applied to, but is not limited to, applications with image processing capabilities (hereinafter referred to as image processing applications) or cloud services provided by cloud-side servers, etc., which are described below:
[0093] 1. Image processing applications:
[0094] The product form of the embodiment of the present application can be an image processing application, in particular, an application with image segmentation function. The image processing application can be run on a terminal device or a cloud-side server.
[0095] In one possible implementation, an image processing application can perform tasks such as image segmentation or target detection based on an input image to obtain a processing result. The processing result can be an image segmentation result (mask area) or a detection result (for example, including a detection box and category).
[0096] 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 using the method provided in an embodiment of the present application, and present the processing results to the user (the presentation method may be, but is not limited to, display, saving, uploading to the cloud, etc.).
[0097] 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 send the image to a server on the cloud side. The server on the cloud side processes the image using a neural network model trained by the method provided in an embodiment of the present application, and transmits the processing result back to the terminal device. The terminal device can present the processing result to the user (the presentation method can be but is not limited to display, saving, uploading to the cloud side, etc.).
[0098] Next, the image processing application in the embodiment of this application is introduced from the perspective of functional architecture and product architecture that implements the functions.
[0099] Referring to FIG. 1B , FIG. 1B is a schematic diagram of the functional architecture of an image processing application in an embodiment of the present application:
[0100] In one possible implementation, as shown in FIG1B , an image processing application 102 may receive input parameters 101 (e.g., including an image) and generate a processing result 103. The image processing application 102 may be executed on, for example, at least one computer system and include computer code that, when executed by one or more computers, causes the computers to execute the method provided in the embodiments of the present application.
[0101] Referring to FIG. 1C , FIG. 1C is a schematic diagram of the physical architecture for running an image processing application in an embodiment of the present application:
[0102] Referring to FIG1C , FIG1C shows a schematic diagram of a system architecture. The system may include a terminal 100 and a server 200. The server 200 may include one or more servers (FIG1C illustrates one server as an example), and the server 200 may provide the method provided in the embodiments of the present application to one or more terminals.
[0103] Among them, an image processing application can be installed on the terminal 100. The above application and web page can provide an interface. The terminal 100 can receive relevant parameters entered by the user on the image processing interface and send the above parameters to the server 200. The server 200 can obtain the processing results based on the received parameters and return the processing results to the terminal 100.
[0104] 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 by itself without the need for the cooperation of the server, and the embodiments of the present application are not limited to this.
[0105] Next, the product form of the terminal 100 in FIG1C is described;
[0106] The terminal 100 in the embodiment of the present application can be a mobile phone, a tablet computer, a wearable device, an in-vehicle device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc., and the embodiment of the present application does not impose any restrictions on this.
[0107] FIG1D shows a schematic diagram of an optional hardware structure of the terminal 100 .
[0108] 1D , the terminal 100 may include components such as 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, and a power supply 190. Those skilled in the art will appreciate that FIG1D is merely an example of a terminal or multi-function device and does not limit the terminal or multi-function device. The terminal or multi-function device may include more or fewer components than shown, or may combine certain components or have different components.
[0109] The input unit 130 can be used to receive input digital or character information and generate key signal input related to user settings and function control of the portable multifunction device. Specifically, the input unit 130 may include a touch screen 131 (optional) and / or other input devices 132. The touch screen 131 can detect user touch operations on or near it (for example, operations performed on or near the touch screen using a finger, joint, stylus, or any other suitable object) and drive corresponding connected devices according to pre-set programs. The touch screen can detect user touch actions on the touch screen, convert the touch actions into touch signals and transmit them to the processor 170. It can also receive and execute commands sent by the processor 170; the touch signals include at least touch point coordinate information. The touch screen 131 provides an input interface and an output interface between the terminal 100 and the user. Touch screens can be implemented using various types, including resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch screen 131, the input unit 130 may also include other input devices. Specifically, the other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.
[0110] The input device 132 may receive input images and the like.
[0111] The display unit 140 may be used to display information input by the user or provided to the user, various menus of the terminal 100, interactive interfaces, file display, and / or playback of any multimedia file. In an embodiment of the present application, the display unit 140 may be used to display the interface of an image processing application, processing results, etc.
[0112] Memory 120 can be used to store instructions and data. It primarily includes an instruction storage area and a data storage area. The data storage area can store various data, such as multimedia files and text. The instruction storage area can store software units such as the operating system, applications, and instructions required for at least one function, or subsets or extensions thereof. It may also include non-volatile random access memory (RAM). It provides processor 170 with management functions for the hardware, software, and data resources within the computing and processing device, supporting control software and applications. It is also used to store multimedia files and running programs and applications.
[0113] The processor 170 is the control center of the terminal 100. It connects all components of the terminal 100 using various interfaces and circuits. By executing instructions stored in the memory 120 and accessing data stored therein, it executes various functions of the terminal 100 and processes data, thereby providing overall control of the terminal device. Optionally, the processor 170 may include one or more processing units. Preferably, the processor 170 may integrate an application processor and a modem processor, with the application processor primarily processing the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into the processor 170. In some embodiments, the processor and memory may be implemented on a single chip; in other embodiments, they may be implemented on separate chips. The processor 170 may also generate corresponding operational control signals and send them to the corresponding components of the computing and processing device. It may also read and process data in the software, particularly the data and programs in the memory 120, to enable the various functional modules therein to perform their corresponding functions, thereby controlling the corresponding components to operate as instructed.
[0114] Among them, the memory 120 can be used to store software codes related to the data processing method, 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 implement corresponding functions.
[0115] The RF unit 110 (optional) can be used to send and receive information or receive and send signals during a call. For example, after receiving downlink information from the base station, it is passed to the processor 170 for processing; in addition, it sends the designed uplink data to the base station. Generally, 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. In addition, the RF unit 110 can also communicate with network devices and other devices via wireless communication. This wireless communication can use any communication standard or protocol, including but not limited to Global System of 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.
[0116] In this embodiment of the present application, the RF unit 110 may send the image to the server 200 and receive the processing result sent by the server 200.
[0117] It should be understood that the radio frequency unit 110 is optional and can be replaced by other communication interfaces, such as a network port.
[0118] The terminal 100 also includes a power supply 190 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, thereby managing functions such as charging, discharging, and power consumption through the power management system.
[0119] The terminal 100 further includes an external interface 180 , which may be a standard Micro USB interface or a multi-pin connector, and may be used to connect the terminal 100 to other devices for communication, or to connect a charger to charge the terminal 100 .
[0120] Although not shown, the terminal 100 may also include a flash, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with different functions, etc., which are not described in detail here. Some or all of the methods described below may be applied to the terminal 100 shown in FIG1D .
[0121] Next, the product form of the server 200 in FIG1C is described;
[0122] FIG2 provides a schematic diagram of the structure of a server 200. As shown in FIG2, the server 200 includes a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.
[0123] Bus 201 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. Buses can be categorized as address buses, data buses, and control buses. For ease of illustration, FIG2 shows only one thick line, but this does not imply that there is only one bus or only one type of bus.
[0124] The processor 202 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0125] The memory 204 may include volatile memory, such as random access memory (RAM). The memory 204 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard drive (HDD), or solid state drive (SSD).
[0126] The memory 204 may be used to store software codes related to the data processing method, and the processor 202 may execute the steps of the data processing method of the chip, and may also schedule other units to implement corresponding functions.
[0127] It should be understood that the above-mentioned terminal 100 and server 200 can be centralized or distributed devices, and the processors in the above-mentioned terminal 100 and server 200 (such as processor 170 and processor 202) can be hardware circuits (such as application specific integrated circuit (ASIC), field-programmable gate array (FPGA), general-purpose processor, digital signal processor (DSP), microprocessor or microcontroller, etc.), or a combination of these hardware circuits. For example, the processor can be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.
[0128] It should be understood that the steps related to the model reasoning 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 system architecture provided in the embodiments of this application is described in detail below with reference to Figure 3.
[0129] FIG3 is a schematic diagram of the system architecture provided by an embodiment of the present application. As shown in FIG3 , 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 .
[0130] The execution device 510 includes a calculation module 511, an I / O interface 512, a pre-processing module 513, and a post-processing module 514. The calculation module 511 may include the target model / rule 501, and the pre-processing module 513 and the post-processing module 514 are optional.
[0131] The execution device 510 may be a terminal device or a server that runs the above-mentioned image processing application.
[0132] The data acquisition device 560 is used to collect training samples. The training samples can be multiple images, etc. After collecting the training samples, the data acquisition device 560 stores these training samples in the database 530.
[0133] The training device 520 can train the neural network based on the training samples maintained in the database 530 to obtain the target model / rule 501.
[0134] 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.
[0135] It should be noted that, in actual applications, the training samples maintained in the database 530 may not all be collected by the data acquisition device 560, but may also be received from other devices. It should also be noted that the training device 520 may not train the target model / rule 501 entirely based on the training samples maintained in the database 530, but may also obtain training samples from the cloud or other places for model training. The above description should not be used as a limitation on the embodiments of the present application.
[0136] The target model / rule 501 obtained through training with the training device 520 can be applied to different systems or devices, such as the execution device 510 shown in FIG3 . The execution device 510 can be a terminal, such as a mobile phone terminal, a tablet computer, a laptop computer, an augmented reality (AR) / virtual reality (VR) device, an in-vehicle terminal, etc., or a server, etc.
[0137] Specifically, the training device 520 may transfer the trained model to the execution device 510 .
[0138] In Figure 3, the execution device 510 is configured with an input / output (I / O) interface 512 for data interaction with external devices. The user can input data (such as images in the embodiment of the present application) to the I / O interface 512 through the client device 540.
[0139] Preprocessing module 513 and preprocessing module 514 are used to preprocess the input data received by I / O interface 512. It should be understood that preprocessing module 513 and preprocessing module 514 may be absent or only one preprocessing module may be present. If preprocessing module 513 and preprocessing module 514 are absent, computing module 511 may be used directly to process the input data.
[0140] When the execution device 510 preprocesses the input data, or when the computing module 511 of the execution device 510 performs calculations and other related processing, the execution device 510 can call the data, code, etc. in the data storage system 550 for corresponding processing, and can also store the data, instructions, etc. obtained from the corresponding processing in the data storage system 550.
[0141] Finally, the I / O interface 512 provides the processed results to the client device 540 and thus to the user.
[0142] In the scenario shown in FIG3 , the user can manually input data, and this "manual input data" can be operated through the interface provided by I / O interface 512. In another scenario, client device 540 can automatically send input data to I / O interface 512. If user authorization is required for client device 540 to automatically send input data, the user can set the corresponding permissions in client device 540. The user can view the results output by execution device 510 on client device 540, and the specific presentation form can be a display, sound, action, or other specific method. Client device 540 can also serve as a data acquisition terminal, collecting input data input into I / O interface 512 and output results output from I / O interface 512 as new sample data, and storing them in database 530. Of course, collection can also be performed without client device 540, and instead the I / O interface 512 directly stores the input data input into I / O interface 512 and output results output from I / O interface 512 as new sample data in database 530.
[0143] It is worth noting that FIG3 is merely a schematic diagram of a system architecture provided by an embodiment of the present application, and the positional relationships between the devices, components, modules, etc. shown in the figure do not constitute any limitation. For example, in FIG3 , the data storage system 550 is an external memory relative to the execution device 510. In other cases, the data storage system 550 can also be placed in the execution device 510. It should be understood that the execution device 510 can be deployed in the client device 540.
[0144] From the inference side of the model:
[0145] In the embodiment of the present application, the computing module 511 of the above-mentioned execution device 510 can obtain the code stored in the data storage system 550 to implement the steps related to the model reasoning process in the embodiment of the present application.
[0146] In an embodiment of the present application, the computing module 511 of the execution device 510 may include a hardware circuit (such as an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a general-purpose processor, a digital signal processor (DSP), a microprocessor or a microcontroller, etc.), or a combination of these hardware circuits. For example, the training device 520 may be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.
[0147] Specifically, the computing module 511 of the execution device 510 can be a hardware system with an execution instruction function, and the steps related to the model reasoning process provided in the embodiment of the present application can be software codes stored in the memory. The computing module 511 of the execution device 510 can obtain the software code from the memory and execute the obtained software code to implement the steps related to the model reasoning process provided in the embodiment of the present application.
[0148] It should be understood that the computing module 511 of the execution device 510 can be a combination of a hardware system that does not have the function of executing instructions and a hardware system that has the function of executing instructions. Some of the steps related to the model reasoning process provided in the embodiment of the present application can also be implemented by the hardware system that does not have the function of executing instructions in the computing module 511 of the execution device 510, which is not limited here.
[0149] From the training side of the model:
[0150] In an embodiment of the present application, the above-mentioned training device 520 can obtain the code stored in the memory (not shown in Figure 3, which can be integrated into the training device 520 or deployed separately from the training device 520) to implement the steps related to model training in the embodiment of the present application.
[0151] In an embodiment of the present application, the training device 520 may include a hardware circuit (such as an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a general-purpose processor, a digital signal processor (DSP), a microprocessor or a microcontroller, etc.), or a combination of these hardware circuits. For example, the training device 520 may be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.
[0152] It should be understood that the training device 520 can be a combination of a hardware system that does not have the function of executing instructions and a hardware system that has the function of executing instructions. Some of the steps related to model training provided in the embodiments of the present application can also be implemented by the hardware system in the training device 520 that does not have the function of executing instructions, which is not limited here.
[0153] 2. Image processing cloud services provided by the server:
[0154] In a possible implementation, the server may provide image processing services to the terminal side through an application programming interface (API).
[0155] Among them, the terminal device can send relevant parameters (such as images) to the server through the API provided by the cloud. The server can obtain processing results based on the received parameters, etc., and return the processing results to the terminal.
[0156] The description of the terminal and the server can be the same as that of the above embodiments, and will not be repeated here.
[0157] FIG4 shows a process of using an image processing cloud service provided by a cloud platform.
[0158] 1. Activate and purchase content review services.
[0159] 2. Users can download the software development kit (SDK) corresponding to the content review service. Usually, the cloud platform provides multiple development versions of the SDK for users to choose according to the requirements of the development environment, such as JAVA version SDK, Python version SDK, PHP version SDK, Android version SDK, etc.
[0160] 3. After the user downloads the corresponding version of the SDK to the local computer as needed, import the SDK project into the local development environment, configure and debug it in the local development environment. The local development environment can also be used to develop other functions, forming an application that integrates image processing capabilities.
[0161] 4. When image processing is needed during use, an image processing application can trigger an image processing API call. When the application triggers the image processing function, it initiates an API request to the running instance of the image processing service in the cloud environment. The API request includes the image, and the running instance in the cloud environment processes the image and obtains the processing result.
[0162] 5. The cloud environment returns the processing results to the application, thereby completing a method call provided in an embodiment of the present application.
[0163] 3. Model compression cloud services provided by the server:
[0164] In one possible implementation, the server may provide model compression services to the client through an application programming interface (API).
[0165] Among them, 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, etc., and return the compressed neural network to the terminal.
[0166] The description of the terminal and the server can be the same as that of the above embodiments, and will not be repeated here.
[0167] For example, the data processing method provided in the embodiments of the present application can be applied to ADAS / ADS visual perception systems.
[0168] As shown in Figure 5A, ADAS and ADS require real-time 2D object detection for multiple types of objects, including dynamic obstacles (pedestrians, cyclists, tricycles, cars, trucks, and buses), static obstacles (traffic cones, traffic sticks, fire hydrants, motorcycles, and bicycles), and traffic signs (traffic signs, guide signs, billboards, red / yellow / green / black traffic lights, and road signs). Furthermore, to accurately determine the area occupied by dynamic obstacles in 3D space, 3D estimation is required to output a 3D bounding box. To fuse data with the LiDAR, it's necessary to obtain a mask for dynamic obstacles, thereby filtering out the laser point cloud that hits them. To accurately locate a parking space, it's necessary to simultaneously detect the four key points of the parking space. To perform composition positioning, it's necessary to detect the key points of static targets. A model trained using the technical solutions provided in the embodiments of this application can perform all or some of the aforementioned functions within the model.
[0169] Since the embodiments of the present application involve the application of a large number of neural networks, in order to facilitate understanding, the relevant terms and related concepts such as neural networks involved in the embodiments of the present application are first introduced below.
[0170] (1) Neural Network
[0171] A neural network can be composed of neural units. A neural unit can refer to an operation unit that takes xs (i.e., input data) and intercept 1 as input. The output of the operation unit can be:
[0172] Where s = 1, 2, ... n, 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, which is used to introduce nonlinear characteristics into the neural network to convert the input signal of the neural unit into the output signal. The output signal of the activation function can be used as the input of the next convolutional layer, and the activation function can be a sigmoid function. A neural network is a network formed by connecting multiple single neural units mentioned above, 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. The local receptive field can be an area composed of several neural units.
[0173] (2) Convolutional neural network (CNN) is a deep neural network with a convolutional structure. Convolutional neural network contains a feature extractor consisting of a convolution layer and a subsampling layer, which can be regarded as a filter. The convolution layer refers to the neuron layer in the convolutional neural network that performs convolution processing on the input signal. In the convolution layer of the convolutional neural network, a neuron can only be connected to some neurons in the adjacent layer. A convolution layer usually contains several feature planes, and each feature plane can be composed of some rectangularly arranged neural units. The neural units in the same feature plane share weights, and the shared weights here are convolution kernels. Shared weights can be understood as the way of extracting features is independent of position. The convolution kernel can be formalized as a matrix of random size, and the convolution kernel can obtain reasonable weights through learning during the training process of the convolutional neural network. In addition, the direct benefit of shared weights is to reduce the connections between the layers of the convolutional neural network, while reducing the risk of overfitting.
[0174] CNN is a very common neural network. The following will focus on the structure of CNN in detail with reference to Figure 5B. As mentioned in the previous basic concepts, a convolutional neural network is a deep neural network with a convolutional structure. It is a deep learning architecture. A deep learning architecture refers to multiple levels of learning at different 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 image input.
[0175] As shown in FIG5B , the convolutional neural network (CNN) 200 may include an input layer 210 , a convolutional layer / pooling layer 220 (wherein the pooling layer is optional), and a fully connected layer 230 .
[0176] Convolutional layer / pooling layer 220:
[0177] Convolutional layer:
[0178] As shown in FIG5B , the convolution layer / pooling layer 220 may include layers 221-226. For example, in one implementation, layer 221 is a convolution layer, layer 222 is a pooling layer, layer 223 is a convolution layer, layer 224 is a pooling layer, layer 225 is a convolution layer, and layer 226 is a pooling layer. In another implementation, layers 221 and 222 are convolution layers, layer 223 is a pooling layer, layers 224 and 225 are convolution layers, and layer 226 is a pooling layer. That is, the output of a convolution layer can serve as the input of a subsequent pooling layer, or as the input of another convolution layer to continue the convolution operation.
[0179] The following will take convolutional layer 221 as an example to introduce the internal working principle of a convolutional layer.
[0180] Convolution layer 221 can include multiple convolution operators, also known as kernels. In image processing, a convolution operator acts as a filter that extracts specific information from an input image matrix. A convolution operator is essentially a weight matrix, which is typically predefined. During the convolution operation, the weight matrix is typically applied horizontally to the input image, pixel by pixel (or two pixels by two pixels, depending on the stride), thereby extracting specific features from the image. The size of the weight matrix should be related to the image size. It is important to note that the depth dimension of the weight matrix is the same as the depth dimension of the input image. During the convolution operation, the weight matrix extends across the entire depth of the input image. Therefore, convolution with a single weight matrix produces a convolution output with a single depth dimension. However, in most cases, a single weight matrix is not used. Instead, multiple weight matrices of the same size (rows × columns) are applied, i.e., multiple homogeneous matrices. The outputs of each weight matrix are stacked to form the depth dimension of the convolved image, where the dimension is 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 edge information, another weight matrix can be used to extract specific colors, and yet another weight matrix can be used to blur unwanted noise in the image. The weight matrices have the same size (rows × columns), and the feature maps extracted by these weight matrices are also the same size. The extracted feature maps of the same size are then merged to form the output of the convolution operation.
[0181] The weight values in these weight matrices need to be obtained through a lot of 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, so that the convolutional neural network 200 can make correct predictions.
[0182] When the convolutional neural network 200 has multiple convolutional layers, the initial convolutional layer (for example, 221) often extracts 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 the later convolutional layers (for example, 226) become more and more complex, such as high-level semantic features. Features with higher semantics are more suitable for the problem to be solved.
[0183] Pooling layer:
[0184] Because it's often necessary to reduce the number of training parameters, pooling layers are often periodically introduced after convolutional layers. For example, in layers 221-226, as shown in the example of 220 in Figure 5B , a single convolutional layer can be followed by a pooling layer, or multiple convolutional layers can be followed by one or more pooling layers. In image processing, the sole purpose of a pooling layer is to reduce the spatial size of an image. A pooling layer can include an average pooling operator and / or a max pooling operator, which are used to downsample the input image to produce a smaller image. The average pooling operator calculates the average value of pixel values within a specific range as the average pooling result. The max pooling operator takes the pixel with the largest value within a specific range as the max pooling result. Furthermore, just as the size of the weight matrix used 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 output image size after processing by a pooling layer can be smaller than the size of the image input to the pooling layer. Each pixel in the output image of the pooling layer represents the average or maximum value of the corresponding subregion of the image input to the pooling layer.
[0185] Fully connected layer 230:
[0186] After being processed by the convolutional layer / pooling layer 220, the convolutional neural network 200 is still insufficient to output the required output information. As previously mentioned, the convolutional layer / pooling layer 220 only extracts features and reduces the parameters brought by the input image. However, in order to generate the final output information (the required class information or other related information), the convolutional neural network 200 needs to use the fully connected layer 230 to generate one or a group of outputs of the required number of classes. Therefore, the fully connected layer 230 may include multiple hidden layers (such as 231, 232 to 23n as shown in Figure 5B). The parameters contained in these multiple hidden layers can be pre-trained based on relevant training data for a specific task type. For example, the task type may include image recognition, image classification, image super-resolution reconstruction, etc.
[0187] After the multiple hidden layers in the fully connected layer 230, that is, the last layer of the entire convolutional neural network 200 is the output layer 240. The output layer 240 has a loss function similar to the classification cross entropy, which is specifically used to calculate the prediction error. Once the forward propagation of the entire convolutional neural network 200 (such as the propagation from 210 to 240 in Figure 5B is forward propagation) is completed, the back propagation (such as the propagation from 240 to 210 in Figure 5B is back propagation) will begin to update the weight values and biases of the aforementioned layers to reduce the loss of the convolutional neural network 200 and the error between the result output by the convolutional neural network 200 through the output layer and the ideal result.
[0188] It should be noted that the convolutional neural network 200 shown in Figure 5B is only an example of a convolutional neural network. In specific applications, the convolutional neural network can also exist in the form of other network models, for example, including only a part of the network structure shown in Figure 5B. For example, the convolutional neural network used in the embodiment of the present application can only include an input layer 210, a convolution layer / pooling layer 220 and an output layer 240.
[0189] It should be noted that the convolutional neural network 100 shown in Figure 5B is only an example of a convolutional neural network. In specific applications, the convolutional neural network can also exist in the form of other network models. For example, as shown in Figure 5C, multiple convolutional layers / pooling layers are run in parallel, and the extracted features are input into the fully connected layer 230 for processing.
[0190] (3) Deep Neural Networks
[0191] Deep Neural Network (DNN), also known as multi-layer neural network, can be understood as a neural network with many hidden layers. There is no special metric for "many" here. Based on the position of different layers in DNN, the neural network inside DNN can be divided into three categories: input layer, hidden layer, and output layer. Generally speaking, the first layer is the input layer, the last layer is the output layer, and the layers in between are all hidden layers. The layers are fully connected, that is, any neuron in the i-th layer must be connected to any neuron in the i+1-th layer. Although DNN looks complicated, the work of each layer is actually not complicated. Simply put, it is the following linear relationship expression: in, is the input vector, is the output vector, is the offset vector, W is the weight matrix (also called coefficient), and α() is the activation function. Each layer is just an input vector After such a simple operation, the output vector Since there are many DNN layers, the coefficient W and the offset vector The definition of these parameters in DNN is as follows: Take the coefficient W as an example: Assume that in 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 of the coefficient W, while the subscript corresponds to the output of the third layer index 2 and the input of the second layer index 4. In summary, the coefficient from the kth neuron in the L-1th layer to the jth neuron in the Lth layer is defined as It's important to note that the input layer has no W parameter. In deep neural networks, more hidden layers allow the network to better capture complex real-world situations. Theoretically, a model with more parameters has higher complexity and greater "capacity," meaning it can handle 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 matrices for all layers of a trained deep neural network (a weight matrix formed by the vectors W across many layers).
[0192] (4) Loss function
[0193] During the training of a deep neural network, because we want the output of the deep neural network to be as close as possible to the desired predicted value, we can compare the current network's predicted value with the desired target value and then update the weight vector of each layer of the neural network based on the difference between the two. (Of course, before the first update, there is usually an initialization process, which pre-configures the parameters for each layer in the deep neural network.) For example, if the network's predicted value is too high, the weight vector is adjusted to make it predict a lower value. This adjustment is continued until the deep neural network can predict the desired target value or a value very close to the desired target value. Therefore, it is necessary to predefine "how to compare the difference between the predicted value and the target value." This is the loss function (or objective function), which is an important equation used to measure the difference between the predicted value and the target value. For example, the loss function output value (loss) indicates a greater difference, so training a deep neural network becomes a process of minimizing this loss.
[0194] (5) Backpropagation algorithm
[0195] Convolutional neural networks can use the back propagation (BP) algorithm to correct the size of the parameters in the initial super-resolution model during training, reducing the reconstruction error loss of the super-resolution model. Specifically, the forward propagation of the input signal to the output generates an error loss. This error loss information is then backpropagated to update the parameters of the initial super-resolution model, thereby converging the error loss. The BP algorithm is a backward propagation movement dominated by the error loss, aiming to obtain the optimal super-resolution model parameters, such as the weight matrix.
[0196] (6) Model quantification:
[0197] A term used in the field of AI model acceleration, it 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-training quantization (PTQ) and quantization-aware training (QAT). The former only requires a small amount of unlabeled calibration data set to complete the quantization process of a pre-trained floating-point model and is often used for compression of higher bit widths. The latter requires a complete data set for training, simulating quantization operations during training to enable the quantized model to further converge to the optimal point. It is often used to recover accuracy after a significant loss in the quantized model.
[0198] (7) Full precision: Parameters in the network model whose numerical type is 32-bit floating point numbers.
[0199] (8) Anchor: An anchor box (or detection box) is a commonly used anchor box in target detection. It represents a fixed reference box. A set of fixed reference boxes of different scales and positions is preset to cover almost all positions and scales. Each reference box is responsible for detecting targets whose intersection-over-union ratio with it is greater than a threshold (a training preset value, usually 0.5 or 0.7).
[0200] (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 achieving model compression and acceleration. This is the application of knowledge distillation and transfer learning in model optimization.
[0201] (10) Teacher model: a large model with full precision that has been trained.
[0202] (11) Student model: It can be a model obtained by pruning and quantizing the teacher model, or it can be a manually designed model with the same framework as the teacher model.
[0203] (12) Transformer layer
[0204] The neural network includes an embedding layer and at least one transformer layer, and the at least one transformer layer can be N transformer layers (N is an integer greater than 0), wherein each transformer layer includes an attention layer, an add&norm layer, a feed forward layer, and an add&norm layer that are adjacent in sequence. 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 previous layer of the first transformer layer, and with any first input vector among the P input vectors as the center, based on the correlation between each input vector within a preset attention window and the first input vector, the intermediate vector corresponding to the first input vector is obtained, thereby determining the P intermediate vectors corresponding to the P input vectors; in the pooling layer, the P intermediate vectors are merged into Q output vectors, wherein the multiple output vectors obtained by the last transformer layer in the transformer layer are used as feature representations of the current input.
[0205] Referring to Figure 5D, Figure 5D is a schematic diagram of the structure of a transformer model. It should be understood that the structure of Figure 5D is merely an example, and the number of neural network layers can be set as needed. The embedding layer can embed the input to obtain multiple feature vectors. The core feature of the transformer model lies in its unique attention mechanism. When processing natural language, such as a sentence, the transformer model uses this attention mechanism to assign different attention coefficients to each word vector in the sentence, thereby more comprehensively considering the impact of the context in the sentence on each word. The embedding layer can obtain N embedding vectors Xl based on the node features and position encoding of each node in the current sequence. The attention layer is connected to the embedding layer and obtains N embedding vectors from the embedding layer as input vectors. Based on the correlation between each input vector in the N input vectors, it synthesizes each input vector to obtain N output vectors, which are output to the subsequent transformer layer. The transformer layer obtains the output of the previous layer as an input vector and performs operations similar to the previous transformer layer.
[0206] Referring to Figure 5E, Figure 5E is a schematic diagram of the structure of a transformer layer, wherein the transformer layer may include a multi-head attention layer (or simply referred to as an attention layer), an addition and normalization (add&norm) layer, a feed forward net (FFN), and an addition and normalization layer adjacent to each other.
[0207] Among them, the multi-head attention layer obtains N input vectors Xl from the layer above it, and the N input vectors Xl can be expressed as a matrix X. The multi-head attention layer adopts a self-attention mechanism to transform each vector based on the correlation between vectors to obtain N output vectors, which can be expressed as a matrix Y. It can be understood that when the multi-head attention layer is a layer directly connected to the embedding layer, such as the transformer layer directly connected to the embedding layer in Figure 5E, the input vector it obtains is the embedding vector output by the embedding layer; when the multi-head attention layer is a multi-head attention layer included in a subsequent transformer layer, such as the multi-head attention layer included in the transformer layer directly connected to the previous transformer layer in Figure 5E, the input vector it obtains is the output vector of the previous transformer layer. The multi-head attention layer can include multiple attention heads (such as Head 1, Head 2, ..., Head N shown in Figure 5E).
[0208] (13) Attention mechanism
[0209] The attention mechanism mimics the internal process of biological observation behavior, namely, a mechanism that aligns internal experience and external sensations to increase the observation precision of certain areas. It can quickly filter out high-value information from a large amount of information using limited attention resources. The attention mechanism can quickly extract important features from sparse data and is therefore widely used in natural language processing tasks, especially machine translation. The self-attention mechanism is an improvement on the attention mechanism, which reduces dependence on external information and is better at capturing the internal correlation of data or features. The essential idea of the attention mechanism can be rewritten as the following formula:
[0210] Here, Lx = ||Source|| represents the length of the Source. This formula implies that the elements in the Source are imagined to consist of a series of data pairs. Given a Query element in the target, the similarity or correlation between the Query and each Key is calculated to obtain the weight coefficient for each Key's corresponding Value. The weighted sum of the Values is then taken to obtain the final Attention value. Essentially, the Attention mechanism performs a weighted sum of the Values of the Source elements, with the Query and Key used to calculate the weight coefficient for the corresponding Value. Conceptually, Attention can be understood as selectively filtering out a small amount of important information from a large amount of information and focusing on this important information, while ignoring the majority of less important information. This focusing process is reflected in the calculation of the weight coefficients: the larger the weight, the more focus is placed on the corresponding Value. In other words, the weight represents the importance of the information, while the Value represents the corresponding information. The self-attention mechanism can be understood as internal attention. The attention mechanism occurs between the Query element of the Target and all elements of the Source. The self-attention mechanism refers to the attention mechanism that occurs between the internal elements of the Source or the internal elements of the Target. It can also be understood as the attention calculation mechanism in the special case of Target = Source. The specific calculation process is the same, only the calculation object has changed.
[0211] Object detection aims to locate and classify visual objects from an input image. In early work, this task was often achieved by combining convolutional neural networks to process regional features of the input image. Recently, transformer-based object detectors have been proposed, in which object detection is regarded as a collective prediction task and can be trained end-to-end. They greatly simplify the object detection task, and users do not need to perform tedious adjustments to hand-designed components, such as the size and scale of anchors. Although object detectors have excellent capabilities, they usually have a large number of parameters and floating-point operations (FLOPs). For example, in the object detector (DETR-R50) with ResNet-50 as the backbone network, the 39.8M parameters occupy 159MB of memory and consume 86GFLOPs of computation. The large amount of memory and computing power required during inference limits the deployment of the model on resource-limited platforms.
[0212] 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 and enabling efficient inference. However, the model parameters before and after quantization vary significantly, resulting in a decrease in model accuracy. In particular, performance degrades dramatically when quantizing to ultra-low bits (4 bits or lower).
[0213] In order to solve the above problems, refer to Figure 6, which is a flow chart of a data processing method provided in an embodiment of the present application. As shown in Figure 6, a data processing method provided in an embodiment of the present application may include steps 601 to 603, and these steps are described in detail below.
[0214] 601. Obtain 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.
[0215] In one possible implementation, a neural network model for target detection may include a feature extraction network (e.g., a backbone network and an encoder), and a decoder, wherein the decoder may input a feature representation (obtained by processing an 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.
[0216] In an embodiment of the present application, a neural network to be compressed (a second neural network) and a neural network after compression processing of the second neural network (a first neural network) can be obtained. The present application can use the second neural network as a teacher network and the first neural network as a student model, and update the first neural network and the corresponding multiple query vectors through knowledge distillation to improve the model accuracy of the first neural network.
[0217] In a possible implementation, the first neural network is obtained by quantizing the second neural network by 2, 3 or 4 bits.
[0218] 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 of the input contained in the intermediate layers of the teacher network and the student model and maximizing the expected output. and to represent the second neural network and the first neural network.
[0219] For example, the loss of knowledge distillation can be constructed as:
[0220] in, and q S Represents the query of the teacher model and the student model respectively; β and γ are Lagrange multipliers; are the parameters of the student model; I(·) returns the mutual information of the two input variables. Minimize the first term I(X;E S ), represents the input and visual features E S to extract task-oriented hints. Maximize the second term I(E S ,q S ;y GT ), which represents the mutual information between the extracted visual features and the real data labels, so as to better detect the target. These two can be accomplished through common network training and detection loss constraints, such as coordinate regression and category classification.
[0221] As for the third It attempts to solve 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 reformulated as follows:
[0222] Among them, H represents information entropy, self-information H(q S ) needs to be maximized, and the conditional entropy needs to be minimized. It is difficult to maximize and minimize both at the same time. Therefore, the above formula can be reformulated as a two-level optimization problem, which is solved by alternately optimizing these two terms. It can be defined as follows: st&q S* =argmaxH(q S )
[0223] Such a goal involves two sub-problems, namely obtaining the current optimal query q through inner-level optimization S* , and complete the knowledge transfer from the teacher model to the student model through upper-level optimization. The optimization of the above two problems can be achieved in the forward and back propagation processes respectively.
[0224] In one possible implementation, the student model's query can be optimized during forward propagation, and the distribution of the student model's query can be adjusted to a preset type of distribution. In an embodiment of the present application, the first query (i.e., the student model's query) obtained is obtained by adjusting the distribution of the query corresponding to the first neural network to a preset type of distribution. The preset type of distribution here can be the distribution of the query corresponding to the teacher model (or an approximate distribution), for example, the preset type of distribution can be a Gaussian distribution.
[0225] The above optimization of the query corresponding to the student model can be called inner-level optimization. The following is a specific example of inner-level optimization:
[0226] According to the definition of self-information, H(q S ) can be expanded to:
[0227] The query distribution of the teacher model tends to follow a Gaussian distribution, so the problem of inner layer optimization can be solved by aligning the distribution. To do this, we can calculate the query q S The average value μ(q S ) and variance σ(q S ), the query distribution is Afterwards, the self-information of the student model’s query can be written as follows:
[0228] when When the above target H(q S* ) reaches its maximum value: H(q S* )=(1 / 2)log2πe[σ(q S ) 2 +∈ q S]. In addition, due to the bias of the query data of the student model, its mean and variance may be inaccurate. To solve this problem, we can use the concept of Batch Normalization to add a learnable shift parameter β qS and scale parameter γ qS Optimize the query of the student model by scaling and translating it:
[0229] At this time, the maximum self-information of the query of the student model is Therefore, in the forward propagation, the optimized query q can be obtained by the above formula S*,After that, further outer layer optimization is performed (that is, completing the knowledge transfer from the teacher model to the student model).
[0230] In one possible implementation, the first neural network includes a first backbone network, a first encoder, and a first decoder. During forward propagation, the first backbone network and the first encoder are used to obtain a first intermediate output based on the target image. The first decoder then processes the first query and the first intermediate output. The first processing result may include a detection box and a category corresponding to the image content within the detection box.
[0231] Minimizing conditional entropy requires a one-to-one match between the detection results of the student model and the teacher model. This means that each detection box output by the student model must correspond 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 true value of the image detection results.
[0232] Due to the discreteness of algorithm matching and the randomness of model training, the matching of the true value ground-truth (that is, the matching between the output of the student model and the true value of the image detection result of the image) becomes a dynamic and unstable process. For example, the true value of the image detection result includes 5 detection frames, and the detection result of the student model includes 8 detection frames. The embodiment of the present application proposes foreground-aware query matching to solve this problem. Specifically, the true value of the image detection result is matched with the detection result output by the student model, and the detection frame that can be matched with the true value of the image detection result (for example, the detection frame whose position relationship meets the preset conditions) is determined from the detection result output by the student model, and a one-to-one correspondence is established between the determined detection frame and the true value of the image detection result, that is, the detection frame with more accurate foreground perception ability in the detection frame output by the student model is selected.
[0233] For example, the maximum overlap ratio can be found as:
[0234] Among them, GloU(·) is the generalized intersection-over-union ratio, and each G i It reflects the overlap between the bounding box predicted by the student model and the bounding box of the true value of the i-th detection result. Then, the high-quality student bounding box is retained:
[0235] Where T is a threshold used to control the proportion of distilled queries. After removing empty queries, we can obtain the detection box information set of the student model:
[0236] 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 of M first detection frames; wherein, among the information of the M first detection frames, only some of the detection frames may be able to establish a correspondence with the detection frames included in the true value of the detection result. Specifically, the true value of the detection result corresponding to the target image can be obtained, and the true value of the detection result includes multiple second detection frames; based on the positional relationship between the first detection frame and the second detection frame, M1 first detection frames are determined from the M first 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 second detection frame satisfies a first preset condition, and the first preset condition is related to the degree of overlap between the areas where the detection frames are located (for example, the degree of overlap may be greater than a threshold).
[0237] In a possible implementation, the first query is a query corresponding to the M1 first detection boxes.
[0238] In one possible implementation, the second neural network includes a second backbone network, a second encoder, and a second decoder. Based on the target image, a second intermediate output can be obtained through the second backbone network and the second encoder. The second decoder processes the second query and the second intermediate output. The detection boxes output by each student model that establishes a matching relationship with the true value can be matched one-to-one with the detection boxes output by the teacher model. The output of the matched teacher model can be the second processing result.
[0239] In one possible implementation, the positional relationship between each detection box output by the teacher model and the detection box output by each student model (the detection box that establishes a matching relationship with the true value) can be determined, and an association relationship can be established between the detection boxes whose positional relationships meet preset conditions.
[0240] In a possible implementation, target detection can be performed on the target image based on the second query and the second neural network to obtain information of N third detection frames; 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, and the second preset condition is related to the degree of overlap between the areas where the detection frames are located (for example, the degree of overlap may be the largest).
[0241] In a possible implementation, the acquired second query is a query corresponding to the M1 third detection boxes.
[0242] Through the above method, we can establish a correspondence between the test results output by the student model and the test results output by the teacher model. Similarly, based on the correspondence between the test results, we can determine the correspondence between the queries of the student model and the queries of the teacher model (that is, the one-to-one correspondence between each query in the first query and each query in the second query). Then, we can construct a loss based on the queries with corresponding relationships.
[0243] 602. Determine a first loss based on the first query and the second query; the first loss indicates minimizing an information difference between the second query and the first query.
[0244] Step 602 may also be referred to as upper-level optimization. In the upper-level optimization, the information difference between the student model and the teacher model may be minimized. Optionally, the information difference may be represented by a distance function such as the L2 norm or conditional entropy.
[0245] For example, you can use Represents the ground-truth label, where N gt is the number of prospects, and Represents the category and bounding-box of the i-th object respectively. For the student model, each query is associated with an object. Therefore, we can obtain N objects of the teacher model teacher and the student model student, which are recorded as and
[0246] For the query of the jth student model, the corresponding teacher model query is:
[0247] Due to differences in network structures, query sequences have differences in importance and order. Through the above method, matching based on importance is achieved.
[0248] Finally, after correction, the outer optimization problem becomes:
[0249] The optimization solution of the above formula is difficult, so it can be solved by minimizing and The L2 norm between is used to obtain the optimal solution, so the loss function of distribution correction distillation can be written as:
[0250] In a possible implementation, the second loss may be constructed based on the difference between the true value of the detection result of the image and the information of the first detection frame having a corresponding relationship.
[0251] For example, the overall training loss function of the model can refer to the following formula, where is a common detection loss for tasks such as coordinate regression, and λ is a trade-off hyperparameter:
[0252] 603. Update the first neural network and the first query according to the first loss.
[0253] An embodiment of the present 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 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; a first loss is determined 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 the first neural network and the first query are updated based on the first loss. The present application minimizes the information gap between the student model and the teacher model by minimizing the information gap between the query queries of the student model and the teacher model, thereby improving the model accuracy of the compression model.
[0254] In the embodiment of the present application, 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 optimization, the query of the student model is distributed aligned (DA) according to the Gaussian distribution to maximize the self-information of the student query; in the outer optimization, a new foreground-aware query matching (FQM) method is introduced to filter out low-quality student queries. The conditional entropy between the student and teacher queries is minimized by performing accurate one-to-one query matching between the student and the teacher, so as to effectively transfer the teacher information to the student model. Through training optimization, the technical solution of the embodiment of the present application can effectively improve the accuracy of the student model.
[0255] A schematic diagram of the process of an embodiment of the present application can be shown in Figure 7. It is proposed to correct the query information of the student model to the query information corresponding to the teacher model through the distribution correction distillation method (DRD), so as to eliminate the distribution difference of the compressed query information and solve the information distortion problem of the attention mechanism during the model compression process.
[0256] Specifically, the full-precision model is used as the teacher model and the compressed model as the student model, and the information bottleneck optimization problem of the student model is modeled as a two-layer optimization model. The two-layer optimization problem consists of an inner-layer optimization to maximize the self-information of the student query and an outer-layer optimization to minimize the conditional entropy between the student and teacher queries, thereby eliminating the difference in query distribution between the student and teacher models. In the inner-layer optimization, a Gaussian distribution is used as the guide distribution, and the self-information of the student query is maximized by aligning the query distribution in the forward propagation. In the outer-layer optimization, a novel foreground-aware query matching method is introduced to filter out low-quality student queries, perform accurate one-to-one query matching between the student and teacher, and minimize the gap between the student and teacher queries, effectively transferring the teacher information to the student model. In the inner-layer optimization, the mean and variance of the student model query are calculated. Based on the known query distribution, the optimal query value when the student query self-information entropy is maximized is obtained. Furthermore, due to the bias in the query data, learnable scale and shift parameters are added to correct the optimal student query, drawing on the idea of batch normalization. In the outer layer optimization, it is necessary to minimize the information gap between the student and teacher queries, and minimization requires a one-to-one match between the student and teacher queries. However, due to the discreteness of the algorithm matching and the randomness of the model training, the matching of the ground-truth becomes a dynamic and unstable process. Therefore, the true value of the detection result of the image is matched with the detection result output by the student model, and the detection results output by the student model that are higher than the set threshold are retained. Then, the object set of the student and teacher can be obtained, and the one-to-one matching of the student and teacher objects is completed. The embodiment of the present application uses distribution alignment and foreground-aware query matching methods to solve the two-layer optimization problem, which effectively solves the problem of information distortion after compression of the multi-head attention module in the baseline model.
[0257] Next, the beneficial effects of the embodiments of the present application are described in conjunction with specific experiments:
[0258] The embodiment of the present application trains Q-DETR based on two mainstream models, DETR and SMCA-DETR. The ImageNet ILSVRC12 dataset is used to pre-train the quantized student backbone network. Using the AdamW optimizer, the initial learning rate is 1e-4, the weight decay is 1e-4, and the batch size is 16. Q-DETR is trained on the VOC and COCO datasets for 300 / 500 step epochs, respectively, and the learning rate is divided by 10 at 200 / 400 epochs. Q-SMCA-DETR is trained on the VOC / COCO datasets for 50 epochs, respectively, and the learning rate is multiplied by 0.1 at 40 epochs. Full-precision DETR-R101 and SMCA-DETR-R101 with VGG16 backbone are selected as teacher models.
[0259] First, we conducted extensive comparative experiments based on the full-precision DETR model and the baseline quantization model to verify the effectiveness of the module proposed in this application. We also conducted extensive comparative experiments to compare the detection accuracy of this application with the baseline and LSQ methods under the same framework in different bit networks.
[0260] Table 1
[0261] The results of the target detection task of the method proposed in the embodiment of the present application are shown in Table 1. As can be seen from Table 1, the distribution alignment (DA, that is, the inner layer optimization and outer layer optimization process introduced above) and foreground-aware query matching (FQM, that is, the matching method between the query of the student model and the query of the teacher model) proposed in the embodiment of the present application can improve the detection accuracy when used alone, and the combination of the two will further significantly improve the model performance. For example, compared with the 2-bit baseline model, AP50 is improved by 1.9% when DA is used alone, and AP50 is improved by 5.2% when FQM is used alone. When DA and FQM are combined, the performance improvement reaches 6.7%.
[0262] Table 2
[0263] A large number of experiments were conducted on the VOC dataset based on 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, which demonstrates the advantages of the Q-DETR proposed in the embodiments of this application in model performance. Compared with the 2 / 3 / 4-bit quantization baselines and LSQ, DETR-R50 / SMCA-DETR-R50 outperformed the 2 / 3 / 4-bit quantization baselines and LSQ by 6.3%-5.3%-4.7% and 6.3%-5.1%-3.8 on the three bit models, respectively.
[0264] 8 , which is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application. As shown in FIG8 , a data processing device 800 provided in an embodiment of the present application includes:
[0265] 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;
[0266] The description of the acquisition module 801 may refer to the description of step 601 in the above embodiment, and will not be repeated here.
[0267] A processing module 802 is configured to determine a first loss based on the first query and the second query, wherein the first loss indicates minimizing an information difference between the second query and the first query;
[0268] Update the first neural network and the first query according to the first loss.
[0269] The description of the processing module 802 may refer to the description of steps 602 and 603 in the above embodiment, and will not be repeated here.
[0270] In a possible implementation, the first neural network is obtained by quantizing the second neural network by 2, 3 or 4 bits.
[0271] In a possible implementation, the processing module is further configured to:
[0272] Performing target detection on the target image according to the first query and the first neural network to obtain information of M first detection boxes;
[0273] Obtaining a true value of a detection result corresponding to the target image, where the true value of the detection result includes a plurality of second detection frames;
[0274] Determine, based on a positional relationship between the first detection frame and the second detection frame, M1 first detection frames from the M first detection frames, where each first detection frame in the M1 first detection frames corresponds to a second detection frame, and a positional relationship between each first detection frame in the M1 first detection frames and the corresponding second detection frame satisfies a first preset condition, where the first preset condition is related to a degree of overlap between regions where the detection frames are located;
[0275] The first query is the query corresponding to the M1 first detection boxes.
[0276] In a possible implementation, the processing module is further configured to:
[0277] Performing target detection on the target image according to the second query and the second neural network to obtain information of N third detection boxes;
[0278] determining M1 third detection frames from the N third detection frames based on a positional relationship between each first detection frame in the M1 first detection frames and the third detection frame, wherein each first detection frame in the M1 first detection frames corresponds to a second detection frame, and a positional relationship between each first detection frame in the M1 first detection frames and the corresponding third detection frame satisfies a second preset condition, where the second preset condition is related to a degree of overlap between regions where the detection frames are located;
[0279] The second query is a query corresponding to the M1 third detection boxes.
[0280] In a possible implementation, the information of the first detection frame and the third detection frame includes the position and size of the detection frame and the category corresponding to the image content of the detection frame.
[0281] In a possible implementation, the first query is obtained by adjusting the distribution of queries corresponding to the first neural network to a preset type of distribution.
[0282] In a possible implementation, the preset type of distribution is a Gaussian distribution.
[0283] In a possible implementation, the information difference is represented by L2 norm or conditional entropy.
[0284] 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;
[0285] The processing module is specifically used to:
[0286] Obtain a first intermediate output according to the target image through the first backbone network and the first encoder;
[0287] Processing the first query and the first intermediate output through the first decoder;
[0288] Obtain a second intermediate output according to the target image through the second backbone network and the second encoder;
[0289] The second query and the second intermediate output are processed by the second decoder.
[0290] Next, an execution device provided in an embodiment of the present application is introduced. Please refer to Figure 9. Figure 9 is a structural diagram of an execution device provided in an embodiment of the present application. The execution device 900 can be specifically manifested as a virtual reality VR device, a mobile phone, a tablet, a laptop computer, a smart wearable device, a monitoring data processing device or a server, etc., which is not limited here. Specifically, the execution device 900 includes: a receiver 901, a transmitter 902, a processor 903 and a memory 904 (wherein the number of processors 903 in the execution device 900 can be one or more, and Figure 9 takes one processor as an example), wherein the processor 903 may include an application processor 9031 and a communication processor 9032. In some embodiments of the present application, the receiver 901, the transmitter 902, the processor 903 and the memory 904 may be connected via a bus or other means.
[0291] The memory 904 may include a read-only memory and a random access memory, and provides instructions and data to the processor 903. A portion of the memory 904 may also include non-volatile random access memory (NVRAM). The memory 904 stores processor and operation instructions, executable modules, or data structures, or subsets or extended sets thereof. The operation instructions may include various operation instructions for implementing various operations.
[0292] Processor 903 controls the operation of the execution device. In specific applications, the various components of the execution device are coupled together via a bus system. In addition to a data bus, the bus system may also include a power bus, a control bus, and a status signal bus. However, for clarity, all bus systems are referred to as a bus system in the figure.
[0293] The methods disclosed in the above embodiments of the present 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 hardware integrated logic circuits in the processor 903 or by software instructions. The above processor 903 can be a general-purpose processor, a digital signal processor (DSP), a microprocessor, or a microcontroller, and can 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 various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of the present application can be directly implemented as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in memory 904, and processor 903 reads information in memory 904 and, in conjunction with its hardware, completes the steps of the above method.
[0294] Receiver 901 can be used to receive input digital or character information and generate signal input related to executing device-related settings and function control. 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 pack through the first interface to modify data in the disk pack. Transmitter 902 can also include a display device such as a display screen.
[0295] The present application also provides a training device. Please refer to FIG. 10 , which is a schematic diagram of the structure of a training device provided by an embodiment of the present application. Specifically, the training device 1000 is implemented by one or more servers. The training device 1000 may 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), a memory 1032, and one or more storage media 1030 (e.g., one or more mass storage devices) storing application programs 1042 or data 1044. The memory 1032 and storage medium 1030 may be either ephemeral or persistent storage. The program stored in the storage medium 1030 may include one or more modules (not shown), each of which may include a series of instruction operations on the training device. Furthermore, the CPU 1010 may be configured to communicate with the storage medium 1030, executing the series of instruction operations in the storage medium 1030 on the training device 1000.
[0296] 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 and output interfaces 1058; or, one or more operating systems 1041, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0297] In the embodiment of the present application, the central processing unit 1010 is used to execute actions related to model training in the above embodiment.
[0298] An embodiment of the present application also provides a computer program product, which, when running on a computer, enables the computer to execute the steps executed by the aforementioned execution device, or enables the computer to execute the steps executed by the aforementioned training device.
[0299] A computer-readable storage medium is also provided in an embodiment of the present application, which stores a program for signal processing. When the computer-readable storage medium is run on a computer, it enables the computer to execute the steps executed by the aforementioned execution device, or enables the computer to execute the steps executed by the aforementioned training device.
[0300] The execution device, training device or terminal device provided in the embodiments of the present application can specifically be a chip, and 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, a pin or a circuit, etc. The processing unit can execute the computer execution instructions stored in the storage unit, so that the chip in the execution device executes the data processing method described in the above embodiment, or so that the chip in the training device executes the data processing method described in the above embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit can also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
[0301] Specifically, see Figure 11, which is a schematic diagram of the structure of a chip provided in an embodiment of the present application. The chip can be represented as a neural network processor NPU 1100. NPU 1100 is mounted on the host CPU (host CPU) as a coprocessor and is assigned tasks by the host CPU. The core of the NPU is arithmetic circuit 1103, which is controlled by controller 1104 to extract matrix data from memory and perform multiplication operations.
[0302] In some implementations, the arithmetic circuit 1103 includes multiple processing units (PEs). In some implementations, the arithmetic circuit 1103 is a two-dimensional systolic array. The arithmetic circuit 1103 may also be a one-dimensional systolic array or other electronic circuitry capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 1103 is a general-purpose matrix processor.
[0303] For example, assume there are input matrix A, weight matrix B, and output matrix C. The arithmetic circuit retrieves the corresponding data of matrix B from weight memory 1102 and caches it on each PE in the arithmetic circuit. The arithmetic circuit retrieves the data of matrix A from input memory 1101 and performs a matrix operation on matrix B. The partial or final matrix result is stored in accumulator 1108.
[0304] Unified memory 1106 is used to store input and output data. Weight data is directly transferred to weight memory 1102 through the Direct Memory Access Controller (DMAC) 1105. Input data is also transferred to unified memory 1106 through the DMAC.
[0305] BIU stands for Bus Interface Unit, i.e., bus interface unit 1110 , which is used for interaction between the AXI bus, DMAC, and instruction fetch buffer (IFB) 1109 .
[0306] The bus interface unit 1110 (BIU) is used for the instruction fetch memory 1109 to obtain instructions from the external memory, and is also used for the storage unit access controller 1105 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
[0307] DMAC is mainly used to move input data in the external memory DDR to the unified memory 1106 or to move weight data to the weight memory 1102 or to move input data to the input memory 1101.
[0308] The vector calculation unit 1107 includes multiple operation processing units. When necessary, it further processes the output of the operation circuit 1103, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. It is mainly used for non-convolutional / fully connected layer network calculations in neural networks, such as batch normalization, pixel-level summation, and upsampling of feature planes.
[0309] In some implementations, the vector calculation unit 1107 can store the processed output vector in the unified memory 1106. For example, the vector calculation unit 1107 can apply a linear function or a nonlinear function to the output of the operation circuit 1103, such as linear interpolation of the feature plane extracted by the convolution layer, or accumulate a vector of values to generate an activation value. In some implementations, the vector calculation unit 1107 generates a normalized value, a pixel-level summed value, or both. In some implementations, the processed output vector can be used as an activation input to the operation circuit 1103, for example, for use in subsequent layers in a neural network.
[0310] An instruction fetch buffer 1109 connected to the controller 1104 is used to store instructions used by the controller 1104;
[0311] Unified memory 1106, input memory 1101, weight memory 1102, and instruction fetch memory 1109 are all on-chip memories. External memories are private to the NPU hardware architecture.
[0312] The processor mentioned in any of the above places can be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the above program.
[0313] It should also be noted that the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed across multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. In addition, in the drawings of the device embodiments provided in this application, the connection relationship between the modules indicates that there is a communication connection between them, which can be specifically implemented as one or more communication buses or signal lines.
[0314] Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course can also be implemented by special hardware including application-specific integrated circuits, special CPUs, special memories, special components, etc. In general, all functions performed by computer programs can be easily implemented with corresponding hardware, and the specific hardware structures used to implement the same function can also be diverse, such as analog circuits, digital circuits or special circuits, etc. However, for the present application, software program implementation is a better implementation method in most cases. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer's floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., and includes a number of instructions to enable a computer device (which can be a personal computer, training equipment, or network equipment, etc.) to execute the methods described in each embodiment of the present application.
[0315] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0316] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, a computer, a training device or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website, a computer, a training device or a data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
Claims
1. A data processing method, characterized in that: The method comprises: Obtaining a first query query corresponding to the first neural network and a second query corresponding to the 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; Determining a first loss according to the first query and the second query; the first loss indicates minimizing an information difference between the second query and the first query; According to the first loss, the first neural network and the first query are updated.
2. The method according to claim 1, characterized in that The first neural network is obtained by quantizing the second neural network by 2, 3 or 4 bits.
3. The method according to claim 1 or 2, characterized in that: The method further comprises: Performing target detection on the target image according to the first query and the first neural network to obtain information of M first detection boxes; Obtaining a true value of a detection result corresponding to the target image, wherein the true value of the detection result includes a plurality of second detection frames; According to the positional relationship between the first detection frame and the second detection frame, M1 first detection frames are determined from the M first 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 second detection frame satisfies a first preset condition, and the first preset condition is related to the overlap between the regions where the detection frames are located; The first query is a query corresponding to the M1 first detection boxes.
4. The method according to claim 3, characterized in that The method further comprises: Performing target detection on the target image according to the second query and the second neural network to obtain information of N third detection boxes; According to the positional relationship between each first detection frame in the M1 first detection frames and the third detection frame, 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, and the second preset condition is related to the overlap between the regions where the detection frames are located; The second query is a query corresponding to the M1 third detection boxes.
5. The method according to claim 3 or 4, characterized in that: The information of the first detection frame and the third detection frame includes the position and size of the detection frame and the category corresponding to the image content of the detection frame.
6. The method according to any one of claims 1 to 5, characterized in that: The first query is obtained by adjusting the distribution of queries corresponding to the first neural network to a preset type of distribution.
7. The method according to claim 6, characterized in that The preset type of distribution is Gaussian distribution.
8. The method according to any one of claims 1 to 7, characterized in that: The information difference is represented by the L2 norm or conditional entropy.
9. The method according to any one of claims 3 to 8, 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 performing target detection on the target image according to the first query and the first neural network includes: According to the target image, obtaining a first intermediate output through the first backbone network and the first encoder; Processing the first query and the first intermediate output by the first decoder; The performing target detection on the target image according to the second query and the second neural network includes: According to the target image, obtaining a second intermediate output through the second backbone network and the second encoder; The second query and the second intermediate output are processed by the second decoder.
10. A data processing method, characterized in that: The method comprises: Get the image; By using the updated first neural network and the updated first query obtained according to any one of claims 1 to 9, target detection is performed on the image to obtain a processing result.
11. A data processing device, characterized in that: The device comprises: An acquisition module, used to acquire a first query 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; A processing module, configured to determine a first loss according to the first query and the second query; the first loss indicates minimizing an information difference between the second query and the first query; According to the first loss, the first neural network and the first query are updated.
12. The device according to claim 11, characterized in that The first neural network is obtained by quantizing the second neural network by 2, 3 or 4 bits.
13. The device according to claim 11 or 12, characterized in that The processing module is further used for: Performing target detection on the target image according to the first query and the first neural network to obtain information of M first detection boxes; Obtaining a true value of a detection result corresponding to the target image, wherein the true value of the detection result includes a plurality of second detection frames; According to the positional relationship between the first detection frame and the second detection frame, M1 first detection frames are determined from the M first 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 second detection frame satisfies a first preset condition, and the first preset condition is related to the overlap between the regions where the detection frames are located; The first query is a query corresponding to the M1 first detection boxes.
14. The device according to claim 13, characterized in that The processing module is further used for: Performing target detection on the target image according to the second query and the second neural network to obtain information of N third detection boxes; According to the positional relationship between each first detection frame in the M1 first detection frames and the third detection frame, 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, and the second preset condition is related to the overlap between the regions where the detection frames are located; The second query is a query corresponding to the M1 third detection boxes.
15. The device according to claim 13 or 14, characterized in that The information of the first detection frame and the third detection frame includes the position and size of the detection frame and the category corresponding to the image content of the detection frame.
16. The device according to any one of claims 11 to 15, characterized in that The first query is obtained by adjusting the distribution of queries corresponding to the first neural network to a preset type of distribution.
17. The device according to claim 16, characterized in that The preset type of distribution is Gaussian distribution.
18. The device according to any one of claims 11 to 17, characterized in that The information difference is represented by the L2 norm or conditional entropy.
19. The device according to any one of claims 11 to 18, 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: According to the target image, obtaining a first intermediate output through the first backbone network and the first encoder; Processing the first query and the first intermediate output by the first decoder; According to the target image, obtaining a second intermediate output through the second backbone network and the second encoder; The second query and the second intermediate output are processed by the second decoder.
20. A data processing device, characterized in that: The device comprises: An acquisition module, used for acquiring images; A processing module, used to perform target detection on the image by using the updated first neural network and the updated first query obtained according to any one of claims 1 to 9 to obtain a processing result.
21. A computer storage medium, characterized in that The computer storage medium stores one or more instructions which, when executed by one or more computers, cause the one or more computers to perform the operations of the method of any one of claims 1 to 10.
22. A computer program product, characterized in that The method comprises computer-readable instructions, and when the computer-readable instructions are executed on a computer device, the computer device is caused to execute the method according to any one of claims 1 to 10.
23. 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 configured to execute the code to perform the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
A data processing method and apparatus
CN116861968B
Target detection method and apparatus, and neural network training method and apparatus
CN106778867A
Deep learning training method and device for computing equipment
CN112183718A
Model compression method and device
CN112257858A
Data processing method and device
CN116861968A
Cited By
Performance detection method of artificial intelligence model and related device
CN119718890A
Model pruning method and system based on weighted attention alignment
CN119990231A
Lightweight stereo image super-resolution reconstruction method and device
CN120355573A
Online evaluation system and method based on occupational skills
CN121146611A
Cable testing method and small handheld cable tester
CN121541002A
