WO2023011093A1 - Task model training method and apparatus, and electronic device and storage medium - Google Patents

Task model training method and apparatus, and electronic device and storage medium Download PDF

Info

Publication number
WO2023011093A1
WO2023011093A1 PCT/CN2022/104081 CN2022104081W WO2023011093A1 WO 2023011093 A1 WO2023011093 A1 WO 2023011093A1 CN 2022104081 W CN2022104081 W CN 2022104081W WO 2023011093 A1 WO2023011093 A1 WO 2023011093A1
Authority
WO
WIPO (PCT)
Prior art keywords
training
sample
samples
test set
test
Prior art date
Application number
PCT/CN2022/104081
Other languages
French (fr)
Chinese (zh)
Inventor
杨德将
Original Assignee
北京百度网讯科技有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 北京百度网讯科技有限公司 filed Critical 北京百度网讯科技有限公司
Publication of WO2023011093A1 publication Critical patent/WO2023011093A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • G06F18/2148Generating training patterns; Bootstrap methods, e.g. bagging or boosting characterised by the process organisation or structure, e.g. boosting cascade
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/22Matching criteria, e.g. proximity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/243Classification techniques relating to the number of classes
    • G06F18/24323Tree-organised classifiers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/04Forecasting or optimisation specially adapted for administrative or management purposes, e.g. linear programming or "cutting stock problem"
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/03Credit; Loans; Processing thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/08Insurance

Definitions

  • an electronic device including:
  • FIG. 2 is a schematic diagram according to a second embodiment of the present disclosure.
  • the original labels of the training samples in the training set and the test samples in the testing set can be removed, and a first label such as 0 is configured for all training samples in the training set to identify that these training samples are all samples in the training set. Configure a second label such as 1 for all test samples in the test set to identify that these samples are all samples in the test set.
  • the combined sample set can be randomly split to obtain a new training set and a new test set.
  • training samples with high weights are more likely to be selected to participate in training, which can make the task model more inclined to learn training samples with high weights, that is, training samples that are more similar to the test set. It can overcome the problem of training set and sample set distribution offset.

