WO2023207665A1 - Data processing method and related device - Google Patents
Data processing method and related device Download PDFInfo
- Publication number
- WO2023207665A1 WO2023207665A1 PCT/CN2023/088869 CN2023088869W WO2023207665A1 WO 2023207665 A1 WO2023207665 A1 WO 2023207665A1 CN 2023088869 W CN2023088869 W CN 2023088869W WO 2023207665 A1 WO2023207665 A1 WO 2023207665A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- matrix
- weight
- amplitude
- feature
- feature block
- Prior art date
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 23
- 239000011159 matrix material Substances 0.000 claims abstract description 275
- 230000009466 transformation Effects 0.000 claims abstract description 78
- 238000000844 transformation Methods 0.000 claims abstract description 33
- 238000000034 method Methods 0.000 claims description 75
- 238000012545 processing Methods 0.000 claims description 67
- 230000015654 memory Effects 0.000 claims description 50
- 230000004927 fusion Effects 0.000 claims description 38
- 238000004364 calculation method Methods 0.000 claims description 32
- 238000013528 artificial neural network Methods 0.000 claims description 26
- 230000007246 mechanism Effects 0.000 claims description 22
- 238000004590 computer program Methods 0.000 claims description 8
- 238000013507 mapping Methods 0.000 claims description 6
- 238000013473 artificial intelligence Methods 0.000 abstract description 16
- 239000013598 vector Substances 0.000 description 107
- 238000012549 training Methods 0.000 description 46
- 238000010586 diagram Methods 0.000 description 36
- 238000013527 convolutional neural network Methods 0.000 description 35
- 230000000875 corresponding effect Effects 0.000 description 33
- 238000011176 pooling Methods 0.000 description 32
- 230000008569 process Effects 0.000 description 29
- 238000003058 natural language processing Methods 0.000 description 22
- 230000006870 function Effects 0.000 description 15
- 238000007781 pre-processing Methods 0.000 description 13
- 230000001537 neural effect Effects 0.000 description 11
- 238000013519 translation Methods 0.000 description 10
- 238000013500 data storage Methods 0.000 description 7
- 238000013135 deep learning Methods 0.000 description 7
- 238000004891 communication Methods 0.000 description 6
- 238000005516 engineering process Methods 0.000 description 6
- 238000000605 extraction Methods 0.000 description 6
- MHABMANUFPZXEB-UHFFFAOYSA-N O-demethyl-aloesaponarin I Natural products O=C1C2=CC=CC(O)=C2C(=O)C2=C1C=C(O)C(C(O)=O)=C2C MHABMANUFPZXEB-UHFFFAOYSA-N 0.000 description 5
- 230000004913 activation Effects 0.000 description 5
- 238000013480 data collection Methods 0.000 description 5
- 238000010801 machine learning Methods 0.000 description 5
- 238000010606 normalization Methods 0.000 description 5
- 239000000284 extract Substances 0.000 description 4
- 238000003062 neural network model Methods 0.000 description 4
- 210000002569 neuron Anatomy 0.000 description 4
- 230000002776 aggregation Effects 0.000 description 3
- 238000004220 aggregation Methods 0.000 description 3
- 230000015572 biosynthetic process Effects 0.000 description 3
- 238000001514 detection method Methods 0.000 description 3
- 239000012634 fragment Substances 0.000 description 3
- 230000003993 interaction Effects 0.000 description 3
- 238000011022 operating instruction Methods 0.000 description 3
- 241000282412 Homo Species 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 2
- 238000004422 calculation algorithm Methods 0.000 description 2
- 230000001427 coherent effect Effects 0.000 description 2
- 230000002596 correlated effect Effects 0.000 description 2
- 238000013461 design Methods 0.000 description 2
- 238000011161 development Methods 0.000 description 2
- 230000018109 developmental process Effects 0.000 description 2
- 230000006872 improvement Effects 0.000 description 2
- 239000003999 initiator Substances 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000007500 overflow downdraw method Methods 0.000 description 2
- 230000008447 perception Effects 0.000 description 2
- 230000005610 quantum mechanics Effects 0.000 description 2
- 230000011218 segmentation Effects 0.000 description 2
- 239000007787 solid Substances 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 238000003786 synthesis reaction Methods 0.000 description 2
- 230000005428 wave function Effects 0.000 description 2
- 241000282326 Felis catus Species 0.000 description 1
- 230000001133 acceleration Effects 0.000 description 1
- 230000009471 action Effects 0.000 description 1
- 230000003190 augmentative effect Effects 0.000 description 1
- 238000013475 authorization Methods 0.000 description 1
- 230000006399 behavior Effects 0.000 description 1
- 230000008901 benefit Effects 0.000 description 1
- 239000003086 colorant Substances 0.000 description 1
- 238000009833 condensation Methods 0.000 description 1
- 230000005494 condensation Effects 0.000 description 1
- 239000000470 constituent Substances 0.000 description 1
- 238000011217 control strategy Methods 0.000 description 1
- 238000006073 displacement reaction Methods 0.000 description 1
- 238000013551 empirical research Methods 0.000 description 1
- 238000005538 encapsulation Methods 0.000 description 1
- 238000002474 experimental method Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 230000008570 general process Effects 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 208000013409 limited attention Diseases 0.000 description 1
- 238000012886 linear function Methods 0.000 description 1
- 239000007788 liquid Substances 0.000 description 1
- 238000007726 management method Methods 0.000 description 1
- 239000000463 material Substances 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000000737 periodic effect Effects 0.000 description 1
- 230000002085 persistent effect Effects 0.000 description 1
- 238000005070 sampling Methods 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000035807 sensation Effects 0.000 description 1
- 230000001953 sensory effect Effects 0.000 description 1
- 230000009897 systematic effect Effects 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
Definitions
- the transformer structure network includes a multi-head self-attention module.
- the attention head in the multi-head self-attention module only calculates the relationship between different feature blocks within the real number domain, and the modeling capability is insufficient.
- a second feature block is obtained; the first amplitude is used as the amplitude of the element in the second feature block, and the first phase value is used as the phase of the elements in the second feature block; map the elements in the second feature block to real numbers to obtain a third feature block; input the third feature block into the convolution layer.
- the linear programming layer Through the linear programming layer, multiple linear transformations are performed on the first feature block in the feature map; the linear programming layer includes a first weight and a second weight, and the first weight and the second weight are trainable parameters. ;in,
- a linear transformation module is used to perform multiple linear transformations on the feature blocks input to the head to obtain respectively a first amplitude value, a second phase value, a second amplitude value and a second phase value;
- Parallel corpus refers to bilingual or multilingual corpus (that is, text data with annotations) composed of original text and its parallel corresponding target text.
- the original text and target text have the same semantics and there is correspondence between text units. relation.
- the original text is "This trip needs careful planning”
- the corresponding English text is "The trip needs careful planning”
- "This trip needs careful planning” and "The trip needs careful planning” can be regarded as a set of parallels.
- Corpus, this group of parallel corpora is a Chinese-English parallel language pair.
- the original text "This trip needs careful planning” can be regarded as the source material of this group of parallel corpora, and the translated text "The trip needs careful planning” can be regarded as this group of parallel corpora.
- the target corpus of the corpus. Among them, travel may correspond to trip.
- the client device 540 can also be used as a data collection terminal to collect the input data of the input I/O interface 512 and the output results of the output I/O interface 512 as new sample data, and store them in the database 530.
- the I/O interface 512 directly uses the input data input to the I/O interface 512 and the output result of the output I/O interface 512 as a new sample as shown in the figure.
- the data is stored in database 530.
- the initial convolutional layer for example, 221
- the features extracted by subsequent convolutional layers for example, 226) become more and more complex, such as high-level semantic features.
- the output layer 240 has a loss function similar to categorical cross entropy and is specifically used to calculate the prediction error.
- Figure 12 is a flow diagram of a data processing method. As shown in Figure 12, the data processing method provided by the embodiment of the present application may include:
- the output of the head is obtained.
- the linear transformation module is specifically used for:
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Health & Medical Sciences (AREA)
- Computing Systems (AREA)
- Biomedical Technology (AREA)
- Biophysics (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Evolutionary Computation (AREA)
- Life Sciences & Earth Sciences (AREA)
- Molecular Biology (AREA)
- Artificial Intelligence (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Health & Medical Sciences (AREA)
- Complex Calculations (AREA)
- Image Processing (AREA)
Abstract
Description
本申请要求于2022年4月29日提交美国专利局、申请号为17/733,758、发明名称为“METHOD AND DEVICE FOR PROCESSING DATA BASED ON MULTI-LAYER PERCEPTRONS”的美国专利申请的优先权,以及于2022年7月30日提交中国专利局、申请号为202210912635.3、发明名称为“一种数据处理方法及相关设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to the U.S. patent application filed with the U.S. Patent Office on April 29, 2022, with application number 17/733,758 and the invention title "METHOD AND DEVICE FOR PROCESSING DATA BASED ON MULTI-LAYER PERCEPTRONS", and in 2022 The priority of the Chinese patent application filed with the China Patent Office on July 30, 2019, with the application number 202210912635.3 and the invention title "A data processing method and related equipment", the entire content of which is incorporated into this application by reference.
本申请涉及人工智能领域,尤其涉及一种数据处理方法及相关设备。This application relates to the field of artificial intelligence, and in particular, to a data processing method and related equipment.
人工智能(artificial intelligence,AI)是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能,感知环境、获取知识并使用知识获得最佳结果的理论、方法、技术及应用系统。换句话说,人工智能是计算机科学的一个分支,它企图了解智能的实质,并生产出一种新的能以人类智能相似的方式作出反应的智能机器。人工智能也就是研究各种智能机器的设计原理与实现方法,使机器具有感知、推理与决策的功能。Artificial intelligence (AI) is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a branch of computer science that attempts to understand the nature of intelligence and produce a new class of intelligent machines that can respond in a manner similar to human intelligence. Artificial intelligence is the study of the design principles and implementation methods of various intelligent machines, so that the machines have the functions of perception, reasoning and decision-making.
随着人工智能技术的不断发展,让人机之间能够通过自然语言进行交互的自然语言人机交互系统变的越来越重要。人机之间能够通过自然语言进行交互,就需要系统能够识别出人类自然语言的具体含义。通常,系统通过采用对自然语言的句子进行关键信息提取来识别句子的具体含义。With the continuous development of artificial intelligence technology, natural language human-computer interaction systems that enable humans and machines to interact through natural language are becoming more and more important. For humans and machines to interact through natural language, the system needs to be able to recognize the specific meaning of human natural language. Usually, the system identifies the specific meaning of the sentence by extracting key information from the natural language sentence.
transformer结构具有强大的语义表达能力,能捕捉文本长依赖关系。自被提出以来在以翻译为代表的一系列自然语言处理的任务上显著超越了之前的模型,基于transformer结构的语言模型在问答系统,语音助手等领域也取得了非常好的效果。The transformer structure has powerful semantic expression capabilities and can capture long text dependencies. Since it was proposed, it has significantly surpassed previous models in a series of natural language processing tasks represented by translation. Language models based on the transformer structure have also achieved very good results in question and answer systems, voice assistants and other fields.
transformer结构的网络通过包括多头自注意力模块,然而,多头自注意力模块中的注意力头head仅在实数域范围内计算不同特征块之间的关系,建模能力不足。The transformer structure network includes a multi-head self-attention module. However, the attention head in the multi-head self-attention module only calculates the relationship between different feature blocks within the real number domain, and the modeling capability is insufficient.
发明内容Contents of the invention
本申请提供了一种数据处理方法,为输入到head中的特征块token分别生成Q矩阵中元素的幅度和相位、以及K矩阵中元素的幅度和相位,增加特征的表达能力,可以更好地建模不同特征块之间的关系。This application provides a data processing method that generates the amplitude and phase of the elements in the Q matrix and the amplitude and phase of the elements in the K matrix respectively for the feature block token input into the head, thereby increasing the expression ability of the features and enabling better Model the relationship between different feature blocks.
第一方面,本申请提供了一种数据处理方法,应用于基于注意力机制的神经网络中的注意力头head,所述方法包括:通过对输入到所述head中的特征块进行多次线性变换,分别得到第一幅值、第二相位值、第二幅值以及第二相位值;根据所述第一数值和所述第一相位值,得到Q矩阵;所述第一幅值用于作为Q矩阵中元素的幅值,所述第一相位值用于作为所述Q矩阵中元素的相位;根据所述第二幅值和所述第二相位值,得到K矩阵;所述第二幅值用于作为K矩阵中元素的幅值,所述第二相位值用于作为所述K矩阵中元素的相位;根据所述Q矩阵、所述K矩阵以及所述head中计算得到的V矩阵,得到所述head的 输出。In the first aspect, this application provides a data processing method applied to the attention head head in the neural network based on the attention mechanism. The method includes: performing multiple linear operations on the feature blocks input to the head. Transform to obtain the first amplitude, the second phase value, the second amplitude and the second phase value respectively; according to the first numerical value and the first phase value, obtain the Q matrix; the first amplitude is used As the amplitude of the element in the Q matrix, the first phase value is used as the phase of the element in the Q matrix; according to the second amplitude and the second phase value, the K matrix is obtained; the second The amplitude is used as the amplitude of the element in the K matrix, and the second phase value is used as the phase of the element in the K matrix; V calculated according to the Q matrix, the K matrix and the head matrix, get the head's output.
在现有的实现中,用变换矩阵Q和变换矩阵K,对输入到head中的特征块token进行线性变换,分别得到Q矩阵和K矩阵,Q矩阵、K矩阵中的元素均为实数,对于特征的表达能力有限。本申请中,可以为输入到head中的特征块token分别生成Q矩阵中元素的幅度和相位、以及K矩阵中元素的幅度和相位。通过这种方式,Q矩阵和K矩阵都可以参数化为复杂的形式,进而增加特征的表达能力,可以更好地建模不同特征块之间的关系。In the existing implementation, the transformation matrix Q and transformation matrix K are used to linearly transform the feature block token input into the head, and the Q matrix and K matrix are obtained respectively. The elements in the Q matrix and K matrix are all real numbers. For Features have limited expressive power. In this application, the amplitude and phase of the elements in the Q matrix and the amplitude and phase of the elements in the K matrix can be generated respectively for the feature block token input into the head. In this way, both the Q matrix and the K matrix can be parameterized into complex forms, thereby increasing the expressive ability of features and better modeling the relationship between different feature blocks.
在一种可能的实现中,所述根据所述Q矩阵、所述K矩阵以及所述head中计算得到的V矩阵,得到所述head的输出,包括:对所述Q矩阵和所述K矩阵进行相关度计算,得到第一注意力矩阵,所述第一注意力矩阵中的元素为复数;将所述第一注意力矩阵中的元素映射为实数,得到第二注意力矩阵;根据所述第二注意力矩阵和所述head中计算得到的V矩阵,得到所述head的输出。In a possible implementation, obtaining the output of the head based on the Q matrix, the K matrix and the V matrix calculated in the head includes: comparing the Q matrix and the K matrix Perform correlation calculation to obtain a first attention matrix, and the elements in the first attention matrix are complex numbers; map the elements in the first attention matrix to real numbers to obtain a second attention matrix; according to The second attention matrix and the V matrix calculated in the head are used to obtain the output of the head.
在一种实现中,可以对所述Q矩阵和所述K矩阵进行相关度计算,得到第一注意力矩阵,由于Q矩阵和所述K矩阵本身是复数域的数,因此所述第一注意力矩阵中的元素为复数。In one implementation, correlation calculation can be performed on the Q matrix and the K matrix to obtain the first attention matrix. Since the Q matrix and the K matrix themselves are numbers in the complex domain, the first attention matrix The elements in the force matrix are complex numbers.
在一种实现中,在基于Q矩阵和K矩阵计算相关度时,所述Q矩阵和所述K矩阵中各个元素之间存在的相位差可以会导致对幅度进行调制,例如,与小相位差相关的特征可能会增强,而与大相位差相关的特征可能会减少,这类似于相干光引起的干涉现象。In one implementation, when calculating the correlation based on the Q matrix and the K matrix, the phase difference existing between the elements in the Q matrix and the K matrix may cause the amplitude to be modulated, for example, with a small phase difference Correlated features may be enhanced, while features associated with large phase differences may be reduced, similar to interference phenomena caused by coherent light.
在一种实现中,可以直接将qi与kj的点乘结果确定为关联度,由于上述计算得到的相关度需要和V矩阵进行加权运算,因此可以将所述第一注意力矩阵中的元素映射为实数,得到第二注意力矩阵,并根据所述第二注意力矩阵和所述head中计算得到的V矩阵,得到所述head的输出。In one implementation, the dot product result of qi and kj can be directly determined as the correlation degree. Since the correlation degree calculated above needs to be weighted with the V matrix, the elements in the first attention matrix can be mapped is a real number, obtain the second attention matrix, and obtain the output of the head according to the second attention matrix and the V matrix calculated in the head.
在一种实现中,可以将点乘结果除以一常数,然后进行softmax运算,由于softmax运算需要在实数域上进行,而Q矩阵和K矩阵之间进行运算的结果(也就是softmax运算的对象)为复数,因此,本申请实施例中可以对Q矩阵和K矩阵之间进行运算的结果(第一注意力矩阵)映射到实数域上。In one implementation, the dot multiplication result can be divided by a constant, and then the softmax operation is performed. Since the softmax operation needs to be performed in the real number domain, the result of the operation between the Q matrix and the K matrix (that is, the object of the softmax operation ) is a complex number. Therefore, in the embodiment of the present application, the result of the operation between the Q matrix and the K matrix (the first attention matrix) can be mapped to the real number domain.
在一种实现中,所述第一注意力矩阵中的元素包括实部和虚部,在将第一注意力矩阵中的元素映射为实数时,可以将所述第一注意力矩阵中元素的实部的数值和虚部的数值进行融合,以得到融合结果,所述融合结果为实数。In one implementation, the elements in the first attention matrix include real parts and imaginary parts. When mapping the elements in the first attention matrix to real numbers, the elements in the first attention matrix can be The numerical value of the real part and the numerical value of the imaginary part are fused to obtain a fusion result, and the fusion result is a real number.
示例性的,所述融合,可以包括:求和操作;或者,求复数的模长。For example, the fusion may include: a summation operation; or, finding the modulus length of a complex number.
在一种可能的实现中,所述通过对输入到所述head中的特征块的元素进行多次线性变换,分别得到第一幅值、第一相位值、第二幅值以及第二相位值,包括:通过线性规划层,对输入到所述head中的特征块进行多次线性变换;所述线性规划层包括第一权重、第二权重、第三权重以及第四权重,所述第一权重、所述第二权重、所述第三权重以及所述第四权重为可训练的参数;其中,所述第一权重用于对所述特征块进行线性变换,以得到所述第一幅值;所述第二权重用于对所述特征块进行线性变换,以得到所述第一相位值;所述第三权重用于对所述特征块进行线性变换,以得到所述第二幅值;所述第四权重用于对所 述特征块进行线性变换,以得到所述第二相位值。In a possible implementation, the first amplitude, the first phase value, the second amplitude and the second phase value are obtained by performing multiple linear transformations on the elements of the feature block input to the head. , including: performing multiple linear transformations on the feature blocks input into the head through a linear programming layer; the linear programming layer includes a first weight, a second weight, a third weight and a fourth weight, the first The weight, the second weight, the third weight and the fourth weight are trainable parameters; wherein the first weight is used to linearly transform the feature block to obtain the first image value; the second weight is used to linearly transform the feature block to obtain the first phase value; the third weight is used to linearly transform the feature block to obtain the second phase value. value; the fourth weight is used to The feature block is linearly transformed to obtain the second phase value.
本申请中每个查询query和关键字key都使用两个线性变换层,分别生成幅值和相位,使得生成的query和key可以表达更丰富的信息。In this application, each query query and keyword key use two linear transformation layers to generate amplitude and phase respectively, so that the generated query and key can express richer information.
在一种可能的实现中,所述特征块为与一段数据的一个切片相关联的信息,所述一段数据为音频数据、视频数据、图像数据或上下文数据。In a possible implementation, the feature block is information associated with a slice of a piece of data, and the piece of data is audio data, video data, image data or context data.
第二方面,本申请提供了一种数据处理方法,所述方法包括:In a second aspect, this application provides a data processing method, which method includes:
通过对特征图中的第一特征块进行多次线性变换,分别得到第一幅值和第一相位值;By performing multiple linear transformations on the first feature block in the feature map, the first amplitude and first phase values are obtained respectively;
根据所述第一幅值和所述第一相位值,得到第二特征块;第一幅值用于作为所述第二特征块中元素的幅值,所述第一相位值用于作为所述第二特征块中元素的相位;将所述第二特征块中的元素映射为实数,得到第三特征块;将所述第三特征块,输入到卷积层中。According to the first amplitude and the first phase value, a second feature block is obtained; the first amplitude is used as the amplitude of the element in the second feature block, and the first phase value is used as the phase of the elements in the second feature block; map the elements in the second feature block to real numbers to obtain a third feature block; input the third feature block into the convolution layer.
对于卷积层需要处理的特征图,可以将特征图中的各个特征块(本申请实施例以第一特征块为例)进行多次线性变换,分别得到第一幅值和第一相位值,第一幅值用于作为所述第二特征块中元素的幅值,所述第一相位值用于作为所述第二特征块中元素的相位。For the feature map that needs to be processed by the convolution layer, each feature block in the feature map (the first feature block is taken as an example in the embodiment of this application) can be linearly transformed multiple times to obtain the first amplitude value and the first phase value respectively. The first amplitude value is used as the amplitude of the element in the second feature block, and the first phase value is used as the phase of the element in the second feature block.
不同于现有方法,本申请中的特征块使用多次线性变换,分别生成幅值和相位,使得生成的优化后的特征块可以表达更丰富的信息。且在网络最终的输出层,通过特征变换的方式,把特征变换到实数域中,得到有实际意义的模型输出。Different from existing methods, the feature block in this application uses multiple linear transformations to generate amplitude and phase respectively, so that the generated optimized feature block can express richer information. And in the final output layer of the network, the features are transformed into the real number domain through feature transformation to obtain practical meaningful model output.
在一种可能的实现中,所述将所述第二特征块中的元素映射为实数,包括:In a possible implementation, mapping the elements in the second feature block to real numbers includes:
将所述第二特征块中元素表示为复数时的实部的数值和虚部的数值进行融合,以得到融合结果,所述融合结果为实数。The values of the real part and the value of the imaginary part when the elements in the second feature block are expressed as complex numbers are fused to obtain a fusion result, and the fusion result is a real number.
在一种可能的实现中,所述融合,包括:拼接操作(concat)。In a possible implementation, the fusion includes: a concatenation operation (concat).
在一种可能的实现中,所述通过对特征图中的第一特征块进行多次线性变换,分别得到第一幅值和第一相位值,包括:In a possible implementation, the first amplitude and the first phase value are obtained respectively by performing multiple linear transformations on the first feature block in the feature map, including:
通过线性规划层,对特征图中的第一特征块进行多次线性变换;所述线性规划层包括第一权重和第二权重,所述第一权重和所述第二权重为可训练的参数;其中,Through the linear programming layer, multiple linear transformations are performed on the first feature block in the feature map; the linear programming layer includes a first weight and a second weight, and the first weight and the second weight are trainable parameters. ;in,
所述第一权重用于对特征图中的第一特征块进行线性变换,以得到所述第一幅值;The first weight is used to linearly transform the first feature block in the feature map to obtain the first amplitude;
所述第二权重用于对特征图中的第一特征块进行线性变换,以得到所述第一相位值。The second weight is used to linearly transform the first feature block in the feature map to obtain the first phase value.
在一种可能的实现中,所述特征块为与一段数据的一个切片相关联的信息,所述一段数据为音频数据、视频数据、图像数据或上下文数据。In a possible implementation, the feature block is information associated with a slice of a piece of data, and the piece of data is audio data, video data, image data or context data.
第三方面,本申请提供了一种数据处理装置,应用于基于注意力机制的神经网络中的注意力头head,所述装置包括:In the third aspect, this application provides a data processing device applied to the attention head in a neural network based on the attention mechanism. The device includes:
线性变换模块,用于通过对输入到所述head中的特征块进行多次线性变换,分别得到 第一幅值、第二相位值、第二幅值以及第二相位值;A linear transformation module is used to perform multiple linear transformations on the feature blocks input to the head to obtain respectively a first amplitude value, a second phase value, a second amplitude value and a second phase value;
注意力计算模块,用于根据所述第一数值和所述第一相位值,得到Q矩阵;所述第一幅值用于作为Q矩阵中元素的幅值,所述第一相位值用于作为所述Q矩阵中元素的相位;Attention calculation module, used to obtain the Q matrix according to the first numerical value and the first phase value; the first amplitude value is used as the amplitude value of the element in the Q matrix, and the first phase value is used to As the phase of the elements in the Q matrix;
根据所述第二幅值和所述第二相位值,得到K矩阵;所述第二幅值用于作为K矩阵中元素的幅值,所述第二相位值用于作为所述K矩阵中元素的相位;According to the second amplitude and the second phase value, a K matrix is obtained; the second amplitude is used as the amplitude of the element in the K matrix, and the second phase value is used as the element in the K matrix. the phase of an element;
根据所述Q矩阵、所述K矩阵以及所述head中计算得到的V矩阵,得到所述head的输出。According to the Q matrix, the K matrix and the V matrix calculated in the head, the output of the head is obtained.
在一种可能的实现中,所述注意力计算模块,具体用于:In a possible implementation, the attention calculation module is specifically used to:
对所述Q矩阵和所述K矩阵进行相关度计算,得到第一注意力矩阵,所述第一注意力矩阵中的元素为复数;Perform correlation calculation on the Q matrix and the K matrix to obtain a first attention matrix, where the elements in the first attention matrix are complex numbers;
将所述第一注意力矩阵中的元素映射为实数,得到第二注意力矩阵;Map the elements in the first attention matrix to real numbers to obtain a second attention matrix;
根据所述第二注意力矩阵和所述head中计算得到的V矩阵,得到所述head的输出。According to the second attention matrix and the V matrix calculated in the head, the output of the head is obtained.
在一种可能的实现中,所述第一注意力矩阵中的元素包括实部和虚部,所述注意力计算模块,具体用于:In a possible implementation, the elements in the first attention matrix include real parts and imaginary parts, and the attention calculation module is specifically used to:
将所述第一注意力矩阵中元素的实部的数值和虚部的数值进行融合,以得到融合结果,所述融合结果为实数。The values of the real part and the value of the imaginary part of the elements in the first attention matrix are fused to obtain a fusion result, and the fusion result is a real number.
在一种可能的实现中,所述融合,包括:In a possible implementation, the fusion includes:
求和操作;或者,sum operation; or,
求复数的模长。Find the modular length of a complex number.
在一种可能的实现中,所述线性变换模块,具体用于:In a possible implementation, the linear transformation module is specifically used for:
通过线性规划层,对输入到所述head中的特征块进行多次线性变换;所述线性规划层包括第一权重、第二权重、第三权重以及第四权重,所述第一权重、所述第二权重、所述第三权重以及所述第四权重为可训练的参数;其中,Through the linear planning layer, multiple linear transformations are performed on the feature blocks input into the head; the linear planning layer includes a first weight, a second weight, a third weight and a fourth weight. The first weight, the The second weight, the third weight and the fourth weight are trainable parameters; wherein,
所述第一权重用于对所述特征块进行线性变换,以得到所述第一幅值;The first weight is used to linearly transform the feature block to obtain the first amplitude;
所述第二权重用于对所述特征块进行线性变换,以得到所述第一相位值;The second weight is used to linearly transform the feature block to obtain the first phase value;
所述第三权重用于对所述特征块进行线性变换,以得到所述第二幅值;The third weight is used to linearly transform the feature block to obtain the second amplitude;
所述第四权重用于对所述特征块进行线性变换,以得到所述第二相位值。The fourth weight is used to linearly transform the feature block to obtain the second phase value.
在一种可能的实现中,所述特征块为与一段数据的一个切片相关联的信息,所述一段数据为音频数据、视频数据、图像数据或上下文数据。In a possible implementation, the feature block is information associated with a slice of a piece of data, and the piece of data is audio data, video data, image data or context data.
第四方面,本申请提供了一种数据处理装置,所述装置包括:In a fourth aspect, this application provides a data processing device, which includes:
线性变换模块,用于通过对特征图中的第一特征块进行多次线性变换,分别得到第一 幅值和第一相位值;The linear transformation module is used to perform multiple linear transformations on the first feature block in the feature map to obtain the first Amplitude and first phase values;
根据所述第一幅值和所述第一相位值,得到第二特征块;第一幅值用于作为所述第二特征块中元素的幅值,所述第一相位值用于作为所述第二特征块中元素的相位;According to the first amplitude and the first phase value, a second feature block is obtained; the first amplitude is used as the amplitude of the element in the second feature block, and the first phase value is used as the The phase of the elements in the second feature block;
将所述第二特征块中的元素映射为实数,得到第三特征块;Map elements in the second feature block to real numbers to obtain a third feature block;
卷积模块,用于将所述第三特征块,输入到卷积层中。The convolution module is used to input the third feature block into the convolution layer.
在一种可能的实现中,所述线性变换模块,具体用于:In a possible implementation, the linear transformation module is specifically used for:
将所述第二特征块中元素表示为复数时的实部的数值和虚部的数值进行融合,以得到融合结果,所述融合结果为实数。The values of the real part and the value of the imaginary part when the elements in the second feature block are expressed as complex numbers are fused to obtain a fusion result, and the fusion result is a real number.
在一种可能的实现中,所述融合,包括:In a possible implementation, the fusion includes:
拼接操作(concat)。Concatenation operation (concat).
在一种可能的实现中,所述线性变换模块,具体用于:In a possible implementation, the linear transformation module is specifically used for:
通过线性规划层,对特征图中的第一特征块进行多次线性变换;所述线性规划层包括第一权重和第二权重,所述第一权重和所述第二权重为可训练的参数;其中,Through the linear programming layer, multiple linear transformations are performed on the first feature block in the feature map; the linear programming layer includes a first weight and a second weight, and the first weight and the second weight are trainable parameters. ;in,
所述第一权重用于对特征图中的第一特征块进行线性变换,以得到所述第一幅值;The first weight is used to linearly transform the first feature block in the feature map to obtain the first amplitude;
所述第二权重用于对特征图中的第一特征块进行线性变换,以得到所述第一相位值。The second weight is used to linearly transform the first feature block in the feature map to obtain the first phase value.
在一种可能的实现中,所述特征块为与一段数据的一个切片相关联的信息,所述一段数据为音频数据、视频数据、图像数据或上下文数据。In a possible implementation, the feature block is information associated with a slice of a piece of data, and the piece of data is audio data, video data, image data or context data.
第五方面,本申请实施例提供了一种执行设备,可以包括存储器、处理器以及总线系统,其中,存储器用于存储程序,处理器用于执行存储器中的程序,以执行如上述第一方面及其任一可选的方法、以及如上述第二方面及其任一可选的方法。In the fifth aspect, embodiments of the present application provide an execution device, which may include a memory, a processor, and a bus system, wherein the memory is used to store programs, and the processor is used to execute the programs in the memory to execute the above-mentioned first aspect and Any optional method thereof, and the above second aspect and any optional method thereof.
第六方面,本申请实施例提供了一种训练设备,可以包括存储器、处理器以及总线系统,其中,存储器用于存储程序,处理器用于执行存储器中的程序,以执行如上述第一方面及其任一可选的方法、以及如上述第二方面及其任一可选的方法。In a sixth aspect, embodiments of the present application provide a training device, which may include a memory, a processor, and a bus system. The memory is used to store programs, and the processor is used to execute programs in the memory to perform the above-mentioned first aspect and Any optional method thereof, and the above second aspect and any optional method thereof.
第七方面,本申请实施例提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行上述第一方面及其任一可选的方法、以及如上述第二方面及其任一可选的方法。In a seventh aspect, embodiments of the present application provide a computer-readable storage medium that stores a computer program that, when run on a computer, causes the computer to execute the first aspect and any one of the above-mentioned aspects. Optional methods, as well as the above-mentioned second aspect and any optional method thereof.
第八方面,本申请实施例提供了一种计算机程序,当其在计算机上运行时,使得计算机执行上述第一方面及其任一可选的方法、以及如上述第二方面及其任一可选的方法。In an eighth aspect, embodiments of the present application provide a computer program that, when run on a computer, causes the computer to execute the above-mentioned first aspect and any optional method thereof, as well as the above-mentioned second aspect and any optional method thereof. method of selection.
第九方面,本申请提供了一种芯片系统,该芯片系统包括处理器,用于支持执行设备或训练设备实现上述方面中所涉及的功能,例如,发送或处理上述方法中所涉及的数据;或,信息。在一种可能的设计中,所述芯片系统还包括存储器,所述存储器,用于保存执行设备或训练设备必要的程序指令和数据。该芯片系统,可以由芯片构成,也可以包括芯片和其他分立器件。 In a ninth aspect, the present application provides a chip system, which includes a processor for supporting an execution device or a training device to implement the functions involved in the above aspects, for example, sending or processing data involved in the above methods; Or, information. In a possible design, the chip system further includes a memory, and the memory is used to store necessary program instructions and data for executing the device or training the device. The chip system may be composed of chips, or may include chips and other discrete devices.
图1为人工智能主体框架的一种结构示意图;Figure 1 is a structural schematic diagram of the main framework of artificial intelligence;
图2为一种自然语言处理系统;Figure 2 shows a natural language processing system;
图3a为另一种自然语言处理系统;Figure 3a shows another natural language processing system;
图3b为一种系统的示意;Figure 3b is a schematic diagram of a system;
图4为本申请实施例提供的自然语言处理的相关设备的示意图;Figure 4 is a schematic diagram of related equipment for natural language processing provided by an embodiment of the present application;
图5A为一种transformer层的架构示意;Figure 5A is a schematic diagram of the architecture of a transformer layer;
图5B为一种卷积神经网络的架构示意;Figure 5B is a schematic diagram of the architecture of a convolutional neural network;
图5C为一种卷积神经网络的架构示意;Figure 5C is a schematic diagram of the architecture of a convolutional neural network;
图6为本申请实施例提供的一种数据处理方法的实施例示意;Figure 6 is a schematic diagram of an embodiment of a data processing method provided by an embodiment of the present application;
图7为本申请实施例中的一种神经网络模型的结构示意;Figure 7 is a schematic structural representation of a neural network model in an embodiment of the present application;
图8为一个注意力头head的操作示意图;Figure 8 is a schematic diagram of the operation of an attention head;
图9为本申请实施例提供的一种head的操作示意图;Figure 9 is a schematic diagram of the operation of a head provided by an embodiment of the present application;
图10为本申请实施例提供的一种融合示意;Figure 10 is a fusion diagram provided by an embodiment of the present application;
图11为本申请实施例提供的一种应用架构示意;Figure 11 is a schematic diagram of an application architecture provided by an embodiment of the present application;
图12为本申请实施例提供的一种数据处理方法的实施例示意;Figure 12 is a schematic diagram of an embodiment of a data processing method provided by an embodiment of the present application;
图13为本申请实施例提供的一种数据处理方法的实施例示意;Figure 13 is a schematic diagram of an embodiment of a data processing method provided by an embodiment of the present application;
图14为本申请实施例提供的数据处理装置的一种结构示意图;Figure 14 is a schematic structural diagram of a data processing device provided by an embodiment of the present application;
图15为本申请实施例提供的数据处理装置的一种结构示意图;Figure 15 is a schematic structural diagram of a data processing device provided by an embodiment of the present application;
图16为本申请实施例提供的执行设备的一种结构示意图;Figure 16 is a schematic structural diagram of an execution device provided by an embodiment of the present application;
图17是本申请实施例提供的训练设备一种结构示意图;Figure 17 is a schematic structural diagram of the training equipment provided by the embodiment of the present application;
图18为本申请实施例提供的芯片的一种结构示意图。Figure 18 is a schematic structural diagram of a chip provided by an embodiment of the present application.
下面结合本发明实施例中的附图对本发明实施例进行描述。本发明的实施方式部分使用的术语仅用于对本发明的具体实施例进行解释,而非旨在限定本发明。The embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention. The terms used in the embodiments of the present invention are only used to explain specific embodiments of the present invention and are not intended to limit the present invention.
下面结合附图,对本申请的实施例进行描述。本领域普通技术人员可知,随着技术的发展和新场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。The embodiments of the present application are described below with reference to the accompanying drawings. Persons of ordinary skill in the art know that with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的术语在适当情况下可以互换,这仅仅是描述本申请的实施例中对相同属性的对象在描述时所采用的区分方式。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,以便包含一系列单元的过程、方法、系统、产品或设备不必限于那些单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它单元。The terms "first", "second", etc. in the description and claims of this application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the terms so used are interchangeable under appropriate circumstances, and are merely a way of distinguishing objects with the same attributes in describing the embodiments of the present application. Furthermore, the terms "include" and "having" and any variations thereof, are intended to cover non-exclusive inclusions, such that a process, method, system, product or apparatus comprising a series of elements need not be limited to those elements, but may include not explicitly other elements specifically listed or inherent to such processes, methods, products or equipment.
首先对人工智能系统总体工作流程进行描述,请参见图1,图1示出的为人工智能主体框架的一种结构示意图,下面从“智能信息链”(水平轴)和“IT价值链”(垂直轴)两个 维度对上述人工智能主题框架进行阐述。其中,“智能信息链”反映从数据的获取到处理的一列过程。举例来说,可以是智能信息感知、智能信息表示与形成、智能推理、智能决策、智能执行与输出的一般过程。在这个过程中,数据经历了“数据—信息—知识—智慧”的凝练过程。“IT价值链”从人智能的底层基础设施、信息(提供和处理技术实现)到系统的产业生态过程,反映人工智能为信息技术产业带来的价值。First, the overall workflow of the artificial intelligence system is described. Please refer to Figure 1. Figure 1 shows a structural schematic diagram of the artificial intelligence main framework. The following is from the "intelligent information chain" (horizontal axis) and "IT value chain" ( vertical axis) two Dimension elaborates on the above artificial intelligence theme framework. Among them, the "intelligent information chain" reflects a series of processes from data acquisition to processing. For example, it can be the general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, intelligent execution and output. In this process, the data has gone through the 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 (providing and processing technology implementation) to the systematic industrial ecological process.
(1)基础设施(1)Infrastructure
基础设施为人工智能系统提供计算能力支持,实现与外部世界的沟通,并通过基础平台实现支撑。通过传感器与外部沟通;计算能力由智能芯片(CPU、NPU、GPU、ASIC、FPGA等硬件加速芯片)提供;基础平台包括分布式计算框架及网络等相关的平台保障和支持,可以包括云存储和计算、互联互通网络等。举例来说,传感器和外部沟通获取数据,这些数据提供给基础平台提供的分布式计算系统中的智能芯片进行计算。Infrastructure provides computing power support for artificial intelligence systems, enables communication with the external world, and supports it through basic platforms. Communicate with the outside through sensors; computing power is provided by smart chips (hardware acceleration chips such as CPU, NPU, GPU, ASIC, FPGA, etc.); the basic platform includes distributed computing framework and network and other related platform guarantees and support, which can include cloud storage and Computing, interconnection networks, etc. For example, sensors communicate with the outside world to obtain data, which are provided to smart chips in the distributed computing system provided by the basic platform for calculation.
(2)数据(2)Data
基础设施的上一层的数据用于表示人工智能领域的数据来源。数据涉及到图形、图像、语音、文本,还涉及到传统设备的物联网数据,包括已有系统的业务数据以及力、位移、液位、温度、湿度等感知数据。Data from the upper layer of the infrastructure is used to represent data sources in the field of artificial intelligence. The data involves graphics, images, voice, and text, as well as IoT data of traditional devices, including business data of existing systems and sensory data such as force, displacement, liquid level, temperature, and humidity.
(3)数据处理(3)Data processing
数据处理通常包括数据训练,机器学习,深度学习,搜索,推理,决策等方式。Data processing usually includes data training, machine learning, deep learning, search, reasoning, decision-making and other methods.
其中,机器学习和深度学习可以对数据进行符号化和形式化的智能信息建模、抽取、预处理、训练等。Among them, machine learning and deep learning can perform symbolic and formal intelligent information modeling, extraction, preprocessing, training, etc. on data.
推理是指在计算机或智能系统中,模拟人类的智能推理方式,依据推理控制策略,利用形式化的信息进行机器思维和求解问题的过程,典型的功能是搜索与匹配。Reasoning refers to the process of simulating human intelligent reasoning in computers or intelligent systems, using formal information to perform machine thinking and problem solving based on reasoning control strategies. Typical functions are search and matching.
决策是指智能信息经过推理后进行决策的过程,通常提供分类、排序、预测等功能。Decision-making refers to the process of decision-making after intelligent information is reasoned, and usually provides functions such as classification, sorting, and prediction.
(4)通用能力(4) General ability
对数据经过上面提到的数据处理后,进一步基于数据处理的结果可以形成一些通用的能力,比如可以是算法或者一个通用系统,例如,翻译,文本的分析,计算机视觉的处理,语音识别,图像的识别等等。After the data is processed as mentioned above, some general capabilities can be formed based on the results of further data processing, such as algorithms or a general system, such as translation, text analysis, computer vision processing, speech recognition, and image processing. identification, etc.
(5)智能产品及行业应用(5) Intelligent products and industry applications
智能产品及行业应用指人工智能系统在各领域的产品和应用,是对人工智能整体解决方案的封装,将智能信息决策产品化、实现落地应用,其应用领域主要包括:智能终端、智能交通、智能医疗、自动驾驶、智慧城市等。Intelligent products and industry applications refer to the 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. Its application fields mainly include: intelligent terminals, intelligent transportation, Smart healthcare, autonomous driving, smart cities, etc.
本申请可以应用于人工智能领域的自然语言处理、图像处理等领域中,下面将对多个落地到产品的多个应用场景进行介绍。This application can be applied to natural language processing, image processing and other fields in the field of artificial intelligence. The following will introduce multiple application scenarios that have been implemented into products.
为了更好地理解本申请实施例的方案,下面先结合图1至图3a对本申请实施例可能的应用场景进行简单的介绍。In order to better understand the solutions of the embodiments of the present application, possible application scenarios of the embodiments of the present application are briefly introduced below with reference to Figures 1 to 3a.
图2示出了一种自然语言处理系统,该自然语言处理系统包括用户设备以及数据处理设备。其中,用户设备包括手机、个人电脑或者信息处理中心等智能终端。用户设备为自 然语言数据处理的发起端,作为语言问答或者查询等请求的发起方,通常用户通过用户设备发起请求。Figure 2 shows a natural language processing system, which includes user equipment and data processing equipment. Among them, user equipment includes smart terminals such as mobile phones, personal computers, or information processing centers. User equipment is from However, as the initiator of language data processing, as the initiator of language question and answer or query requests, the user usually initiates the request through the user device.
上述数据处理设备可以是云服务器、网络服务器、应用服务器以及管理服务器等具有数据处理功能的设备或服务器。数据处理设备通过交互接口接收来自智能终端的查询语句/语音/文本等,再通过存储数据的存储器以及数据处理的处理器环节进行机器学习,深度学习,搜索,推理,决策等方式的语言数据处理,并将处理结果反馈至用户设备。数据处理设备中的存储器可以是一个统称,包括本地存储以及存储历史数据的数据库,数据库可以在数据处理设备上,也可以在其它网络服务器上。The above-mentioned data processing equipment may be a cloud server, a network server, an application server, a management server, and other equipment or servers with data processing functions. The data processing equipment receives query statements/voice/text, etc. from the smart terminal through an interactive interface, and then performs language data processing in the form of machine learning, deep learning, search, reasoning, decision-making, etc. through the memory for storing data and the processor for data processing. , and feedback the processing results to the user device. The memory in the data processing device can be a general term, including local storage and a database that stores historical data. The database can be on the data processing device or on other network servers.
在图2所示的自然语言处理系统中,用户设备可以接收用户的指令,例如用户设备可以接收用户输入的一段文本,然后向数据处理设备发起请求,使得数据处理设备针对用户设备得到的该一段文本执行自然语言处理应用(例如自然语言生成、文本分类、文本推理、命名实体识别、翻译等),从而得到针对该一段文本的对应的自然语言处理应用的处理结果(例如预测词结果、分类结果、推理结果、命名实体识别结果、翻译结果等)。In the natural language processing system shown in Figure 2, the user device can receive the user's instructions. For example, the user device can receive a piece of text input by the user, and then initiate a request to the data processing device, so that the data processing device can respond to the piece of text obtained by the user device. The text executes natural language processing applications (such as natural language generation, text classification, text reasoning, named entity recognition, translation, etc.), thereby obtaining the processing results of the corresponding natural language processing application for the text (such as predicted word results, classification results) , inference results, named entity recognition results, translation results, etc.).
以自然语言生成为例,自然语言生成(natural language generation)也可以称之为文本预测任务或者自然语言合成任务,是指在给定一段文字的前提下,生成其中的缺失文本或者后续文本的任务。自然语言生成在搜索引擎,输入法等场景均有广泛应用,可以在用户输入部分文字的前提下预测用户接下来的输入,可以大大提高用户的使用该产品的效率,此外还可以对存在文字缺失的文本进行恢复。Taking natural language generation as an example, natural language generation (natural language generation) can also be called text prediction task or natural language synthesis task. It refers to the task of generating missing text or subsequent text given a piece of text. . Natural language generation is widely used in search engines, input methods and other scenarios. It can predict the user's next input based on the user's input of part of the text, which can greatly improve the user's efficiency in using the product. In addition, it can also detect missing text. text to be restored.
示例性的,本申请实施例中,用户设备可以接收用户输入的一段文本数据,其中文本数据中包括已知词和待预测词,待预测词不可见,仅仅知晓待预测词在文本数据中的位置,然后用户设备可以向数据处理设备发起请求(请求中携带文本数据),使得数据处理设备对该文本数据中的待预测词进行预测,从而得到待预测词,并将待预测词反馈至用户设备。Exemplarily, in the embodiment of the present application, the user equipment can receive a piece of text data input by the user, where the text data includes known words and words to be predicted. The words to be predicted are not visible, and only the location of the words to be predicted in the text data is known. location, and then the user device can initiate a request to the data processing device (the request carries text data), so that the data processing device predicts the word to be predicted in the text data, thereby obtaining the word to be predicted, and feeds the word to be predicted to the user equipment.
示例性的,用户设备可以接收用户输入的一段文本数据,然后向数据处理设备发起请求,使得数据处理设备对该一段文本数据进行实体分类,从而得到针对该一段文本数据的实体分类结果,并将实体分类结果反馈至用户设备;For example, the user device can receive a piece of text data input by the user, and then initiate a request to the data processing device, so that the data processing device performs entity classification on the piece of text data, thereby obtaining the entity classification result for the piece of text data, and The entity classification results are fed back to the user device;
示例性的,用户设备可以接收用户输入的一段文本数据(文本数据为中文文本),然后向数据处理设备发起请求,使得数据处理设备将该一段文本数据翻译成英文,从而得到针对该一段文本数据的英文译文,并将英文译文反馈至用户设备。For example, the user device can receive a piece of text data input by the user (the text data is Chinese text), and then initiate a request to the data processing device, so that the data processing device translates the piece of text data into English, thereby obtaining the text data for the piece of text data. English translation, and feedback the English translation to the user device.
图3a示出了另一种自然语言处理系统,在图3a中,用户设备直接作为数据处理设备,该用户设备能够直接接收来自用户的输入并直接由用户设备本身的硬件进行处理,具体过程与图2相似,可参考上面的描述,在此不再赘述。Figure 3a shows another natural language processing system. In Figure 3a, the user device directly serves as a data processing device. The user device can directly receive input from the user and process it directly by the hardware of the user device itself. The specific process is as follows Figure 2 is similar, please refer to the above description, and will not be repeated here.
图4是本申请实施例提供的自然语言处理的相关设备300的示意图。FIG. 4 is a schematic diagram of a natural language processing related device 300 provided by an embodiment of the present application.
上述图2和图3a中的用户设备具体可以是图4中的本地设备301或者本地设备302,图2中的数据处理设备具体可以是图4中的执行设备310,其中,数据存储系统350可以存储执行设备310的待处理数据,数据存储系统350可以集成在执行设备310上,也可以设置在云上或其它网络服务器上。 The user equipment in Figure 2 and Figure 3a can be the local device 301 or the local device 302 in Figure 4, and the data processing device in Figure 2 can be the execution device 310 in Figure 4, where the data storage system 350 can To store the data to be processed by the execution device 310, the data storage system 350 can be integrated on the execution device 310, or can be set up on the cloud or other network servers.
图2和图3a中的处理器可以通过神经网络模型或者其它模型进行数据训练/机器学习/深度学习,并利用数据最终训练或者学习得到的模型针对文本数据执行自然语言处理应用(例如自然语言生成、文本分类、序列标注、阅读理解、文本生成、文本推理、翻译等),从而得到相应的处理结果。The processors in Figures 2 and 3a can perform data training/machine learning/deep learning through neural network models or other models, and use the model finally trained or learned on the data to execute natural language processing applications (such as natural language generation) on text data , text classification, sequence annotation, reading comprehension, text generation, text reasoning, translation, etc.) to obtain corresponding processing results.
此外,在计算机视觉中,神经网络架构通常用于处理各种任务,例如图像分类,对象检测和语义分割等任务。Furthermore, in computer vision, neural network architectures are often used to handle various tasks such as image classification, object detection, and semantic segmentation.
下面结合图3b对本申请实施例提供的系统架构进行详细的介绍。图3b为本申请一实施例提供的系统架构示意图。如图3b所示,系统架构500包括执行设备510、训练设备520、数据库530、客户设备540、数据存储系统550以及数据采集系统560。The system architecture provided by the embodiment of the present application will be introduced in detail below with reference to Figure 3b. Figure 3b is a schematic diagram of the system architecture provided by an embodiment of the present application. As shown in Figure 3b, 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 collection system 560.
执行设备510包括计算模块511、I/O接口512、预处理模块513和预处理模块514。计算模块511中可以包括目标模型/规则501,预处理模块513和预处理模块514是可选的。The execution device 510 includes a computing module 511, an I/O interface 512, a preprocessing module 513 and a preprocessing module 514. The target model/rule 501 may be included in the calculation module 511, and the preprocessing module 513 and the preprocessing module 514 are optional.
数据采集设备560用于采集训练数据。Data collection device 560 is used to collect training data.
其中,在自然语言合成的任务中,训练数据可以为存在文本缺失的文本数据以及该存在文本缺失的文本数据对应的完整文本数据。Among them, in the task of natural language synthesis, the training data can be text data with missing text and complete text data corresponding to the text data with missing text.
其中,在翻译任务中,训练数据可以包括但不限于平行语料、单语语料等。Among them, in the translation task, the training data can include but is not limited to parallel corpus, monolingual corpus, etc.
平行语料,是指由原文文本及其平行对应的译语文本构成的双语或多语语料(也就是具有标注的文本数据),原文文本和译语文本具有相同的语义且文本单元之间具有对应关系。比如原文文本是“这次旅行需要认真计划”,与其平行对应的英文文本为“The trip needscareful planning”,则“这次旅行需要认真计划”和“The trip needs careful planning”可以看做一组平行语料,该组平行语料是中英平行语言对,可以将原文文本“这次旅行需要认真计划”看做该组平行语料的源语料,将译文文本“The trip needs careful planning”看做该组平行语料的目标语料。其中,旅行可以对应于trip。Parallel corpus refers to bilingual or multilingual corpus (that is, text data with annotations) composed of original text and its parallel corresponding target text. The original text and target text have the same semantics and there is correspondence between text units. relation. For example, the original text is "This trip needs careful planning", and the corresponding English text is "The trip needs careful planning", then "This trip needs careful planning" and "The trip needs careful planning" can be regarded as a set of parallels. Corpus, this group of parallel corpora is a Chinese-English parallel language pair. The original text "This trip needs careful planning" can be regarded as the source material of this group of parallel corpora, and the translated text "The trip needs careful planning" can be regarded as this group of parallel corpora. The target corpus of the corpus. Among them, travel may correspond to trip.
此外,“这次旅行需要认真计划”可以看做一个单语语料,“The trip needs careful planning”也可以都看做一个单语语料。In addition, "This trip needs careful planning" can be regarded as a monolingual corpus, and "The trip needs careful planning" can also be regarded as a monolingual corpus.
在计算机视觉相关的任务中,训练数据可以为图像、以及图像对应的标签等、增强后的图像等。In computer vision-related tasks, training data can be images, labels corresponding to the images, enhanced images, etc.
在采集到训练数据之后,数据采集设备560将这些训练数据存入数据库530,训练设备520基于数据库530中维护的训练数据训练得到目标模型/规则501。After collecting the training data, the data collection device 560 stores the training data into the database 530, and the training device 520 trains to obtain the target model/rule 501 based on the training data maintained in the database 530.
其中,训练设备520基于数据库530中维护的训练数据对本申请实施例中的预训练语言模型(pretrained language model,PLM)进行训练,得到目标模型/规则501。Among them, the training device 520 trains the pretrained language model (PLM) in the embodiment of the present application based on the training data maintained in the database 530 to obtain the target model/rule 501.
需要说明的是,在实际应用中,数据库530中维护的训练数据不一定都来自于数据采集设备560的采集,也有可能是从其他设备接收得到的。另外需要说明的是,训练设备520也不一定完全基于数据库530维护的训练数据进行目标模型/规则501的训练,也有可能从云端或其他地方获取训练数据进行模型训练,上述描述不应该作为对本申请实施例的限定。It should be noted that in actual applications, the training data maintained in the database 530 may not necessarily be collected by the data collection device 560, but may also be received from other devices. In addition, it should be noted that the training device 520 does not necessarily perform training of the target model/rules 501 based entirely on the training data maintained by the database 530. It may also obtain training data from the cloud or other places for model training. The above description should not be regarded as a limitation of this application. Limitations of Examples.
根据训练设备520训练得到的目标模型/规则501可以应用于不同的系统或设备中,如应用于图3b所示的执行设备510,所述执行设备510可以是终端,如手机终端,平板电脑, 笔记本电脑,增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR)设备,车载终端等,还可以是服务器或者云端等。在图3b中,执行设备510配置输入/输出(input/output,I/O)接口512,用于与外部设备进行数据交互,用户可以通过客户设备540向I/O接口512输入数据。The target model/rules 501 trained according to the training device 520 can be applied to different systems or devices, such as to the execution device 510 shown in Figure 3b. The execution device 510 can be a terminal, such as a mobile phone terminal, a tablet computer, Laptops, augmented reality (AR)/virtual reality (VR) devices, vehicle-mounted terminals, etc., or servers or clouds, etc. In Figure 3b, the execution device 510 is configured with an input/output (I/O) interface 512 for data interaction with external devices. The user can input data to the I/O interface 512 through the client device 540.
预处理模块513和预处理模块514用于根据I/O接口512接收到的输入数据进行预处理(例如获取已知数据单元以及待预测数据单元在目标数据中的位置、或者生成注意力信息等预处理过程)。应理解,可以没有预处理模块513和预处理模块514或者只有的一个预处理模块。当不存在预处理模块513和预处理模块514时,可以直接采用计算模块511对输入数据进行处理。The preprocessing module 513 and the preprocessing module 514 are used to perform preprocessing according to the input data received by the I/O interface 512 (for example, obtaining the position of the known data unit and the data unit to be predicted in the target data, or generating attention information, etc. preprocessing process). It should be understood that there may be no preprocessing module 513 and 514 or only one preprocessing module. When the preprocessing module 513 and the preprocessing module 514 do not exist, the computing module 511 can be directly used to process the input data.
在执行设备510对输入数据进行预处理,或者在执行设备510的计算模块511执行计算等相关的处理过程中,执行设备510可以调用数据存储系统550中的数据、代码等以用于相应的处理,也可以将相应处理得到的数据、指令等存入数据存储系统550中。When the execution device 510 preprocesses input data, or when the calculation module 511 of the execution device 510 performs calculations and other related processes, the execution device 510 can call data, codes, etc. in the data storage system 550 for corresponding processing. , the data, instructions, etc. obtained by corresponding processing can also be stored in the data storage system 550.
最后,I/O接口512将处理结果呈现给客户设备540,从而提供给用户。Finally, the I/O interface 512 presents the processing results to the client device 540, thereby providing them to the user.
在图3b所示情况下,用户可以手动给定输入数据,该“手动给定输入数据”可以通过I/O接口512提供的界面进行操作。另一种情况下,客户设备540可以自动地向I/O接口512发送输入数据,如果要求客户设备540自动发送输入数据需要获得用户的授权,则用户可以在客户设备540中设置相应权限。用户可以在客户设备540查看执行设备510输出的结果,具体的呈现形式可以是显示、声音、动作等具体方式。客户设备540也可以作为数据采集端,采集如图所示输入I/O接口512的输入数据及输出I/O接口512的输出结果作为新的样本数据,并存入数据库530。当然,也可以不经过客户设备540进行采集,而是由I/O接口512直接将如图所示输入I/O接口512的输入数据及输出I/O接口512的输出结果,作为新的样本数据存入数据库530。In the situation shown in FIG. 3 b , the user can manually set the input data, and the "manually set input data" can be operated through the interface provided by the I/O interface 512 . In another case, the client device 540 can automatically send input data to the I/O interface 512. If requiring the client device 540 to automatically send the input data requires the user's authorization, the user can set corresponding permissions in the client device 540. The user can view the results output by the execution device 510 on the client device 540, and the specific presentation form may be display, sound, action, etc. The client device 540 can also be used as a data collection terminal to collect the input data of the input I/O interface 512 and the output results of the output I/O interface 512 as new sample data, and store them in the database 530. Of course, it is also possible to collect without going through the client device 540. Instead, the I/O interface 512 directly uses the input data input to the I/O interface 512 and the output result of the output I/O interface 512 as a new sample as shown in the figure. The data is stored in database 530.
值得注意的是,图3b仅是本申请实施例提供的一种系统架构的示意图,图中所示设备、器件、模块等之间的位置关系不构成任何限制,例如,在图3b中,数据存储系统550相对执行设备510是外部存储器,在其它情况下,也可以将数据存储系统550置于执行设备510中。It is worth noting that Figure 3b is only a schematic diagram of a system architecture provided by an embodiment of the present application, and the positional relationship between the devices, devices, modules, etc. shown in the figure does not constitute any limitation. For example, in Figure 3b, the data The 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.
应理解上述执行设备510也可以部署于客户设备540中。It should be understood that the above execution device 510 can also be deployed in the client device 540.
由于本申请实施例涉及大量神经网络的应用,为了便于理解,下面先对本申请实施例涉及的相关术语及神经网络等相关概念进行介绍。Since the embodiments of the present application involve the application of a large number of neural networks, in order to facilitate understanding, the relevant terms involved in the embodiments of the present application and related concepts such as neural networks are first introduced below.
(1)神经网络(1)Neural network
神经网络可以是由神经单元组成的,神经单元可以是指以xs(即输入数据)和截距1为输入的运算单元,该运算单元的输出可以为:
The neural network can be composed of neural units. The neural unit can refer to an operation unit that takes xs (ie, input data) and intercept 1 as input. The output of the operation unit can be:
其中,s=1、2、……n,n为大于1的自然数,Ws为xs的权重,b为神经单元的偏置。f为神经单元的激活函数(activation functions),用于将非线性特性引入神经网络中,来将神 经单元中的输入信号转换为输出信号。该激活函数的输出信号可以作为下一层卷积层的输入,激活函数可以是sigmoid函数。神经网络是将多个上述单一的神经单元联结在一起形成的网络,即一个神经单元的输出可以是另一个神经单元的输入。每个神经单元的输入可以与前一层的局部接受域相连,来提取局部接受域的特征,局部接受域可以是由若干个神经单元组成的区域。Among them, s=1, 2,...n, n is a natural number greater than 1, Ws is the weight of xs, and b is the bias of the neural unit. f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to transform the neural network. The input signal in the unit is converted 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 a sigmoid function. A neural network is a network formed by connecting multiple above-mentioned single 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. The local receptive field can be an area composed of several neural units.
(2)transformer层(2)Transformer layer
参照图5A,图5A为一种transformer层的架构示意,如图5A所示,神经网络包括嵌入层和至少一个transformer层,至少一个transformer层可以为N个transformer层(N大于0的整数),其中,每个transformer层包括依次相邻的注意力层、加和与归一化(add&norm)层、前馈(feed forward)层和加和与归一化层。在嵌入层,对当前输入进行嵌入处理,得到多个嵌入向量;在所述注意力层,从所述第一transformer层的上一层获取P个输入向量,以P个输入向量中的任意的第一输入向量为中心,基于预设的注意力窗口范围内的各个输入向量与该第一输入向量之间的关联度,得到该第一输入向量对应的中间向量,如此确定出P个输入向量对应的P个中间向量;在所述池化层,将所述P个中间向量合并为Q个输出向量,其中transformer层中最后一个transformer层得到的多个输出向量用作所述当前输入的特征表示。Referring to Figure 5A, Figure 5A is a schematic diagram of the architecture of a transformer layer. As shown in Figure 5A, the neural network includes an embedding layer and at least one transformer layer. At least one transformer layer can be N transformer layers (N is an integer greater than 0). Among them, each transformer layer includes successively adjacent attention layers, addition and normalization (add&norm) layers, feed forward layers, and addition and normalization layers. In the embedding layer, the current input is embedded to obtain multiple embedding vectors; in the attention layer, P input vectors are obtained from the upper layer of the first transformer layer, and any of the P input vectors are The first input vector is the center. Based on the correlation between each input vector within the preset attention window range and the first input vector, the intermediate vector corresponding to the first input vector is obtained. In this way, P input vectors are determined. Corresponding P intermediate vectors; in the pooling layer, the P intermediate vectors are merged into Q output vectors, where the multiple output vectors obtained by the last transformer layer in the transformer layer are used as features of the current input express.
(3)注意力机制(attention mechanism)(3) attention mechanism
注意力机制模仿了生物观察行为的内部过程,即一种将内部经验和外部感觉对齐从而增加部分区域的观察精细度的机制,能够利用有限的注意力资源从大量信息中快速筛选出高价值信息。注意力机制可以快速提取稀疏数据的重要特征,因而被广泛用于自然语言处理任务,特别是机器翻译。而自注意力机制(self-attention mechanism)是注意力机制的改进,其减少了对外部信息的依赖,更擅长捕捉数据或特征的内部相关性。注意力机制的本质思想可以改写为如下公式:The attention mechanism imitates the internal process of biological observation behavior, that is, a mechanism that aligns internal experience and external sensation to increase the precision of observation in some areas, and can use limited attention resources to quickly filter out high-value information from a large amount of information. . The attention mechanism can quickly extract important features of sparse data and is therefore 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:
其中,Lx=||Source||代表Source的长度,公式含义即将Source中的构成元素想象成是由一系列的数据对构成,此时给定目标Target中的某个元素Query,通过计算Query和各个Key的相似性或者相关性,得到每个Key对应Value的权重系数,然后对Value进行加权求和,即得到了最终的Attention数值。所以本质上Attention机制是对Source中元素的Value值进行加权求和,而Query和Key用来计算对应Value的权重系数。从概念上理解,把Attention可以理解为从大量信息中有选择地筛选出少量重要信息并聚焦到这些重要信息上,忽略大多不重要的信息。聚焦的过程体现在权重系数的计算上,权重越大越聚焦于其对应的Value值上,即权重代表了信息的重要性,而Value是其对应的信息。自注意力机制可以理解为内部Attention(intra attention),Attention机制发生在Target的元素Query和Source中的所有元素之间,自注意力机制指的是在Source内部元素之间或者Target内部元素之间发生的Attention机制,也可以理解为Target=Source这种特殊情况下的注意力计算机制,其具体计算过程是一样的,只是计算对象发生了变化而已。Among them, Lx=||Source|| represents the length of Source. The meaning of the formula is to imagine that the constituent elements in Source are composed of a series of data pairs. At this time, given a certain element Query in the target Target, by calculating the Query and Based on the similarity or correlation of each Key, the weight coefficient of each Key's corresponding Value is obtained, and then the Value is weighted and summed to obtain the final Attention value. So essentially the Attention mechanism is a weighted summation of the Value values of the elements in the Source, and Query and Key are used to calculate the weight coefficient of the corresponding Value. Conceptually, Attention can be understood as selectively filtering out a small amount of important information from a large amount of information and focusing on this important information, while ignoring most of the unimportant information. The process of focusing is reflected in the calculation of the weight coefficient. The greater the weight, the more focused it is on its corresponding Value value. That is, the weight represents the importance of the information, and the Value is its corresponding information. The self-attention mechanism can be understood as internal Attention (intra attention). The Attention mechanism occurs between the Target element Query and all elements in the Source. The self-attention mechanism refers to between the internal elements of the Source or between the internal elements of the Target. The Attention mechanism that occurs can also be understood as the attention calculation mechanism in the special case of Target=Source. The specific calculation process is the same, but the calculation object has changed.
(4)自然语言处理(natural language processing,NLP) (4) Natural language processing (NLP)
自然语言(natural language)即人类语言,自然语言处理(NLP)就是对人类语言的处理。自然语言处理是以一种智能与高效的方式,对文本数据进行系统化分析、理解与信息提取的过程。通过使用NLP及其组件,我们可以管理非常大块的文本数据,或者执行大量的自动化任务,并且解决各式各样的问题,如自动摘要(automatic summarization),机器翻译(machine translation,MT),命名实体识别(named entity recognition,NER),关系提取(relation extraction,RE),信息抽取(information extraction,IE),情感分析,语音识别(speech recognition),问答系统(question answering)以及主题分割等等。Natural language is human language, and natural language processing (NLP) is the processing of human language. Natural language processing is the process of systematically analyzing, understanding and extracting information from text data in an intelligent and efficient way. By using NLP and its components, we can manage very large pieces of text data, or perform a large number of automated tasks, and solve a variety of problems, such as automatic summarization (automatic summarization), machine translation (MT), Named entity recognition (NER), relationship extraction (RE), information extraction (IE), sentiment analysis, speech recognition (speech recognition), question answering system (question answering), topic segmentation, etc. .
(5)多层感知机(multilayer perceptron,MLP)(5) Multilayer perceptron (MLP)
多层感知机是一种前向结构的人工神经网络架构,由多个节点层组成,可以将输入向量变换成输出向量。Multi-layer perceptron is a forward-structured artificial neural network architecture composed of multiple node layers that can transform input vectors into output vectors.
(6)量子(quantum mechanics)(6)Quantum mechanics
量子力学是现代物理学的基本支柱之一,是很多现代学科的基础。Quantum mechanics is one of the fundamental pillars of modern physics and the foundation of many modern disciplines.
(7)特征块(token)(7) Feature block (token)
一段特征或者数据。A piece of feature or data.
(8)卷积神经网络(convolutional neuron network,CNN)是一种带有卷积结构的深度神经网络。卷积神经网络包含了一个由卷积层和子采样层构成的特征抽取器,该特征抽取器可以看作是滤波器。卷积层是指卷积神经网络中对输入信号进行卷积处理的神经元层。在卷积神经网络的卷积层中,一个神经元可以只与部分邻层神经元连接。一个卷积层中,通常包含若干个特征平面,每个特征平面可以由一些矩形排列的神经单元组成。同一特征平面的神经单元共享权重,这里共享的权重就是卷积核。共享权重可以理解为提取特征的方式与位置无关。卷积核可以以随机大小的矩阵的形式化,在卷积神经网络的训练过程中卷积核可以通过学习得到合理的权重。另外,共享权重带来的直接好处是减少卷积神经网络各层之间的连接,同时又降低了过拟合的风险。(8) Convolutional neural network (CNN) is a deep neural network with a convolutional structure. The convolutional neural network contains a feature extractor consisting of a convolutional layer and a subsampling layer, which can be regarded as a filter. The convolutional layer refers to the neuron layer in the convolutional neural network that convolves the input signal. In the convolutional layer of a convolutional neural network, a neuron can be connected to only some of the neighboring layer neurons. A convolutional layer usually contains several feature planes, and each feature plane can be composed of some rectangularly arranged neural units. Neural units in the same feature plane share weights, and the shared weights here are convolution kernels. Shared weights can be understood as extracting features in a way that is independent of location. The convolution kernel can be formalized as a matrix of random size. During the training process of the convolutional neural network, the convolution kernel can obtain reasonable weights through learning. In addition, the direct benefit of sharing weights is to reduce the connections between the layers of the convolutional neural network, while reducing the risk of overfitting.
CNN是一种非常常见的神经网络,下面结合图5B重点对CNN的结构进行详细的介绍。如前文的基础概念介绍所述,卷积神经网络是一种带有卷积结构的深度神经网络,是一种深度学习(deep learning)架构,深度学习架构是指通过机器学习的算法,在不同的抽象层级上进行多个层次的学习。作为一种深度学习架构,CNN是一种前馈(feed-forward)人工神经网络,该前馈人工神经网络中的各个神经元可以对输入其中的图像作出响应。CNN is a very common neural network. The structure of CNN will be introduced in detail below with reference to Figure 5B. As mentioned in the previous introduction to the basic concepts, a convolutional neural network is a deep neural network with a convolutional structure. It is a deep learning architecture. The deep learning architecture refers to the algorithm of machine learning. Multiple levels of learning at different levels of abstraction. As a deep learning architecture, CNN is a feed-forward artificial neural network. Each neuron in the feed-forward artificial neural network can respond to the image input into it.
如图5B所示,卷积神经网络(CNN)200可以包括输入层210,卷积层/池化层220(其中池化层为可选的),以及全连接层(fully connected layer)230。As shown in Figure 5B, the convolutional neural network (CNN) 200 may include an input layer 210, a convolutional layer/pooling layer 220 (where the pooling layer is optional), and a fully connected layer 230.
卷积层/池化层220:Convolutional layer/pooling layer 220:
卷积层:Convolutional layer:
如图5B所示卷积层/池化层220可以包括如示例221-226层,举例来说:在一种实现中,221层为卷积层,222层为池化层,223层为卷积层,224层为池化层,225为卷积层,226为池化层;在另一种实现方式中,221、222为卷积层,223为池化层,224、225为卷积层,226为池化层。即卷积层的输出可以作为随后的池化层的输入,也可以作为另一个卷积层的输入以继续进行卷积操作。 As shown in Figure 5B, the convolution layer/pooling layer 220 may include layers 221-226, for example: in one implementation, layer 221 is a convolution layer, layer 222 is a pooling layer, and layer 223 is a convolution layer. Product layer, 224 is a pooling layer, 225 is a convolution layer, and 226 is a pooling layer; in another implementation, 221 and 222 are convolution layers, 223 is a pooling layer, and 224 and 225 are convolutions. layer, 226 is the pooling layer. That is, the output of the convolutional layer can be used as the input of the subsequent pooling layer, or can be used as the input of another convolutional layer to continue the convolution operation.
下面将以卷积层221为例,介绍一层卷积层的内部工作原理。The following will take convolutional layer 221 as an example to introduce the internal working principle of a convolutional layer.
卷积层221可以包括很多个卷积算子,卷积算子也称为核,其在图像处理中的作用相当于一个从输入图像矩阵中提取特定信息的过滤器,卷积算子本质上可以是一个权重矩阵,这个权重矩阵通常被预先定义,在对图像进行卷积操作的过程中,权重矩阵通常在输入图像上沿着水平方向一个像素接着一个像素(或两个像素接着两个像素……这取决于步长stride的取值)的进行处理,从而完成从图像中提取特定特征的工作。该权重矩阵的大小应该与图像的大小相关,需要注意的是,权重矩阵的纵深维度(depth dimension)和输入图像的纵深维度是相同的,在进行卷积运算的过程中,权重矩阵会延伸到输入图像的整个深度。因此,和一个单一的权重矩阵进行卷积会产生一个单一纵深维度的卷积化输出,但是大多数情况下不使用单一权重矩阵,而是应用多个尺寸(行×列)相同的权重矩阵,即多个同型矩阵。每个权重矩阵的输出被堆叠起来形成卷积图像的纵深维度,这里的维度可以理解为由上面所述的“多个”来决定。不同的权重矩阵可以用来提取图像中不同的特征,例如一个权重矩阵用来提取图像边缘信息,另一个权重矩阵用来提取图像的特定颜色,又一个权重矩阵用来对图像中不需要的噪点进行模糊化等。该多个权重矩阵尺寸(行×列)相同,经过该多个尺寸相同的权重矩阵提取后的特征图的尺寸也相同,再将提取到的多个尺寸相同的特征图合并形成卷积运算的输出。The convolution layer 221 can include many convolution operators. The convolution operator is also called a kernel. Its role in image processing is equivalent to a filter that extracts specific information from the input image matrix. The convolution operator is essentially It can be a weight matrix. This weight matrix is usually predefined. During the convolution operation on the image, the weight matrix is usually one pixel after one pixel (or two pixels after two pixels) along the horizontal direction on the input image. ...This depends on the value of the step size) to complete the process of extracting specific features from the image. The size of the weight matrix should be related to the size of the image. It should be noted that the depth dimension of the weight matrix is the same as the depth dimension of the input image. During the convolution operation, the weight matrix will extend to Enter the entire depth of the image. Therefore, convolution with a single weight matrix will produce a convolved output with a single depth dimension, but in most cases, instead of using a single weight matrix, multiple weight matrices of the same size (rows × columns) are applied, That is, multiple matrices of the same type. The output of each weight matrix is stacked to form the depth dimension of the convolution image. The dimension here can be understood as being determined by the "multiple" mentioned above. Different weight matrices can be used to extract different features in the image. For example, one weight matrix is used to extract edge information of the image, another weight matrix is used to extract specific colors of the image, and another weight matrix is used to remove unnecessary noise in the image. Perform blurring, etc. The multiple weight matrices have the same size (row × column), and the feature maps extracted by the multiple weight matrices with the same size are also the same size. The extracted multiple feature maps with the same size are then merged to form a convolution operation. output.
这些权重矩阵中的权重值在实际应用中需要经过大量的训练得到,通过训练得到的权重值形成的各个权重矩阵可以用来从输入图像中提取信息,从而使得卷积神经网络200进行正确的预测。The weight values in these weight matrices require a large amount of training in practical applications. Each weight matrix formed by the weight values obtained through training can be used to extract information from the input image, thereby allowing the convolutional neural network 200 to make correct predictions. .
当卷积神经网络200有多个卷积层的时候,初始的卷积层(例如221)往往提取较多的一般特征,该一般特征也可以称之为低级别的特征;随着卷积神经网络200深度的加深,越往后的卷积层(例如226)提取到的特征越来越复杂,比如高级别的语义之类的特征,语义越高的特征越适用于待解决的问题。When the convolutional neural network 200 has multiple convolutional layers, the initial convolutional layer (for example, 221) often extracts more general features, which can also be called low-level features; as the convolutional neural network As the depth of the network 200 deepens, the features extracted by subsequent convolutional layers (for example, 226) become more and more complex, such as high-level semantic features. Features with higher semantics are more suitable for the problem to be solved.
池化层:Pooling layer:
由于常常需要减少训练参数的数量,因此卷积层之后常常需要周期性的引入池化层,在如图5B中220所示例的221-226各层,可以是一层卷积层后面跟一层池化层,也可以是多层卷积层后面接一层或多层池化层。在图像处理过程中,池化层的唯一目的就是减少图像的空间大小。池化层可以包括平均池化算子和/或最大池化算子,以用于对输入图像进行采样得到较小尺寸的图像。平均池化算子可以在特定范围内对图像中的像素值进行计算产生平均值作为平均池化的结果。最大池化算子可以在特定范围内取该范围内值最大的像素作为最大池化的结果。另外,就像卷积层中用权重矩阵的大小应该与图像尺寸相关一样,池化层中的运算符也应该与图像的大小相关。通过池化层处理后输出的图像尺寸可以小于输入池化层的图像的尺寸,池化层输出的图像中每个像素点表示输入池化层的图像的对应子区域的平均值或最大值。Since it is often necessary to reduce the number of training parameters, it is often necessary to periodically introduce a pooling layer after the convolution layer. In each layer 221-226 as shown at 220 in Figure 5B, there can be a layer of convolution layer followed by a layer of The pooling layer can also be a multi-layer convolution layer followed by one or more pooling layers. During image processing, the only purpose of the pooling layer is to reduce the spatial size of the image. The pooling layer may include an average pooling operator and/or a maximum pooling operator for sampling the input image to obtain a smaller size image. The average pooling operator can calculate the pixel values in the image within a specific range to generate an average value as the result of average pooling. The max pooling operator can take the pixel with the largest value in a specific range as the result of max pooling. In addition, just like the size of the weight matrix used in the convolutional layer should be related to the image size, the operators in the pooling layer should also be related to the size of the image. The size of the image output after processing by the pooling layer can be smaller than the size of the image input to the pooling layer. Each pixel in the image output by the pooling layer represents the average or maximum value of the corresponding sub-region of the image input to the pooling layer.
全连接层230:Fully connected layer 230:
在经过卷积层/池化层220的处理后,卷积神经网络200还不足以输出所需要的输出信息。因为如前所述,卷积层/池化层220只会提取特征,并减少输入图像带来的参数。然而 为了生成最终的输出信息(所需要的类信息或其他相关信息),卷积神经网络200需要利用全连接层230来生成一个或者一组所需要的类的数量的输出。因此,在全连接层230中可以包括多层隐含层(如图5B所示的231、232至23n),该多层隐含层中所包含的参数可以根据具体的任务类型的相关训练数据进行预先训练得到,例如该任务类型可以包括图像识别,图像分类,图像超分辨率重建等等……After being processed by the convolutional layer/pooling layer 220, the convolutional neural network 200 is not enough to output the required output information. Because as mentioned above, the convolutional layer/pooling layer 220 will only extract features and reduce the parameters brought by the input image. However In order to generate the final output information (required class information or other related information), the convolutional neural network 200 needs to use the fully connected layer 230 to generate the output of one or a set of required number of classes. Therefore, the fully connected layer 230 may include multiple hidden layers (231, 232 to 23n as shown in Figure 5B), and the parameters contained in the multiple hidden layers may be based on the relevant training data of the specific task type. Obtained by pre-training, for example, the task type can include image recognition, image classification, image super-resolution reconstruction, etc...
在全连接层230中的多层隐含层之后,也就是整个卷积神经网络200的最后层为输出层240,该输出层240具有类似分类交叉熵的损失函数,具体用于计算预测误差,一旦整个卷积神经网络200的前向传播(如图5B由210至240方向的传播为前向传播)完成,反向传播(如图5B由240至210方向的传播为反向传播)就会开始更新前面提到的各层的权重值以及偏差,以减少卷积神经网络200的损失,及卷积神经网络200通过输出层输出的结果和理想结果之间的误差。After the multi-layer hidden layer in the fully connected layer 230, that is, the last layer of the entire convolutional neural network 200 is the output layer 240. The output layer 240 has a loss function similar to categorical cross entropy and is specifically used to calculate the prediction error. Once the forward propagation of the entire convolutional neural network 200 (the propagation from the direction 210 to 240 in Figure 5B is forward propagation) is completed, the back propagation (the propagation from the direction 240 to 210 in Figure 5B is back propagation) will Start updating the weight values and biases of each layer mentioned above to reduce the loss of the convolutional neural network 200 and the error between the result output by the convolutional neural network 200 through the output layer and the ideal result.
需要说明的是,如图5B所示的卷积神经网络200仅作为一种卷积神经网络的示例,在具体的应用中,卷积神经网络还可以以其他网络模型的形式存在,例如,仅包括图5B中所示的网络结构的一部分,比如,本申请实施例中所采用的卷积神经网络可以仅包括输入层210、卷积层/池化层220和输出层240。It should be noted that the convolutional neural network 200 shown in Figure 5B is only an example of a convolutional neural network. In specific applications, the convolutional neural network can also exist in the form of other network models, for example, only Including part of the network structure shown in FIG. 5B , for example, the convolutional neural network used in the embodiment of the present application may only include an input layer 210 , a convolutional layer/pooling layer 220 and an output layer 240 .
需要说明的是,如图5B所示的卷积神经网络100仅作为一种卷积神经网络的示例,在具体的应用中,卷积神经网络还可以以其他网络模型的形式存在,例如,如图5C所示的多个卷积层/池化层并行,将分别提取的特征均输入给全连接层230进行处理。It should be noted that the convolutional neural network 100 shown in Figure 5B is only an example of a convolutional neural network. In specific applications, the convolutional neural network can also exist in the form of other network models, for example, as The multiple convolutional layers/pooling layers shown in Figure 5C are parallel, and the respectively extracted features are input to the fully connected layer 230 for processing.
参照图6,图6为本申请实施例提供的一种数据处理方法的实施例示意,本申请实施例提供的一种数据处理方法可以应用在手机、平板、笔记本电脑、智能穿戴设备等终端设备上,也可以应用在服务器上,如图6示出的那样,本申请实施例提供的一种数据处理方法包括:Referring to Figure 6, Figure 6 is a schematic diagram of a data processing method provided by an embodiment of the present application. The data processing method provided by an embodiment of the present application can be applied to terminal devices such as mobile phones, tablets, notebook computers, and smart wearable devices. on the server, and can also be applied on the server. As shown in Figure 6, a data processing method provided by the embodiment of the present application includes:
601、通过对输入到所述head中的特征块进行多次线性变换,分别得到第一幅值、第二相位值、第二幅值以及第二相位值。601. By performing multiple linear transformations on the feature blocks input to the head, obtain the first amplitude value, the second phase value, the second amplitude value and the second phase value respectively.
在一些实施例中,计算设备(例如,终端设备、智能手机、笔记本电脑、服务器等)为一段数据(例如,图像、一段音频/视频或一段上下文数据)获取多个特征块(token)。每个token都可以作为数据片段的一段生成,这些数据片段充当计算设备要处理的基本单元。因此,每个token包括与部分数据相关联的信息(例如,特征或内容)。例如,token可以定义为包含输入图像中的16×16像素的图像块。计算设备可以实现基于注意力机制的神经网络架构,以处理多个token。In some embodiments, a computing device (eg, terminal device, smartphone, laptop, server, etc.) acquires multiple feature blocks (tokens) for a piece of data (eg, an image, a piece of audio/video, or a piece of context data). Each token can be generated as a piece of data that serves as the basic unit for processing by a computing device. Therefore, each token includes information (eg, characteristics or content) associated with part of the data. For example, a token can be defined as an image patch containing 16×16 pixels in the input image. Computing devices can implement neural network architectures based on attention mechanisms to process multiple tokens.
在一种可能的实现中,基于注意力机制的神经网络可以处理输入数据,输入数据可以为一段数据,一段数据可以为音频数据、视频数据、图像数据或上下文数据,当一段数据被分割成n个token时,该数据片段中包含的特征信息可以分布在n个token上。与输入数据片段关联的token集(用Z表示)可以表示为Z=[z1,z2,…,zn],zj表示第j个token,j和n是整数。In a possible implementation, a neural network based on the attention mechanism can process input data. The input data can be a piece of data, and a piece of data can be audio data, video data, image data or context data. When a piece of data is divided into n When there are n tokens, the characteristic information contained in the data fragment can be distributed on n tokens. The token set (represented by Z) associated with the input data fragment can be expressed as Z = [z 1 , z 2 ,..., z n ], z j represents the jth token, and j and n are integers.
在一种可能的实现中,在获取输入数据之后,可以通过嵌入层对输入数据的各个数据 片段进行嵌入处理,得到多个特征块(token),这里的token也可以称之为嵌入向量。In a possible implementation, after obtaining the input data, each data of the input data can be The fragments are embedded and processed to obtain multiple feature blocks (tokens). The tokens here can also be called embedding vectors.
以输入数据为文本数据为例,在一种可能的实现中,所述嵌入层可以包括输入嵌入层和位置编码(positional encoding)层。在输入嵌入层,可以对当前输入中的未被掩码的数据单元中的每个数据单元进行词嵌入处理,从而得到未被掩码的数据单元中的每个数据单元的词向量(例如可以表示语义信息)。在位置编码层,可以获取未被掩码的数据单元中的每个数据单元在该当前输入中的位置,进而对未被掩码的数据单元中的每个数据单元的位置生成位置向量。Taking the input data as text data as an example, in a possible implementation, the embedding layer may include an input embedding layer and a positional encoding layer. In the input embedding layer, word embedding processing can be performed on each data unit in the unmasked data unit in the current input, thereby obtaining the word vector of each data unit in the unmasked data unit (for example, you can represents semantic information). At the position coding layer, the position of each data unit in the current input can be obtained and a position vector can be generated for the position of each data unit in the unmasked data unit.
在一些示例中,未被掩码的数据单元中的每个数据单元在数据序列中的位置信息可以为未被掩码的数据单元中的每个数据单元在数据序列中的绝对位置。以当前输入为“几号应还花呗”为例,其中的“几”的位置可以表示为第一位,“号”的位置可以表示为第二位,……。在一些示例中,未被掩码的数据单元中的每个数据单元在数据序列中的位置可以为未被掩码的数据单元中的每个数据单元在数据序列中的相对位置。仍以当前输入为“几号应还花呗”为例,其中的“几”的位置可以表示为“号”之前,“号”的位置可以表示为“几”之后、“应”之前,……。当得到当前输入中未被掩码的数据单元中的每个数据单元的词向量和位置向量时,可以将未被掩码的数据单元中的每个数据单元的位置向量和对应的词向量进行融合,得到未被掩码的数据单元中的每个数据单元的嵌入向量。应理解,融合的方式可以是对位置向量和对应的词向量进行加法运算,或者是通过其他运算,这里并不限定具体的融合方式。嵌入向量可以表示为具有预设维度的嵌入矩阵。可以设定该嵌入向量的个数为M,预设维度为H维,则嵌入向量可以表示为M×H的嵌入矩阵。In some examples, the position information of each of the unmasked data units in the data sequence may be the absolute position of each of the unmasked data units in the data sequence. Taking the current input as "What number should I pay back the Huabei?" for example, the position of "number" can be represented as the first digit, the position of "number" can be represented as the second digit,... In some examples, the position of each of the unmasked data units in the data sequence may be the relative position of each of the unmasked data units in the data sequence. Still taking the current input as "what number should I pay back Huabei" as an example, the position of "what number" can be expressed as before "number", and the position of "number" can be expressed as after "what number" and before "should",... …. When the word vector and position vector of each data unit in the unmasked data unit in the current input are obtained, the position vector of each data unit in the unmasked data unit and the corresponding word vector can be obtained. Fusion to obtain the embedding vector of each data unit in the unmasked data units. It should be understood that the fusion method can be an addition operation of the position vector and the corresponding word vector, or other operations, and the specific fusion method is not limited here. Embedding vectors can be represented as embedding matrices with preset dimensions. The number of embedding vectors can be set to M, and the default dimension is H dimension. Then the embedding vector can be expressed as an M×H embedding matrix.
在一种可能的实现中,多个特征块可以输入到transformer层中,具体可以输入到transformer层中的多头注意力头的每个注意力头(head)中,接下来介绍transformer层:In a possible implementation, multiple feature blocks can be input into the transformer layer, specifically into each attention head (head) of the multi-head attention heads in the transformer layer. Next, the transformer layer is introduced:
参照图7,图7为本申请实施例中的一种神经网络模型的结构示意。如图7中示出的那样,预训练语言模型可以包括依次连接的嵌入层以及多个transformer层(本申请实施例中也可以称之为特征提取网络)。如本领域技术人员所了解,transformer模型多用于执行自然语言处理NLP任务。需要理解,图7的结构仅仅是一个示例,transformer层的数目可以根据需要而设置。例如,可以仅设置一个transformer层,也可以设置更多的transformer层。神经网络模型基于各transformer层得到的N个输出向量,确定当前节点对应的特征向量。Referring to Figure 7, Figure 7 is a schematic structural diagram of a neural network model in an embodiment of the present application. As shown in Figure 7, the pre-trained language model may include an embedding layer and multiple transformer layers connected in sequence (which may also be called a feature extraction network in this embodiment). As those skilled in the art understand, the transformer model is mostly used to perform natural language processing NLP tasks. It should be understood that the structure in Figure 7 is just an example, and the number of transformer layers can be set as needed. For example, you can set up only one transformer layer, or you can set up more transformer layers. The neural network model determines the feature vector corresponding to the current node based on the N output vectors obtained from each transformer layer.
下面描述各个层的具体工作过程。The specific working process of each layer is described below.
关于嵌入层:About the embedding layer:
在嵌入层(或者称之为复数嵌入层),对当前输入进行嵌入处理,得到多个特征向量(该向量为复数向量(或者可以称之为复值向量),可选的,该向量为固定维度的复值向量)。transformer模型的核心特点在于其采用的独特的注意力机制。在处理自然语言,例如一个句子时,transformer模型利用该注意力机制,为句子中各个词向量赋予不同的注意力系数,从而更全面地考虑句子中上下文对各个词的影响。嵌入层基于当前序列中各个节点的节点特征及其位置编码,得到N个嵌入向量Xl。注意力层与嵌入层相连,从嵌入层获取N个嵌入向量作为输入向量,基于N个输入向量中各个输入向量之间的关联度,对各个输入向量进行综合,得到N个输出向量,输出给后续的transformer层。transformer层获取前一层的 输出作为输入向量,执行与前一级transformer层类似的操作。In the embedding layer (or called the complex embedding layer), the current input is embedded to obtain multiple feature vectors (this vector is a complex vector (or it can be called a complex-valued vector), optionally, this vector is fixed a complex-valued vector of dimensions). The core feature of the transformer model lies in its unique attention mechanism. When processing natural language, such as a sentence, the transformer model uses this attention mechanism to assign different attention coefficients to each word vector in the sentence, thereby more comprehensively considering the impact of the context on each word in the sentence. The embedding layer obtains N embedding vectors X l based on the node characteristics and position encoding of each node in the current sequence. The attention layer is connected to the embedding layer, and N embedding vectors are obtained from the embedding layer as input vectors. Based on the correlation between each input vector in the N input vectors, each input vector is synthesized to obtain N output vectors, which are output to Subsequent transformer layer. The transformer layer gets the previous layer's The output is used as an input vector and performs similar operations to the previous transformer layer.
关于特征提取网络:About feature extraction network:
在一种可能的实现中,特征提取网络可以包括多个transformer层。In one possible implementation, the feature extraction network can include multiple transformer layers.
参照7和图8,图7和图8都示出了一种transformer层的结构示意,本申请实施例中的各个神经网络的transformer层都可以参照图8中示出的结构,如图8中示出的那样,transformer层包括依次相邻的多头注意力层、加和与归一化(add&norm)层、前馈(feed forward)层、加和与归一化层。Referring to Figures 7 and 8, both Figures 7 and 8 show a structural diagram of a transformer layer. The transformer layer of each neural network in the embodiment of the present application can refer to the structure shown in Figure 8, as shown in Figure 8 As shown, the transformer layer includes sequentially adjacent multi-head attention layers, summation and normalization (add&norm) layers, feed forward (feed forward) layers, and summation and normalization layers.
其中,多头注意力层从其上一层获取N个输入向量Xl,又可以表示为矩阵X,采用自注意力机制,基于向量间的关联度对各个向量进行变换,得到N个输出向量,又可以表示为矩阵Y。可以理解,当该多头注意力层是与嵌入层直接相连的层,例如图7中与嵌入层直连的t1ransformer层,其获取的输入向量即为嵌入层输出的嵌入向量;当该多头注意力层是后续的transformer层包括的多头注意力层,例如图7中与上一级transformer层直连的transformer层包括的多头注意力层,其获取的输入向量即为前一级transformer层的输出向量。在多头注意力层,基于多头注意力(multi-head attention,MHA)的MHA层包括多个注意力头head(如图7中示出的Head 1、Head 2、…、Head N)。Among them, the multi-head attention layer obtains N input vectors X l from its upper layer, which can also be expressed as a matrix It can also be expressed as matrix Y. It can be understood that when the multi-head attention layer is a layer directly connected to the embedding layer, such as the t1ransformer layer directly connected to the embedding layer in Figure 7, the input vector it obtains is the embedding vector output by the embedding layer; when the multi-head attention layer The layer is the multi-head attention layer included in the subsequent transformer layer. For example, in Figure 7, the multi-head attention layer included in the transformer layer directly connected to the previous level transformer layer. The input vector obtained is the output vector of the previous level transformer layer. . In the multi-head attention layer, the MHA layer based on multi-head attention (MHA) includes multiple attention heads (Head 1, Head 2, ..., Head N as shown in Figure 7).
图8为一个注意力头head的操作示意图,该示意图示出注意力头head如何将输入矩阵X变换为输出矩阵Y。如图8所示,在现有的实现中,分别采用第一变换矩阵Q,第二变换矩阵K和第三变换矩阵V对N个输入向量<X1,X2,…,XN>中各个输入向量Xi进行变换,得到各个输入向量对应的第一中间向量(q向量),第二中间向量(k向量)和第三中间向量(v向量)。操作上,可以分别用第一变换矩阵Q,第二变换矩阵K和第三变换矩阵V,对N个输入向量构成的输入矩阵X进行线性变换,分别得到输入矩阵的Q矩阵,K矩阵和V矩阵,再分别对矩阵进行拆分,即可得到各个输入向量对应的q向量,k向量和v向量。对于N个输入向量中任意的第i输入向量Xi,基于该第i输入向量对应的第一中间向量(q向量,qi)与各个输入向量Xj对应的各个第二中间向量(k向量,kj)的点乘操作,确定该第i输入向量Xi与各个输入向量Xj的各个关联度(αi,j)。尽管也可以直接将qi与kj的点乘结果确定为关联度,但是更经典地,先将点乘结果除以一常数,然后进行softmax运算,将运算结果作为输入向量Xi与Xj的关联度,即:
Figure 8 is a schematic diagram of the operation of the attention head, which shows how the attention head transforms the input matrix X into the output matrix Y. As shown in Figure 8, in the existing implementation, the first transformation matrix Q, the second transformation matrix K and the third transformation matrix V are respectively used to each of the N input vectors <X1, X2,...,XN> Xi is transformed to obtain the first intermediate vector (q vector), the second intermediate vector (k vector) and the third intermediate vector (v vector) corresponding to each input vector. Operationally, the first transformation matrix Q, the second transformation matrix K and the third transformation matrix V can be used to linearly transform the input matrix X composed of N input vectors, respectively, to obtain the Q matrix, K matrix and V of the input matrix. Matrix, and then split the matrix separately to obtain the q vector, k vector and v vector corresponding to each input vector. For any i-th input vector Xi among the N input vectors, based on the first intermediate vector (q vector, qi) corresponding to the i-th input vector and each second intermediate vector (k vector, kj) corresponding to each input vector Xj The dot product operation is used to determine each degree of correlation (α i,j ) between the i-th input vector Xi and each input vector Xj. Although the dot multiplication result of qi and kj can also be directly determined as the correlation degree, more classically, the dot multiplication result is divided by a constant, and then a softmax operation is performed, and the operation result is used as the correlation degree of the input vectors Xi and Xj, Right now:
于是,可以以该第i输入向量Xi与各个输入向量Xj的各个关联度αi,j作为权重因子,对各个输入向量Xj对应的第三中间向量(v向量,vj)进行加权组合,得到该第i输入向量Xi对应的第i组合向量Ci:
Therefore, each correlation degree αi,j between the i-th input vector Xi and each input vector Xj can be used as a weighting factor to perform a weighted combination on the third intermediate vector (v vector, vj) corresponding to each input vector The i-th combination vector Ci corresponding to the i input vector Xi:
于是,可以得到N个输入向量对应的N个组合向量的向量序列<C1,C2,…,CN>,或矩阵C。基于该组合向量序列,可以得到N个输出向量。具体地,在一个实施例中,可以直接将N个组合向量的向量序列作为N个输出向量,即Yi=Ci。此时,输出矩阵Y即为组合向量矩阵C,又可以写成:
Therefore, the vector sequence <C1, C2,...,CN>, or matrix C, of N combined vectors corresponding to N input vectors can be obtained. Based on this combined vector sequence, N output vectors can be obtained. Specifically, in one embodiment, the vector sequence of N combined vectors can be directly used as N output vectors, that is, Yi=Ci. At this time, the output matrix Y is the combined vector matrix C, which can also be written as:
在现有的实现中,分别用第一变换矩阵Q,第二变换矩阵K和第三变换矩阵V,对N个输入向量(也就是输入到head中的特征块token)构成的输入矩阵X进行线性变换,分别得到输入矩阵的Q矩阵,K矩阵和V矩阵,Q矩阵、K矩阵中的元素均为实数,对于特征的表达能力有限。In the existing implementation, the first transformation matrix Q, the second transformation matrix K and the third transformation matrix V are respectively used to perform the input matrix X composed of N input vectors (that is, the feature block token input into the head). Linear transformation obtains the Q matrix, K matrix and V matrix of the input matrix respectively. The elements in the Q matrix and K matrix are all real numbers, and the ability to express features is limited.
不同于上述第一变换矩阵Q和第二变换矩阵K,本申请中,可以为输入到head中的特征块token分别生成Q矩阵中元素的幅度和相位、以及K矩阵中元素的幅度和相位。通过这种方式,Q矩阵和K矩阵都可以参数化为复杂的形式,进而增加特征的表达能力,可以更好地建模不同特征块之间的关系。Different from the above-mentioned first transformation matrix Q and second transformation matrix K, in this application, the amplitude and phase of the elements in the Q matrix and the amplitude and phase of the elements in the K matrix can be generated respectively for the feature block token input into the head. In this way, both the Q matrix and the K matrix can be parameterized into complex forms, thereby increasing the expressive ability of features and better modeling the relationship between different feature blocks.
参照图9,图9为本申请实施例中一个注意力头head的操作示意图。通过对输入到所述head中的特征块X的元素进行多次线性变换,分别得到第一幅值、第一相位值、第二幅值以及第二相位值。第一幅值和第一相位值可以用于构建Q矩阵中的元素,第二幅值和第二相位值可以用于构建K矩阵中的元素。Referring to Figure 9, Figure 9 is a schematic diagram of the operation of an attention head in an embodiment of the present application. By performing multiple linear transformations on the elements of the feature block X input into the head, the first amplitude, the first phase value, the second amplitude and the second phase value are obtained respectively. The first amplitude value and the first phase value can be used to construct the elements in the Q matrix, and the second amplitude value and the second phase value can be used to construct the elements in the K matrix.
在一种可能的实现中,可以通过线性规划层,对输入到所述head中的特征块进行多次线性变换;所述线性规划层包括第一权重Wq1、第二权重Wq2、第三权重Wk1以及第四权重Wk2,所述第一权重Wq1、第二权重Wq2、第三权重Wk1以及第四权重Wk2为可训练的参数;其中,所述第一权重用于对所述特征块进行线性变换,以得到所述第一幅值;所述第二权重用于对所述特征块进行线性变换,以得到所述第一相位值;所述第三权重用于对所述特征块进行线性变换,以得到所述第二幅值;所述第四权重用于对所述特征块进行线性变换,以得到所述第二相位值。In a possible implementation, multiple linear transformations can be performed on the feature blocks input to the head through a linear programming layer; the linear programming layer includes a first weight Wq1, a second weight Wq2, and a third weight Wk1 And the fourth weight Wk2, the first weight Wq1, the second weight Wq2, the third weight Wk1 and the fourth weight Wk2 are trainable parameters; wherein the first weight is used to linearly transform the feature block , to obtain the first amplitude; the second weight is used to linearly transform the feature block to obtain the first phase value; the third weight is used to linearly transform the feature block , to obtain the second amplitude; the fourth weight is used to linearly transform the feature block to obtain the second phase value.
通过上述方式,得到的Q矩阵以及K矩阵中的元素可以表示为:
Through the above method, the elements in the obtained Q matrix and K matrix can be expressed as:
其中,i是虚部指示器,满足i2=-1,|·|表示绝对值操作,⊙是按元素相乘,幅值|zj|是实值特征,表示每个特征块的内容。是一个具有单位范数的周期函数。θj表示相位,表示在当前状态在一个周期内所处的位置。每个特征块可以表示在复数域中,同时具有相位和幅值信息。这种使用波函数表示的特征块,也可以被称为量子特征块。Among them, i is the imaginary part indicator, which satisfies i 2 =-1, |·| represents the absolute value operation, ⊙ is element-wise multiplication, and the amplitude |z j | is the real-valued feature, representing the content of each feature block. is a periodic function with unit norm. θ j represents the phase, which represents the position of the current state within a cycle. Each feature block It can be represented in the complex domain with both phase and amplitude information. This kind of feature block represented by a wave function can also be called a quantum feature block.
602、根据所述第一数值和所述第一相位值,得到Q矩阵;所述第一幅值用于作为Q矩阵中元素的幅值,所述第一相位值用于作为所述Q矩阵中元素的相位。602. Obtain the Q matrix according to the first numerical value and the first phase value; the first amplitude value is used as the amplitude of the element in the Q matrix, and the first phase value is used as the Q matrix phase of the elements.
603、根据所述第二幅值和所述第二相位值,得到K矩阵;所述第二幅值用于作为K矩阵中元素的幅值,所述第二相位值用于作为所述K矩阵中元素的相位。603. According to the second amplitude and the second phase value, obtain the K matrix; the second amplitude is used as the amplitude of the element in the K matrix, and the second phase value is used as the K The phase of the elements in the matrix.
在多头自注意力网络中,一共有查询query、关键字key和值value三路特征。其中查询query和关键字key均可通过一个线性映射层表示成量子特征块,从而计算得到复数域的注意力矩阵,更好地建模不同特征块之间的关系。In the multi-head self-attention network, there are three-way features: query, keyword key and value. Both the query query and the keyword key can be represented as quantum feature blocks through a linear mapping layer, thereby calculating the attention matrix in the complex domain and better modeling the relationship between different feature blocks.
具体实现过程如下:The specific implementation process is as follows:
给定X为输入特征,为线性变换层,和为量子特征块,它们的计算方式为:
Given X as the input feature, is the linear transformation layer, and are quantum feature blocks, and their calculation method is:
Wq1和Wq2一起构成了查询query的线性变换层,Wk1和Wk2构成了关键字key的线性变换层,他们将输入特征变换到不同的特征空间里,使得量子特征块具有很强的表达能力。现有的query和key大多使用一个线性变换层生成,这限制了他们的表达能力;不同于现有方法,本申请中每个查询query和关键字key都使用两个线性变换层,分别生成幅值和相位,使得生成的query和key可以表达更丰富的信息。Wq1 and Wq2 together form the linear transformation layer of the query, and Wk1 and Wk2 form the linear transformation layer of the keyword key. They transform the input features into different feature spaces, making the quantum feature block have strong expressive ability. Most of the existing queries and keys are generated using a linear transformation layer, which limits their expressive capabilities; different from existing methods, each query and key in this application use two linear transformation layers to generate amplitudes respectively. value and phase, so that the generated query and key can express richer information.
604、根据所述Q矩阵、所述K矩阵以及所述head中计算得到的V矩阵,得到所述head的输出。604. Obtain the output of the head according to the Q matrix, the K matrix and the V matrix calculated in the head.
在一种实现中,可以根据Q矩阵和K矩阵来计算出输入的特征块之间的关联度,具体的,可以基于输入的特征块中的第i个输入向量Xi对应的q向量(qi)与第j个输入向量Xj对应的各个k向量(kj)的点乘操作,确定该第i输入向量Xi与各个输入向量Xj的各个关联度。尽管也可以直接将qi与kj的点乘结果确定为关联度(也就是注意力矩阵,或者复值注意力矩阵),但是更经典地,先将点乘结果除以一常数,然后进行softmax运算,将运算结果作为输入向量Xi与Xj的关联度(也就是注意力矩阵,或者复值注意力矩阵),即:
In one implementation, the correlation between the input feature blocks can be calculated based on the Q matrix and the K matrix. Specifically, it can be based on the q vector (qi) corresponding to the i-th input vector Xi in the input feature block. The dot multiplication operation of each k vector (kj) corresponding to the j-th input vector Xj determines each correlation degree between the i-th input vector Xi and each input vector Xj. Although the dot product result of qi and kj can also be directly determined as the correlation degree (that is, the attention matrix, or the complex-valued attention matrix), more classically, the dot product result is divided by a constant and then the softmax operation is performed. , use the operation result as the correlation between the input vectors Xi and Xj (that is, the attention matrix, or the complex-valued attention matrix), that is:
在一种实现中,可以对所述Q矩阵和所述K矩阵进行相关度计算,得到第一注意力矩阵,由于Q矩阵和所述K矩阵本身是复数域的数,因此所述第一注意力矩阵中的元素为复数。In one implementation, correlation calculation can be performed on the Q matrix and the K matrix to obtain the first attention matrix. Since the Q matrix and the K matrix themselves are numbers in the complex domain, the first attention matrix The elements in the force matrix are complex numbers.
在一种实现中,在基于Q矩阵和K矩阵计算相关度时,所述Q矩阵和所述K矩阵中各个元素之间存在的相位差可以会导致对幅度进行调制,例如,与小相位差相关的特征可能会增强,而与大相位差相关的特征可能会减少,这类似于相干光引起的干涉现象。In one implementation, when calculating the correlation based on the Q matrix and the K matrix, the phase difference existing between the elements in the Q matrix and the K matrix may cause the amplitude to be modulated, for example, with a small phase difference Correlated features may be enhanced, while features associated with large phase differences may be reduced, similar to interference phenomena caused by coherent light.
具体的,当两个特征块相互聚合时,他们的聚合结果如图10所示。其中,浅色虚线和深色实线的虚线表示原始的特征块,实线的实线表示聚合之后的结果。两个特征块之间的相位差调制着它们的聚合过程。Specifically, when two feature blocks are aggregated with each other, their aggregation results are shown in Figure 10. Among them, the light dotted line and the dark solid line represent the original feature blocks, and the solid line represents the aggregation result. The phase difference between two feature blocks modulates their aggregation process.
在一种实现中,可以直接将qi与kj的点乘结果确定为关联度,由于上述计算得到的相关度需要和V矩阵进行加权运算,因此可以将所述第一注意力矩阵中的元素映射为实数,得到第二注意力矩阵,并根据所述第二注意力矩阵和所述head中计算得到的V矩阵,得到所述head的输出。In one implementation, the dot product result of qi and kj can be directly determined as the correlation degree. Since the correlation degree calculated above needs to be weighted with the V matrix, the elements in the first attention matrix can be mapped is a real number, obtain the second attention matrix, and obtain the output of the head according to the second attention matrix and the V matrix calculated in the head.
在一种实现中,可以将点乘结果除以一常数,然后进行softmax运算,由于softmax运算需要在实数域上进行,而Q矩阵和K矩阵之间进行运算的结果(也就是softmax运算的对象)为复数,因此,本申请实施例中可以对Q矩阵和K矩阵之间进行运算的结果(第一注意力矩阵)映射到实数域上。In one implementation, the dot multiplication result can be divided by a constant, and then the softmax operation is performed. Since the softmax operation needs to be performed in the real number domain, the result of the operation between the Q matrix and the K matrix (that is, the object of the softmax operation ) is a complex number. Therefore, in the embodiment of the present application, the result of the operation between the Q matrix and the K matrix (the first attention matrix) can be mapped to the real number domain.
在一种实现中,所述第一注意力矩阵中的元素包括实部和虚部,在将第一注意力矩阵中的元素映射为实数时,可以将所述第一注意力矩阵中元素的实部的数值和虚部的数值进行融合,以得到融合结果,所述融合结果为实数。In one implementation, the elements in the first attention matrix include real parts and imaginary parts. When mapping the elements in the first attention matrix to real numbers, the elements in the first attention matrix can be The numerical value of the real part and the numerical value of the imaginary part are fused to obtain a fusion result, and the fusion result is a real number.
示例性的,所述融合,可以包括:求和操作;或者,求复数的模长。For example, the fusion may include: a summation operation; or, finding the modulus length of a complex number.
在一种实现中,计算得到的复值注意力矩阵(或者点乘结果除以一常数,然后进行
softmax运算)为:
In one implementation, the calculated complex-valued attention matrix (or dot product result is divided by a constant, and then softmax operation) is:
可以将上式展开,分别展开成实部和虚部的形式,得到复数域的注意力矩阵。
The above formula can be expanded into the form of real part and imaginary part respectively to obtain the attention matrix in the complex domain.
基于复值注意力矩阵,确定实数域特征。例如,通过一个额外的线性变换层,对实部和虚部做求和处理,最终的到实值注意力矩阵A:
Based on the complex-valued attention matrix, real number domain features are determined. For example, through an additional linear transformation layer, the real part and the imaginary part are summed, and finally the real-valued attention matrix A is obtained:
将A乘在value V上得到模型输出Y:
Y=AX,V=WvX;Multiply A by value V to get the model output Y:
Y=AX, V=W v X;
输出Y将被送入到模型的下一层中。The output Y will be fed to the next layer of the model.
在大规模数据集进行实验,对本申请实施例中所提出的方法进行实证研究。表1可以说明,使用量子特征块可以实现明显的精度提升。Experiments are conducted on large-scale data sets to conduct empirical research on the methods proposed in the embodiments of this application. Table 1 can illustrate that using quantum feature blocks can achieve significant accuracy improvements.
表1 ImageNet数据集上的实验效果
Table 1 Experimental results on ImageNet data set
参照图11,图11为本发明应用的系统架构或场景示意,其中本申请可以嵌入到不同模型中,在图像理解、自然语言处理中等不同任务中都可使用,并实际部署到手机、手表、自动驾驶汽车等不通设备上。Referring to Figure 11, Figure 11 is a schematic diagram of the system architecture or scenario of the application of the present invention. The present application can be embedded in different models and can be used in different tasks such as image understanding and natural language processing, and is actually deployed on mobile phones, watches, On various devices such as self-driving cars.
本申请实施例提供了一种数据处理方法,应用于基于注意力机制的神经网络中的注意力头head,所述方法包括:通过对输入到所述head中的特征块进行多次线性变换,分别得到第一幅值、第二相位值、第二幅值以及第二相位值;根据所述第一数值和所述第一相位值,得到Q矩阵;所述第一幅值用于作为Q矩阵中元素的幅值,所述第一相位值用于作为所述Q矩阵中元素的相位;根据所述第二幅值和所述第二相位值,得到K矩阵;所述第二幅值用于作为K矩阵中元素的幅值,所述第二相位值用于作为所述K矩阵中元素的相位;根据所述Q矩阵、所述K矩阵以及所述head中计算得到的V矩阵,得到所述head的输出。The embodiment of the present application provides a data processing method applied to the attention head in the neural network based on the attention mechanism. The method includes: performing multiple linear transformations on the feature blocks input to the head, Obtain the first amplitude, the second phase value, the second amplitude and the second phase value respectively; according to the first numerical value and the first phase value, obtain the Q matrix; the first amplitude is used as Q The amplitude of the elements in the matrix, the first phase value is used as the phase of the element in the Q matrix; according to the second amplitude and the second phase value, the K matrix is obtained; the second amplitude is used as the amplitude of the element in the K matrix, and the second phase value is used as the phase of the element in the K matrix; according to the V matrix calculated in the Q matrix, the K matrix and the head, Get the output of the head.
在现有的实现中,用变换矩阵Q和变换矩阵K,对输入到head中的特征块token进行线性变换,分别得到Q矩阵和K矩阵,Q矩阵、K矩阵中的元素均为实数,对于特征的表达能力有限。本申请中,可以为输入到head中的特征块token分别生成Q矩阵中元素的幅度和相位、以及K矩阵中元素的幅度和相位。通过这种方式,Q矩阵和K矩阵都可以参数化为复杂的形式,进而增加特征的表达能力,可以更好地建模不同特征块之间的关系。In the existing implementation, the transformation matrix Q and transformation matrix K are used to linearly transform the feature block token input into the head, and the Q matrix and K matrix are obtained respectively. The elements in the Q matrix and K matrix are all real numbers. For Features have limited expressive power. In this application, the amplitude and phase of the elements in the Q matrix and the amplitude and phase of the elements in the K matrix can be generated respectively for the feature block token input into the head. In this way, both the Q matrix and the K matrix can be parameterized into complex forms, thereby increasing the expressive ability of features and better modeling the relationship between different feature blocks.
参照图12,图12为一种数据处理方法的流程示意,如图12所示,本申请实施例提供的数据处理方法,可以包括:Referring to Figure 12, Figure 12 is a flow diagram of a data processing method. As shown in Figure 12, the data processing method provided by the embodiment of the present application may include:
1201、通过对特征图中的第一特征块进行多次线性变换,分别得到第一幅值和第一相位值。1201. By performing multiple linear transformations on the first feature block in the feature map, the first amplitude value and the first phase value are obtained respectively.
对于卷积层需要处理的特征图,可以将特征图中的各个特征块(本申请实施例以第一 特征块为例)进行多次线性变换,分别得到第一幅值和第一相位值,第一幅值用于作为所述第二特征块中元素的幅值,所述第一相位值用于作为所述第二特征块中元素的相位。For the feature map that needs to be processed by the convolution layer, each feature block in the feature map (the embodiment of this application uses the first Taking the feature block as an example) perform multiple linear transformations to obtain the first amplitude and the first phase value respectively. The first amplitude is used as the amplitude of the element in the second feature block, and the first phase value is used to As the phase of the elements in the second feature block.
在一种可能的实现中,可以通过线性规划层,对特征图中的第一特征块进行多次线性变换;所述线性规划层包括第一权重和第二权重,所述第一权重和所述第二权重为可训练的参数;其中,所述第一权重用于对特征图中的第一特征块进行线性变换,以得到所述第一幅值;所述第二权重用于对特征图中的第一特征块进行线性变换,以得到所述第一相位值。In a possible implementation, multiple linear transformations can be performed on the first feature block in the feature map through a linear programming layer; the linear programming layer includes a first weight and a second weight, and the first weight and the The second weight is a trainable parameter; wherein the first weight is used to linearly transform the first feature block in the feature map to obtain the first amplitude; the second weight is used to linearly transform the feature The first feature block in the figure is linearly transformed to obtain the first phase value.
1202、根据所述第一幅值和所述第一相位值,得到第二特征块;第一幅值用于作为所述第二特征块中元素的幅值,所述第一相位值用于作为所述第二特征块中元素的相位。1202. Obtain a second feature block according to the first amplitude value and the first phase value; the first amplitude value is used as the amplitude value of the element in the second feature block, and the first phase value is used for As the phase of the elements in the second feature block.
在一种可能的实现中,卷积神经网络通过堆叠多个卷积层来处理输入数据,最终得到模型输入。以用于图像识别的卷积神经网络为例,网络的中间层为大小为H*W*C的特征图,其中H、W、C分别是模型的高度、宽度和通道数。可以把每个位置的特征(1x1xC)看做一个特征块,每个特征块又可以表示成波函数的形式,即量子特征块。基于量子特征块的卷积神经网络中的一个基本单元如图13所示:In one possible implementation, a convolutional neural network processes input data by stacking multiple convolutional layers to finally get the model input. Taking the convolutional neural network used for image recognition as an example, the middle layer of the network is a feature map of size H*W*C, where H, W, and C are the height, width, and number of channels of the model respectively. The characteristics of each position (1x1xC) can be regarded as a feature block, and each feature block can be expressed in the form of a wave function, that is, a quantum feature block. A basic unit in the convolutional neural network based on quantum feature blocks is shown in Figure 13:
首先使用两个线性变换层W1,W2,将输入特征X表示成量子特征块
First, two linear transformation layers W1 and W2 are used to represent the input feature X into a quantum feature block.
不同于现有方法,每个特征块都使用两个线性变换层W1,W2,分别生成幅值和相位,使得生成的优化后的特征块可以表达更丰富的信息。Different from existing methods, each feature block uses two linear transformation layers W1 and W2 to generate amplitude and phase respectively, so that the generated optimized feature blocks can express richer information.
1203、将所述第二特征块中的元素映射为实数,得到第三特征块。1203. Map the elements in the second feature block to real numbers to obtain a third feature block.
在一种可能的实现中,可以将所述第二特征块中元素表示为复数时的实部的数值和虚部的数值进行融合,以得到融合结果,所述融合结果为实数。In a possible implementation, the values of the real part and the value of the imaginary part when the elements in the second feature block are expressed as complex numbers can be fused to obtain a fusion result, and the fusion result is a real number.
在一种可能的实现中,所述融合,可以包括:拼接操作(concat)。In a possible implementation, the fusion may include: a concatenation operation (concat).
示例性的,可以使用欧拉公式将将复值特征(也就是第二特征块)展开,得到:
For example, Euler's formula can be used to expand the complex-valued feature (that is, the second feature block) to obtain:
基于复值特征,确定实数域特征。例如,拼接复值特征的实部和虚部,得到实数域特征Z:
Z=cat[W1X⊙cosW2X,W1X⊙sinW2X];Based on complex-valued features, the real number domain features are determined. For example, splicing the real part and imaginary part of the complex-valued feature to obtain the real-number domain feature Z:
Z=cat[W 1 X⊙cosW 2 X,W 1 X⊙sinW 2 X];
1204、将所述第三特征块,输入到卷积层中。1204. Input the third feature block into the convolution layer.
在特征Z上部署卷积,得到模型输出Y:
Y=Conv(Z);Deploy convolution on feature Z to get model output Y:
Y=Conv(Z);
本申请把特征块表示成量子特征块,模型在复数域中进行计算,可以实现更准确的推理。在网络最终的输出层,通过特征变换的方式,把特征变换到实数域中,得到有实际意义的模型输出。This application represents feature blocks as quantum feature blocks, and the model performs calculations in the complex number domain, which can achieve more accurate reasoning. In the final output layer of the network, the features are transformed into the real number domain through feature transformation to obtain practical meaningful model output.
本申请将量子特征块与卷积神经网络结合也可以取得更优的性能,他们在目标检测数据集COCO上的结果表2所示:This application can also achieve better performance by combining quantum feature blocks with convolutional neural networks. Their results on the target detection data set COCO are shown in Table 2:
表2 COCO数据集上目标检测任务的实验效果
Table 2 Experimental results of the target detection task on the COCO data set
本申请提供了一种数据处理方法,所述方法包括:通过对特征图中的第一特征块进行多次线性变换,分别得到第一幅值和第一相位值;根据所述第一幅值和所述第一相位值,得到第二特征块;第一幅值用于作为所述第二特征块中元素的幅值,所述第一相位值用于作为所述第二特征块中元素的相位;将所述第二特征块中的元素映射为实数,得到第三特征块;将所述第三特征块,输入到卷积层中。本申请将量子特征块引入到卷积运算中,通过把特征块表示成量子特征块,使得模型在复数域中进行计算,可以实现更准确的推理。在网络最终的输出层,通过特征变换的方式,把特征变换到实数域中,得到有实际意义的模型输出。This application provides a data processing method. The method includes: performing multiple linear transformations on the first feature block in the feature map to obtain the first amplitude and the first phase value respectively; according to the first amplitude and the first phase value to obtain a second feature block; the first amplitude value is used as the amplitude of the element in the second feature block, and the first phase value is used as the element in the second feature block phase; map the elements in the second feature block to real numbers to obtain the third feature block; input the third feature block into the convolution layer. This application introduces quantum feature blocks into the convolution operation. By representing the feature blocks as quantum feature blocks, the model can be calculated in the complex number domain and more accurate reasoning can be achieved. In the final output layer of the network, the features are transformed into the real number domain through feature transformation to obtain practical meaningful model output.
在图1至图13所对应的实施例的基础上,为了更好的实施本申请实施例的上述方案,下面还提供用于实施上述方案的相关设备。具体参阅图14,图14为本申请实施例提供的数据处理设备1400的一种结构示意图,数据处理设备1400可以是终端设备或服务器,数据处理设备1400包括:On the basis of the embodiments corresponding to Figures 1 to 13, in order to better implement the above solutions of the embodiments of the present application, relevant equipment for implementing the above solutions is also provided below. Specifically referring to Figure 14, Figure 14 is a schematic structural diagram of a data processing device 1400 provided by an embodiment of the present application. The data processing device 1400 may be a terminal device or a server. The data processing device 1400 includes:
线性变换模块1401,用于通过对输入到所述head中的特征块进行多次线性变换,分别得到第一幅值、第二相位值、第二幅值以及第二相位值;The linear transformation module 1401 is used to perform multiple linear transformations on the feature blocks input into the head to obtain the first amplitude, the second phase value, the second amplitude and the second phase value respectively;
其中,关于线性变换模块1401的具体描述可以参照上述实施例中步骤601,这里不再赘述。For a specific description of the linear transformation module 1401, reference may be made to step 601 in the above embodiment, which will not be described again here.
注意力计算模块1402,用于根据所述第一数值和所述第一相位值,得到Q矩阵;所述第一幅值用于作为Q矩阵中元素的幅值,所述第一相位值用于作为所述Q矩阵中元素的相位;The attention calculation module 1402 is used to obtain the Q matrix according to the first numerical value and the first phase value; the first amplitude value is used as the amplitude of the element in the Q matrix, and the first phase value is used Yu is the phase of the element in the Q matrix;
根据所述第二幅值和所述第二相位值,得到K矩阵;所述第二幅值用于作为K矩阵中元素的幅值,所述第二相位值用于作为所述K矩阵中元素的相位;According to the second amplitude and the second phase value, a K matrix is obtained; the second amplitude is used as the amplitude of the element in the K matrix, and the second phase value is used as the element in the K matrix. the phase of an element;
根据所述Q矩阵、所述K矩阵以及所述head中计算得到的V矩阵,得到所述head的输出。According to the Q matrix, the K matrix and the V matrix calculated in the head, the output of the head is obtained.
其中,关于注意力计算模块1402的具体描述可以参照上述实施例中步骤602、步骤603以及步骤604,这里不再赘述。For a specific description of the attention calculation module 1402, reference may be made to step 602, step 603, and step 604 in the above embodiment, which will not be described again here.
在一种可能的实现中,所述注意力计算模块,具体用于:In a possible implementation, the attention calculation module is specifically used to:
对所述Q矩阵和所述K矩阵进行相关度计算,得到第一注意力矩阵,所述第一注意力矩阵中的元素为复数;Perform correlation calculation on the Q matrix and the K matrix to obtain a first attention matrix, where the elements in the first attention matrix are complex numbers;
将所述第一注意力矩阵中的元素映射为实数,得到第二注意力矩阵;Map the elements in the first attention matrix to real numbers to obtain a second attention matrix;
根据所述第二注意力矩阵和所述head中计算得到的V矩阵,得到所述head的输出。According to the second attention matrix and the V matrix calculated in the head, the output of the head is obtained.
在一种可能的实现中,所述第一注意力矩阵中的元素包括实部和虚部,所述注意力计算模块,具体用于:In a possible implementation, the elements in the first attention matrix include real parts and imaginary parts, and the attention calculation module is specifically used to:
将所述第一注意力矩阵中元素的实部的数值和虚部的数值进行融合,以得到融合结果,所述融合结果为实数。The values of the real part and the value of the imaginary part of the elements in the first attention matrix are fused to obtain a fusion result, and the fusion result is a real number.
在一种可能的实现中,所述融合,包括: In a possible implementation, the fusion includes:
求和操作;或者,sum operation; or,
求复数的模长。Find the modular length of a complex number.
在一种可能的实现中,所述线性变换模块,具体用于:In a possible implementation, the linear transformation module is specifically used for:
通过线性规划层,对输入到所述head中的特征块进行多次线性变换;所述线性规划层包括第一权重、第二权重、第三权重以及第四权重,所述第一权重、所述第二权重、所述第三权重以及所述第四权重为可训练的参数;其中,Through the linear planning layer, multiple linear transformations are performed on the feature blocks input into the head; the linear planning layer includes a first weight, a second weight, a third weight and a fourth weight. The first weight, the The second weight, the third weight and the fourth weight are trainable parameters; wherein,
所述第一权重用于对所述特征块进行线性变换,以得到所述第一幅值;The first weight is used to linearly transform the feature block to obtain the first amplitude;
所述第二权重用于对所述特征块进行线性变换,以得到所述第一相位值;The second weight is used to linearly transform the feature block to obtain the first phase value;
所述第三权重用于对所述特征块进行线性变换,以得到所述第二幅值;The third weight is used to linearly transform the feature block to obtain the second amplitude;
所述第四权重用于对所述特征块进行线性变换,以得到所述第二相位值。The fourth weight is used to linearly transform the feature block to obtain the second phase value.
在一种可能的实现中,所述特征块为与一段数据的一个切片相关联的信息,所述一段数据为音频数据、视频数据、图像数据或上下文数据。In a possible implementation, the feature block is information associated with a slice of a piece of data, and the piece of data is audio data, video data, image data or context data.
参阅图15,图15为本申请实施例提供的数据处理设备1500的一种结构示意图,数据处理设备1500可以是终端设备或服务器,数据处理设备1500包括:Referring to Figure 15, Figure 15 is a schematic structural diagram of a data processing device 1500 provided by an embodiment of the present application. The data processing device 1500 may be a terminal device or a server. The data processing device 1500 includes:
线性变换模块1501,用于通过对特征图中的第一特征块进行多次线性变换,分别得到第一幅值和第一相位值;The linear transformation module 1501 is used to perform multiple linear transformations on the first feature block in the feature map to obtain the first amplitude and the first phase value respectively;
根据所述第一幅值和所述第一相位值,得到第二特征块;第一幅值用于作为所述第二特征块中元素的幅值,所述第一相位值用于作为所述第二特征块中元素的相位;According to the first amplitude and the first phase value, a second feature block is obtained; the first amplitude is used as the amplitude of the element in the second feature block, and the first phase value is used as the The phase of the elements in the second feature block;
将所述第二特征块中的元素映射为实数,得到第三特征块;Map elements in the second feature block to real numbers to obtain a third feature block;
其中,关于线性变换模块1501的具体描述可以参照上述实施例中步骤1201、步骤1202以及步骤1203,这里不再赘述。For detailed description of the linear transformation module 1501, reference may be made to step 1201, step 1202, and step 1203 in the above embodiment, which will not be described again here.
卷积模块1502,用于将所述第三特征块,输入到卷积层中。The convolution module 1502 is used to input the third feature block into the convolution layer.
其中,关于卷积模块1502的具体描述可以参照上述实施例中步骤1204,这里不再赘述。For a detailed description of the convolution module 1502, reference may be made to step 1204 in the above embodiment, which will not be described again here.
在一种可能的实现中,所述线性变换模块,具体用于:In a possible implementation, the linear transformation module is specifically used for:
将所述第二特征块中元素表示为复数时的实部的数值和虚部的数值进行融合,以得到融合结果,所述融合结果为实数。The values of the real part and the value of the imaginary part when the elements in the second feature block are expressed as complex numbers are fused to obtain a fusion result, and the fusion result is a real number.
在一种可能的实现中,所述融合,包括:In a possible implementation, the fusion includes:
拼接操作(concat)。Concatenation operation (concat).
在一种可能的实现中,所述线性变换模块,具体用于:In a possible implementation, the linear transformation module is specifically used for:
通过线性规划层,对特征图中的第一特征块进行多次线性变换;所述线性规划层包括第一权重和第二权重,所述第一权重和所述第二权重为可训练的参数;其中,Through the linear programming layer, multiple linear transformations are performed on the first feature block in the feature map; the linear programming layer includes a first weight and a second weight, and the first weight and the second weight are trainable parameters. ;in,
所述第一权重用于对特征图中的第一特征块进行线性变换,以得到所述第一幅值;The first weight is used to linearly transform the first feature block in the feature map to obtain the first amplitude;
所述第二权重用于对特征图中的第一特征块进行线性变换,以得到所述第一相位值。The second weight is used to linearly transform the first feature block in the feature map to obtain the first phase value.
接下来介绍本申请实施例提供的一种执行设备,请参阅图16,图16为本申请实施例提供的执行设备的一种结构示意图,执行设备1600具体可以表现为虚拟现实VR设备、手 机、平板、笔记本电脑、智能穿戴设备、监控数据处理设备或服务器等,此处不做限定。具体的,执行设备1600包括:接收器1601、发射器1602、处理器1603和存储器1604(其中执行设备1600中的处理器1603的数量可以一个或多个,图16中以一个处理器为例),其中,处理器1603可以包括应用处理器16031和通信处理器16032。在本申请的一些实施例中,接收器1601、发射器1602、处理器1603和存储器1604可通过总线或其它方式连接。Next, an execution device provided by an embodiment of the present application is introduced. Please refer to Figure 16. Figure 16 is a schematic structural diagram of an execution device provided by an embodiment of the present application. The execution device 1600 can be embodied as a virtual reality VR device, a mobile phone, or a virtual reality device. Computers, tablets, laptops, smart wearable devices, monitoring data processing equipment or servers, etc. are not limited here. Specifically, the execution device 1600 includes: a receiver 1601, a transmitter 1602, a processor 1603 and a memory 1604 (the number of processors 1603 in the execution device 1600 can be one or more, one processor is taken as an example in Figure 16) , wherein the processor 1603 may include an application processor 16031 and a communication processor 16032. In some embodiments of the present application, the receiver 1601, the transmitter 1602, the processor 1603, and the memory 1604 may be connected by a bus or other means.
存储器1604可以包括只读存储器和随机存取存储器,并向处理器1603提供指令和数据。存储器1604的一部分还可以包括非易失性随机存取存储器(non-volatile random access memory,NVRAM)。存储器1604存储有处理器和操作指令、可执行模块或者数据结构,或者它们的子集,或者它们的扩展集,其中,操作指令可包括各种操作指令,用于实现各种操作。Memory 1604 may include read-only memory and random access memory and provides instructions and data to processor 1603 . A portion of memory 1604 may also include non-volatile random access memory (NVRAM). The memory 1604 stores processor and operating instructions, executable modules or data structures, or a subset thereof, or an extended set thereof, where the operating instructions may include various operating instructions for implementing various operations.
处理器1603控制执行设备的操作。具体的应用中,执行设备的各个组件通过总线系统耦合在一起,其中总线系统除包括数据总线之外,还可以包括电源总线、控制总线和状态信号总线等。但是为了清楚说明起见,在图中将各种总线都称为总线系统。The processor 1603 controls the execution of operations of the device. In specific applications, various components of the execution device are coupled together through a bus system. In addition to the data bus, the bus system may also include a power bus, a control bus, a status signal bus, etc. However, for the sake of clarity, various buses are called bus systems in the figure.
上述本申请实施例揭示的方法可以应用于处理器1603中,或者由处理器1603实现。处理器1603可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器1603中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器1603可以是通用处理器、数字信号处理器(digital signal processing,DSP)、微处理器或微控制器,还可进一步包括专用集成电路(application specific integrated circuit,ASIC)、现场可编程门阵列(field-programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。该处理器1603可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器1604,处理器1603读取存储器1604中的信息,结合其硬件完成上述方法的步骤。The methods disclosed in the above embodiments of the present application can be applied to the processor 1603 or implemented by the processor 1603. The processor 1603 may be an integrated circuit chip with signal processing capabilities. During the implementation process, each step of the above method can be completed by instructions in the form of hardware integrated logic circuits or software in the processor 1603 . The above-mentioned processor 1603 can be a general processor, a digital signal processor (DSP), a microprocessor or a microcontroller, and can further include an application specific integrated circuit (ASIC), a field programmable Gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The processor 1603 can implement or execute each method, step and logical block diagram disclosed in the embodiment of this application. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present application can be directly implemented by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module can be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other mature storage media in this field. The storage medium is located in the memory 1604. The processor 1603 reads the information in the memory 1604 and completes the steps of the above method in combination with its hardware.
接收器1601可用于接收输入的数字或字符信息,以及产生与执行设备的相关设置以及功能控制有关的信号输入。发射器1602可用于通过第一接口输出数字或字符信息;发射器1602还可用于通过第一接口向磁盘组发送指令,以修改磁盘组中的数据;发射器1602还可以包括显示屏等显示设备。The receiver 1601 may be configured to receive input numeric or character information and generate signal inputs related to performing relevant settings and functional controls of the device. The transmitter 1602 can be used to output numeric or character information through the first interface; the transmitter 1602 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; the transmitter 1602 can also include a display device such as a display screen .
本申请实施例中,在一种情况下,处理器1603,用于执行图6以及图12对应实施例中的设备执行的数据处理方法。In the embodiment of the present application, in one case, the processor 1603 is used to execute the data processing method executed by the device in the corresponding embodiment of FIG. 6 and FIG. 12 .
本申请实施例还提供了一种训练设备,请参阅图17,图17是本申请实施例提供的训练设备一种结构示意图,具体的,训练设备1700由一个或多个服务器实现,训练设备1700可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上中央处理器(central processing units,CPU)1717(例如,一个或一个以上处理器)和存储器1732,一个或一个 以上存储应用程序1742或数据1744的存储介质1730(例如一个或一个以上海量存储设备)。其中,存储器1732和存储介质1730可以是短暂存储或持久存储。存储在存储介质1730的程序可以包括一个或一个以上模块(图示没标出),每个模块可以包括对训练设备中的一系列指令操作。更进一步地,中央处理器1717可以设置为与存储介质1730通信,在训练设备1700上执行存储介质1730中的一系列指令操作。The embodiment of the present application also provides a training device. Please refer to Figure 17. Figure 17 is a schematic structural diagram of the training device provided by the embodiment of the present application. Specifically, the training device 1700 is implemented by one or more servers. The training device 1700 There may be relatively large differences due to different configurations or performance, which may include one or more central processing units (CPU) 1717 (for example, one or more processors) and memory 1732, one or one The above storage medium 1730 (such as one or more mass storage devices) stores application programs 1742 or data 1744. Among them, the memory 1732 and the storage medium 1730 may be short-term storage or persistent storage. The program stored in the storage medium 1730 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the training device. Furthermore, the central processor 1717 may be configured to communicate with the storage medium 1730 and execute a series of instruction operations in the storage medium 1730 on the training device 1700 .
训练设备1700还可以包括一个或一个以上电源1726,一个或一个以上有线或无线网络接口1750,一个或一个以上输入输出接口1758;或,一个或一个以上操作系统1741,例如Windows ServerTM,Mac OS XTM,UnixTM,LinuxTM,FreeBSDTM等等。The training device 1700 may also include one or more power supplies 1726, one or more wired or wireless network interfaces 1750, one or more input and output interfaces 1758; or, one or more operating systems 1741, such as Windows ServerTM, Mac OS XTM , UnixTM, LinuxTM, FreeBSDTM and so on.
本申请实施例中,中央处理器1717,用于执行图6以及图12对应实施例中的数据处理装置执行的数据处理方法。In the embodiment of the present application, the central processor 1717 is used to execute the data processing method executed by the data processing device in the corresponding embodiment of FIG. 6 and FIG. 12 .
本申请实施例中还提供一种包括计算机程序产品,当其在计算机上运行时,使得计算机执行如前述执行设备所执行的步骤,或者,使得计算机执行如前述训练设备所执行的步骤。An embodiment of the present application also provides a computer program product that, when run on a computer, causes the computer to perform the steps performed by the foregoing execution device, or causes the computer to perform the steps performed by the foregoing training device.
本申请实施例中还提供一种计算机可读存储介质,该计算机可读存储介质中存储有用于进行信号处理的程序,当其在计算机上运行时,使得计算机执行如前述执行设备所执行的步骤,或者,使得计算机执行如前述训练设备所执行的步骤。Embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium stores a program for performing signal processing. When the program is run on a computer, it causes the computer to perform the steps performed by the aforementioned execution device. , or, causing the computer to perform the steps performed by the aforementioned training device.
本申请实施例提供的执行设备、训练设备或终端设备具体可以为芯片,芯片包括:处理单元和通信单元,所述处理单元例如可以是处理器,所述通信单元例如可以是输入/输出接口、管脚或电路等。该处理单元可执行存储单元存储的计算机执行指令,以使执行设备内的芯片执行上述实施例描述的数据处理方法,或者,以使训练设备内的芯片执行上述实施例描述的数据处理方法。可选地,所述存储单元为所述芯片内的存储单元,如寄存器、缓存等,所述存储单元还可以是所述无线接入设备端内的位于所述芯片外部的存储单元,如只读存储器(read-only memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(random access memory,RAM)等。The execution device, training device or terminal device provided by the embodiment of the present application may specifically be a chip. The chip includes: a processing unit and a communication unit. The processing unit may be, for example, a processor. The communication unit may be, for example, an input/output interface. Pins or circuits, etc. The processing unit can execute the computer execution instructions stored in the storage unit, so that the chip in the execution device executes the data processing method described in the above embodiment, or so that the chip in the training device executes the data processing method described in the above embodiment. Optionally, the storage unit is a storage unit within the chip, such as a register, cache, etc. The storage unit may also be a storage unit located outside the chip in the wireless access device, such as Read-only memory (ROM) or other types of static storage devices that can store static information and instructions, random access memory (random access memory, RAM), etc.
具体的,请参阅图18,图18为本申请实施例提供的芯片的一种结构示意图,所述芯片可以表现为神经网络处理器NPU 1800,NPU 1800作为协处理器挂载到主CPU(Host CPU)上,由Host CPU分配任务。NPU的核心部分为运算电路1803,通过控制器1804控制运算电路1803提取存储器中的矩阵数据并进行乘法运算。Specifically, please refer to Figure 18. Figure 18 is a structural schematic diagram of a chip provided by an embodiment of the present application. The chip can be represented as a neural network processor NPU 1800. The NPU 1800 serves as a co-processor and is mounted to the main CPU (Host). CPU), tasks are allocated by the Host CPU. The core part of the NPU is the arithmetic circuit 1803. The arithmetic circuit 1803 is controlled by the controller 1804 to extract the matrix data in the memory and perform multiplication operations.
在一些实现中,运算电路1803内部包括多个处理单元(Process Engine,PE)。在一些实现中,运算电路1803是二维脉动阵列。运算电路1803还可以是一维脉动阵列或者能够执行例如乘法和加法这样的数学运算的其它电子线路。在一些实现中,运算电路1803是通用的矩阵处理器。In some implementations, the computing circuit 1803 includes multiple processing units (Process Engine, PE). In some implementations, arithmetic circuit 1803 is a two-dimensional systolic array. The arithmetic circuit 1803 may also be a one-dimensional systolic array or other electronic circuit capable of performing mathematical operations such as multiplication and addition. In some implementations, arithmetic circuit 1803 is a general-purpose matrix processor.
举例来说,假设有输入矩阵A,权重矩阵B,输出矩阵C。运算电路从权重存储器1802中取矩阵B相应的数据,并缓存在运算电路中每一个PE上。运算电路从输入存储器1801中取矩阵A数据与矩阵B进行矩阵运算,得到的矩阵的部分结果或最终结果,保存在累加器(accumulator)1808中。 For example, assume there is an input matrix A, a weight matrix B, and an output matrix C. The arithmetic circuit obtains the corresponding data of matrix B from the weight memory 1802 and caches it on each PE in the arithmetic circuit. The operation circuit takes matrix A data and matrix B from the input memory 1801 to perform matrix operations, and the partial result or final result of the matrix is stored in an accumulator (accumulator) 1808 .
统一存储器1806用于存放输入数据以及输出数据。权重数据直接通过存储单元访问控制器(Direct Memory Access Controller,DMAC)1805,DMAC被搬运到权重存储器1802中。输入数据也通过DMAC被搬运到统一存储器1806中。The unified memory 1806 is used to store input data and output data. The weight data directly passes through the storage unit access controller (Direct Memory Access Controller, DMAC) 1805, and the DMAC is transferred to the weight memory 1802. Input data is also transferred to unified memory 1806 via DMAC.
BIU为Bus Interface Unit即,总线接口单元1810,用于AXI总线与DMAC和取指存储器(Instruction Fetch Buffer,IFB)1809的交互。BIU is the Bus Interface Unit, that is, the bus interface unit 1810, which is used for the interaction between the AXI bus and the DMAC and the Instruction Fetch Buffer (IFB) 1809.
总线接口单元1810(Bus Interface Unit,简称BIU),用于取指存储器1809从外部存储器获取指令,还用于存储单元访问控制器1805从外部存储器获取输入矩阵A或者权重矩阵B的原数据。The bus interface unit 1810 (Bus Interface Unit, BIU for short) is used to fetch the memory 1809 to obtain instructions from the external memory, and is also used for the storage unit access controller 1805 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
DMAC主要用于将外部存储器DDR中的输入数据搬运到统一存储器1806或将权重数据搬运到权重存储器1802中或将输入数据数据搬运到输入存储器1801中。DMAC is mainly used to transfer the input data in the external memory DDR to the unified memory 1806 or the weight data to the weight memory 1802 or the input data to the input memory 1801 .
向量计算单元1807包括多个运算处理单元,在需要的情况下,对运算电路的输出做进一步处理,如向量乘,向量加,指数运算,对数运算,大小比较等等。主要用于神经网络中非卷积/全连接层网络计算,如Batch Normalization(批归一化),像素级求和,对特征平面进行上采样等。The vector calculation unit 1807 includes multiple arithmetic processing units, and if necessary, further processes the output of the arithmetic circuit, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. Mainly used for non-convolutional/fully connected layer network calculations in neural networks, such as Batch Normalization, pixel-level summation, upsampling of feature planes, etc.
在一些实现中,向量计算单元1807能将经处理的输出的向量存储到统一存储器1806。例如,向量计算单元1807可以将线性函数;或,非线性函数应用到运算电路1803的输出,例如对卷积层提取的特征平面进行线性插值,再例如累加值的向量,用以生成激活值。在一些实现中,向量计算单元1807生成归一化的值、像素级求和的值,或二者均有。在一些实现中,处理过的输出的向量能够用作到运算电路1803的激活输入,例如用于在神经网络中的后续层中的使用。In some implementations, vector calculation unit 1807 can store the processed output vectors to unified memory 1806 . For example, the vector calculation unit 1807 can apply a linear function; or a nonlinear function to the output of the operation circuit 1803, such as linear interpolation on the feature plane extracted by the convolution layer, or a vector of accumulated values, to generate an activation value. In some implementations, vector calculation unit 1807 generates normalized values, pixel-wise summed values, or both. In some implementations, the processed output vector can be used as an activation input to the arithmetic circuit 1803, such as for use in a subsequent layer in a neural network.
控制器1804连接的取指存储器(instruction fetch buffer)1809,用于存储控制器1804使用的指令;The instruction fetch buffer 1809 connected to the controller 1804 is used to store instructions used by the controller 1804;
统一存储器1806,输入存储器1801,权重存储器1802以及取指存储器1809均为On-Chip存储器。外部存储器私有于该NPU硬件架构。The unified memory 1806, the input memory 1801, the weight memory 1802 and the fetch memory 1809 are all On-Chip memories. External memory is private to the NPU hardware architecture.
其中,上述任一处提到的处理器,可以是一个通用中央处理器,微处理器,ASIC,或一个或多个用于控制上述程序执行的集成电路。The processor mentioned in any of the above places can be a general central processing unit, a microprocessor, an ASIC, or one or more integrated circuits used to control the execution of the above programs.
另外需说明的是,以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。另外,本申请提供的装置实施例附图中,模块之间的连接关系表示它们之间具有通信连接,具体可以实现为一条或多条通信总线或信号线。In addition, it should be noted that the device embodiments described above are only illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physically separate. The physical unit can be located in one place, or it can be distributed across multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. In addition, in the drawings of the device embodiments provided in this application, the connection relationship between modules indicates that there are communication connections between them, which can be specifically implemented as one or more communication buses or signal lines.
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到本申请可借助软件加必需的通用硬件的方式来实现,当然也可以通过专用硬件包括专用集成电路、专用CPU、专用存储器、专用元器件等来实现。一般情况下,凡由计算机程序完成的功能都可以很容易地用相应的硬件来实现,而且,用来实现同一功能的具体硬件结构也可以是多种多样的,例如模拟电路、数字电路或专用电路等。但是,对本申请而言更多情况下软件程序实现是 更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在可读取的存储介质中,如计算机的软盘、U盘、移动硬盘、ROM、RAM、磁碟或者光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,训练设备,或者网络设备等)执行本申请各个实施例所述的方法。Through the above description of the embodiments, those skilled in the art can clearly understand that the present application can be implemented by software plus necessary general hardware. Of course, it can also be implemented by dedicated hardware including dedicated integrated circuits, dedicated CPUs, dedicated memories, Special components, etc. to achieve. In general, all functions performed by computer programs can be easily implemented with corresponding hardware. Moreover, the specific hardware structures used to implement the same function can also be diverse, such as analog circuits, digital circuits or special-purpose circuits. circuit etc. However, for this application more often the software program implementation is Better implementation. Based on this understanding, the technical solution of the present application can be embodied in the form of a software product in essence or that contributes to the existing technology. The computer software product is stored in a readable storage medium, such as a computer floppy disk. , U disk, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., including several instructions to cause a computer device (which can be a personal computer, training device, or network device, etc.) to execute the steps described in various embodiments of this application. method.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it may be implemented in whole or in part in the form of a computer program product.
所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、训练设备或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、训练设备或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存储的任何可用介质或者是包含一个或多个可用介质集成的训练设备、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(Solid State Disk,SSD))等。 The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. 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 or transmitted from one computer-readable storage medium to another, for example, the computer instructions may be transferred from a website, computer, training device, or data The center transmits to another website site, computer, training equipment or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as 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 a data center integrated with one or more available media. The available media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, DVD), or semiconductor media (eg, solid state disk (Solid State Disk, SSD)), etc.
Claims (23)
Applications Claiming Priority (4)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US17/733,758 | 2022-04-29 | ||
US17/733,758 US20230351163A1 (en) | 2022-04-29 | 2022-04-29 | Method and device for processing data based on multi-layer perceptrons |
CN202210912635.3A CN117035019A (en) | 2022-04-29 | 2022-07-30 | Data processing method and related equipment |
CN202210912635.3 | 2022-07-30 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2023207665A1 true WO2023207665A1 (en) | 2023-11-02 |
Family
ID=88517582
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2023/088869 WO2023207665A1 (en) | 2022-04-29 | 2023-04-18 | Data processing method and related device |
Country Status (1)
Country | Link |
---|---|
WO (1) | WO2023207665A1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118333167A (en) * | 2024-04-12 | 2024-07-12 | 上海交通大学 | A method for calculating an attention mechanism, a computing system and a storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110739002A (en) * | 2019-10-16 | 2020-01-31 | 中山大学 | Complex domain speech enhancement method, system and medium based on generation countermeasure network |
WO2021009319A1 (en) * | 2019-07-17 | 2021-01-21 | Audionamix Sa | Method for separating an acoustic mix signal into a plurality of m sound contributions; associated computer program product and associated readable data medium |
CN113553988A (en) * | 2021-08-03 | 2021-10-26 | 同济大学 | An Analog Signal Recognition Method Based on Complex Neural Network and Attention Mechanism |
CN113849767A (en) * | 2021-09-27 | 2021-12-28 | 中国科学院声学研究所 | Personalized HRTF (head related transfer function) generation method and system based on physiological parameters and artificial head data |
-
2023
- 2023-04-18 WO PCT/CN2023/088869 patent/WO2023207665A1/en active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2021009319A1 (en) * | 2019-07-17 | 2021-01-21 | Audionamix Sa | Method for separating an acoustic mix signal into a plurality of m sound contributions; associated computer program product and associated readable data medium |
CN110739002A (en) * | 2019-10-16 | 2020-01-31 | 中山大学 | Complex domain speech enhancement method, system and medium based on generation countermeasure network |
CN113553988A (en) * | 2021-08-03 | 2021-10-26 | 同济大学 | An Analog Signal Recognition Method Based on Complex Neural Network and Attention Mechanism |
CN113849767A (en) * | 2021-09-27 | 2021-12-28 | 中国科学院声学研究所 | Personalized HRTF (head related transfer function) generation method and system based on physiological parameters and artificial head data |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118333167A (en) * | 2024-04-12 | 2024-07-12 | 上海交通大学 | A method for calculating an attention mechanism, a computing system and a storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112183718B (en) | A deep learning training method and device for computing equipment | |
CN111368993B (en) | Data processing method and related equipment | |
WO2021244249A1 (en) | Classifier training method, system and device, and data processing method, system and device | |
CN112288075B (en) | Data processing method and related equipment | |
CN113656563B (en) | A neural network search method and related equipment | |
WO2022253074A1 (en) | Data processing method and related device | |
WO2022001805A1 (en) | Neural network distillation method and device | |
CN113627163B (en) | A kind of attention model, feature extraction method and related device | |
WO2024041479A1 (en) | Data processing method and apparatus | |
WO2022222854A1 (en) | Data processing method and related device | |
WO2021136058A1 (en) | Video processing method and device | |
CN116861850A (en) | A data processing method and its device | |
CN116432019A (en) | Data processing method and related equipment | |
WO2023231794A1 (en) | Neural network parameter quantification method and apparatus | |
CN117273074A (en) | Data processing method and device | |
WO2024140630A1 (en) | Model training method and related device | |
CN117251592A (en) | A data processing method and its device | |
Andrianaivo et al. | Architecture recognition by means of convolutional neural networks | |
CN116258176A (en) | Data processing method and device | |
WO2023207665A1 (en) | Data processing method and related device | |
WO2024179485A1 (en) | Image processing method and related device thereof | |
WO2025044967A1 (en) | Data processing method and apparatus | |
CN117035019A (en) | Data processing method and related equipment | |
CN114298289A (en) | Data processing method, data processing equipment and storage medium | |
CN117392491A (en) | A data processing method and its device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 23795098 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 23795098 Country of ref document: EP Kind code of ref document: A1 |