WO2020253049A1 - 数据处理方法和装置、及存储介质和电子装置 - Google Patents
数据处理方法和装置、及存储介质和电子装置 Download PDFInfo
- Publication number
- WO2020253049A1 WO2020253049A1 PCT/CN2019/117724 CN2019117724W WO2020253049A1 WO 2020253049 A1 WO2020253049 A1 WO 2020253049A1 CN 2019117724 W CN2019117724 W CN 2019117724W WO 2020253049 A1 WO2020253049 A1 WO 2020253049A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- dimensional
- vector
- network model
- neural network
- hot
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
Definitions
- This application relates to the field of data processing, and specifically to a data processing method and device, a storage medium, and an electronic device.
- each object needs to be assigned a unique corresponding ID, and different objects are usually identified by different vectors.
- label encoder There are currently two main methods for assigning a unique ID to an object: label encoder and one-hot encoder.
- the specific method of label encoder is to assign a value to each object. For example, for the three colors of red, yellow, and green, the corresponding assigned values of 1, 2, and 3 are indicated. However, the label encoder will introduce numerical value information, for example, The average of 1+3 is 2. However, the average of red and green is not yellow. Therefore, the label encoder is not suitable for general scenes.
- the specific method of the one-hot encoder is to use n-dimensional one-hot vectors to identify n objects, each element in the vector is 0 or 1.
- the corresponding one-hot vector has only one corresponding position
- the element of is 1, and the rest are 0.
- the one-hot encoder will increase the vector dimension. If there are hundreds or thousands of objects, they need to be identified by hundreds or thousands of dimensional vectors, which consumes a lot of memory during operation and slows down the running speed.
- the embodiments of the present application provide a data processing method and device, a storage medium, and an electronic device to at least solve the problem of using one-hot vectors to identify different objects in the prior art, which causes the machine learning training process to occupy too much memory and the training speed Slower technical issues.
- an electronic device including a memory and a processor, the memory stores computer-readable instructions, and the processor is configured to run the computer-readable instructions to execute Steps in any of the above method embodiments.
- the first embedding layer of the neural network model is designed to be one that can output the n-dimensional vector as The embedding layer of m-dimensional vector, and use some n-dimensional one-hot vectors labeled with training labels to train the neural network model, so that the embedding layer of the neural network model can more accurately express the n-dimensional one-hot with m-dimensional vectors Vector information, so that the trained neural network model can be used to reduce the dimension of any n-dimensional one-hot vector to m-dimensionality, reducing the memory occupied during the training process, increasing the training speed of the neural network model, and shortening the training of the neural network model Time, solved the technical problem that the machine learning training process takes up too much memory and the training speed is slow due to the one-hot vector identifying different objects in the related technology.
- Fig. 1 is a flowchart of a data processing method according to an embodiment of the present application
- Figure 2 is a schematic diagram of a data processing device according to an embodiment of the present application.
- Fig. 3 is a block diagram of the hardware structure of an electronic device according to an embodiment of the present application.
- This embodiment provides a data processing method, which can be run in a mobile terminal, a handheld terminal or a similar computing device. Running on different computing devices is only the difference in the implementation of the scheme. Those skilled in the art can foresee that running on different computing devices can produce the same technical effect.
- the first embedding layer of the neural network model is designed to be a
- the output of the dimensional vector is the embedding layer of the m-dimensional vector, and some n-dimensional one-hot vectors with training labels are used to train the neural network model, so that the embedding layer of the neural network model can be more accurately expressed by the m-dimensional vector n-dimensional one-hot vector information, so that the trained neural network model can be used to reduce the dimension of any n-dimensional one-hot vector to m-dimensional, reducing the memory occupied during the training process, increasing the training speed of the neural network model, and shortening the nerve
- the training time of the network model solves the technical problem that the one-hot vector is used to identify different objects in the related technology, which causes the machine learning training process to occupy too much memory and the training speed is slow.
- the data processing method provided in this embodiment includes the following steps:
- Step 101 Obtain multiple first-type training samples, where each first-type training sample includes an n-dimensional one-hot vector and a corresponding first-type training label; each first-type training sample is an object, n-dimensional
- the one-hot vector is used to identify the object through the vector so that the machine can recognize and process it.
- the corresponding first type of training label is also a vector, used to identify a feature or attribute of the object, which is a neural network model
- the training goal of, that is, the neural network model is used to output a corresponding first-type training label for each object identified by an n-dimensional one-hot vector after training.
- the i-th first type of training samples ⁇ A i x i1, x i2, whil, x in, y i ⁇ , where, x i1 ⁇ x in n elements is an n-dimensional vector N i of heat alone, in x i1 ⁇ x in, only one element is 1, the remaining elements are all 0, y i is the n-dimensional one-hot vector N i corresponding to a first type of training labels, for representing one hot n-dimensional vector N i The category of the object represented.
- each n-dimensional one-hot vector is the code of an object, for example, using a vector [... 0, 1, 0,...] represents Beijing; secondly, the first type of training label corresponding to each n-dimensional one-hot vector is obtained.
- the first type of training label is used to train the neural network model to achieve the first type of classification goal, for example,
- the first type of training label can be the scale of the city.
- the first type of training label corresponding to Beijing is 1, which is used to indicate that Beijing is a first-tier city; finally, each n-dimensional one-hot vector is combined with the corresponding first type of training label, Obtain n first-type training samples, and after training the model with the first-type training samples, the obtained model is used to classify the input city and determine the size of the input city.
- each n-dimensional one-hot vector is used to represent an object.
- the identifiers of n objects can be obtained first, and the identities of n objects can be one-to-one corresponding to n different n-dimensional one-hot vectors.
- Using a plurality of training samples of the first type can train the first neural network model into the second neural network model, so that the second neural network model has a classification function corresponding to the training samples of the first type.
- n first-class training samples For example, in order to obtain a neural network model that can output the city scale (divided into first-line, second-line, third-line, etc.) after inputting the city name, obtain n first-class training samples. Take one city C as an example, and city C corresponds to The first type of training label is 2, which is used to indicate that city C is a second-tier city, and the n-dimensional one-hot vector corresponding to the name of city C is [x i1 , x i2 ,..., 0,..., x in ], Combine the n-dimensional one-hot vector of city C with the first type of training label, and get the first type of training sample corresponding to city C as [x i1 , x i2 ,..., 0,..., x in , 2] .
- the dimension of the input vector of the embedding layer (that is, the input vector of the first neural network model) is pre-configured as n, and the dimension of the output vector of the embedding layer is configured as m, so that the embedding layer is used to receive the input n-dimensional one-hot vector , And output the corresponding m-dimensional vector.
- other layers after the embedding layer can be designed as a conventional neural network model.
- the second layer of the first neural network model is a fully connected layer
- the output layer is a normalized layer
- the output layer is used for output classification.
- Target where the input vector dimension of the layer connected to the embedding layer is m, and the output vector dimension of the output layer of the first neural network model is the dimension of the first type of training label.
- Step 103 Input each n-dimensional one-hot vector into the second neural network model, and extract the output vector of the embedding layer for each n-dimensional one-hot vector to obtain an m-dimensional vector corresponding to each n-dimensional one-hot vector;
- the resulting model is the second neural network model, that is, the trained neural network model.
- the one-hot vector is used for dimensionality reduction.
- the specific method is to input each n-dimensional one-hot vector into the second neural network model, and the m-dimensional vector output by the embedding layer of the second neural network model is the corresponding dimensionality reduction vector.
- m is a pre-configured parameter.
- Step 104 Establish and store the correspondence between each n-dimensional one-hot vector and the corresponding m-dimensional vector. After the corresponding relationship between each n-dimensional one-hot vector and the corresponding m-dimensional vector is obtained, it is stored for use as a code for training other models.
- the method further includes the following steps:
- Step 201 Obtain a second type of training label corresponding to each input m-dimensional vector.
- Step 202 Generate multiple second-type training samples based on each m-dimensional vector and the corresponding second-type training label
- Step 203 Use a plurality of samples of the second type to train a third neural network model to obtain a fourth neural network model, that is, to obtain another classification model.
- the second type of training label is the training target of another classification model that needs to be trained
- the second type of training label is represented by a vector of a specified dimension
- the fourth neural network model is another required classification model. That is, the fourth neural network model is used to output the second type of training label of the specified dimension for each input m-dimensional vector.
- the parameter m of the first neural network model may be determined by the input vector of the third neural network model. Before training the first neural network model with multiple first-type training samples, obtain the input parameters used to configure the input vector dimension of the third neural network model, and configure the output dimension of the embedding layer of the first neural network model according to the parameters .
- the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, of course, it can also be implemented by hardware, but in many cases the former is Better implementation.
- the technical solution of this application essentially or the part that contributes to the existing technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium (such as ROM/RAM, magnetic disk, The optical disc) includes several instructions to enable a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the method described in each embodiment of the present application.
- a data processing device is also provided, which is used to implement the above-mentioned embodiment 1 and its preferred embodiments.
- a data processing device is also provided, which is used to implement the above-mentioned embodiment 1 and its preferred embodiments.
- module is a combination of software and/or hardware that can implement predetermined functions.
- the devices described in the following embodiments are preferably implemented by software, the implementation of hardware or a combination of software and hardware can also be conceived.
- FIG. 2 is a schematic diagram of a data processing device according to an embodiment of the present application. As shown in FIG. 2, the device includes: a first acquisition module 10, a first training module 20, a first execution module 30, and a second execution module 40.
- the first acquisition module is used to acquire a plurality of first-type training samples, where each first-type training sample includes an n-dimensional one-hot vector and a corresponding first-type training label; the first training module is used to use multiple Training samples of the first type to train the first neural network model to obtain the second neural network model, where the first layer of the first neural network model is an embedding layer, and the embedding layer is used to output an m-dimensional vector for an n-dimensional vector.
- the first execution module is used to input each n-dimensional one-hot vector into the second neural network model, and extract the output vector of the embedding layer for each n-dimensional one-hot vector to obtain the corresponding n-dimensional one-hot vector
- the second execution module is used to establish and store the correspondence between each n-dimensional one-hot vector and the corresponding m-dimensional vector.
- the acquisition module includes: a first acquisition unit for acquiring n n-dimensional one-hot vectors that are different from each other; a second acquisition unit for acquiring the first-type training label corresponding to each n-dimensional one-hot vector ;
- the combination unit is used to combine each n-dimensional one-hot vector with the corresponding first-type training label to obtain n first-type training samples.
- the first acquiring unit includes: a third acquiring unit, configured to acquire the identities of n objects; and an identification unit, configured to correspond the identities of the n objects through n different n-dimensional one-hot vectors in a one-to-one correspondence.
- the representation is configured to: a third acquiring unit, configured to acquire the identities of n objects; and an identification unit, configured to correspond the identities of the n objects through n different n-dimensional one-hot vectors in a one-to-one correspondence.
- the device further includes: a second acquisition module for acquiring the corresponding relationship between each n-dimensional one-hot vector and the corresponding m-dimensional vector after establishing and storing The second type of training label; a generating module, used to generate multiple second type training samples based on each m-dimensional vector and the corresponding second type of training label; the second training module, used to train using multiple second type samples
- the third neural network model, the fourth neural network model is obtained.
- the device further includes: a third acquisition module, configured to acquire input parameters for configuring the dimensions of the input vector of the third neural network model before training the first neural network model using a plurality of first-type training samples ;
- the first configuration module is used to configure the output dimensions of the embedding layer of the first neural network model according to the parameters.
- the device further includes: a fourth acquiring module, configured to acquire the input dimensions of the embedding layer used to configure the first neural network model before training the first neural network model using a plurality of first-type training samples
- the second configuration module is used to configure the output dimension of the embedding layer of the first neural network model according to the parameters.
- the second layer of the first neural network model is a fully connected layer, and the output layer is a normalized layer.
- each of the above modules can be implemented by software or hardware.
- it can be implemented in the following manner, but not limited to this: the above modules are all located in the same processor; or, the above modules are combined in any combination The forms are located in different processors.
- modules or steps of this application can be implemented by a general computing device, and they can be concentrated on a single computing device or distributed in a network composed of multiple computing devices.
- they can be implemented with program codes executable by the computing device, so that they can be stored in the storage device for execution by the computing device, and in some cases, can be executed in a different order than here.
- the embodiment of the present application also provides a non-volatile readable storage medium, the storage medium stores a computer readable instruction, wherein the computer readable instruction is set to execute any of the above method embodiments when running Steps in.
- the foregoing storage medium may include, but is not limited to: U disk, Read-Only Memory (Read-Only Memory, ROM for short), Random Access Memory (Random Access Memory, RAM for short), Various media that can store computer-readable instructions, such as mobile hard disks, magnetic disks, or optical disks.
- the transmission device 306 includes a network adapter (Network Interface Controller, NIC for short), which can be connected to other network devices through a base station to communicate with the Internet.
- the transmission device 306 may be a radio frequency (RF) module, which is used to communicate with the Internet in a wireless manner.
- RF radio frequency
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- General Health & Medical Sciences (AREA)
- Biomedical Technology (AREA)
- Biophysics (AREA)
- Computational Linguistics (AREA)
- Life Sciences & Earth Sciences (AREA)
- Evolutionary Computation (AREA)
- Artificial Intelligence (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Health & Medical Sciences (AREA)
- Image Analysis (AREA)
Abstract
本申请提供了一种数据处理方法和装置、及存储介质和电子装置,其中,该方法包括:获取多个第一类训练样本,每个第一类训练样本包括一个n维独热向量与对应的第一类训练标签;利用多个第一类训练样本训练第一神经网络模型,得到第二神经网络模型,第一神经网络模型的第一层为嵌入层,嵌入层用于针对n维的向量输出m维的向量,n>m;将每个n维独热向量输入第二神经网络模型,并提取嵌入层对于每个n维独热向量的输出向量,建立并存储每个n维独热向量与对应的m维向量之间的对应关系。通过本申请,解决了相关技术中通过独热向量来标识不同对象导致机器学习的训练过程占用内存过多、训练速度较慢的技术问题。
Description
本申请要求与2019年6月20日提交中国专利局、申请号为2019105348150、申请名称为“数据处理方法和装置、及存储介质和电子装置”的中国专利申请的优先权,其全部内容通过引用结合在申请中。
本申请涉及数据处理领域,具体而言,涉及一种数据处理方法和装置、及存储介质和电子装置。
在机器学习问题中,需要对每个对象分配唯一对应的ID,通常是通过不同的向量来标识不同的对象。发明人发现目前对对象分配唯一对应的ID的方法主要有两种:label encoder(标签编码)以及one-hot encoder(独热编码)。label encoder的具体做法是为每一个对象分配一个数值,例如,对于红、黄、绿三种颜色,分别对应的分配数值1、2、3表示,但是,label encoder会引入数值大小信息,例如,1+3平均为2,但是,红和绿的平均不是黄色,因此,label encoder并不适用于一般的场景。one-hot encoder的具体做法为,用n维独热向量来分别标识n个对象,向量中的每个元素为0或1,对于一个具体的对象,其对应的独热向量仅有一个对应位置的元素为1,其余的元素均为0,例如,对于红、黄、绿三种颜色,分别用向量【0,0,1】、【0,1,0】、【1,0,0】表示。但是,one-hot encoder会增加向量维度,如果有成百上千个对象,需要采用成百上千个维度的向量来标识,在运算时,会消耗大量的内存,使得运行速度变慢。
针对相关技术中存在的上述问题,目前尚未发现有效的解决方案。
发明内容
本申请实施例提供了一种数据处理方法和装置、及存储介质和电子装置,以至少解决现有技术中的通过独热向量来标识不同对象导致机器学习的训练过程占用内存过多、训练速度较慢的技术问题。
根据本申请的一个实施例,提供了一种数据处理方法,包括:获取多个第一类训练样本,其中,每个第一类训练样本包括一个n维独热向量与对应的第一类训练标签;利用多个第一类训练样本训练第一神经网络模型,得到第二神经网络模型,其中,第一神经网络模型的第一层为嵌入层,嵌入层用于针对n维的向量输出m维的向量,n>m;将每个n维独热向量输入第二神经网络模型,并提取嵌入层对于每个n维独热向量的输出向量,得到每个n维独热向量对应的m维向量;建立并存储每个n维独热向量与对应的m维向量之间的对应关系。
根据本申请的另一个实施例,提供了一种数据处理装置,该装置包括:第一获取模块,用于获取多个第一类训练样本,其中,每个第一类训练样本包括一个n维独热向量与对应的第一类训练标签;第一训练模块,用于利用多个第一类训练样本训练第一神经网络模型,得到第二神经网 络模型,其中,第一神经网络模型的第一层为嵌入层,嵌入层用于针对n维的向量输出m维的向量,n>m;第一执行模块,用于将每个n维独热向量输入第二神经网络模型,并提取嵌入层对于每个n维独热向量的输出向量,得到每个n维独热向量对应的m维向量;第二执行模块,用于建立并存储每个n维独热向量与对应的m维向量之间的对应关系。
根据本申请的又一个实施例,还提供了一种电子装置,包括存储器和处理器,所述存储器中存储有计算机可读指令,所述处理器被设置为运行所述计算机可读指令以执行上述任一项方法实施例中的步骤。
通过本申请,通过在任意需要通过不同的n维独热向量来标识不同对象来训练一个神经网络模型的情况下,将神经网络模型的第一层嵌入层设计为一个可以将n维向量输出为m维向量的嵌入层,并利用一些标注好训练标签的n维独热向量对该神经网络模型进行训练,使得该神经网络模型的嵌入层可以更准确地用m维向量来表达n维独热向量的信息,从而可以利用训练后的神经网络模型来对任意n维独热向量降维至m维,减少在训练过程中占用的内存,提高神经网络模型的训练速度,缩短神经网络模型的训练时间,解决了相关技术中通过独热向量来标识不同对象导致机器学习的训练过程占用内存过多、训练速度较慢的技术问题。
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:
图1是根据本申请实施例的数据处理方法的流程图;
图2是根据本申请实施例的数据处理装置的示意图;
图3是本申请实施例的一种电子装置的硬件结构框图。
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分的实施例,而不是全部的实施例,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。
需要说明的是,本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
实施例1
本实施例提供了一种数据处理方法,可以运行中移动终端、手持终端或类似的运算设备之中。运行在不同的运算设备仅是方案在执行主体上的差异,本领域人员可预见在不同运算设备中运行能够产生相同的技术效果。
本实施例提供的数据处理方法,在任意需要通过不同的n维独热向量来标识不同对象来训练一个神经网络模型的情况下,将神经网络模型的第一层嵌入层设计为一个可以将n维向量输出为m维向量的嵌入层,并利用一些标注好训练标签的n维独热向量对该神经网络模型进行训练,使得该神经网络模型的嵌入层可以更准确地用m维向量来表达n维独热向量的信息,从而可以利用训练后的神经网络模型来对任意n维独热向量降维至m维,减少在训练过程中占用的内存,提高神经网络模型的训练速度,缩短神经网络模型的训练时间,解决了相关技术中通过独热向量来标识不同对象导致机器学习的训练过程占用内存过多、训练速度较慢的技术问题。
如图1所示,本实施例提供的数据处理方法包括如下步骤:
步骤101,获取多个第一类训练样本,其中,每个第一类训练样本包括一个n维独热向量与对应的第一类训练标签;每个第一类训练样本是一个对象,n维独热向量用于通过向量标识该对象以使机器能够进行识别和处理,对应的第一类训练标签也是一个向量,用于标识该对象的一种特征或属性,该特征或属性是神经网络模型的训练目标,也即,神经网络模型用于在训练之后针对每一个用n维独热向量标识的对象来输出一个对应的第一类训练标签。例如,第i个第一类训练样本A
i为【x
i1,x
i2,……,x
in,y
i】,其中,x
i1~x
in为n维独热向量N
i的n个元素,在x
i1~x
in中,仅有一个元素为1,其余元素均为0,y
i为与n维独热向量N
i对应的第一类训练标签,用于表示n维独热向量N
i所表示的对象的类别。
可选的,在获取多个第一类训练样本时,首先,获取互不相同的n个n维独热向量,每个n维独热向量为一个对象的编码,例如,用向量【……0,1,0,……】表示北京;其次,获取每个n维独热向量对应的第一类训练标签,第一类训练标签用于训练神经网络模型实现第一类分类目标,例如,第一类训练标签可以是城市的规模,对应于北京的第一类训练标签为1,用于表示北京是一线城市;最后,组合每个n维独热向量与对应的第一类训练标签,得到n个第一类训练样本,利用第一类训练样本对模型进行训练之后,得到的模型用于对输入的城市进行分类,确定输入城市的规模。
其中,每个n维独热向量用于表示一个对象,可选的,可以先获取n个对象的标识,并将n个对象的标识通过互不相同的n个n维独热向量一一对应的表示,以得到每个n维独热向量与对应的对象标识之间的对应关系,并存储。例如,对于红色,用向量【0,0,1】表示,将“红色”与向量【0,0,1】的对应关系存储起来。利用多个第一类训练样本能够将第一神经网络模型训练为第二神经网络模型,以使得第二神经网络模型具有与第一类训练样本所对应的分类功能。例如,为了得到一个在输入城市名称之后,能够输出城市规模(分为一线、二线、三线等)的神经网络模型,获取n个第一类训练样本,以其中一个城市C为例,城市C对应的第一类训练标签为2,用于表示城市C为二线城市,城市C的名称所对应的n维独热向量为【x
i1,x
i2,……,0,……,x
in】,将城市C的n维独热向量和第一类训练标签组合起来,得到对应于城市C的第一类训练样本 为【x
i1,x
i2,……,0,……,x
in,2】。
步骤102,利用多个第一类训练样本训练第一神经网络模型,得到第二神经网络模型,其中,第一神经网络模型的第一层为嵌入层,嵌入层用于针对n维的向量输出m维的向量,其中,n>m;
在得到多个第一类训练样本之后,利用多个第一类训练样本训练第一神经网络模型,训练目标为使第一神经网络模型对于输入的n维独热向量能够得到对应的第一类训练标签。需要说明的是,本申请为了减少训练过程中占用的内存,提高训练速度,缩短训练时间,将第一神经网络模型的输入层(第一层)设计为一个输入向量维度为n、输出向量维度为m的嵌入层,其中m<n。嵌入层的输入向量(也即第一神经网络模型的输入向量)的维度被预先配置为n,嵌入层的输出向量维度被配置为m,从而,嵌入层用于接收输入的n维独热向量,并输出对应的m维向量。相应的,嵌入层之后的其它层可以设计为常规的神经网络模型的模式,例如,第一神经网络模型的第二层为全连接层、输出层为归一化层,输出层用于输出分类目标,其中,与嵌入层相连的层的输入向量维度为m,第一神经网络模型的输出层的输出向量维度为第一类训练标签的维度。
步骤103,将每个n维独热向量输入第二神经网络模型,并提取嵌入层对于每个n维独热向量的输出向量,得到每个n维独热向量对应的m维向量;
在利用多个第一类训练样本训练第一神经网络模型之后,得到的模型为第二神经网络模型,也即,训练后的神经网络模型,从而,利用第二神经网络模型对每个n维独热向量进行降维,具体的做法为,将每个n维独热向量输入第二神经网络模型,第二神经网络模型的嵌入层输出的m维向量则为对应的降维向量,其中,m为预先配置的参数。需要采用训练后的神经网络模型来对n维独热向量进行降维的原因是,需要通过第一类训练样本来对第一神经网络模型进行训练,使得该神经网络模型的嵌入曾输出的m维向量更准确的表达n维独热向量所标识的对象。举例而言,该步骤在一种应用场景中,如果存在100个待分配标记向量的城市,如果采用独热向量,需要用100维的独热向量表示,在使用本申请实施例提供的方法之后,能够将维度降为指定的维度m,例如,用10维向量标识,并且,降维后的向量能够包含其它特征,例如,如果第一类训练标签用于表示城市的规模,则降维后的向量携带有城市规模的特征信息。
步骤104,建立并存储每个n维独热向量与对应的m维向量之间的对应关系。在得到每个n维独热向量与对应的m维向量之间的对应关系之后,存储起来,以用于作为训练其它模型的编码。
可选的,在建立并存储每个n维独热向量与对应的m维向量之间的对应关系之后,如果需要训练另一种分类模型,该方法还包括如下步骤:
步骤201,获取输入的每个m维向量对应的第二类训练标签。
步骤202,基于每个m维向量与对应的第二类训练标签,生成多个第二类训练样本;
步骤203,利用多个第二类样本训练第三神经网络模型,得到第四神经网络模型,也即,得到了另一种分类模型。其中,第二类训练标签为需要训练的另一种分类模型的训练目标,第二类训练标签通过一个指定维度的向量来表示,第四神经网络模型是所需的另一种分类模型,也即,第四神经网络模型用于针对每一个输入的m维向量输出指定维度的第二类训练标签。
可选的,第一神经网络模型的参数m可以是由第三神经网络模型的输入向量决定的。在利用多个第一类训练样本训练第一神经网络模型之前,获取输入的用于配置第三神经网络模型的输入向量维度的参数,并根据参数配置第一神经网络模型的嵌入层的输出维度。
需要说明的是,在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到根据上述实施例的方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本申请各个实施例所述的方法。
实施例2
在本实施例中还提供了一种数据处理装置,该装置用于实现上述实施例1及其优选实施方式,对于本实施例中未详述的术语或实现方式,可参见实施例1中的相关说明,已经进行过说明的不再赘述。如以下所使用的术语“模块”,是可以实现预定功能的软件和/或硬件的组合。尽管以下实施例所描述的装置较佳地以软件来实现,但是硬件,或者软件和硬件的组合的实现也是可以被构想的。
图2是根据本申请实施例的数据处理装置的示意图,如图2所示,该装置包括:第一获取模块10,第一训练模块20,第一执行模块30,第二执行模块40。
其中,第一获取模块用于获取多个第一类训练样本,其中,每个第一类训练样本包括一个n维独热向量与对应的第一类训练标签;第一训练模块用于利用多个第一类训练样本训练第一神经网络模型,得到第二神经网络模型,其中,第一神经网络模型的第一层为嵌入层,嵌入层用于针对n维的向量输出m维的向量,n>m;第一执行模块用于将每个n维独热向量输入第二神经网络模型,并提取嵌入层对于每个n维独热向量的输出向量,得到每个n维独热向量对应的m维向量;第二执行模块用于建立并存储每个n维独热向量与对应的m维向量之间的对应关系。
可选的,获取模块包括:第一获取单元,用于获取互不相同的n个n维独热向量;第二获取单元,用于获取每个n维独热向量对应的第一类训练标签;组合单元,用于组合每个n维独热向量与对应的第一类训练标签,得到n个第一类训练样本。
可选的,第一获取单元包括:第三获取单元,用于获取n个对象的标识;标识单元,用于将n个对象的标识通过互不相同的n个n维独热向量一一对应的表示。
可选的,该装置还包括:第二获取模块,用于在建立并存储每个n维独热向量与对应的m维向量之间的对应关系之后,获取输入的每个m维向量对应的第二类训练标签;生成模块,用于基于每个m维向量与对应的第二类训练标签,生成多个第二类训练样本;第二训练模块,用于利用 多个第二类样本训练第三神经网络模型,得到第四神经网络模型。
可选的,该装置还包括:第三获取模块,用于在利用多个第一类训练样本训练第一神经网络模型之前,获取输入的用于配置第三神经网络模型的输入向量维度的参数;第一配置模块,用于根据参数配置第一神经网络模型的嵌入层的输出维度。
可选的,该装置还包括:第四获取模块,用于在利用多个第一类训练样本训练第一神经网络模型之前,获取输入的用于配置第一神经网络模型的嵌入层的输出维度的参数;第二配置模块,用于根据参数配置第一神经网络模型的嵌入层的输出维度。
可选的,第一神经网络模型的第二层为全连接层、输出层为归一化层。
需要说明的是,上述各个模块是可以通过软件或硬件来实现的,对于后者,可以通过以下方式实现,但不限于此:上述模块均位于同一处理器中;或者,上述各个模块以任意组合的形式分别位于不同的处理器中。
显然,本领域的技术人员应该明白,上述的本申请的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,可选地,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本申请不限制于任何特定的硬件和软件结合。
实施例3
本申请的实施例还提供了一种非易失性可读存储介质,该存储介质中存储有计算机可读指令,其中,该计算机可读指令被设置为运行时执行上述任一项方法实施例中的步骤。可选地,在本实施例中,上述存储介质可以包括但不限于:U盘、只读存储器(Read-Only Memory,简称为ROM)、随机存取存储器(Random Access Memory,简称为RAM)、移动硬盘、磁碟或者光盘等各种可以存储计算机可读指令的介质。
实施例4
本申请的实施例还提供了一种电子装置,包括存储器和处理器,该存储器中存储有计算机可读指令,该处理器被设置为运行计算机可读指令以执行上述任一项方法实施例中的步骤。
可选地,上述电子装置还可以包括传输设备以及输入输出设备,其中,该传输设备和上述处理器连接,该输入输出设备和上述处理器连接。图3是本申请实施例的一种电子装置的硬件结构框图。如图3所示,电子装置可以包括一个或多个(图3中仅示出一个)处理器302(处理器302可以包括但不限于微处理器MCU或可编程逻辑器件FPGA等的处理装置)和用于存储数据的存储器304,可选地,上述电子装置还可以包括用于通信功能的传输设备306以及输入输出设备308。本领域普通技术人员可以理解,图3所示的结构仅为示意,其并不对上述电子装置的结构造成限定。例如,电子装置还可包括比图3中所示更多或者更少的组件,或者具有与图3所示不同的配置。存储器304可用于存储计算机可读指令,例如,应用软件的软件程序以及模块,如本申请实 施例中的图像的识别方法对应的计算机可读指令,处理器302通过运行存储在存储器304内的计算机可读指令,从而执行各种功能应用以及数据处理,即实现上述的方法。存储器304可包括高速随机存储器,还可包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些实例中,存储器304可进一步包括相对于处理器302远程设置的存储器,这些远程存储器可以通过网络连接至电子装置。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。传输装置306用于经由一个网络接收或者发送数据。上述的网络具体实例可包括电子装置的通信供应商提供的无线网络。在一个实例中,传输装置306包括一个网络适配器(Network Interface Controller,简称为NIC),其可通过基站与其他网络设备相连从而可与互联网进行通讯。在一个实例中,传输装置306可以为射频(Radio Frequency,简称为RF)模块,其用于通过无线方式与互联网进行通讯。
以上所述仅为本申请的优选实施例而已,并不用于限制本申请,对于本领域的技术人员来说,本申请可以有各种更改和变化。凡在本申请的原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。
Claims (20)
- 一种数据处理方法,所述方法包括:获取多个第一类训练样本,其中,每个所述第一类训练样本包括一个n维独热向量与对应的第一类训练标签;利用所述多个第一类训练样本训练第一神经网络模型,得到第二神经网络模型,其中,所述第一神经网络模型的第一层为嵌入层,所述嵌入层用于针对n维的向量输出m维的向量,n>m;将每个所述n维独热向量输入所述第二神经网络模型,并提取所述嵌入层对于每个所述n维独热向量的输出向量,得到每个所述n维独热向量对应的m维向量;建立并存储每个所述n维独热向量与对应的m维向量之间的对应关系。
- 根据权利要求1所述的方法,所述获取多个第一类训练样本,包括:获取互不相同的n个n维独热向量;获取每个所述n维独热向量对应的第一类训练标签;组合每个所述n维独热向量与对应的第一类训练标签,得到n个第一类训练样本。
- 根据权利要求2所述的方法,所述获取互不相同的n个n维独热向量,包括:获取n个对象的标识;将所述n个对象的标识通过所述互不相同的n个n维独热向量一一对应的表示。
- 根据权利要求1所述的方法,在建立并存储每个所述n维独热向量与对应的m维向量之间的对应关系之后,所述方法还包括:获取输入的每个所述m维向量对应的第二类训练标签;基于每个所述m维向量与对应的第二类训练标签,生成多个第二类训练样本;利用所述多个第二类样本训练第三神经网络模型,得到第四神经网络模型。
- 根据权利要求4所述的方法,在利用所述多个第一类训练样本训练第一神经网络模型之前,所述方法还包括:获取输入的用于配置所述第三神经网络模型的输入向量维度的参数;根据所述参数配置所述第一神经网络模型的嵌入层的输出维度。
- 根据权利要求1所述的方法,在利用所述多个第一类训练样本训练第一神经网络模型之前,所述方法还包括:获取输入的用于配置所述第一神经网络模型的嵌入层的输出维度的参数;根据所述参数配置所述第一神经网络模型的嵌入层的输出维度。
- 根据权利要求1所述的方法,所述第一神经网络模型的第二层为全连接层、输出层为归一化层。
- 一种信息处理装置,所述装置包括:第一获取模块,用于获取多个第一类训练样本,其中,每个所述第一类训练样本包括一个n维独热向量与对应的第一类训练标签;第一训练模块,用于利用所述多个第一类训练样本训练第一神经网络模型,得到第二神经网络模型,其中,所述第一神经网络模型的第一层为嵌入层,所述嵌入层用于针对n维的向量输出m维的向量,n>m;第一执行模块,用于将每个所述n维独热向量输入所述第二神经网络模型,并提取所述嵌入层对于每个所述n维独热向量的输出向量,得到每个所述n维独热向量对应的m维向量;第二执行模块,用于建立并存储每个所述n维独热向量与对应的m维向量之间的对应关系。
- 根据权利要求8所述的装置,所述获取模块包括:第一获取单元,用于获取互不相同的n个n维独热向量;第二获取单元,用于获取每个所述n维独热向量对应的第一类训练标签;组合单元,用于组合每个所述n维独热向量与对应的第一类训练标签,得到n个第一类训练样本。
- 根据权利要求9所述的装置,所述第一获取单元包括:第三获取单元,用于获取n个对象的标识;标识单元,用于将所述n个对象的标识通过所述互不相同的n个n维独热向量一一对应的表示。
- 根据权利要求8所述的装置,所述装置还包括:第二获取模块,用于在建立并存储每个所述n维独热向量与对应的m维向量之间的对应关系之后,获取输入的每个所述m维向量对应的第二类训练标签;生成模块,用于基于每个所述m维向量与对应的第二类训练标签,生成多个第二类训练样本;第二训练模块,用于利用所述多个第二类样本训练第三神经网络模型,得到第四神经网络模型。
- 根据权利要求11所述的装置,所述装置还包括:第三获取模块,用于在利用所述多个第一类训练样本训练第一神经网络模型之前,获取输入的用于配置所述第三神经网络模型的输入向量维度的参数;第一配置模块,用于根据所述参数配置所述第一神经网络模型的嵌入层的输出维度。
- 根据权利要求8所述的装置,所述装置还包括:第四获取模块,用于在利用所述多个第一类训练样本训练第一神经网络模型之前,获取输入的用于配置所述第一神经网络模型的嵌入层的输出维度的参数;第二配置模块,用于根据所述参数配置所述第一神经网络模型的嵌入层的输出维度。
- 根据权利要求8所述的装置,所述第一神经网络模型的第二层为全连接层、输出层为归一化层。
- 一种非易失性可读存储介质,所述存储介质中存储有计算机可读指令,其中,所述计算机可读指令被设置为运行时执行数据处理方法,包括:获取多个第一类训练样本,其中,每个所述第一类训练样本包括一个n维独热向量与对应的第一类训练标签;利用所述多个第一类训练样本训练第一神经网络模型,得到第二神经网络模型,其中,所述第一神经网络模型的第一层为嵌入层,所述嵌入层用于针对n维的向量输出m维的向量,n>m;将每个所述n维独热向量输入所述第二神经网络模型,并提取所述嵌入层对于每个所述n维独热向量的输出向量,得到每个所述n维独热向量对应的m维向量;建立并存储每个所述n维独热向量与对应的m维向量之间的对应关系。
- 根据权利要求15所述的存储介质,所述计算机可读指令被设置为运行时执行所述获取多个第一类训练样本,包括:获取互不相同的n个n维独热向量;获取每个所述n维独热向量对应的第一类训练标签;组合每个所述n维独热向量与对应的第一类训练标签,得到n个第一类训练样 本。
- 根据权利要求16所述的存储介质,所述计算机可读指令被设置为运行时执行所述获取互不相同的n个n维独热向量,包括:获取n个对象的标识;将所述n个对象的标识通过所述互不相同的n个n维独热向量一一对应的表示。
- 一种电子装置,包括存储器和处理器,所述存储器中存储有计算机可读指令,所述处理器被设置为运行所述计算机可读指令以执行数据处理方法,包括:获取多个第一类训练样本,其中,每个所述第一类训练样本包括一个n维独热向量与对应的第一类训练标签;利用所述多个第一类训练样本训练第一神经网络模型,得到第二神经网络模型,其中,所述第一神经网络模型的第一层为嵌入层,所述嵌入层用于针对n维的向量输出m维的向量,n>m;将每个所述n维独热向量输入所述第二神经网络模型,并提取所述嵌入层对于每个所述n维独热向量的输出向量,得到每个所述n维独热向量对应的m维向量;建立并存储每个所述n维独热向量与对应的m维向量之间的对应关系。
- 根据权利要求18所述的电子装置,所述处理器被设置为运行所述计算机可读指令以执行所述获取多个第一类训练样本,包括:获取互不相同的n个n维独热向量;获取每个所述n维独热向量对应的第一类训练标签;组合每个所述n维独热向量与对应的第一类训练标签,得到n个第一类训练样本。
- 根据权利要求19所述的电子装置,所述处理器被设置为运行所述计算机可读指令以执行所述获取互不相同的n个n维独热向量,包括:获取n个对象的标识;将所述n个对象的标识通过所述互不相同的n个n维独热向量一一对应的表示。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910534815.0 | 2019-06-20 | ||
| CN201910534815.0A CN110414678B (zh) | 2019-06-20 | 2019-06-20 | 数据处理方法和装置、及存储介质和电子装置 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020253049A1 true WO2020253049A1 (zh) | 2020-12-24 |
Family
ID=68359398
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2019/117724 Ceased WO2020253049A1 (zh) | 2019-06-20 | 2019-11-13 | 数据处理方法和装置、及存储介质和电子装置 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN110414678B (zh) |
| WO (1) | WO2020253049A1 (zh) |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110414678B (zh) * | 2019-06-20 | 2024-07-09 | 平安科技(深圳)有限公司 | 数据处理方法和装置、及存储介质和电子装置 |
| CN115130548B (zh) * | 2022-05-24 | 2025-07-18 | 腾讯科技(深圳)有限公司 | 数据处理方法和装置、存储介质及电子设备 |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20180089152A1 (en) * | 2016-09-02 | 2018-03-29 | Digital Genius Limited | Message text labelling |
| CN108665064A (zh) * | 2017-03-31 | 2018-10-16 | 阿里巴巴集团控股有限公司 | 神经网络模型训练、对象推荐方法及装置 |
| CN110414678A (zh) * | 2019-06-20 | 2019-11-05 | 平安科技(深圳)有限公司 | 数据处理方法和装置、及存储介质和电子装置 |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| KR102801724B1 (ko) * | 2016-06-28 | 2025-04-30 | 삼성전자주식회사 | 언어 처리 방법 및 장치 |
| CN109189889B (zh) * | 2018-09-10 | 2021-03-12 | 武汉斗鱼网络科技有限公司 | 一种弹幕识别模型建立方法、装置、服务器及介质 |
| CN109460821A (zh) * | 2018-10-29 | 2019-03-12 | 重庆中科云丛科技有限公司 | 一种神经网络压缩方法、装置、电子设备及存储介质 |
-
2019
- 2019-06-20 CN CN201910534815.0A patent/CN110414678B/zh active Active
- 2019-11-13 WO PCT/CN2019/117724 patent/WO2020253049A1/zh not_active Ceased
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20180089152A1 (en) * | 2016-09-02 | 2018-03-29 | Digital Genius Limited | Message text labelling |
| CN108665064A (zh) * | 2017-03-31 | 2018-10-16 | 阿里巴巴集团控股有限公司 | 神经网络模型训练、对象推荐方法及装置 |
| CN110414678A (zh) * | 2019-06-20 | 2019-11-05 | 平安科技(深圳)有限公司 | 数据处理方法和装置、及存储介质和电子装置 |
Non-Patent Citations (1)
| Title |
|---|
| GUO, CHENG ET AL.: "Entity Embeddings of Categorical Variables", "ARXIV:1604.06737V1 [CS.LG]", 22 April 2016 (2016-04-22), XP080697333, DOI: 20200301224910A * |
Also Published As
| Publication number | Publication date |
|---|---|
| CN110414678B (zh) | 2024-07-09 |
| CN110414678A (zh) | 2019-11-05 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2025077380A1 (zh) | 数据处理方法、装置、电子设备及存储介质 | |
| CN109871845B (zh) | 证件图像提取方法及终端设备 | |
| CN107016415B (zh) | 一种基于全卷积网络的彩色图像色彩语义分类方法 | |
| CN109409377B (zh) | 图像中文字的检测方法及装置 | |
| CN111523324B (zh) | 命名实体识别模型的训练方法及装置 | |
| CN108319888B (zh) | 视频类型的识别方法及装置、计算机终端 | |
| WO2020253506A1 (zh) | 合同内容的提取方法及装置、计算机设备、存储介质 | |
| CN109885828A (zh) | 基于语言模型的词语纠错方法、装置、计算机设备及介质 | |
| CN111091106B (zh) | 图像聚类方法及装置、存储介质、电子装置 | |
| CN109918984A (zh) | 保险单号码识别方法、装置、电子设备及存储介质 | |
| CN112861894A (zh) | 一种数据流分类方法、装置及系统 | |
| CN114333014A (zh) | 训练目标检测模型的方法、目标检测方法及电子设备 | |
| WO2020253049A1 (zh) | 数据处理方法和装置、及存储介质和电子装置 | |
| CN110852082B (zh) | 同义词的确定方法及装置 | |
| CN114332564B (zh) | 车辆分类方法、设备及存储介质 | |
| CN112580750A (zh) | 图像识别方法、装置、电子设备及存储介质 | |
| CN109783678B (zh) | 一种图像搜索的方法及装置 | |
| CN114550143A (zh) | 无人车行驶中的场景识别方法及装置 | |
| CN114296861A (zh) | 前端应用风格切换方法、装置、电子设备及存储介质 | |
| CN113326888A (zh) | 标注能力信息确定方法、相关装置及计算机程序产品 | |
| CN116758373B (zh) | 深度学习模型的训练方法、图像处理方法、装置和设备 | |
| CN109165200B (zh) | 数据同步方法、装置、计算设备及计算机存储介质 | |
| CN107783856A (zh) | 一种图像处理器参数的测试方法及系统 | |
| CN114283403B (zh) | 一种图像检测方法、装置、存储介质及设备 | |
| CN117556100A (zh) | 审核标签配置策略生成方法、装置、设备及存储介质 |
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: 19933646 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: 19933646 Country of ref document: EP Kind code of ref document: A1 |