Landscapes

  • Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Artificial Intelligence (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present disclosure relates to the technical field of artificial intelligence such as machine learning and natural language processing. Provided are a task model training method and apparatus, and an electronic device and a storage medium. The specific implementation solution involves: acquiring the similarities between training samples in a training set and a test set; configuring the weights of corresponding training samples according to the similarities between the training samples in the training set and the test set; and training a task model according to the training samples in the training set and the weights of the corresponding training samples. By means of the present disclosure, the accuracy of a trained task model can be effectively improved.

Description

任务模型的训练方法、装置、电子设备及存储介质Task model training method, device, electronic equipment and storage medium
本申请要求了申请日为2021年08月04日,申请号为202110891285.2发明名称为“任务模型的训练方法、装置、电子设备及存储介质”的中国专利申请的优先权。This application claims the priority of the Chinese patent application with the application date of August 4, 2021 and the application number 202110891285.2 titled "task model training method, device, electronic equipment and storage medium".
技术领域technical field
本公开涉及计算机技术领域,具体涉及机器学习与自然语言处理等人工智能技术领域,尤其涉及一种任务模型的训练方法、装置、电子设备及存储介质。The present disclosure relates to the field of computer technology, in particular to the field of artificial intelligence technology such as machine learning and natural language processing, and in particular to a task model training method, device, electronic equipment, and storage medium.
背景技术Background technique
随着人工智能(Artificial Intelligence;AI)技术的发展,基于AI的神经网络模型可以应用在各种领域的各种场景下,且可以实现一定的任务,也可以称之为任务模型。With the development of artificial intelligence (AI) technology, AI-based neural network models can be applied in various scenarios in various fields, and can achieve certain tasks, which can also be called task models.
现有的任务模型在使用之前,需要采用训练集进行训练,并采用测试集进行测试,符合使用需求才可以投入使用。通常情况下,训练集和测试集来自于按时间切分的历史数据,相比于测试集,训练集可以采用时间更远的历史数据。有些任务模型所应用的场景中,需要1~2年甚至更久才能确定一个样本的真实标签。当遇到市场环境变化、准入策略发生调整等情况时,由于时间跨度较大,随着时间推移,样本的分布发生较大的偏移,此时按时间切分的训练集与测试集上的样本分布不一致,导致任务模型在测试集上的效果比训练集上的效果相差很多。Before the existing task model is used, it needs to be trained with the training set and tested with the test set, and it can be put into use only if it meets the usage requirements. Usually, the training set and test set come from time-sliced historical data. Compared with the test set, the training set can use historical data with a longer time. In the scenarios where some task models are applied, it takes 1 to 2 years or even longer to determine the true label of a sample. When the market environment changes, the access strategy is adjusted, etc., due to the large time span, the distribution of samples will shift greatly with the passage of time. At this time, the training set and test set divided by time Inconsistent sample distribution, resulting in a much different effect of the task model on the test set than on the training set.
发明内容Contents of the invention
本公开提供了一种任务模型的训练方法、装置、电子设备及存储介质。The disclosure provides a task model training method, device, electronic equipment and storage medium.
根据本公开的一方面,提供了一种任务模型的训练方法,其中,所述方法包括:According to an aspect of the present disclosure, a method for training a task model is provided, wherein the method includes:
获取训练集中的各训练样本与测试集的相似度;Obtain the similarity between each training sample in the training set and the test set;
根据所述训练集中的各所述训练样本与所述测试集的相似度,配置 对应的所述训练样本的权重;According to the similarity between each of the training samples in the training set and the test set, configure the weight of the corresponding training samples;
根据所述训练集中的各所述训练样本以及对应的各所述训练样本的权重,对任务模型进行训练。The task model is trained according to each of the training samples in the training set and the corresponding weight of each of the training samples.
根据本公开的另一方面,提供了一种任务模型的训练装置,其中,所述装置包括:According to another aspect of the present disclosure, a task model training device is provided, wherein the device includes:
获取模块,用于获取训练集中的各训练样本与测试集的相似度;An acquisition module, configured to acquire the similarity between each training sample in the training set and the test set;
配置模块,用于根据所述训练集中的各所述训练样本与所述测试集的相似度,配置对应的所述训练样本的权重;A configuration module, configured to configure the weight of the corresponding training samples according to the similarity between each of the training samples in the training set and the test set;
训练模块,用于根据所述训练集中的各所述训练样本以及对应的各所述训练样本的权重,对任务模型进行训练。The training module is configured to train the task model according to the training samples in the training set and the corresponding weights of the training samples.
根据本公开的再一方面,提供了一种电子设备,包括:According to still another aspect of the present disclosure, an electronic device is provided, including:
至少一个处理器;以及at least one processor; and
与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,
所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行如上所述的方面和任一可能的实现方式的方法。The memory stores instructions executable by the at least one processor, the instructions are executed by the at least one processor, so that the at least one processor can perform the above aspects and any possible implementation way of way.
根据本公开的又一方面,提供了一种存储有计算机指令的非瞬时计算机可读存储介质,所述计算机指令用于使所述计算机执行如上所述的方面和任一可能的实现方式的方法。According to yet another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions, the computer instructions are used to make the computer execute the method of the above aspect and any possible implementation manner .
根据本公开的再另一方面,提供了一种计算机程序产品,包括计算机程序,所述计算机程序在被处理器执行时实现如上所述的方面和任一可能的实现方式的方法。According to yet another aspect of the present disclosure, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the above aspect and the method of any possible implementation manner are implemented.
根据本公开的技术,能够提供一种更加高效的任务模型的训练方案,能够进一步有效地提高训练的任务模型的准确性。According to the technology of the present disclosure, a more efficient task model training scheme can be provided, and the accuracy of the trained task model can be further effectively improved.
应当理解,本部分所描述的内容并非旨在标识本公开的实施例的关键或重要特征,也不用于限制本公开的范围。本公开的其它特征将通过以下的说明书而变得容易理解。It should be understood that what is described in this section is not intended to identify key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will be readily understood through the following description.
附图说明Description of drawings
附图用于更好地理解本方案,不构成对本公开的限定。其中:The accompanying drawings are used to better understand the present solution, and do not constitute a limitation to the present disclosure. in:
图1是根据本公开第一实施例的示意图;FIG. 1 is a schematic diagram according to a first embodiment of the present disclosure;
图2是根据本公开第二实施例的示意图;FIG. 2 is a schematic diagram according to a second embodiment of the present disclosure;
图3是根据本公开第三实施例的示意图;Fig. 3 is a schematic diagram according to a third embodiment of the present disclosure;
图4是根据本公开第四实施例的示意图;FIG. 4 is a schematic diagram according to a fourth embodiment of the present disclosure;
图5是用来实现本公开实施例的任务模型的训练方法的电子设备的框图。Fig. 5 is a block diagram of an electronic device used to implement the task model training method of the embodiment of the present disclosure.
具体实施方式Detailed ways
以下结合附图对本公开的示范性实施例做出说明,其中包括本公开实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。因此,本领域普通技术人员应当认识到,可以对这里描述的实施例做出各种改变和修改,而不会背离本公开的范围和精神。同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and they should be regarded as exemplary only. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
显然,所描述的实施例是本公开一部分实施例,而不是全部的实施例。基于本公开中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的全部其他实施例,都属于本公开保护的范围。Apparently, the described embodiments are some of the embodiments of the present disclosure, but not all of them. Based on the embodiments in the present disclosure, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of the present disclosure.
需要说明的是,本公开实施例中所涉及的终端设备可以包括但不限于手机、个人数字助理(Personal Digital Assistant,PDA)、无线手持设备、平板电脑(Tablet Computer)等智能设备;显示设备可以包括但不限于个人电脑、电视等具有显示功能的设备。It should be noted that the terminal devices involved in the embodiments of the present disclosure may include but not limited to mobile phones, personal digital assistants (Personal Digital Assistant, PDA), wireless handheld devices, tablet computers (Tablet Computer) and other smart devices; Including but not limited to personal computers, televisions and other devices with display functions.
另外,本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系。In addition, the term "and/or" in this article is only an association relationship describing associated objects, which means that there may be three relationships, for example, A and/or B, which may mean: A exists alone, A and B exist at the same time, There are three cases of B alone. In addition, the character "/" in this article generally indicates that the contextual objects are an "or" relationship.
图1是根据本公开第一实施例的示意图;如图1所示,本实施例提供一种任务模型的训练方法,具体可以包括如下步骤:Fig. 1 is a schematic diagram according to the first embodiment of the present disclosure; as shown in Fig. 1 , this embodiment provides a method for training a task model, which may specifically include the following steps:
S101、获取训练集中的各训练样本与测试集的相似度;S101. Obtain the similarity between each training sample in the training set and the test set;
S102、根据训练集中的各训练样本与测试集的相似度,配置对应的训练样本的权重;S102. According to the similarity between each training sample in the training set and the test set, configure the weight of the corresponding training sample;
S103、根据训练集中的各训练样本以及对应的各训练样本的权重,对任务模型进行训练。S103. Train the task model according to each training sample in the training set and the corresponding weight of each training sample.
本实施例的任务模型的训练方法的执行主体为任务模型的训练装置, 该装置可以为电子实体,或者也可以为采用软件集成的应用。The task model training method of this embodiment is executed by a task model training device, which may be an electronic entity, or may also be an application using software integration.
本实施例的任务模型可以应用于各种领域的各种场景,例如保险领域中预测车辆是否会出险或者预测用户是否会购买某种保险产品、金融领域预测用户是否会出险信用问题、交通领域中预测用户乘坐指定交通工具的概率等等。总之,本实施例的任务模型主要可以用于实现对各种领域的各种场景下的二分类任务的预测。The task model of this embodiment can be applied to various scenarios in various fields, such as predicting whether a vehicle will be in danger in the insurance field or predicting whether a user will purchase a certain insurance product, predicting whether a user will be in danger in the financial field Predict the probability of a user taking a designated vehicle, etc. In short, the task model of this embodiment can be mainly used to realize the prediction of binary classification tasks in various scenarios in various fields.
由于训练集和测试集通常按照时间来切分,相对于训练集,测试集更靠近当前时间。但是由于随着时间的推移,训练集和测试集中的样本的特性并不一致,导致采用训练集训练的任务模型,在测试集上测试的效果并不好,而出现过拟合的问题。即本实施例的任务模型的训练方法的背景为训练集和测试集的分布不一致的问题。Since the training set and test set are usually divided according to time, the test set is closer to the current time than the training set. However, as time goes by, the characteristics of the samples in the training set and the test set are not consistent, resulting in the task model trained with the training set, the test effect on the test set is not good, and the problem of overfitting occurs. That is, the background of the training method of the task model in this embodiment is the problem that the distribution of the training set and the test set are inconsistent.
为了克服上述问题,本实施例中,首先获取训练集中的各训练样本与测试集的相似度,这样可以区分训练样本中哪些样本与测试集比较相似,哪些样本与测试集差异较大。为了后续有效地基于各训练样本与测试集的相似度训练任务模型,可以根据训练集中的各训练样本与测试集的相似度,配置对应的训练样本的权重;进而可以根据训练集中的各训练样本以及对应的各训练样本的权重,对任务模型进行倾向性地训练,即可以使得任务模型更偏向于学习权重高的、即与测试集的相似度大的训练样本。采用本实施例的训练方法,即使训练集与测试集的样本分布不均,训练的任务模型在测试集上也具有很好的测试效果,能够很好地解决样本分布偏移的问题。In order to overcome the above problems, in this embodiment, the similarity between each training sample in the training set and the test set is obtained first, so that it is possible to distinguish which samples in the training samples are relatively similar to the test set, and which samples are quite different from the test set. In order to effectively train the task model based on the similarity between each training sample and the test set, the weight of the corresponding training sample can be configured according to the similarity between each training sample in the training set and the test set; And the corresponding weights of each training sample, the task model is trained preferentially, which can make the task model more inclined to learn the training samples with high weight, that is, with a large similarity with the test set. With the training method of this embodiment, even if the samples in the training set and the test set are unevenly distributed, the trained task model has a good test effect on the test set, which can well solve the problem of sample distribution deviation.
其中,根据训练集中的各训练样本与测试集的相似度,配置对应的训练样本的权重时,可以直接将训练样本与测试集的相似度,配置为对应的训练样本的权重。或者也可以基于训练样本与测试集的相似度,再结合其他常数或者数学计算方式,为对应的训练样本的权重。例如,若训练样本与测试集的相似度大于或者等于预设的相似度阈值时,可以将该相似度乘以一个大于1的常数,作为对应的训练样本的权重。而对于训练样本与测试集的相似度小于预设的相似度阈值时,可以将该相似度乘以一个小于1的常数,作为对应的训练样本的权重,或者此时也可以取相似度的平方,作为对应的训练样本的权重。实际应用中,还可以基于训练集中的各训练样本与测试集的相似度,采用其他方式配置对应的 训练样本的权重。总之,使得相似度大于预设相似度阈值的训练样本,具有更高的权重,以使得相应的训练样本更多参与任务模型的训练;而使得相似度小于预设相似度阈值的训练样本,具有更低的权重,以使得相应的训练样本减少参与任务模型的训练。Wherein, according to the similarity between each training sample in the training set and the test set, when configuring the weight of the corresponding training sample, the similarity between the training sample and the test set can be directly configured as the weight of the corresponding training sample. Or it can also be based on the similarity between the training sample and the test set, combined with other constants or mathematical calculation methods, to be the weight of the corresponding training sample. For example, if the similarity between the training sample and the test set is greater than or equal to the preset similarity threshold, the similarity can be multiplied by a constant greater than 1 as the weight of the corresponding training sample. When the similarity between the training sample and the test set is less than the preset similarity threshold, the similarity can be multiplied by a constant less than 1 as the weight of the corresponding training sample, or the square of the similarity can also be taken at this time , as the weight of the corresponding training sample. In practical applications, based on the similarity between each training sample in the training set and the test set, other methods can be used to configure the weights of the corresponding training samples. In short, the training samples whose similarity is greater than the preset similarity threshold have higher weights, so that the corresponding training samples are more involved in the training of the task model; and the training samples whose similarity is smaller than the preset similarity threshold have Lower weight, so that the corresponding training samples are reduced to participate in the training of the task model.
本实施例的任务模型的训练方法,通过获取训练集中的各训练样本与测试集的相似度;根据训练集中的各训练样本与测试集的相似度,配置对应的训练样本的权重;根据训练集中的各训练样本以及对应的各训练样本的权重,对任务模型进行倾向性地训练,可以使得任务模型更偏向于学习权重高的、即与测试集的相似度大的训练样本,从而可以解决样本分布偏移的问题,能够有效地提高训练的任务模型的准确性。The training method of the task model of the present embodiment obtains the similarity between each training sample in the training set and the test set; configures the weight of the corresponding training sample according to the similarity between each training sample in the training set and the test set; Each training sample and the corresponding weight of each training sample, the task model is tended to be trained, which can make the task model more inclined to learn the training samples with high weight, that is, the training sample with a large similarity with the test set, so that the sample can be solved. The problem of distribution shift can effectively improve the accuracy of the trained task model.
图2是根据本公开第二实施例的示意图;如图1所示,本实施例提供一种任务模型的训练方法,具体可以包括如下步骤:Fig. 2 is a schematic diagram according to the second embodiment of the present disclosure; as shown in Fig. 1 , this embodiment provides a method for training a task model, which may specifically include the following steps:
S201、基于训练集和测试集,训练样本分类器;S201. Based on the training set and the test set, train a sample classifier;
例如,具体实施时,该步骤具体可以包括如下步骤:For example, during specific implementation, this step may specifically include the following steps:
(1)重新为训练集中的所有训练样本配置第一标签;(1) reconfiguring the first label for all training samples in the training set;
(2)重新为测试集中的所有测试样本配置第二标签,第二标签不同于第一标签;(2) reconfigure the second label for all test samples in the test set, the second label is different from the first label;
具体实施时,可以去除训练集中的训练样本和测试集中的测试样本的原始标签,为训练集中的所有训练样本配置第一标签如0,标识这些训练样本都是训练集中的样本。为测试集中的所有测试样本配置第二标签如1,标识这些样本都是测试集中的样本。During specific implementation, the original labels of the training samples in the training set and the test samples in the testing set can be removed, and a first label such as 0 is configured for all training samples in the training set to identify that these training samples are all samples in the training set. Configure a second label such as 1 for all test samples in the test set to identify that these samples are all samples in the test set.
(3)合并训练集和测试集,得到合并样本集;(3) Merge the training set and the test set to obtain the combined sample set;
具体地,将上述步骤(1)和步骤(2)重新打标签后的训练集和样本集合并,得到合并样本集。此时合并样本集中的每条样本的标签为0或者1,表示该条样本来自原来的训练集或者测试集。Specifically, the relabeled training set and sample set in the above step (1) and step (2) are combined to obtain a combined sample set. At this time, the label of each sample in the combined sample set is 0 or 1, indicating that the sample comes from the original training set or test set.
(4)基于合并样本集,获取新训练集和新测试集;(4) Obtain a new training set and a new test set based on the merged sample set;
具体地,可以对合并样本集进行随机切分,得到新训练集和新测试集。Specifically, the combined sample set can be randomly split to obtain a new training set and a new test set.
(5)基于新训练集和新测试集,构建样本分类器,使得样本分类器能够区分训练集和测试集中的样本。(5) Construct a sample classifier based on the new training set and the new test set, so that the sample classifier can distinguish the samples in the training set and the test set.
具体地,采用新训练集训练样本分类器,使得样本分类器学习识别 训练集中的样本和测试集中的样本,并且经过新测试集测试,训练的样本分类器性能良好,符合模型的建模要求。Specifically, the new training set is used to train the sample classifier, so that the sample classifier learns to identify the samples in the training set and the samples in the test set, and after the new test set test, the trained sample classifier has good performance and meets the modeling requirements of the model.
具体地,训练过程中,从新训练集中随机选择一条训练样本,输入至样本分类器中,样本分类器预测该条训练样本来自于训练集还是测试集,然后基于该训练样本的标签,该标签标识该训练样本的真实出处,即来自于训练集还是测试集,检测样本分类器的预测是否正确,若不正确,调整样本分类器的参数,使得样本分类器朝向正确预测的方向调整。采用新训练集中的数条训练样本,不断地对样本分类器进行训练,使得样本分类器在连续预设轮数的训练中,一直能准确预测样本的出处,或者一直到训练次数达到最大次数阈值,训练结束,此时确定样本分类器的参数,进而确定样本分类器。Specifically, during the training process, a training sample is randomly selected from the new training set and input to the sample classifier. The sample classifier predicts whether the training sample comes from the training set or the test set, and then based on the label of the training sample, the label identifies The real source of the training samples, that is, from the training set or the test set, is to check whether the prediction of the sample classifier is correct. If not, adjust the parameters of the sample classifier so that the sample classifier is adjusted in the direction of correct prediction. Use several training samples in the new training set to continuously train the sample classifier, so that the sample classifier can always accurately predict the source of the sample in the continuous preset number of rounds of training, or until the number of training times reaches the maximum threshold , the training is over, at this time, the parameters of the sample classifier are determined, and then the sample classifier is determined.
本实施例的该样本分类器可以为随机森林、Xgboost等等二分类模型。The sample classifier in this embodiment may be a binary classification model such as random forest, Xgboost, or the like.
S202、基于训练好的样本分类器,检测训练集和测试集是否存在样本分布偏移;若存在,执行步骤S203;否则,暂不执行操作,结束。S202. Based on the trained sample classifier, detect whether there is a sample distribution offset between the training set and the test set; if yes, perform step S203; otherwise, do not perform the operation temporarily, and end.
例如,本实施例中,是采用训练好的样本分类器来检测训练集和测试集是否存在样本分布偏移,该方式检测训练集和测试集是否存在样本分布偏移的准确性非常高。或者实际应用中,也可以采用其他方式来确定训练集和测试集存在样本分布偏移。例如,可以通过接收外部输入的训练集和测试集存在样本分布偏移的信息。For example, in this embodiment, a trained sample classifier is used to detect whether there is a sample distribution offset between the training set and the test set, and the accuracy of detecting whether there is a sample distribution offset between the training set and the test set is very high. Or in practical applications, other methods can also be used to determine that there is a sample distribution offset between the training set and the test set. For example, information of sample distribution shift can be obtained by receiving externally input training set and test set.
例如,基于训练好的样本分类器,检测训练集和测试集是否存在样本分布偏移,具体可以包括如下步骤:For example, based on the trained sample classifier, detecting whether there is a sample distribution shift between the training set and the test set may specifically include the following steps:
(a)计算训练好的样本分类器在新测试集上的曲线下的面积(area under the curve;AUC)指标;(a) Calculate the area under the curve (AUC) index of the trained sample classifier on the new test set;
其中,AUC指标具体指的是接收机工作特性(Receiver Operating Characteristic;ROC)曲线下的面积指标。AUC指标为机器学习领域的一种模型评估指标。Among them, the AUC indicator specifically refers to the area indicator under the receiver operating characteristic (Receiver Operating Characteristic; ROC) curve. The AUC indicator is a model evaluation indicator in the field of machine learning.
(b)检测AUC指标是否大于第一预设阈值、且小于或者等于第二预设阈值;若是,执行步骤(c);否则,若大于或者等于第三预设阈值、且小于或者等于第一预设阈值;执行步骤(d);(b) Detect whether the AUC index is greater than the first preset threshold and less than or equal to the second preset threshold; if so, perform step (c); otherwise, if greater than or equal to the third preset threshold and less than or equal to the first preset threshold value; perform step (d);
例如,本实施例中,可以设置第一预设阈值为0.6或者与0.6接近的 其他数值如0.59、0.61等等。第二预设阈值可以为0.9或者与0.9接近的其他数值如0.89、0.91等等。第三预设阈值可以为0.5或者接近0.5的其他数值如0.49、0.51等等。For example, in this embodiment, the first preset threshold can be set to 0.6 or other values close to 0.6, such as 0.59, 0.61 and so on. The second preset threshold may be 0.9 or other values close to 0.9, such as 0.89, 0.91 and so on. The third preset threshold may be 0.5 or other values close to 0.5, such as 0.49, 0.51 and so on.
(c)确定训练集和测试集存在样本分布偏移。该方式检测样本分布偏移的准确性非常高。(c) Determine that there is a sample distribution shift between the training set and the test set. This method is very accurate in detecting sample distribution shifts.
(d)确定训练集和测试集不存在样本分布偏移,即此时样本分类器无法有效区分训练集和测试集中的样本,此时不需要按照本实施例的方法进行倾向性地训练。(d) It is determined that there is no sample distribution shift between the training set and the test set, that is, the sample classifier cannot effectively distinguish the samples in the training set and the test set at this time, and it is not necessary to perform biased training according to the method of this embodiment.
S203、采用样本分类器,对训练集中各训练样本进行打分,以标识训练样本与测试集的相似度;S203. Use a sample classifier to score each training sample in the training set to identify the similarity between the training sample and the test set;
具体地,将训练集中的各训练样本输入至样本分类器中,该样本分类器可以输出一个大于0、且小于1的数值,以标识该输入的训练样本属于测试集还是属于训练集。由于样本分类器训练的时候,训练集的标签为0,测试集的标签为1,所以样本分类器输出的打分,还可以看作是该训练样本属于测试集的概率,能够标识训练样本与测试集的相似度。该数值越靠近于0,表示该训练样本与测试集的相似度越低,该数值越靠近于1,表示该训练样本与测试集的相似度越高。而且通过该方式得到的训练样本与测试集的相似度非常准确。Specifically, each training sample in the training set is input into the sample classifier, and the sample classifier may output a value greater than 0 and less than 1 to identify whether the input training sample belongs to the test set or the training set. When the sample classifier is trained, the label of the training set is 0, and the label of the test set is 1, so the score output by the sample classifier can also be regarded as the probability that the training sample belongs to the test set, which can identify the training sample and the test set set similarity. The closer the value is to 0, the lower the similarity between the training sample and the test set, and the closer the value is to 1, the higher the similarity between the training sample and the test set. Moreover, the similarity between the training sample and the test set obtained in this way is very accurate.
S204、将训练集中的各训练样本与测试集的相似度,配置为对应的训练样本的权重;S204. Configure the similarity between each training sample in the training set and the test set as the weight of the corresponding training sample;
该步骤中,以直接将训练集中的各训练样本与测试集的相似度,配置为对应的训练样本的权重为例,实际应用中,也可以参考上述实施例一的相关方式基于训练集中的各训练样本与测试集的相似度,配置对应的训练样本的权重。In this step, take directly configuring the similarity between each training sample in the training set and the test set as the weight of the corresponding training sample as an example. The similarity between the training sample and the test set, configure the weight of the corresponding training sample.
S205、根据训练集中的各训练样本以及对应的各训练样本的权重,对任务模型进行训练。S205. Train the task model according to each training sample in the training set and the corresponding weight of each training sample.
本实施例的训练方法,可以参考如Xgboost、Lightgbm等可进行有权重的样本建模。在构造训练集时,将上述得到的训练样本的权重作为入参weight传入。For the training method of this embodiment, reference can be made to model weighted samples such as Xgboost and Lightgbm. When constructing the training set, the weight of the training sample obtained above is passed in as the input parameter weight.
如Xgboost构造的有权重训练集,可以表示为:For example, the weighted training set constructed by Xgboost can be expressed as:
dtrain=xgb.DMatrix(data=X_train,label=y_train,weight=weight)dtrain=xgb.DMatrix(data=X_train, label=y_train, weight=weight)
如Lightgbm构造的有权重训练集,可以表示为:For example, the weighted training set constructed by Lightgbm can be expressed as:
dtrain=lgb.Dataset(data=X_train,label=y_train,weight=weight)dtrain=lgb.Dataset(data=X_train, label=y_train, weight=weight)
本实施例的根据训练集中的各训练样本以及对应的各训练样本的权重,对任务模型进行训练,具体可以包括如下几种方式:In this embodiment, according to each training sample in the training set and the weight of each corresponding training sample, the task model is trained, which may specifically include the following methods:
第一种方式:The first way:
基于各训练样本的权重,从训练集中选择参与训练的训练样本;基于选择的训练样本,对任务模型进行训练。Based on the weight of each training sample, the training samples participating in the training are selected from the training set; based on the selected training samples, the task model is trained.
该种方式中,在训练的时候,权重高的训练样本,被选择参与训练的几率更大,可以使得任务模型更加倾向于学习权重高的训练样本,即与测试集更相似的训练样本,这样可以克服训练集和样本集分布偏移的问题。In this way, during training, training samples with high weights are more likely to be selected to participate in training, which can make the task model more inclined to learn training samples with high weights, that is, training samples that are more similar to the test set. It can overcome the problem of training set and sample set distribution offset.
基于该种方式,还可以直接从训练集中筛选权重大于预设权重阈值的所有训练样本,构成训练子集,然后采用训练子集对任务模型进行训练。由于训练子集中的训练样本都是权重较高、与测试集的相似度高的样本,同样可以克服训练集和样本集分布偏移的问题。Based on this method, all training samples whose weight is greater than the preset weight threshold can be directly screened from the training set to form a training subset, and then the task model is trained using the training subset. Since the training samples in the training subset are all samples with high weight and high similarity with the test set, the problem of distribution offset between the training set and the sample set can also be overcome.
第二种方式:The second way:
从训练集中随机选择参与训练的训练样本;基于选择的训练样本以及训练样本的权重,对任务模型进行训练。Randomly select training samples to participate in the training from the training set; based on the selected training samples and the weights of the training samples, the task model is trained.
该种方式中,每条训练样本被选择参与训练的概率一样,但是在训练过程中,还是要参考各训练样本的权重,例如,可以根据每个训练样本的权重计算对应的损失函数,使得权重高的样本损失函数相对较大,可以基于损失函数调整任务模型的参数时,调整的幅度更大,可以促使任务模型更加偏向于学习权重高的训练样本,即偏向于学习与测试集相似度高的训练样本,进而可以克服训练集和测试集分布偏移的问题。In this way, the probability of each training sample being selected to participate in training is the same, but in the training process, the weight of each training sample should still be referred to. For example, the corresponding loss function can be calculated according to the weight of each training sample, so that the weight The loss function of a high sample is relatively large, and when the parameters of the task model can be adjusted based on the loss function, the adjustment range is larger, which can make the task model more biased towards training samples with high learning weights, that is, it is biased towards learning and testing. The training samples can overcome the problem of distribution offset between training set and test set.
本实施例的任务模型的训练方法,通过采用上述技术方案,可以使得任务模型更加偏向于学习与测试集相似度较高的样本,从而可以克服训练集和样本集分布偏移的问题,避免训练得到的任务模型出现过拟合的问题,能够有效地提高训练的任务模型的准确性。The training method of the task model of this embodiment, by adopting the above-mentioned technical scheme, can make the task model more inclined to learn samples with higher similarity with the test set, so as to overcome the problem of the distribution offset between the training set and the sample set, and avoid training The obtained task model has the problem of overfitting, which can effectively improve the accuracy of the trained task model.
图3是根据本公开第三实施例的示意图;如图3所示,本实施例提供一种任务模型的训练装置300,包括:Fig. 3 is a schematic diagram according to a third embodiment of the present disclosure; as shown in Fig. 3 , this embodiment provides a task model training device 300, including:
获取模块301,用于获取训练集中的各训练样本与测试集的相似度;Obtaining module 301, used to obtain the similarity between each training sample in the training set and the test set;
配置模块302,用于根据训练集中的各训练样本与测试集的相似度,配置对应的训练样本的权重;The configuration module 302 is used to configure the weight of the corresponding training samples according to the similarity between each training sample in the training set and the test set;
训练模块303,用于根据训练集中的各训练样本以及对应的各训练样本的权重,对任务模型进行训练。The training module 303 is configured to train the task model according to each training sample in the training set and the corresponding weight of each training sample.
本实施例的任务模型的训练装置300,通过采用上述模块实现任务模型的训练的实现原理以及技术效果,与上述相关方法实施例的实现相同,详细可以参考上述相关方法实施例的记载,在此不再赘述。The task model training device 300 of this embodiment uses the above-mentioned modules to realize the realization principle and technical effect of task model training, which is the same as the implementation of the above-mentioned related method embodiments. For details, please refer to the records of the above-mentioned related method embodiments, here No longer.
图4是根据本公开第四实施例的示意图;如图4所示,本实施例的任务模型的训练装置300,在上述图3所述实施例的技术方案的基础上,进一步更加详细地描述本申请的技术方案。Fig. 4 is a schematic diagram according to the fourth embodiment of the present disclosure; as shown in Fig. 4, the task model training device 300 of this embodiment is further described in more detail on the basis of the technical solution of the embodiment described in Fig. 3 above The technical scheme of the present application.
如图4所示,本实施例的任务模型的训练装置300中,还包括:As shown in Figure 4, in the training device 300 of the task model of the present embodiment, also include:
检测模块304,用于检测并确定训练集和测试集存在样本分布偏移。The detection module 304 is configured to detect and determine that there is a sample distribution deviation between the training set and the test set.
进一步可选地,如图4所示,本实施例的任务模型的训练装置300中,获取模块301,包括:Further optionally, as shown in FIG. 4, in the task model training device 300 of this embodiment, the acquisition module 301 includes:
训练单元3011,用于基于训练集和测试集,训练样本分类器;A training unit 3011, configured to train a sample classifier based on a training set and a test set;
打分单元3012,用于采用样本分类器,对训练集中各训练样本进行打分,以标识训练样本与测试集的相似度。The scoring unit 3012 is configured to use a sample classifier to score each training sample in the training set, so as to identify the similarity between the training sample and the test set.
进一步可选地,训练单元3011,用于:Further optionally, the training unit 3011 is used for:
为训练集中的所有训练样本配置第一标签;Configure the first label for all training samples in the training set;
为测试集中的所有测试样本配置第二标签,第二标签不同于第一标签;Configure a second label for all test samples in the test set, the second label is different from the first label;
合并训练集和测试集,得到合并样本集;Combine the training set and the test set to obtain the combined sample set;
基于合并样本集,获取新训练集和新测试集;Obtain a new training set and a new test set based on the combined sample set;
基于新训练集和新测试集,构建样本分类器,使得样本分类器能够区分训练集和测试集中的样本。Based on the new training set and the new test set, a sample classifier is constructed, so that the sample classifier can distinguish the samples in the training set and the test set.
进一步可选地,检测模块304,用于:Further optionally, the detection module 304 is configured to:
基于训练好的样本分类器,检测训练集和测试集是否存在样本分布偏移。Based on the trained sample classifier, detect whether there is a sample distribution shift between the training set and the test set.
进一步可选地,检测模块304,用于:Further optionally, the detection module 304 is configured to:
计算训练好的样本分类器在新测试集上的曲线下的面积指标;Calculate the area under the curve of the trained sample classifier on the new test set;
检测曲线下的面积指标是否大于第一预设阈值、且小于或者等于第 二预设阈值;Whether the area index under the detection curve is greater than the first preset threshold and less than or equal to the second preset threshold;
若是,确定训练集和测试集存在样本分布偏移。If so, it is determined that there is a sample distribution shift between the training set and the test set.
进一步可选地,训练模块303,用于:Further optionally, the training module 303 is used for:
基于各训练样本的权重,从训练集中选择参与训练的训练样本;Based on the weight of each training sample, select training samples to participate in training from the training set;
基于选择的训练样本,对任务模型进行训练。Based on the selected training samples, the task model is trained.
进一步可选地,训练模块303,用于:Further optionally, the training module 303 is used for:
从训练集中随机选择参与训练的训练样本;Randomly select training samples to participate in training from the training set;
基于选择的训练样本以及训练样本的权重,对任务模型进行训练。Based on the selected training samples and the weights of the training samples, the task model is trained.
本实施例的任务模型的训练装置300,通过采用上述模块实现任务模型的训练的实现原理以及技术效果,与上述相关方法实施例的实现相同,详细可以参考上述相关方法实施例的记载,在此不再赘述。The task model training device 300 of this embodiment uses the above-mentioned modules to realize the realization principle and technical effect of task model training, which is the same as the implementation of the above-mentioned related method embodiments. For details, please refer to the records of the above-mentioned related method embodiments, here No longer.
本公开的技术方案中,所涉及的用户个人信息的获取,存储和应用等,均符合相关法律法规的规定,且不违背公序良俗。In the technical solution of the present disclosure, the acquisition, storage and application of the user's personal information involved are in compliance with relevant laws and regulations, and do not violate public order and good customs.
根据本公开的实施例,本公开还提供了一种电子设备、一种可读存储介质和一种计算机程序产品。According to the embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.
图5示出了可以用来实施本公开的实施例的示例电子设备500的示意性框图。电子设备旨在表示各种形式的数字计算机,诸如,膝上型计算机、台式计算机、工作台、个人数字助理、服务器、刀片式服务器、大型计算机、和其它适合的计算机。电子设备还可以表示各种形式的移动装置,诸如,个人数字处理、蜂窝电话、智能电话、可穿戴设备和其它类似的计算装置。本文所示的部件、它们的连接和关系、以及它们的功能仅仅作为示例,并且不意在限制本文中描述的和/或者要求的本公开的实现。FIG. 5 shows a schematic block diagram of an example electronic device 500 that may be used to implement embodiments of the present disclosure. Electronic device is intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other suitable computers. Electronic devices may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are by way of example only, and are not intended to limit implementations of the disclosure described and/or claimed herein.
如图5所示,设备500包括计算单元501,其可以根据存储在只读存储器(ROM)502中的计算机程序或者从存储单元508加载到随机访问存储器(RAM)503中的计算机程序,来执行各种适当的动作和处理。在RAM 503中,还可存储设备500操作所需的各种程序和数据。计算单元501、ROM 502以及RAM 503通过总线504彼此相连。输入/输出(I/O)接口505也连接至总线504。As shown in FIG. 5 , the device 500 includes a computing unit 501 that can execute according to a computer program stored in a read-only memory (ROM) 502 or loaded from a storage unit 508 into a random-access memory (RAM) 503. Various appropriate actions and treatments. In the RAM 503, various programs and data necessary for the operation of the device 500 can also be stored. The computing unit 501, ROM 502, and RAM 503 are connected to each other through a bus 504. An input/output (I/O) interface 505 is also connected to the bus 504 .
设备500中的多个部件连接至I/O接口505,包括:输入单元506,例如键盘、鼠标等;输出单元507,例如各种类型的显示器、扬声器等; 存储单元508,例如磁盘、光盘等;以及通信单元509,例如网卡、调制解调器、无线通信收发机等。通信单元509允许设备500通过诸如因特网的计算机网络和/或各种电信网络与其他设备交换信息/数据。Multiple components in the device 500 are connected to the I/O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a magnetic disk, an optical disk, etc. ; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, and the like. The communication unit 509 allows the device 500 to exchange information/data with other devices over a computer network such as the Internet and/or various telecommunication networks.
计算单元501可以是各种具有处理和计算能力的通用和/或专用处理组件。计算单元501的一些示例包括但不限于中央处理单元(CPU)、图形处理单元(GPU)、各种专用的人工智能(AI)计算芯片、各种运行机器学习模型算法的计算单元、数字信号处理器(DSP)、以及任何适当的处理器、控制器、微控制器等。计算单元501执行上文所描述的各个方法和处理,例如任务模型的训练方法。例如,在一些实施例中,任务模型的训练方法可被实现为计算机软件程序,其被有形地包含于机器可读介质,例如存储单元508。在一些实施例中,计算机程序的部分或者全部可以经由ROM 502和/或通信单元509而被载入和/或安装到设备500上。当计算机程序加载到RAM 503并由计算单元501执行时,可以执行上文描述的任务模型的训练方法的一个或多个步骤。备选地,在其他实施例中,计算单元501可以通过其他任何适当的方式(例如,借助于固件)而被配置为执行任务模型的训练方法。The computing unit 501 may be various general-purpose and/or special-purpose processing components having processing and computing capabilities. Some examples of computing units 501 include, but are not limited to, central processing units (CPUs), graphics processing units (GPUs), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, digital signal processing processor (DSP), and any suitable processor, controller, microcontroller, etc. The calculation unit 501 executes various methods and processes described above, such as a task model training method. For example, in some embodiments, the task model training method may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as storage unit 508 . In some embodiments, part or all of the computer program may be loaded and/or installed on the device 500 via the ROM 502 and/or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, one or more steps of the task model training method described above can be performed. Alternatively, in other embodiments, the computing unit 501 may be configured in any other appropriate way (for example, by means of firmware) to execute the task model training method.
本文中以上描述的系统和技术的各种实施方式可以在数字电子电路系统、集成电路系统、场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、芯片上系统的系统(SOC)、负载可编程逻辑设备(CPLD)、计算机硬件、固件、软件、和/或它们的组合中实现。这些各种实施方式可以包括:实施在一个或者多个计算机程序中,该一个或者多个计算机程序可在包括至少一个可编程处理器的可编程系统上执行和/或解释,该可编程处理器可以是专用或者通用可编程处理器,可以从存储系统、至少一个输入装置、和至少一个输出装置接收数据和指令,并且将数据和指令传输至该存储系统、该至少一个输入装置、和该至少一个输出装置。Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips Implemented in a system of systems (SOC), load programmable logic device (CPLD), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include being implemented in one or more computer programs executable and/or interpreted on a programmable system including at least one programmable processor, the programmable processor Can be special-purpose or general-purpose programmable processor, can receive data and instruction from storage system, at least one input device, and at least one output device, and transmit data and instruction to this storage system, this at least one input device, and this at least one output device an output device.
用于实施本公开的方法的程序代码可以采用一个或多个编程语言的任何组合来编写。这些程序代码可以提供给通用计算机、专用计算机或其他可编程数据处理装置的处理器或控制器,使得程序代码当由处理器或控制器执行时使流程图和/或框图中所规定的功能/操作被实施。程序代码可以完全在机器上执行、部分地在机器上执行,作为独立软件包部 分地在机器上执行且部分地在远程机器上执行或完全在远程机器或服务器上执行。Program codes for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special purpose computer, or other programmable data processing devices, so that the program codes, when executed by the processor or controller, make the functions/functions specified in the flow diagrams and/or block diagrams Action is implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
在本公开的上下文中,机器可读介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的程序。机器可读介质可以是机器可读信号介质或机器可读储存介质。机器可读介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或快闪存储器)、光纤、便捷式紧凑盘只读存储器(CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media would include one or more wire-based electrical connections, portable computer discs, hard drives, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, compact disk read only memory (CD-ROM), optical storage, magnetic storage, or any suitable combination of the foregoing.
为了提供与用户的交互,可以在计算机上实施此处描述的系统和技术,该计算机具有:用于向用户显示信息的显示装置(例如,CRT(阴极射线管)或者LCD(液晶显示器)监视器);以及键盘和指向装置(例如,鼠标或者轨迹球),用户可以通过该键盘和该指向装置来将输入提供给计算机。其它种类的装置还可以用于提供与用户的交互;例如,提供给用户的反馈可以是任何形式的传感反馈(例如,视觉反馈、听觉反馈、或者触觉反馈);并且可以用任何形式(包括声输入、语音输入或者、触觉输入)来接收来自用户的输入。To provide for interaction with the user, the systems and techniques described herein can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user. ); and a keyboard and pointing device (eg, a mouse or a trackball) through which a user can provide input to the computer. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and can be in any form (including Acoustic input, speech input or, tactile input) to receive input from the user.
可以将此处描述的系统和技术实施在包括后台部件的计算系统(例如,作为数据服务器)、或者包括中间件部件的计算系统(例如,应用服务器)、或者包括前端部件的计算系统(例如,具有图形用户界面或者网络浏览器的用户计算机,用户可以通过该图形用户界面或者该网络浏览器来与此处描述的系统和技术的实施方式交互)、或者包括这种后台部件、中间件部件、或者前端部件的任何组合的计算系统中。可以通过任何形式或者介质的数字数据通信(例如,通信网络)来将系统的部件相互连接。通信网络的示例包括:局域网(LAN)、广域网(WAN)和互联网。The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., as a a user computer having a graphical user interface or web browser through which a user can interact with embodiments of the systems and techniques described herein), or including such backend components, middleware components, Or any combination of front-end components in a computing system. The components of the system can be interconnected by any form or medium of digital data communication, eg, a communication network. Examples of communication networks include: Local Area Network (LAN), Wide Area Network (WAN) and the Internet.
计算机系统可以包括客户端和服务器。客户端和服务器一般远离彼此并且通常通过通信网络进行交互。通过在相应的计算机上运行并且彼 此具有客户端-服务器关系的计算机程序来产生客户端和服务器的关系。服务器可以是云服务器,也可以为分布式系统的服务器,或者是结合了区块链的服务器。A computer system may include clients and servers. Clients and servers are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, a server of a distributed system, or a server combined with a blockchain.
应该理解,可以使用上面所示的各种形式的流程,重新排序、增加或删除步骤。例如,本发公开中记载的各步骤可以并行地执行也可以顺序地执行也可以不同的次序执行,只要能够实现本公开公开的技术方案所期望的结果,本文在此不进行限制。It should be understood that steps may be reordered, added or deleted using the various forms of flow shown above. For example, each step described in the present disclosure may be executed in parallel, sequentially, or in a different order, as long as the desired result of the technical solution disclosed in the present disclosure can be achieved, no limitation is imposed herein.
上述具体实施方式,并不构成对本公开保护范围的限制。本领域技术人员应该明白的是,根据设计要求和其他因素,可以进行各种修改、组合、子组合和替代。任何在本公开的精神和原则之内所作的修改、等同替换和改进等,均应包含在本公开保护范围之内。The specific implementation manners described above do not limit the protection scope of the present disclosure. It should be apparent to those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made depending on design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present disclosure shall be included within the protection scope of the present disclosure.

