Data processing method and apparatus therefor
By combining channel self-attention and spatial self-attention mechanisms within the same network layer, the shortcomings of transformer-based networks in establishing spatial dependencies are addressed, thereby improving processing accuracy.
Patent Information
- Application Number
- PCT/CN2025/078435
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-02-27
- Filing Date
- 2025-02-21
- Publication Date
- 2025-10-30
AI Technical Summary
Transformer-based networks cannot effectively establish direct dependencies between different spatial locations and spatial dependencies between windows when implementing attention operations, resulting in poor processing accuracy.
By combining channel self-attention and spatial self-attention mechanisms within the same network layer, and performing operations in parallel or series, direct dependencies between different spatial locations are established and spatial dependencies between windows are captured.
This improves the network's ability to learn direct dependencies between different spatial locations and spatial dependencies between windows, thereby enhancing processing accuracy.
Smart Images

Figure CN2025078435_30102025_PF_FP_ABST
Abstract
Description
A data processing method and apparatus
[0001] This application claims priority to Chinese Patent Application No. 202410216885.2, filed on February 27, 2024, entitled “A Data Processing Method and Apparatus”, the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of artificial intelligence, and more particularly to a data processing method and apparatus thereof. Background Technology
[0003] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a branch of computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.
[0004] Transformer-based networks are a type of neural network based on a self-attention mechanism. In existing implementations, when implementing attention operations, transformer-based networks either compute self-attention along the channel dimension, failing to establish direct dependencies between different spatial locations, or compute self-attention within the spatial dimension, failing to clearly and completely capture spatial dependencies between windows, thus leading to poor processing accuracy.
[0005] Therefore, there is an urgent need to design a network architecture that can capture spatial dependencies between windows and establish direct dependencies between different spatial locations. Summary of the Invention
[0006] Firstly, this application provides a data processing method applied to a machine learning model. The machine learning model includes a first network, a target network layer, and a second network. The first network layer can be a network connected before the target network layer in the machine learning model, and the second network layer can be a network connected after the target network layer in the machine learning model. When processing data, the machine learning model can obtain a first feature representation of the target data through the first network based on the target data input to the machine learning model. Based on the first feature representation, a feature extraction operation is performed through the target network layer to obtain a second feature representation of the target data. The feature extraction operation includes operations of self-attention mechanisms between different channels and between different spaces. The target network layer is a network layer in the first network. Based on the second feature representation, the processing result of the target data is obtained through the second network.
[0007] In existing implementations, when implementing attention operations, the target network layer either calculates self-attention along the channel dimension, failing to establish direct dependencies between different spatial locations, or calculates self-attention within the spatial dimension, failing to clearly and completely capture spatial dependencies between windows. In this embodiment, self-attention mechanisms between different channels and between different spaces are performed simultaneously within the same network layer. By combining channel-based self-attention with a grid-based spatial self-attention mechanism, it can both establish direct dependencies between different spatial locations, supplementing the lack of direct interaction between distant pixels in spatial self-attention, and capture spatial dependencies between windows.
[0008] The target network layer can be a layer within the first network, such as a transformer layer within the first network. Implementing both spatial and channel self-attention operations within the same network layer allows for interactive operations between two dimensions (space and channel). Compared to performing spatial and channel self-attention operations in different network layers, this further improves the network's ability to learn direct dependencies between different spatial locations and spatial dependencies between windows. In one possible implementation, the target network layer is a transformer layer.
[0009] For example, the target data is image data, and a machine learning model can be used to perform image processing tasks. The processing result obtained by processing the target data through the machine learning model is the processing result of the image processing task.
[0010] For example, the target data is audio data, and a machine learning model can be used to perform audio processing tasks. The processing result obtained by processing the target data through the machine learning model is the processing result of the audio processing task.
[0011] For example, if the target data is text data, a machine learning model can be used to perform text processing tasks, and the processing result obtained by processing the target data through the machine learning model is the processing result of the text processing task.
[0012] For example, image processing tasks can include image classification, object recognition, image enhancement (such as, but not limited to, super-resolution, denoising, deraining, deblurring, demosaicing, etc.), and image generation.
[0013] For example, audio processing tasks can include speech-to-text, audio enhancement, and audio synthesis.
[0014] For example, text processing tasks can include summary generation, dialogue response, and text-to-image generation.
[0015] In one possible implementation, the target network layer includes a first attention module and a second attention module. The step of performing feature extraction operations through the target network layer based on the first feature representation includes: performing a self-attention operation mechanism between different channels on the first feature representation through the first attention module; and performing a self-attention mechanism between different spaces on the first feature representation after the operation of the self-attention operation mechanism between different channels through the second attention module.
[0016] In other words, the first attention module in the target network layer, which is used to perform self-attention operations between different channels, can be connected in series with the second attention module, which is used to perform self-attention operations between different spaces, and the first attention module is connected before the second attention module.
[0017] In one possible implementation, the target network layer includes a first attention module and a second attention module. The step of performing feature extraction operations through the target network layer based on the first feature representation includes: performing self-attention mechanism operations between different spaces on the first feature representation through the first attention module; and performing self-attention operation mechanism operations between different channels on the first feature representation after self-attention operations within the spatial dimension through the second attention module.
[0018] In other words, the first attention module in the target network layer, which is used to perform self-attention operations between different channels, can be connected in series with the second attention module, which is used to perform self-attention operations between different spaces, and the second attention module is connected before the first attention module.
[0019] In one possible implementation, the target network layer includes a first processing branch and a second processing branch in parallel. The first processing branch includes a first attention module, and the second processing branch includes a second attention module. The processing result of the first processing branch is used to fuse with the processing result of the second processing branch.
[0020] In other words, the first attention module in the target network layer, which performs self-attention operations between different channels, and the second attention module, which performs self-attention operations between different spaces, are not connected in series, but belong to different branches in parallel.
[0021] For example, the first attention module and the second attention module can be connected in parallel. That is, the first attention module in the target network layer, which performs self-attention operations between different channels, can be connected in parallel with the second attention module, which performs self-attention operations between different spaces. The first attention module can perform self-attention operations between different channels on the first feature representation; the second attention module can perform self-attention operations between different spaces on the first feature representation; and the first feature representation after the self-attention operations between different channels and the first feature representation after the self-attention operations within the spatial dimension are then fused.
[0022] In one possible implementation, the operation of the self-attention mechanism between different channels includes: dividing the Q matrix, K matrix, and V matrix of the input features to obtain multiple first Q matrices, multiple first K matrices, and multiple first V matrices; wherein the first Q matrix, the first K matrix, and the first V matrix are in one-to-one correspondence, and the sizes of the corresponding first Q matrix, the first K matrix, and the first V matrix are consistent; obtaining multiple first calculation results based on the multiple first Q matrices, the multiple first K matrices, and the multiple first V matrices, each of the first calculation results being obtained through operation between the corresponding first Q matrix, the first K matrix, and the first V matrix; and using the fusion result of the multiple first calculation results to obtain the result of the operation of the self-attention mechanism between different channels.
[0023] Channel self-attention (CSA) computes self-attention along the channel dimension, thus achieving computational complexity linear with resolution. CSA is a spatially global self-attention computation method that can obtain a certain global perspective. However, the global perspective of CSA is obtained indirectly through the computation of the channel self-attention matrix across the entire global scope; it is a coarse global perspective and cannot accurately capture the dependencies that establish the global context.
[0024] In this embodiment of the application, in order to make the channel self-attention mechanism pay more attention to local information, the original global-based channel self-attention mechanism is improved into a local context-based channel self-attention mechanism.
[0025] In one possible implementation, the elements of the input feature's Q, K, and V matrices can be shuffled and partitioned to obtain multiple second Q matrices, multiple second K matrices, and multiple second V matrices. These second Q matrices, second K matrices, and second V matrices correspond one-to-one, and their sizes are identical. Unlike Method 1, which directly splits the window based on partitions and calculates channels within non-overlapping windows, Method 2 first slides the window spatially and then calculates the self-attention of the window channels in the same way. Similar to Method 1, Method 2 can also obtain multiple second calculation results based on the multiple second Q matrices, the multiple second K matrices, and the multiple second V matrices. Each second calculation result is obtained through operations between corresponding second Q matrices, second K matrices, and second V matrices. The fusion result (e.g., concatenation) of these multiple second calculation results is used to obtain the result of the self-attention operation mechanism between the different channels.
[0026] In one possible implementation, the method further includes: fusing the fusion result of multiple first operation results and the fusion result of multiple second operation results to obtain the operation result of the self-attention operation mechanism between the different channels.
[0027] In one possible implementation, the first network, the target network layer, or the second network further includes: a feedforward network (FFN); the FFN is used to perform multiple parallel depthwise separable convolution operations and / or multiple cascaded point convolution operations on the results obtained from nonlinear activation; or, the FFN is used to perform a target point convolution operation on the results obtained from nonlinear activation.
[0028] In existing technologies, locally enhanced feedforward networks improve local feature extraction capabilities by inserting a 3x3 depthwise separable convolution between 1x1 convolutions in a feedforward network. However, the receptive field of a 3x3 depthwise separable convolution is limited, making it unable to extract larger-scale local features.
[0029] In this embodiment, multiple parallel depthwise separable convolution operations and / or multiple cascaded point convolution operations are connected after the nonlinear layer, thereby enabling the extraction of local features at a larger scale and significantly enhancing the performance of FFN.
[0030] In one possible implementation,
[0031] During model training, the FFN is used to perform multiple parallel depthwise separable convolution operations and / or multiple cascaded point convolution operations on the results obtained from nonlinear activation.
[0032] During model inference, the FFN is used to perform target point convolution operations on the results obtained from nonlinear activation, and the target point convolution operation is equivalent to the multiple parallel depthwise separable convolution operations and / or the multiple cascaded point convolution operations after training.
[0033] During training, the network's representational capabilities are enhanced by adding sequential point convolutions and parallel depthwise separable convolutions with various kernel sizes. During inference, the sequential point convolutions are reparameterized into single point convolutions, and the parallel multi-path depthwise separable convolutions are reparameterized into depthwise separable convolutions with a large kernel. Thus, without sacrificing the model's representational capabilities, the computational cost during inference is significantly reduced.
[0034] Secondly, this application provides a data processing apparatus for processing a machine learning model, the machine learning model including a first network, a target network layer, and a second network, the apparatus comprising:
[0035] The acquisition module is used to acquire target data;
[0036] The processing module is configured to obtain a first feature representation of the target data through the first network based on the target data; and to perform feature extraction operations through the target network layer based on the first feature representation to obtain a second feature representation of the target data; wherein the feature extraction operations include operations of self-attention mechanisms between different channels and operations of self-attention mechanisms between different spaces, and the target network layer is a network layer in the first network;
[0037] Based on the second feature representation, the processing result of the target data is obtained through the second network.
[0038] In one possible implementation,
[0039] The target data is image data, and the processing result is the result of the image processing task; or,
[0040] The target data is audio data, and the processing result is the result of the audio processing task; or,
[0041] The target data is text data, and the processing result is the result of the text processing task.
[0042] In one possible implementation, the target network layer includes a first attention module and a second attention module, and the processing module is specifically used for:
[0043] The first attention module performs self-attention operation on the first feature representation through different channels;
[0044] The second attention module performs self-attention mechanism operations between different spaces on the first feature representation after it has been processed by the self-attention operation mechanism between the different channels.
[0045] In one possible implementation, the target network layer includes a first attention module and a second attention module, and the processing module is specifically used for:
[0046] The first attention module performs self-attention mechanism operations between different spaces on the first feature representation.
[0047] The second attention module performs self-attention operations between different channels on the first feature representation after self-attention operations within the spatial dimension.
[0048] In one possible implementation, the target network layer includes a first processing branch and a second processing branch in parallel. The first processing branch includes a first attention module, and the second processing branch includes a second attention module. The processing result of the first processing branch is used to fuse with the processing result of the second processing branch.
[0049] In one possible implementation, the operation of the self-attention mechanism between the different channels includes:
[0050] The Q matrix, K matrix, and V matrix of the input features are divided to obtain multiple first Q matrices, multiple first K matrices, and multiple first V matrices; wherein the first Q matrix, the first K matrix, and the first V matrix correspond one-to-one, and the sizes of the first Q matrix, the first K matrix, and the first V matrix with the corresponding relationship are consistent.
[0051] Based on the plurality of first Q matrices, the plurality of first K matrices, and the plurality of first V matrices, a plurality of first calculation results are obtained, each of which is obtained by operation between the first Q matrices, the first K matrices, and the first V matrices that have a corresponding relationship;
[0052] The results of the multiple first operations are fused together to obtain the result of the self-attention operation mechanism between the different channels.
[0053] In one possible implementation, the operation of the self-attention mechanism between the different channels includes:
[0054] The elements of the Q, K, and V matrices of the input features are shuffled and partitioned to obtain multiple second Q matrices, multiple second K matrices, and multiple second V matrices; wherein the second Q matrices, the second K matrices, and the second V matrices correspond one-to-one, and the corresponding second Q matrices, second K matrices, and second V matrices have the same size;
[0055] Based on the plurality of second Q matrices, the plurality of second K matrices, and the plurality of second V matrices, a plurality of second calculation results are obtained, each of which is obtained by operation between corresponding second Q matrices, second K matrices, and second V matrices; the fusion result of the plurality of second calculation results is used to obtain the result of the operation of the self-attention operation mechanism between the different channels.
[0056] In one possible implementation, the processing module is further configured to:
[0057] By fusing the fusion results of multiple first operation results and the fusion results of multiple second operation results, the operation result of the self-attention operation mechanism between the different channels is obtained.
[0058] In one possible implementation, the first network, the target network layer, or the second network further includes a feedforward network (FFN).
[0059] The FFN is used to perform multiple parallel depthwise separable convolution operations and / or multiple cascaded pointwise convolution operations on the results obtained from nonlinear activation; or,
[0060] The FFN is used to perform target point convolution operations on the results obtained from nonlinear activation.
[0061] In one possible implementation,
[0062] During model training, the FFN is used to perform multiple parallel depthwise separable convolution operations and / or multiple cascaded point convolution operations on the results obtained from nonlinear activation.
[0063] During model inference, the FFN is used to perform target point convolution operations on the results obtained from nonlinear activation, and the target point convolution operation is equivalent to the multiple parallel depthwise separable convolution operations and / or the multiple cascaded point convolution operations after training.
[0064] Thirdly, embodiments of this application provide a data processing apparatus, which may include a memory, a processor, and a bus system, wherein the memory is used to store a program, and the processor is used to execute the program in the memory to perform the methods described in the first aspect above and any of its optional methods.
[0065] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when run on a computer, causes the computer to perform the methods described in the first aspect and any of its optional methods.
[0066] Fifthly, embodiments of this application provide a computer program that, when run on a computer, causes the computer to perform the methods described in the first aspect and any of its optional methods.
[0067] Sixthly, this application provides a chip system including a processor for supporting an execution data processing device in implementing the functions involved in the foregoing aspects, such as transmitting or processing data involved in the foregoing methods; or, information. In one possible design, the chip system further includes a memory for storing program instructions and data necessary for the execution device or training device. This chip system may be composed of chips or may include chips and other discrete devices. Attached Figure Description
[0068] Figure 1 is a schematic diagram of a structural framework for artificial intelligence.
[0069] Figure 2 is a schematic diagram of a server structure;
[0070] Figure 3 is a flowchart illustrating a data processing method provided in an embodiment of this application;
[0071] Figure 4 illustrates the process of a cloud service.
[0072] Figure 5 is a flowchart illustrating a data processing method provided in an embodiment of this application;
[0073] Figure 6 is a schematic diagram of a data processing method provided in an embodiment of this application;
[0074] Figure 7 is a schematic diagram of a data processing method provided in an embodiment of this application;
[0075] Figure 8 is a schematic diagram of a data processing method provided in an embodiment of this application;
[0076] Figure 9A is a schematic diagram of a data processing method provided in an embodiment of this application;
[0077] Figure 9B is a schematic diagram of a data processing method provided in an embodiment of this application;
[0078] Figure 9C is a schematic diagram of an effect provided by an embodiment of this application;
[0079] Figure 10 is a schematic diagram of a data processing device provided in an embodiment of this application;
[0080] Figure 11 is a schematic diagram of an execution device provided in an embodiment of this application;
[0081] Figure 12 is a schematic diagram of a training device provided in an embodiment of this application;
[0082] Figure 13 is a schematic diagram of a chip structure provided in an embodiment of this application. Detailed Implementation
[0083] The embodiments of the present invention will now be described with reference to the accompanying drawings. The terminology used in the embodiments section is for illustrative purposes only and is not intended to limit the scope of the invention.
[0084] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0085] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.
[0086] The terms “substantially,” “about,” and similar terms used herein are used as approximations rather than as terms of degree, and are intended to take into account the inherent biases of measurements or calculations known to those skilled in the art. Furthermore, the use of “may” in describing embodiments of the invention refers to “one or more possible embodiments.” The terms “use,” “using,” and “used” used herein are to be considered synonymous with the terms “utilize,” “utilizing,” and “utilized,” respectively. Additionally, the term “exemplary” is intended to refer to an instance or illustration.
[0087] First, the overall workflow of an artificial intelligence system is described, as shown in Figure 1. Figure 1 is a structural diagram of the main framework of artificial intelligence. The framework is then elaborated on from two dimensions: the "Intelligent Information Chain" (horizontal axis) and the "IT Value Chain" (vertical axis). The "Intelligent Information Chain" reflects a series of processes from data acquisition to processing. For example, it could be the general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, and intelligent execution and output. In this process, data undergoes a condensation process of "data—information—knowledge—wisdom." The "IT Value Chain" reflects the value that artificial intelligence brings to the information technology industry, from the underlying infrastructure of human intelligence and information (provided and processed by technology) to the industrial ecosystem of the system.
[0088] (1) Infrastructure
[0089] Infrastructure provides computing power to support artificial intelligence systems, enabling communication with the external world and providing support through a basic platform. This communication occurs through sensors; computing power is provided by intelligent chips (hardware acceleration chips such as CPUs, NPUs, GPUs, ASICs, and FPGAs); and the basic platform includes distributed computing frameworks and related platform guarantees and support, which may include cloud storage and computing, interconnected networks, etc. For example, sensors communicate with the outside world to acquire data, and this data is provided to intelligent chips in the distributed computing system provided by the basic platform for computation.
[0090] (2) Data
[0091] The data at the next layer of infrastructure is used to represent the data sources in the field of artificial intelligence. The data involves graphics, images, voice, text, and IoT data from traditional devices, including business data from existing systems and sensor data such as force, displacement, liquid level, temperature, and humidity.
[0092] (3) Data processing
[0093] Data processing typically includes methods such as data training, machine learning, deep learning, search, reasoning, and decision-making.
[0094] Among them, machine learning and deep learning can perform intelligent information modeling, extraction, preprocessing, and training of data by symbolizing and formalizing it.
[0095] Reasoning refers to the process in which, in a computer or intelligent system, the machine thinks and solves problems by simulating human intelligent reasoning, based on reasoning control strategies and using formalized information. Typical functions include search and matching.
[0096] Decision-making refers to the process of making decisions based on intelligent information after reasoning, and it typically provides functions such as classification, sorting, and prediction.
[0097] (4) General ability
[0098] After the data processing mentioned above, the results of the data processing can be used to form some general capabilities, such as algorithms or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.
[0099] (5) Smart Products and Industry Applications
[0100] Intelligent products and industry applications refer to products and applications of artificial intelligence systems in various fields. They are the encapsulation of overall artificial intelligence solutions, productizing intelligent information decision-making and realizing practical applications. Their application areas mainly include: intelligent terminals, intelligent transportation, intelligent healthcare, autonomous driving, smart cities, etc.
[0101] It should be understood that the steps related to the model inference process in the embodiments of this application involve AI-related operations. When performing AI operations, the instruction execution architecture of the terminal device and the server is not limited to the processor-memory architecture described above. The system architecture provided in the embodiments of this application will be described in detail below with reference to Figure 2.
[0102] Figure 2 is a schematic diagram of the system architecture provided in an embodiment of this application. As shown in Figure 2, 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.
[0103] The execution device 510 includes a computing module 511, an I / O interface 512, a preprocessing module 513, and a preprocessing module 514. The computing module 511 may include a machine learning model / rule 501, while the preprocessing modules 513 and 514 are optional.
[0104] The execution device 510 can be a terminal device or a server that runs the aforementioned image editing and recognition application.
[0105] The data acquisition device 560 is used to collect training samples. Training samples can be image data, etc. After collecting the training samples, the data acquisition device 560 stores these training samples in the database 530.
[0106] The training device 520 can maintain training samples in the database 530 and obtain the machine learning model / rule 501 from the neural network to be trained (e.g., the machine learning model in the embodiments of this application).
[0107] 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.
[0108] It should be noted that in practical applications, the training samples maintained in database 530 may not all come from the data acquisition device 560; they may also be received from other devices. Furthermore, it should be noted that training device 520 may not necessarily train the machine learning model / rule 501 entirely based on the training samples maintained in database 530; it may also obtain training samples from the cloud or other sources for model training. The above description should not be construed as limiting the embodiments of this application.
[0109] The machine learning model / rule 501 trained by the training device 520 can be applied to different systems or devices, such as the execution device 510 shown in Figure 2. The execution device 510 can be a terminal, such as a mobile terminal, tablet computer, laptop computer, augmented reality (AR) / virtual reality (VR) device, vehicle terminal, etc., or it can be a server, etc.
[0110] Specifically, the training device 520 can transfer the trained model to the execution device 510.
[0111] In Figure 2, the execution device 510 is configured with an input / output (I / O) interface 512 for data interaction with external devices. Users can input data (such as target data in this embodiment) into the I / O interface 512 through the client device 540.
[0112] Preprocessing modules 513 and 514 are used to preprocess the input data received from the I / O interface 512. It should be understood that preprocessing modules 513 and 514 may be absent, or only one preprocessing module may be used. When preprocessing modules 513 and 514 are absent, the calculation module 511 can be used directly to process the input data.
[0113] During the preprocessing of input data by the execution device 510, or during the calculation module 511 of the execution device 510 performing calculations and other related processes, the execution device 510 can call data, code, etc. in the data storage system 550 for corresponding processing, or store the data, instructions, etc. obtained from the corresponding processing into the data storage system 550.
[0114] Finally, the I / O interface 512 provides the processing result to the client device 540, thereby providing it to the user.
[0115] In the scenario shown in Figure 2, the user can manually provide input data, which can be done through the interface provided by I / O interface 512. Alternatively, the client device 540 can automatically send input data to I / O interface 512. If user authorization is required for the client device 540 to automatically send input data, the user can set the corresponding permissions in the client device 540. The user can view the output results of the execution device 510 on the client device 540, which can be presented in various forms such as display, sound, or animation. The client device 540 can also act as a data acquisition terminal, collecting the input data and output results of the input I / O interface 512 as shown in the figure, and storing them as new sample data in database 530. Alternatively, data can be collected directly from the I / O interface 512 without going through the client device 540, using the input data and output results of the input I / O interface 512 as shown in the figure, and storing them as new sample data in database 530.
[0116] It is worth noting that Figure 2 is merely a schematic diagram of a system architecture provided in an embodiment of this application. The positional relationships between the devices, components, modules, etc., shown in the figure do not constitute any limitation. For example, in Figure 2, 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 aforementioned execution device 510 can be deployed in the client device 540.
[0117] From the inference side of the model:
[0118] In this embodiment, the computing module 511 of the 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 this embodiment.
[0119] In this embodiment of the application, the computing module 511 of the execution device 510 may include hardware circuits (such as application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), general-purpose processors, digital signal processors (DSPs), microprocessors or microcontrollers, etc.) or combinations of these hardware circuits. For example, the training device 520 may be a hardware system with instruction execution capabilities, such as a CPU or DSP, or a hardware system without instruction execution capabilities, such as an ASIC or FPGA, or a combination of the aforementioned hardware systems without instruction execution capabilities and hardware systems with instruction execution capabilities.
[0120] Specifically, the computing module 511 of the execution device 510 can be a hardware system with the function of executing instructions. The steps related to the model inference process provided in this application embodiment can be software code stored in the memory. The computing module 511 of the execution device 510 can obtain the software code from the memory and execute the obtained software code to implement the steps related to the model inference process provided in this application embodiment.
[0121] It should be understood that the computing module 511 of the execution device 510 can be a combination of a hardware system without the function of executing instructions and a hardware system with the function of executing instructions. Some steps related to the model reasoning process provided in the embodiments of this application can also be implemented by the hardware system in the computing module 511 of the execution device 510 without the function of executing instructions, which is not limited here.
[0122] From the training side of the model:
[0123] In this embodiment, the training device 520 can obtain the code stored in the memory (not shown in Figure 2, 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 this embodiment.
[0124] In this embodiment of the application, the training device 520 may include hardware circuits (such as application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), general-purpose processors, digital signal processors (DSPs), microprocessors or microcontrollers, etc.) or combinations of these hardware circuits. For example, the training device 520 may be a hardware system with instruction execution capabilities, such as a CPU or DSP, or a hardware system without instruction execution capabilities, such as an ASIC or FPGA, or a combination of the aforementioned hardware systems without instruction execution capabilities and hardware systems with instruction execution capabilities.
[0125] It should be understood that the training device 520 can be a combination of a hardware system without the function of executing instructions and a hardware system with the function of executing instructions. Some steps related to the training of the neutralization model provided in the embodiments of this application can also be implemented by the hardware system in the training device 520 without the function of executing instructions, which is not limited here.
[0126] Since the embodiments of this application involve a large number of neural network applications, for ease of understanding, the relevant terms and concepts such as neural networks involved in the embodiments of this application will be introduced below.
[0127] (1) Neural Network
[0128] A neural network can be composed of neural units, which can be defined as a computational unit that takes xs (i.e., input data) and an intercept of 1 as input. The output of this computational unit can be:
[0129] Where s = 1, 2, ..., n, where n is a natural number greater than 1, Ws is the weight of xs, and b is the bias of the neural unit. f is the activation function of the neural unit, used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into an output signal. The output signal of this activation function can be used as the input of the next convolutional layer, and the activation function can be the sigmoid function. A neural network is a network formed by connecting multiple of the above-mentioned individual neural units together, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the features of the local receptive field, which can be a region composed of several neural units.
[0130] (2) A convolutional neural network (CNN) is a deep neural network with a convolutional structure. A CNN contains a feature extractor consisting of convolutional layers and subsampling layers, which can be viewed as a filter. A convolutional layer refers to the layer of neurons in a CNN that performs convolutional processing on the input signal. In a convolutional layer of a CNN, a neuron can be connected to only some of the neurons in its neighboring layers. A convolutional layer typically contains several feature planes, each composed of rectangularly arranged neural units. Neural units on the same feature plane share weights, which are the convolutional kernel. Shared weights can be understood as the way features are extracted being independent of their location. The convolutional kernel can be formalized as a matrix of random size, and during the training process of the CNN, the kernel can learn reasonable weights. Furthermore, the direct benefit of shared weights is reducing the connections between layers in the CNN, while also reducing the risk of overfitting.
[0131] CNN is a very common type of neural network. A Convolutional Neural Network (CNN) is a deep neural network with a convolutional structure, and it's a deep learning architecture. Deep learning architectures refer to learning at multiple levels of abstraction using machine learning algorithms. As a deep learning architecture, CNN is a feed-forward artificial neural network, where each neuron can respond to the input image.
[0132] (3) Deep Neural Networks
[0133] Deep Neural Networks (DNNs), also known as multilayer neural networks, can be understood as neural networks with many hidden layers, though there's no specific metric for "many." DNNs can be categorized into three layers based on their position: input layers, hidden layers, and output layers. Generally, the first layer is the input layer, the last layer is the output layer, and the layers in between are hidden layers. All layers are fully connected, meaning that any neuron in the i-th layer is connected to any neuron in the (i+1)-th layer. Although DNNs appear complex, the operation of each layer is actually quite simple, resembling a linear relationship as follows: in, It is the input vector. It is the output vector. α is the offset vector, W is the weight matrix (also called coefficients), and α() is the activation function. Each layer is simply an adjustment of the input vector. The output vector is obtained through such a simple operation. Because DNNs have many layers, the coefficients W and the offset vector... The number of these parameters is therefore quite large. The definitions of these parameters in a DNN are as follows: Taking the coefficient W as an example: Assuming a three-layer DNN, the linear coefficient from the 4th neuron in the second layer to the 2nd neuron in the third layer is defined as... The superscript 3 represents the layer number where coefficient W resides, while the subscript corresponds to the output third layer index 2 and the input second layer index 4. In summary, the coefficients from the k-th neuron in layer L-1 to the j-th neuron in layer L are defined as follows: It's important to note that the input layer does not have a W parameter. In deep neural networks, more hidden layers allow the network to better represent complex real-world situations. Theoretically, the more parameters a model has, the higher its complexity and "capacity," meaning it can perform more complex learning tasks. Training a deep neural network is essentially the process of learning the weight matrix, with the ultimate goal of obtaining the weight matrix of all layers in the trained deep neural network (a weight matrix formed by the vectors W from many layers).
[0134] (4) Loss Function
[0135] In training a deep neural network, to ensure the output closely approximates the desired predicted value, we compare the network's prediction with the target value. Based on the difference, we update the weight vector of each layer (usually pre-configuring parameters before the initial update). For example, if the prediction is too high, the weight vector is adjusted to predict a lower value. This adjustment continues until the deep neural network predicts the target value or a value very close to it. Therefore, we need to predefine "how to compare the difference between the predicted and target values," which is the loss function or objective function. These are important equations used to measure the difference between the predicted and target values. Taking the loss function as an example, a higher output value (loss) indicates a greater difference, and training the deep neural network becomes a process of minimizing this loss.
[0136] (5) Backpropagation algorithm
[0137] Backpropagation (BP) can be used during training to correct the parameters in the initial model, thereby reducing the model's error loss. Specifically, forward propagation of the input signal to the output generates error loss; this error loss information is then propagated back to update the parameters in the initial model, leading to convergence of the error loss. The backpropagation algorithm is an error-loss-driven backpropagation process aimed at obtaining optimal model parameters, such as the weight matrix.
[0138] (6) Transformer network
[0139] A transformer network may include an embedding layer and at least one transformer layer. The at least one transformer layer may consist of N transformer layers (N being an integer greater than 0), where each transformer layer includes sequentially adjacent attention layers, add and normalize layers, feed-forward layers, and add and normalize layers. In the embedding layer, the current input is embedded to obtain multiple feature vectors. In the attention layer, P input vectors are obtained from the layer above the transformer layer. Using any first input vector among the P input vectors as the center, intermediate vectors corresponding to the first input vector are obtained based on the correlation between each input vector within a preset attention window and the first input vector. This process determines P intermediate vectors corresponding to the P input vectors. In the pooling layer, the P intermediate vectors are merged into Q output vectors, where the multiple output vectors obtained from the last transformer layer in at least one transformer layer are used as feature representations of the current input.
[0140] Next, we will explain each of the above steps in detail with specific examples.
[0141] First, in the embedding layer, the current input is embedded to obtain multiple feature vectors.
[0142] The embedding layer can be referred to as the input embedding layer. The current input can be a text input, such as a passage of text or a sentence. The text can be Chinese text, English text, or text in other languages. After obtaining the current input, the embedding layer can perform embedding processing on each word in the current input to obtain the feature vectors of each word. In some embodiments, the embedding layer includes an input embedding layer and a positional encoding layer. In the input embedding layer, word embedding processing can be performed on each word in the current input to obtain the word embedding vectors of each word. In the positional encoding layer, the position of each word in the current input can be obtained, and then the position vector of each word can be processed. In some examples, the position of each word can be the absolute position of each word in the current input. Taking the current input "When should I pay back Huabei" as an example, the position of "When" can be represented as the first position, the position of "should" can be represented as the second position, and so on. In some examples, the position of each word can be the relative position between each word. Still taking the current input "When should I pay back" as an example, the position of "When" can be represented as before "should", the position of "should" can be represented as after "When" and before "pay back", and so on. When the word embedding vectors and position vectors of each word in the current input are obtained, the position vectors of each word and the corresponding word embedding vectors can be combined to obtain the feature vectors of each word, that is, multiple feature vectors corresponding to the current input are obtained. The multiple feature vectors can be represented as an embedding matrix with a preset dimension. It can be set that the number of feature vectors in the multiple feature vectors is M, and the preset dimension is H dimensions, then the multiple feature vectors can be represented as an M×H embedding matrix.
[0143] (7) Attention mechanism
[0144] The attention mechanism mimics the internal process of biological observation behavior, that is, a mechanism that aligns internal experience and external sensations to increase the observation fineness of some areas, and can quickly screen out high-value information from a large amount of information using limited attention resources. The attention mechanism can quickly extract the important features of sparse data and is thus widely used in natural language processing tasks, especially machine translation. The self-attention mechanism is an improvement of the attention mechanism, which reduces the 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:
[0145] In this formula, Lx = ||Source|| represents the length of the Source. The meaning is that the elements in the Source are imagined as a series of data pairs. Given a Query element in the Target, the similarity or relevance between the Query and each Key is calculated to obtain the weight coefficient of the Value corresponding to each Key. Then, the Values are weighted and summed to obtain the final Attention value. Therefore, the Attention mechanism essentially performs a weighted sum of the Values of the elements in the Source, while the Query and Key are used to calculate the weight coefficients of their corresponding Values. Conceptually, Attention can be understood as selectively filtering a small amount of important information from a large amount of information and focusing on this important information, ignoring most of the unimportant information. The focusing process is reflected in the calculation of the weight coefficients; the larger the weight, the more focused it is on its corresponding Value. That is, the weight represents the importance of the information, and the Value is the corresponding information. Self-attention can be understood as intra attention. The attention mechanism occurs between the elements of the Target (Query) and all elements of the Source. Self-attention refers to the attention mechanism that occurs between elements within the Source or between elements within the Target. It can also be understood as the attention calculation mechanism in the special case where Target = Source. The specific calculation process is the same, only the calculation object changes.
[0146] The Transformer architecture, through its multi-head attention mechanism, can effectively simulate long-range dependencies. However, the computational complexity of the traditional Transformer architecture increases quadratically with the input size, making it difficult to directly apply to high-resolution image restoration tasks.
[0147] The computational complexity of the traditional Transformer architecture increases quadratically with the input size, making it difficult to directly apply to high-resolution image restoration tasks. Recent lightweight Transformer methods include channel self-attention (CSA), which computes self-attention along the channel dimension, achieving computational complexity linear with resolution. However, CSA cannot establish direct dependencies between different spatial locations.
[0148] Therefore, there is an urgent need to design a network architecture that can capture spatial dependencies between windows and establish direct dependencies between different spatial locations.
[0149] To address the aforementioned problems, embodiments of this application provide a data processing method. The data processing method of this application embodiment will be described in detail below with reference to the accompanying drawings.
[0150] Referring to Figure 3, which is a flowchart of a data processing method provided in an embodiment of this application, as shown in Figure 3, the data processing method provided in an embodiment of this application may include steps 301 to 304, which will be described in detail below.
[0151] 301. Obtain target data;
[0152] The embodiments of this application can be applied to the processing of machine learning models, wherein the machine learning model may include a first network, a target network layer, and a second network.
[0153] The target network layer can be a transformer layer or other types of network layers. Specifically, the target network layer can be a network layer in the feature extraction network of a machine learning model.
[0154] The first network layer can be a network in the machine learning model connected before the target network layer, and the second network layer can be a network in the machine learning model connected after the target network layer. For example, the first network may include the input projection layer of the machine learning model, some network layers in the feature extraction network, and the second network may include some network layers in the feature extraction network of the machine learning model (when the target network layer is the last layer of the feature extraction network, the second network may not include the network layers in the feature extraction network of the machine learning model) and the task network including the output projection layer.
[0155] In one possible implementation, the target network can be the data input into the machine learning model.
[0156] For example, the target data is image data, and a machine learning model can be used to perform image processing tasks. The processing result obtained by processing the target data through the machine learning model is the processing result of the image processing task.
[0157] For example, the target data is audio data, and a machine learning model can be used to perform audio processing tasks. The processing result obtained by processing the target data through the machine learning model is the processing result of the audio processing task.
[0158] For example, if the target data is text data, a machine learning model can be used to perform text processing tasks, and the processing result obtained by processing the target data through the machine learning model is the processing result of the text processing task.
[0159] For example, image processing tasks can include image classification, object recognition, image enhancement (such as, but not limited to, super-resolution, denoising, deraining, deblurring, demosaicing, etc.), and image generation.
[0160] For example, audio processing tasks can include speech-to-text, audio enhancement, and audio synthesis.
[0161] For example, text processing tasks can include summary generation, dialogue response, and text-to-image generation.
[0162] The structure of the machine learning model in this application embodiment is described below with reference to the accompanying drawings. As shown in Figure 4, one schematic architecture of the machine learning model is a U-shaped encoder-decoder network, comprising an input projection layer, multiple stacked channel-spatial self-attention modules (CSTB), and an output projection layer. The target network layer may have the structural features of the channel-spatial self-attention module (CSTB). Figure 4 illustrates that all stacked transformer layers have the structural features of the target network layer. It should be understood that one or more layers in the machine learning model of this application embodiment may have the structural features of the target network layer; the illustration in Figure 4 does not limit this application.
[0163] Optionally, the input projection layer and the output projection layer can be a 3x3 convolution. The Channel-Spatial Transformer module (CSTB) is composed of a context-based channel self-attention (CB-CSA) module, a grid spatial self-attention (G-SSA) module connected in series, a re-parameterization locally-enhance feed-forward network (Rep-LeFFN) and a layer normalization module connected in series.
[0164] Besides the Unet network, the embodiments of this application may also be applied to other network architectures, and this application is not limited thereto.
[0165] 302. Based on the target data, obtain a first feature representation of the target data through the first network;
[0166] 303. Based on the first feature representation, a feature extraction operation is performed through the target network layer to obtain a second feature representation of the target data; wherein the feature extraction operation includes operations of self-attention mechanism between different channels and operations of self-attention mechanism between different spaces.
[0167] The first feature representation can be the result obtained from the network connected before the target network layer, and the first feature representation can be used as the input of the target network layer.
[0168] In existing implementations, when implementing attention operations, the target network layer either calculates self-attention along the channel dimension, failing to establish direct dependencies between different spatial locations, or calculates self-attention within the spatial dimension, failing to clearly and completely capture spatial dependencies between windows. In this embodiment, self-attention mechanisms between different channels and between different spaces are performed simultaneously within the same network layer. By combining channel-based self-attention with a grid-based spatial self-attention mechanism, it can both establish direct dependencies between different spatial locations, supplementing the lack of direct interaction between distant pixels in spatial self-attention, and capture spatial dependencies between windows.
[0169] The following are schematic diagrams of several target network layer structures:
[0170] In one possible implementation, the target network layer includes a first attention module and a second attention module. The first attention module can perform self-attention operation on the first feature representation through different channels, and the second attention module can perform self-attention operation on the first feature representation after the operation of the self-attention operation through different channels through different spaces.
[0171] In other words, the first attention module in the target network layer, which is used to perform self-attention operations between different channels, can be connected in series with the second attention module, which is used to perform self-attention operations between different spaces, and the first attention module is connected before the second attention module.
[0172] It should be understood that other modules can be connected between the first attention module and the second attention module.
[0173] For example, referring to Figure 5, which is a schematic diagram of a target network layer, the first attention module (G-SSA) precedes the second attention module (CB-CSA). An FFN module, a layer regularization module, etc., may also be connected between the first and second attention modules. The target network layer shown in Figure 5 can perform the following operation: X′ l=CB-CSA(LN(X) l-1 ))+X l-1 X l =Rep-LeFFN(LN(X′) l ))+X′ l ,
[0174] X′ l+1 =G-SSA(LN(X) l ))+X l ,
[0175] X l+1 =Rep-LeFFN(LN(X′) l+1 ))+X′ l+1 ;
[0176] In one possible implementation, the target network layer includes a first attention module and a second attention module. The first attention module can perform self-attention mechanism operations between different spaces on the first feature representation; the second attention module can perform self-attention operation mechanism operations between different channels on the first feature representation after self-attention operations within the spatial dimension.
[0177] In other words, the first attention module in the target network layer, which is used to perform self-attention operations between different channels, can be connected in series with the second attention module, which is used to perform self-attention operations between different spaces, and the second attention module is connected before the first attention module.
[0178] It should be understood that other modules can be connected between the first attention module and the second attention module.
[0179] For example, referring to Figure 6, which is a schematic diagram of a target network layer, the first attention module (G-SSA) is after the second attention module (CB-CSA), and an FFN module, a layer regularization module, etc. can also be connected between the first attention module and the second attention module.
[0180] In one possible implementation, the target network layer includes a first processing branch and a second processing branch in parallel. The first processing branch includes a first attention module, and the second processing branch includes a second attention module. The processing result of the first processing branch is used to fuse with the processing result of the second processing branch.
[0181] In other words, the first attention module in the target network layer, which performs self-attention operations between different channels, and the second attention module, which performs self-attention operations between different spaces, are not connected in series, but belong to different branches in parallel.
[0182] For example, the first attention module and the second attention module can be connected in parallel. That is, the first attention module in the target network layer, which performs self-attention operations between different channels, can be connected in parallel with the second attention module, which performs self-attention operations between different spaces. The first attention module can perform self-attention operations between different channels on the first feature representation; the second attention module can perform self-attention operations between different spaces on the first feature representation; and the first feature representation after the self-attention operations between different channels and the first feature representation after the self-attention operations within the spatial dimension are then fused.
[0183] For example, referring to Figure 7, which is a schematic diagram of a target network layer, the first attention module (G-SSA) and the second attention module (CB-CSA) are connected in parallel.
[0184] Channel self-attention (CSA) computes self-attention along the channel dimension, thus achieving computational complexity linear with resolution. CSA is a spatially global self-attention computation method that can obtain a certain global perspective. However, the global perspective of CSA is obtained indirectly through the computation of the channel self-attention matrix across the entire global scope; it is a coarse global perspective and cannot accurately capture the dependencies that establish the global context.
[0185] In this embodiment of the application, in order to make the channel self-attention mechanism pay more attention to local information, the original global-based channel self-attention mechanism is improved into a local context-based channel self-attention mechanism.
[0186] Method 1:
[0187] In one possible implementation, when performing self-attention calculation in the channel dimension, the corresponding Q matrix, K matrix and V matrix can be obtained according to the input features. For example, Query(Q), Key(K) and Value(V) matrices can be generated by three sets of 1x1 point convolutions followed by 3x3 depthwise decomposable convolutions.
[0188] In one possible implementation, the Q, K, and V matrices of the input features can be partitioned to obtain multiple first Q matrices, multiple first K matrices, and multiple first V matrices; wherein the first Q matrices, first K matrices, and first V matrices correspond one-to-one, and the sizes of the corresponding first Q matrices, first K matrices, and first V matrices are consistent. Unlike the original CSA which directly calculates the attention maps of Q and K and applies them to V, this embodiment can divide the Q, K, and V matrices into windows of equal size along the spatial dimension.
[0189] In one possible implementation, multiple first calculation results can be obtained based on the multiple first Q matrices, the multiple first K matrices, and the multiple first V matrices. Each first calculation result is obtained by operation between the corresponding first Q matrices, first K matrices, and first V matrices. The fusion result (e.g., splicing) of the multiple first calculation results is used to obtain the result of the operation of the self-attention operation mechanism between the different channels.
[0190] Method 2:
[0191] In one possible implementation, the elements of the input feature's Q, K, and V matrices can be shuffled and partitioned to obtain multiple second Q matrices, multiple second K matrices, and multiple second V matrices. These second Q matrices, second K matrices, and second V matrices correspond one-to-one, and their sizes are identical. Unlike Method 1, which directly splits the window based on partitions and calculates channels within non-overlapping windows, Method 2 first slides the window spatially and then calculates the self-attention of the window channels in the same way. Similar to Method 1, Method 2 can also obtain multiple second calculation results based on the multiple second Q matrices, the multiple second K matrices, and the multiple second V matrices. Each second calculation result is obtained through operations between corresponding second Q matrices, second K matrices, and second V matrices. The fusion result (e.g., concatenation) of these multiple second calculation results is used to obtain the result of the self-attention operation mechanism between the different channels.
[0192] In one possible implementation, the target network layer may include both the self-attention operation performed in method 1 and the self-attention operation performed in method 2. The self-attention operation performed in method 1 and the self-attention operation performed in method 2 can be performed in two separate branches. Then, the fusion result of the self-attention operation performed in method 1 (that is, the multiple first operation results in the above embodiment) and the fusion result of the self-attention operation performed in method 2 (that is, the multiple second operation results in the above embodiment) are fused together.
[0193] In one possible implementation, the result of the self-attention mechanism operation between the different channels can be obtained by fusing the fusion result of multiple first operation results and the fusion result of multiple second operation results (e.g., weighted fusion).
[0194] Referring to Figure 8, which shows an example architecture of CB-CSA, similar to the original CSA, the feature map is first processed by three sets of 1x1 point convolutions followed by 3x3 depthwise decomposable convolutions to generate Query(Q), Key(K), and Value(V) matrices. Next, unlike the original CSA which directly computes attention maps for Q and K and applies them to V, this invention divides the Q, K, and V matrices into windows of equal size along the spatial dimension. To enhance contextual information, two parallel branches are constructed: one branch directly splits the windows based on the partitions, computes channel attention maps within non-overlapping windows, and applies them to the V of the corresponding window; the other branch first slides the window spatially and then computes the window channel self-attention in the same way. The outputs from the two branches are multiplied by the corresponding Mask and then summed to obtain the final output.
[0195] The channel self-attention operation shown in Figure 8 can be represented as the following operation: F out =Mask top ×F top +Mask bottom ×F bottom .
[0196] In existing implementations, a combination of dense and sparse spatial self-attention is used to establish global and local dependencies simultaneously. However, the effectiveness and computational complexity of this method are still limited by the dense self-attention mechanism (computational complexity increases quadratically with the window size), resulting in less than ideal overall performance.
[0197] CB-CSA suffers from severe islanding due to its small window size, resulting in no interaction between non-adjacent windows. However, underlying vision tasks require a global receptive field for better performance. To address this issue, embodiments of this application introduce a grid spatial self-attention (G-SSA) module to provide information interaction between windows.
[0198] As shown in Figure 9A, a schematic diagram of a G-SSA module is presented. Unlike the original SSA, G-SSA divides the global spatial dimension into equally spaced grids and calculates spatial self-attention between equally spaced grid points. 3) G-SSA decomposes the global SSA along the spatial dimension into pxp groups of global grid SSAs, while also reducing the computational cost to pxp times. The G-SSA module shown in Figure 9A can perform the following operations:
[0199] O(H 2 W 2 C)→O(H 2 W 2 C / p 2 )
[0200] In existing technologies, locally enhanced feedforward networks improve local feature extraction capabilities by inserting a 3x3 depthwise separable convolution between 1x1 convolutions in a feedforward network. However, the receptive field of a 3x3 depthwise separable convolution is limited, making it unable to extract larger-scale local features.
[0201] In this embodiment, multiple parallel depthwise separable convolution operations and / or multiple cascaded point convolution operations are connected after the nonlinear layer, thereby enabling the extraction of local features at a larger scale and significantly enhancing the performance of FFN.
[0202] In one possible implementation, the first network, the target network layer, or the second network further includes: a feedforward network (FFN); the FFN is used to perform multiple parallel depthwise separable convolution operations and / or multiple cascaded point convolution operations on the results obtained from nonlinear activation; or, the FFN is used to perform a target point convolution operation on the results obtained from nonlinear activation.
[0203] In one possible implementation, during model training, the FFN is used to perform multiple parallel depthwise separable convolution operations and / or multiple cascaded point convolution operations on the results obtained from nonlinear activation; during model inference, the FFN is used to perform target point convolution operations on the results obtained from nonlinear activation, and the target point convolution operation is equivalent to the multiple parallel depthwise separable convolution operations and / or the multiple cascaded point convolution operations after training.
[0204] Referring to Figure 9B, which illustrates the structure of a LeFFN, we introduce a reparameterization method to further enhance its local representation capabilities. As shown in Figure 9B, during the training phase, we enhance the network's representation capabilities by adding sequential point convolutions and parallel depthwise separable convolutions with various kernel sizes. During the inference phase, the sequential point convolutions are reparameterized into a single point convolution, and the parallel multi-path depthwise separable convolutions are reparameterized into a depthwise separable convolution with a large kernel. Thus, without sacrificing the model's representation capabilities, we significantly reduce the computational load during the inference phase.
[0205] The FFN shown in Figure 9A can be operated on as follows: FFN(x) = PW-Conv(GELU(PW-Conv(x))), LeFFN(x) = PW-Conv(DW-Conv(GELU(PW-Conv(x)))), RepPW-Conv(x) = PW-Conv((PW-Conv(x)), RepDW-Conv(x) = DW-Conv 5×5 (x)+DW-Conv 3×3 (x)+DW-Conv 1×1 (x)+x, Rep-LeFFN(x)=RepPW-Conv(RepDW-Conv(GELU(RepPW-Conv(x)))),
[0206] 304. Based on the second feature representation, the processing result of the target data is obtained through the second network.
[0207] Referring to Figure 9C, which illustrates the FLOPS-PNSR curves of different models on Gaussian denoising, real denoising, and rain removal tasks, the results show that IPT-V2 surpasses existing state-of-the-art (SOTA) solutions in multiple low-level visual tasks, including theoretical Gaussian denoising, real denoising, and rain removal, achieving superior FLOPS-PNSR curves. Referring to Table 1, which illustrates the ablation experiments of different modules on the Gaussian denoising task, as shown in Table 1, replacing the original CSA with the CB-CSA of this invention resulted in a significant improvement in PSNR without a significant increase in FLOPS and Params. Table 2 illustrates the effects of the cascaded, anti-cascaded, and parallel structures of channel self-attention and mesh self-attention. As shown in Table 2, compared to the baseline (30.02 dB), all achieved significant PSNR improvements, verifying the effectiveness of this invention.
[0208] Table 1
[0209] Table 2
[0210] Referring to Figure 10, which is a schematic diagram of the structure of a data processing apparatus provided in an embodiment of this application, as shown in Figure 10, the data processing apparatus 1000 provided in this embodiment includes:
[0211] Module 1001 is used to acquire target data;
[0212] For a detailed description of the acquisition module 1001, please refer to the description of step 301 in the above embodiments, which will not be repeated here.
[0213] The processing module 1002 is configured to obtain a first feature representation of the target data through the first network based on the target data; and to perform feature extraction operations through the target network layer based on the first feature representation to obtain a second feature representation of the target data; wherein the feature extraction operations include operations of self-attention mechanisms between different channels and operations of self-attention mechanisms between different spaces;
[0214] Based on the second feature representation, the processing result of the target data is obtained through the second network.
[0215] For a detailed description of the processing module 1002, please refer to the description of steps 302 to 304 in the above embodiments, which will not be repeated here.
[0216] In one possible implementation,
[0217] The target data is image data, and the processing result is the result of the image processing task; or,
[0218] The target data is audio data, and the processing result is the result of the audio processing task; or,
[0219] The target data is text data, and the processing result is the result of the text processing task.
[0220] In one possible implementation, the target network layer includes a first attention module and a second attention module, and the processing module 1002 is specifically used for:
[0221] The first attention module performs self-attention operation on the first feature representation through different channels;
[0222] The second attention module performs self-attention mechanism operations between different spaces on the first feature representation after it has been processed by the self-attention operation mechanism between the different channels.
[0223] In one possible implementation, the target network layer includes a first attention module and a second attention module, and the processing module 1002 is specifically used for:
[0224] The first attention module performs self-attention mechanism operations between different spaces on the first feature representation.
[0225] The second attention module performs self-attention operations between different channels on the first feature representation after self-attention operations within the spatial dimension.
[0226] In one possible implementation, the processing module is specifically used for:
[0227] The first attention module performs self-attention operation on the first feature representation through different channels;
[0228] The first feature representation is processed by a self-attention mechanism across different spaces through the second attention module.
[0229] The fusion module fuses the first feature representation after the operation of the self-attention mechanism between the different channels and the first feature representation after the operation of the self-attention mechanism within the spatial dimension.
[0230] In one possible implementation, the operation of the self-attention mechanism between the different channels includes:
[0231] The Q matrix, K matrix, and V matrix of the input features are divided to obtain multiple first Q matrices, multiple first K matrices, and multiple first V matrices; wherein the first Q matrix, the first K matrix, and the first V matrix correspond one-to-one, and the sizes of the first Q matrix, the first K matrix, and the first V matrix with the corresponding relationship are consistent.
[0232] Based on the plurality of first Q matrices, the plurality of first K matrices, and the plurality of first V matrices, a plurality of first calculation results are obtained, each of which is obtained by operation between the first Q matrices, the first K matrices, and the first V matrices that have a corresponding relationship; the fusion result of the plurality of first calculation results is used to obtain the result of the operation of the self-attention operation mechanism between the different channels.
[0233] In one possible implementation, the operation of the self-attention mechanism between the different channels includes:
[0234] The elements of the Q, K, and V matrices of the input features are shuffled and partitioned to obtain multiple second Q matrices, multiple second K matrices, and multiple second V matrices; wherein the second Q matrices, the second K matrices, and the second V matrices correspond one-to-one, and the corresponding second Q matrices, second K matrices, and second V matrices have the same size;
[0235] Based on the plurality of second Q matrices, the plurality of second K matrices, and the plurality of second V matrices, a plurality of second calculation results are obtained, each of which is obtained by operation between the corresponding second Q matrices, second K matrices, and second V matrices;
[0236] The results of the multiple first operations are fused together to obtain the result of the self-attention operation mechanism between the different channels.
[0237] In one possible implementation, the processing module 1002 is further configured to:
[0238] By fusing the fusion results of multiple first operation results and the fusion results of multiple second operation results, the operation result of the self-attention operation mechanism between the different channels is obtained.
[0239] In one possible implementation, the first network, the target network layer, or the second network further includes a feedforward network (FFN).
[0240] The FFN is used to perform multiple parallel depthwise separable convolution operations and / or multiple cascaded pointwise convolution operations on the results obtained from nonlinear activation; or,
[0241] The FFN is used to perform target point convolution operations on the results obtained from nonlinear activation.
[0242] In one possible implementation,
[0243] During model training, the FFN is used to perform multiple parallel depthwise separable convolution operations and / or multiple cascaded point convolution operations on the results obtained from nonlinear activation.
[0244] During model inference, the FFN is used to perform target point convolution operations on the results obtained from nonlinear activation, and the target point convolution operation is equivalent to the multiple parallel depthwise separable convolution operations and / or the multiple cascaded point convolution operations after training.
[0245] The following describes a terminal device provided in an embodiment of this application. Please refer to Figure 11, which is a structural schematic diagram of a terminal device provided in an embodiment of this application. The terminal device 1100 can specifically be a virtual reality (VR) device, a mobile phone, a tablet, a laptop computer, a smart wearable device, etc., and is not limited here. Specifically, the terminal device 1100 includes: a receiver 1101, a transmitter 1102, a processor 1103, and a memory 1104 (the number of processors 1103 in the terminal device 1100 can be one or more; Figure 11 shows one processor as an example). The processor 1103 may include an application processor 11031 and a communication processor 11032. In some embodiments of this application, the receiver 1101, transmitter 1102, processor 1103, and memory 1104 can be connected via a bus or other means.
[0246] Memory 1104 may include read-only memory and random access memory, and provides instructions and data to processor 1103. A portion of memory 1104 may also include non-volatile random access memory (NVRAM). Memory 1104 stores processor and operation instructions, executable modules, or data structures, or subsets thereof, or extended sets thereof, wherein the operation instructions may include various operation instructions for implementing various operations.
[0247] Processor 1103 controls the operation of the execution device. In specific applications, the various components of the execution device are coupled together through a bus system, which may include not only the data bus, but also power buses, control buses, and status signal buses. However, for clarity, all buses are referred to as the bus system in the diagram.
[0248] The methods disclosed in the embodiments of this application can be applied to or implemented by the processor 1103. The processor 1103 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 1103 or by instructions in software form. The processor 1103 can be a general-purpose processor, a digital signal processor (DSP), a microprocessor, or a microcontroller, and may further include an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The processor 1103 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 1104. Processor 1103 reads the information from memory 1104 and, in conjunction with its hardware, completes the steps involved in the model training or model inference process described above.
[0249] Receiver 1101 can be used to receive input digital or character information, and to generate signal inputs related to the settings and function control of the execution device. Transmitter 1102 can be used to output digital or character information through the first interface; transmitter 1102 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; transmitter 1102 may also include a display device such as a display screen.
[0250] This application embodiment also provides a server. Referring to Figure 12, Figure 12 is a schematic diagram of a server structure provided in this application embodiment. The server 1200 can vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 1212 (e.g., one or more processors) and a memory 1232, and one or more storage media 1230 (e.g., one or more mass storage devices) for storing application programs 1242 or data 1244. The memory 1232 and storage media 1230 can be temporary or persistent storage. The program stored in the storage media 1230 may include one or more modules (not shown in the figure), each module may include a series of instruction operations on the server. Furthermore, the CPU 1212 may be configured to communicate with the storage media 1230 and execute the series of instruction operations in the storage media 1230 on the server 1200.
[0251] Server 1200 may also include one or more power supplies 1226, one or more wired or wireless network interfaces 1250, one or more input / output interfaces 1258; or, one or more operating systems 1241, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0252] In this embodiment, the central processing unit 1212 is used to perform actions related to model training or model inference in the above embodiments.
[0253] This application also provides a computer program product that, when run on a computer, causes the computer to perform steps as performed by the aforementioned execution device, or causes the computer to perform steps as performed by the aforementioned training device.
[0254] This application also provides a computer-readable storage medium storing a program for signal processing, which, when run on a computer, causes the computer to perform steps as performed by the aforementioned execution device, or causes the computer to perform steps as performed by the aforementioned training device.
[0255] The execution device, training device, or terminal device provided in this application embodiment can specifically be a chip. The chip includes a processing unit and a communication unit. The processing unit can be, for example, a processor, and the communication unit can be, for example, an input / output interface, pins, or circuits. The processing unit can execute computer execution instructions stored in the storage unit to cause the chip within the execution device to execute the data processing method described in the above embodiments, or to cause the chip within the training device to execute the data processing method described in the above embodiments. Optionally, the storage unit can be a storage unit within the chip, such as a register or cache. Alternatively, the storage unit can be a storage unit located outside the chip within the wireless access device, such as a read-only memory (ROM) or other types of static storage devices capable of storing static information and instructions, such as random access memory (RAM).
[0256] Specifically, please refer to Figure 13, which is a schematic diagram of a chip structure provided in an embodiment of this application. The chip can be represented as a neural network processor (NPU) 1300. The NPU 1300 is mounted as a coprocessor on the host CPU, and tasks are assigned by the host CPU. The core part of the NPU is the arithmetic circuit 1303, which is controlled by the controller 1304 to extract matrix data from the memory and perform multiplication operations.
[0257] In some implementations, the arithmetic circuit 1303 internally includes multiple processing engines (PEs). In some implementations, the arithmetic circuit 1303 is a two-dimensional pulsating array. The arithmetic circuit 1303 can also be a one-dimensional pulsating array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 1303 is a general-purpose matrix processor.
[0258] For example, suppose we have an input matrix A, a weight matrix B, and an output matrix C. The arithmetic circuit retrieves the corresponding data of matrix B from the weight memory 1302 and caches it in each PE of the arithmetic circuit. The arithmetic circuit retrieves the data of matrix A from the input memory 1301 and performs matrix operations with matrix B. The partial result or the final result of the obtained matrix is stored in the accumulator 1308.
[0259] Unified memory 1306 is used to store input and output data. Weight data is directly transferred to weight memory 1302 via Direct Memory Access Controller (DMAC) 1305. Input data is also transferred to unified memory 1306 via DMAC.
[0260] BIU stands for Bus Interface Unit, which is used for interaction between the AXI bus and the DMAC and the Instruction Fetch Buffer (IFB) 1309.
[0261] The Bus Interface Unit (BIU) 1310 is used by the instruction fetch memory 1309 to fetch instructions from external memory, and also by the memory access controller 1305 to fetch the original data of the input matrix A or the weight matrix B from external memory.
[0262] The DMAC is mainly used to move input data from external memory DDR to unified memory 1306, or to weight data to weight memory 1302, or to input data to input memory 1301.
[0263] The vector computation unit 1307 includes multiple processing units that further process the output of the computation circuit 1303 when needed, such as vector multiplication, vector addition, exponential operations, logarithmic operations, size comparisons, etc. It is mainly used for computation in non-convolutional / fully connected layers of neural networks, such as Batch Normalization, pixel-level summation, and upsampling of feature planes.
[0264] In some implementations, the vector computation unit 1307 can store the processed output vector in the unified memory 1306. For example, the vector computation unit 1307 can apply a linear function, or a nonlinear function, to the output of the computation circuit 1303, such as performing linear interpolation on the feature planes extracted by the convolutional layer, or, for example, accumulating a vector of values to generate activation values. In some implementations, the vector computation unit 1307 generates normalized values, pixel-level summed values, or both. In some implementations, the processed output vector can be used as an activation input to the computation circuit 1303, for example, for use in subsequent layers of the neural network.
[0265] The instruction fetch buffer 1309 connected to the controller 1304 is used to store the instructions used by the controller 1304;
[0266] Unified memory 1306, input memory 1301, weighted memory 1302, and instruction fetch memory 1309 are all on-chip memories. External memory is proprietary to this NPU hardware architecture.
[0267] The processor mentioned above can be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits used to control the execution of the above program.
[0268] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.
[0269] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0270] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.
[0271] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
Claims
1. A data processing method, characterized in that, The method is applied to the processing of a machine learning model, wherein the machine learning model includes a first network, a target network layer, and a second network, and includes: Obtain the target data; Based on the target data, a first feature representation of the target data is obtained through the first network; Based on the first feature representation, a feature extraction operation is performed through the target network layer to obtain a second feature representation of the target data; wherein, the feature extraction operation includes performing self-attention mechanism operations between different channels and performing self-attention mechanism operations between different spaces, and the target network layer is a network layer in the first network; Based on the second feature representation, the processing result of the target data is obtained through the second network.
2. The method according to claim 1, characterized in that, The target network layer is a transformer layer.
3. The method according to claim 1 or 2, characterized in that, The target data is image data, and the processing result is the result of the image processing task; or, The target data is audio data, and the processing result is the result of the audio processing task; or, The target data is text data, and the processing result is the result of the text processing task.
4. The method according to any one of claims 1 to 3, characterized in that, The target network layer includes a first attention module and a second attention module. The step of performing feature extraction operations through the target network layer based on the first feature representation includes: The first attention module performs self-attention operation on the first feature representation through different channels; The second attention module performs self-attention mechanism operations between different spaces on the first feature representation after it has been processed by the self-attention operation mechanism between the different channels.
5. The method according to any one of claims 1 to 3, characterized in that, The target network layer includes a first attention module and a second attention module. The step of performing feature extraction operations through the target network layer based on the first feature representation includes: The first attention module performs self-attention mechanism operations between different spaces on the first feature representation. The second attention module performs self-attention operations between different channels on the first feature representation after self-attention operations within the spatial dimension.
6. The method according to any one of claims 1 to 3, characterized in that, The target network layer includes a first attention module, a second attention module, and a fusion module. The step of performing feature extraction operations through the target network layer based on the first feature representation includes: The first attention module performs self-attention operation on the first feature representation through different channels; The second attention module performs self-attention mechanism operations between different spaces on the first feature representation; The fusion module fuses the first feature representation after the operation of the self-attention mechanism between the different channels and the first feature representation after the operation of the self-attention mechanism within the spatial dimension.
7. The method according to any one of claims 1 to 6, characterized in that, The self-attention mechanism between the different channels includes the following operations: The Q matrix, K matrix, and V matrix of the input features are divided into multiple first Q matrices, multiple first K matrices, and multiple first V matrices; wherein the first Q matrix, the first K matrix, and the first V matrix correspond one-to-one. Based on the plurality of first Q matrices, the plurality of first K matrices, and the plurality of first V matrices, a plurality of first calculation results are obtained, each of which is obtained by operation between the first Q matrices, the first K matrices, and the first V matrices that have a corresponding relationship; The results of the multiple first operations are fused together to obtain the result of the self-attention operation mechanism between the different channels.
8. The method according to any one of claims 1 to 6, characterized in that, The self-attention mechanism between the different channels includes the following operations: The elements of the Q, K, and V matrices of the input features are shuffled and partitioned to obtain multiple second Q matrices, multiple second K matrices, and multiple second V matrices; wherein the second Q matrices, the second K matrices, and the second V matrices correspond one-to-one, and the corresponding second Q matrices, second K matrices, and second V matrices have the same size; Based on the plurality of second Q matrices, the plurality of second K matrices, and the plurality of second V matrices, a plurality of second calculation results are obtained, each of which is obtained by operation between corresponding second Q matrices, second K matrices, and second V matrices; the fusion result of the plurality of second calculation results is used to obtain the result of the operation of the self-attention operation mechanism between the different channels.
9. The method according to claim 7 or 8, characterized in that, The method further includes: By fusing the fusion results of multiple first operation results and the fusion results of multiple second operation results, the operation result of the self-attention operation mechanism between the different channels is obtained.
10. The method according to any one of claims 1 to 9, characterized in that, The first network, the target network layer, or the second network further includes: a feedforward network (FFN); The FFN is used to perform multiple parallel depthwise separable convolution operations and / or multiple cascaded pointwise convolution operations on the results obtained from nonlinear activation; or, The FFN is used to perform target point convolution operations on the results obtained from nonlinear activation.
11. The method according to claim 10, characterized in that, During model training, the FFN is used to perform multiple parallel depthwise separable convolution operations and / or multiple cascaded point convolution operations on the results obtained from nonlinear activation. During model inference, the FFN is used to perform target point convolution operations on the results obtained from nonlinear activation, and the target point convolution operation is equivalent to the multiple parallel depthwise separable convolution operations and / or the multiple cascaded point convolution operations after training.
12. A data processing apparatus, characterized in that, The apparatus is used for processing machine learning models, the machine learning models including a first network, a target network layer, and a second network, and includes: The acquisition module is used to acquire target data; The processing module is configured to obtain a first feature representation of the target data through the first network based on the target data; and to perform feature extraction operations through the target network layer based on the first feature representation to obtain a second feature representation of the target data; wherein the feature extraction operations include operations of self-attention mechanisms between different channels and operations of self-attention mechanisms between different spaces, and the target network layer is a network layer in the first network; Based on the second feature representation, the processing result of the target data is obtained through the second network.
13. The apparatus according to claim 12, characterized in that, The target data is image data, and the processing result is the result of the image processing task; or, The target data is audio data, and the processing result is the result of the audio processing task; or, The target data is text data, and the processing result is the result of the text processing task.
14. The apparatus according to claim 12 or 13, characterized in that, The target network layer includes a first attention module and a second attention module, and the processing module is specifically used for: The first attention module performs self-attention operation on the first feature representation through different channels; The second attention module performs self-attention mechanism operations between different spaces on the first feature representation after it has been processed by the self-attention operation mechanism between the different channels.
15. The apparatus according to claim 12 or 13, characterized in that, The target network layer includes a first attention module and a second attention module, and the processing module is specifically used for: The first attention module performs self-attention mechanism operations between different spaces on the first feature representation. The second attention module performs self-attention operations between different channels on the first feature representation after self-attention operations within the spatial dimension.
16. The apparatus according to claim 12 or 13, characterized in that, The processing module is specifically used for: The first attention module performs self-attention operation on the first feature representation through different channels; The first feature representation is processed by a self-attention mechanism across different spaces through the second attention module. The fusion module fuses the first feature representation after the operation of the self-attention mechanism between the different channels and the first feature representation after the operation of the self-attention mechanism within the spatial dimension.
17. The apparatus according to any one of claims 12 to 16, characterized in that, The self-attention mechanism between the different channels includes the following operations: The Q matrix, K matrix, and V matrix of the input features are divided to obtain multiple first Q matrices, multiple first K matrices, and multiple first V matrices; wherein the first Q matrix, the first K matrix, and the first V matrix correspond one-to-one, and the sizes of the first Q matrix, the first K matrix, and the first V matrix with the corresponding relationship are consistent. Based on the plurality of first Q matrices, the plurality of first K matrices, and the plurality of first V matrices, a plurality of first calculation results are obtained, each of which is obtained by operation between the first Q matrices, the first K matrices, and the first V matrices that have a corresponding relationship; The results of the multiple first operations are fused together to obtain the result of the self-attention operation mechanism between the different channels.
18. The apparatus according to any one of claims 12 to 16, characterized in that, The self-attention mechanism between the different channels includes the following operations: The elements of the Q, K, and V matrices of the input features are shuffled and partitioned to obtain multiple second Q matrices, multiple second K matrices, and multiple second V matrices; wherein the second Q matrices, the second K matrices, and the second V matrices correspond one-to-one, and the corresponding second Q matrices, second K matrices, and second V matrices have the same size; Based on the plurality of second Q matrices, the plurality of second K matrices, and the plurality of second V matrices, a plurality of second calculation results are obtained, each of which is obtained by operation between corresponding second Q matrices, second K matrices, and second V matrices; the fusion result of the plurality of second calculation results is used to obtain the result of the operation of the self-attention operation mechanism between the different channels.
19. The apparatus according to claim 17 or 18, characterized in that, The processing module is further configured to: By fusing the fusion results of multiple first operation results and the fusion results of multiple second operation results, the operation result of the self-attention operation mechanism between the different channels is obtained.
20. The apparatus according to any one of claims 12 to 19, characterized in that, The first network, the target network layer, or the second network further includes: a feedforward network (FFN); The FFN is used to perform multiple parallel depthwise separable convolution operations and / or multiple cascaded pointwise convolution operations on the results obtained from nonlinear activation; or, The FFN is used to perform target point convolution operations on the results obtained from nonlinear activation.
21. The apparatus according to claim 20, characterized in that, During model training, the FFN is used to perform multiple parallel depthwise separable convolution operations and / or multiple cascaded point convolution operations on the results obtained from nonlinear activation. During model inference, the FFN is used to perform target point convolution operations on the results obtained from nonlinear activation, and the target point convolution operation is equivalent to the multiple parallel depthwise separable convolution operations and / or the multiple cascaded point convolution operations after training.
22. 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 operation of the method according to any one of claims 1 to 11.
23. A computer program product, characterized in that, Includes computer-readable instructions that, when executed on a computer device, cause the computer device to perform the method as described in any one of claims 1 to 11.
24. A system comprising at least one processor and at least one memory; the processor and the memory are connected via a communication bus and communicate with each other. The at least one memory is used to store code; The at least one processor is used to execute the code to perform the method as described in any one of claims 1 to 11.
25. A chip, comprising a processor, characterized in that, The processor is used to support the data processing device in implementing the method as described in any one of claims 1 to 11.