Claims (19)

  1. 一种任务模型的训练方法,其中,所述方法包括:A training method for a task model, wherein the method includes:
    获取训练集中的各训练样本与测试集的相似度;Obtain the similarity between each training sample in the training set and the test set;
    根据所述训练集中的各所述训练样本与所述测试集的相似度,配置对应的所述训练样本的权重;According to the similarity between each of the training samples in the training set and the test set, configure the weight of the corresponding training samples;
    根据所述训练集中的各所述训练样本以及对应的各所述训练样本的权重,对任务模型进行训练。The task model is trained according to each of the training samples in the training set and the corresponding weight of each of the training samples.
  2. 根据权利要求1所述的方法,其中,获取训练集中的各训练样本与测试集的相似度之前,还包括:The method according to claim 1, wherein, before obtaining the similarity between each training sample in the training set and the test set, it also includes:
    检测并确定所述训练集和所述测试集存在样本分布偏移。Detecting and determining that there is a sample distribution shift between the training set and the test set.
  3. 根据权利要求2所述的方法,其中,获取训练集中的各训练样本与测试集的相似度,包括:The method according to claim 2, wherein obtaining the degree of similarity between each training sample in the training set and the test set comprises:
    基于所述训练集和所述测试集,训练样本分类器;training a sample classifier based on the training set and the test set;
    采用所述样本分类器,对所述训练集中各所述训练样本进行打分,以标识所述训练样本与所述测试集的相似度。The sample classifier is used to score each of the training samples in the training set to identify the similarity between the training samples and the test set.
  4. 根据权利要求3所述的方法,其中,基于所述训练集和所述测试集,训练样本分类器,包括:The method according to claim 3, wherein, based on the training set and the test set, training a sample classifier comprises:
    为所述训练集中的所有训练样本配置第一标签;configuring a first label for all training samples in the training set;
    为所述测试集中的所有测试样本配置第二标签,所述第二标签不同于第一标签;configuring a second label for all test samples in the test set, the second label being different from the first label;
    合并所述训练集和所述测试集,得到合并样本集;Merging the training set and the test set to obtain a combined sample set;
    基于所述合并样本集,获取新训练集和新测试集;Obtain a new training set and a new test set based on the combined sample set;
    基于所述新训练集和所述新测试集,构建所述样本分类器,使得所述样本分类器能够区分所述训练集和所述测试集中的样本。Based on the new training set and the new test set, construct the sample classifier, so that the sample classifier can distinguish the samples in the training set and the test set.
  5. 根据权利要求4所述的方法,其中,检测并确定所述训练集和所述测试集存在样本分布偏移,包括:The method according to claim 4, wherein detecting and determining that there is a sample distribution deviation between the training set and the test set comprises:
    基于训练好的所述样本分类器,检测所述训练集和所述测试集是否存在样本分布偏移。Based on the trained sample classifier, it is detected whether there is a sample distribution deviation between the training set and the test set.
  6. 根据权利要求5所述的方法,基于训练好的所述样本分类器,检测所述训练集和所述测试集是否存在样本分布偏移,包括:The method according to claim 5, based on the trained sample classifier, detecting whether there is a sample distribution deviation in the training set and the test set, comprising:
    计算训练好的所述样本分类器针对所述新测试集的曲线下的面积ACU指标;Calculate the area under the curve ACU index of the trained sample classifier for the new test set;
    检测所述ACU指标是否大于第一预设阈值、且小于或者等于第二预设阈值;Detecting whether the ACU index is greater than a first preset threshold and less than or equal to a second preset threshold;
    若是,确定所述训练集和所述测试集存在样本分布偏移。If yes, determine that there is a sample distribution deviation between the training set and the test set.
  7. 根据权利要求1-6任一所述的方法,其中,根据所述训练集中的各所述训练样本以及对应的各所述训练样本的权重,对任务模型进行训练,包括:The method according to any one of claims 1-6, wherein, according to each of the training samples in the training set and the corresponding weights of each of the training samples, training the task model includes:
    基于各所述训练样本的权重,从所述训练集中选择参与训练的训练样本;selecting training samples to participate in training from the training set based on the weight of each of the training samples;
    基于选择的所述训练样本,对所述任务模型进行训练。The task model is trained based on the selected training samples.
  8. 根据权利要求1-6任一所述的方法,其中,根据所述训练集中的各所述训练样本以及对应的各所述训练样本的权重,对任务模型进行训练,包括:The method according to any one of claims 1-6, wherein, according to each of the training samples in the training set and the corresponding weights of each of the training samples, training the task model includes:
    从所述训练集中随机选择参与训练的训练样本;Randomly select training samples to participate in training from the training set;
    基于选择的所述训练样本以及所述训练样本的权重,对所述任务模型进行训练。The task model is trained based on the selected training samples and the weights of the training samples.
  9. 一种任务模型的训练装置,其中,所述装置包括:A training device for a task model, wherein the device includes:
    获取模块,用于获取训练集中的各训练样本与测试集的相似度;An acquisition module, configured to acquire the similarity between each training sample in the training set and the test set;
    配置模块,用于根据所述训练集中的各所述训练样本与所述测试集的相似度,配置对应的所述训练样本的权重;A configuration module, configured to configure the weight of the corresponding training samples according to the similarity between each of the training samples in the training set and the test set;
    训练模块,用于根据所述训练集中的各所述训练样本以及对应的各所述训练样本的权重,对任务模型进行训练。The training module is configured to train the task model according to the training samples in the training set and the corresponding weights of the training samples.
  10. 根据权利要求9所述的装置,其中,所述装置还包括:The device according to claim 9, wherein the device further comprises:
    检测模块,用于检测并确定所述训练集和所述测试集存在样本分布偏移。A detection module, configured to detect and determine that there is a sample distribution deviation between the training set and the test set.
  11. 根据权利要求10所述的装置,其中,所述获取模块,包括:The device according to claim 10, wherein the acquiring module comprises:
    训练单元,用于基于所述训练集和所述测试集,训练样本分类器;a training unit, configured to train a sample classifier based on the training set and the test set;
    打分单元,用于采用所述样本分类器,对所述训练集中各所述训练样本进行打分,以标识所述训练样本与所述测试集的相似度。The scoring unit is configured to use the sample classifier to score each of the training samples in the training set, so as to identify the similarity between the training samples and the test set.
  12. 根据权利要求11所述的装置,其中,所述训练单元,用于:The device according to claim 11, wherein the training unit is configured to:
    为所述训练集中的所有训练样本配置第一标签;configuring a first label for all training samples in the training set;
    为所述测试集中的所有测试样本配置第二标签,所述第二标签不同于第一标签;configuring a second label for all test samples in the test set, the second label being different from the first label;
    合并所述训练集和所述测试集,得到合并样本集;Merging the training set and the test set to obtain a combined sample set;
    基于所述合并样本集,获取新训练集和新测试集;Obtain a new training set and a new test set based on the combined sample set;
    基于所述新训练集和所述新测试集,构建所述样本分类器,使得所述样本分类器能够区分所述训练集和所述测试集中的样本。Based on the new training set and the new test set, construct the sample classifier, so that the sample classifier can distinguish the samples in the training set and the test set.
  13. 根据权利要求12所述的装置,其中,所述检测模块,用于:The device according to claim 12, wherein the detection module is configured to:
    基于训练好的所述样本分类器,检测所述训练集和所述测试集是否存在样本分布偏移。Based on the trained sample classifier, it is detected whether there is a sample distribution deviation between the training set and the test set.
  14. 根据权利要求13所述的装置,所述检测模块,用于:The device according to claim 13, the detection module is configured to:
    计算训练好的所述样本分类器针对所述新测试集的曲线下的面积ACU指标;Calculate the area under the curve ACU index of the trained sample classifier for the new test set;
    检测所述ACU指标是否大于第一预设阈值、且小于或者等于第二预设阈值;Detecting whether the ACU index is greater than a first preset threshold and less than or equal to a second preset threshold;
    若是,确定所述训练集和所述测试集存在样本分布偏移。If yes, determine that there is a sample distribution deviation between the training set and the test set.
  15. 根据权利要求9-14任一所述的装置,其中,所述训练模块,用于:The device according to any one of claims 9-14, wherein the training module is configured to:
    基于各所述训练样本的权重,从所述训练集中选择参与训练的训练样本;selecting training samples to participate in training from the training set based on the weight of each of the training samples;
    基于选择的所述训练样本,对所述任务模型进行训练。The task model is trained based on the selected training samples.
  16. 根据权利要求9-14任一所述的装置,其中,所述训练模块,用于:The device according to any one of claims 9-14, wherein the training module is configured to:
    从所述训练集中随机选择参与训练的训练样本;Randomly select training samples to participate in training from the training set;
    基于选择的所述训练样本以及所述训练样本的权重,对所述任务模型进行训练。The task model is trained based on the selected training samples and the weights of the training samples.
  17. 一种电子设备,包括:An electronic device comprising:
    至少一个处理器;以及at least one processor; and
    与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,
    所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行权利要 求1-8中任一项所述的方法。The memory stores instructions executable by the at least one processor, the instructions are executed by the at least one processor, so that the at least one processor can perform any one of claims 1-8. Methods.
  18. 一种存储有计算机指令的非瞬时计算机可读存储介质,其中,所述计算机指令用于使所述计算机执行根据权利要求1-8中任一项所述的方法。A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the method according to any one of claims 1-8.
  19. 一种计算机程序产品,包括计算机程序,所述计算机程序在被处理器执行时实现根据权利要求1-8中任一项所述的方法。A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-8.
PCT/CN2022/104081 2021-08-04 2022-07-06 Task model training method and apparatus, and electronic device and storage medium WO2023011093A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110891285.2A CN113807391A (en) 2021-08-04 2021-08-04 Task model training method and device, electronic equipment and storage medium
CN202110891285.2 2021-08-04

Publications (1)

Publication Number Publication Date
WO2023011093A1 true WO2023011093A1 (en) 2023-02-09

Family

ID=78893267

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/104081 WO2023011093A1 (en) 2021-08-04 2022-07-06 Task model training method and apparatus, and electronic device and storage medium

Country Status (2)

Country Link
CN (1) CN113807391A (en)
WO (1) WO2023011093A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113807391A (en) * 2021-08-04 2021-12-17 北京百度网讯科技有限公司 Task model training method and device, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160078359A1 (en) * 2014-09-12 2016-03-17 Xerox Corporation System for domain adaptation with a domain-specific class means classifier
CN105574547A (en) * 2015-12-22 2016-05-11 北京奇虎科技有限公司 Integrated learning method and device adapted to weight of dynamically adjustable base classifier
CN110515836A (en) * 2019-07-31 2019-11-29 杭州电子科技大学 A kind of Weighted naive bayes method of software-oriented failure prediction
CN113807391A (en) * 2021-08-04 2021-12-17 北京百度网讯科技有限公司 Task model training method and device, electronic equipment and storage medium
CN114187979A (en) * 2022-02-15 2022-03-15 北京晶泰科技有限公司 Data processing, model training, molecular prediction and screening method and device thereof

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160078359A1 (en) * 2014-09-12 2016-03-17 Xerox Corporation System for domain adaptation with a domain-specific class means classifier
CN105574547A (en) * 2015-12-22 2016-05-11 北京奇虎科技有限公司 Integrated learning method and device adapted to weight of dynamically adjustable base classifier
CN110515836A (en) * 2019-07-31 2019-11-29 杭州电子科技大学 A kind of Weighted naive bayes method of software-oriented failure prediction
CN113807391A (en) * 2021-08-04 2021-12-17 北京百度网讯科技有限公司 Task model training method and device, electronic equipment and storage medium
CN114187979A (en) * 2022-02-15 2022-03-15 北京晶泰科技有限公司 Data processing, model training, molecular prediction and screening method and device thereof

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
WANG LINGDI, XU HUA: "An Adaptive Ensemble Algorithm Based on Clustering and AdaBoost", JILIN DAXUE XUEBAO (LIXUE BAN) - UNIVERSITY. JOURNAL (SCIENCE EDITION), JILIN DAXUE CHUBANSHE, CHANGCHUN, CN, vol. 56, no. 4, 26 July 2018 (2018-07-26), CN , pages 917 - 924, XP093031569, ISSN: 1671-5489, DOI: 10.13413/j.cnki.jdxblxb.2018.04.25 *
ZENG XI, LING-JUN KONG, WEN-JIE ZHAN: "Spectral Reflectance Reconstruction Based on Vector Angle Sample Selection", BAOZHUANG GONGCHENG - PACKAGING ENGINEERING, ZHONGGUO BINGQI GONGYE DI-59 YANJIUSUO, CN, vol. 39, no. 15, 10 August 2018 (2018-08-10), CN , pages 216 - 220, XP093031576, ISSN: 1001-3563, DOI: 10.19554/j.cnki.1001-3563.2018.15.034 *

Also Published As

Publication number Publication date
CN113807391A (en) 2021-12-17

Similar Documents

Publication Publication Date Title
US20210295100A1 (en) Data processing method and apparatus, electronic device, and storage medium
US20220374678A1 (en) Method for determining pre-training model, electronic device and storage medium
CN115082920A (en) Deep learning model training method, image processing method and device
CN113657483A (en) Model training method, target detection method, device, equipment and storage medium
WO2023011093A1 (en) Task model training method and apparatus, and electronic device and storage medium
CN113392920B (en) Method, apparatus, device, medium, and program product for generating cheating prediction model
CN114821063A (en) Semantic segmentation model generation method and device and image processing method
CN114462598A (en) Deep learning model training method, and method and device for determining data category
CN116910573A (en) Training method and device for abnormality diagnosis model, electronic equipment and storage medium
CN116342164A (en) Target user group positioning method and device, electronic equipment and storage medium
CN114692778A (en) Multi-modal sample set generation method, training method and device for intelligent inspection
CN114492364A (en) Same vulnerability judgment method, device, equipment and storage medium
CN114417822A (en) Method, apparatus, device, medium and product for generating model interpretation information
CN114511022A (en) Feature screening, behavior recognition model training and abnormal behavior recognition method and device
CN114067805A (en) Method and device for training voiceprint recognition model and voiceprint recognition
CN114238611A (en) Method, apparatus, device and storage medium for outputting information
CN114021642A (en) Data processing method and device, electronic equipment and storage medium
CN113806541A (en) Emotion classification method and emotion classification model training method and device
CN111325350A (en) Suspicious tissue discovery system and method
US20240037410A1 (en) Method for model aggregation in federated learning, server, device, and storage medium
CN114844889B (en) Video processing model updating method and device, electronic equipment and storage medium
CN113391989B (en) Program evaluation method, device, equipment, medium and program product
CN114066278B (en) Method, apparatus, medium, and program product for evaluating article recall
CN113408664B (en) Training method, classification method, device, electronic equipment and storage medium
US20230004774A1 (en) Method and apparatus for generating node representation, electronic device and readable storage medium

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE