Method for generating model using training data, and electronic device
AssigneeBeijing Baidu Netcom Science Technology Co., Ltd.
InventorsHanyu Peng, Weiguo Pian, Mingming Sun, Ping Li
Life of this patent
Estimating the term…
Abstract
A method for generating a model includes: obtaining training data for training a target model, in which the training data includes labeled data and unlabeled data; obtaining a first output result by the target model based on the labeled data; obtaining a second output result by the target model based on the unlabeled data; and obtaining an optimized target model by optimizing the target model based on the first output result and the second output result.
Claims14
A method for generating a model, comprising:
- obtaining training data for training a target model, wherein the training data comprises labeled data and unlabeled data;
- obtaining a first output result by the target model based on the labeled data;
- obtaining a second output result by the target model based on the unlabeled data;
- and
- obtaining an optimized target model by optimizing the target model based on the first output result and the second output result;
- wherein obtaining the optimized target model by optimizing the target model based on the first output result and the second output result, comprises:
- calculating a first loss value based on the first output result;
- calculating a second loss value based on the second output result;
- and obtaining the optimized target model by optimizing the target model based on the first loss value and the second loss value, wherein calculating the first loss value based on the first output result, comprises:
- calculating the first loss value based on a valid number of the labeled data, the first output result and labels for the labeled data, wherein the valid number of the labeled data is calculated based on part of the labeled data satisfying a preset condition, wherein the valid number (the number of representative samples) of the labeled data is
- e
- c
- l
- =
- (
- 1
- -
- β
- N
- c
- s
- ,
- l
- )
- /
- (
- 1
- -
- β
- )
- ,
- wherein β=(Ns,l−l)/Ns,l, wherein the first loss value is
- CE
- softmax
- (
- z
- s
- ,
- l
- ,
- y
- s
- ,
- l
- )
- =
- -
- 1
- -
- β
- 1
- -
- β
- N
- c
- s
- ,
- l
-
- log
-
- (
- exp
-
- (
- z
- y
- s
- ,
- l
- )
- ∑
- i
- =
- 0
- C
-
- exp
-
- (
- z
- i
- s
- ,
- l
- )
- )
- ,
- N
- c
- s
- ,
- l
- is a number of labeled data for each category, Ns,l is a total number of the labeled data, C is a number of categories, θ is variable parameter of the target model,
- x
- i
- l
- is sample of labeled data,
- wherein the target model is configured to identify a target object, and the labeled data in the training data are images containing the target object, the label represents that the target object is present in a target object area of the image of the labeled data, the unlabeled data in the training data is an image containing the target object, and there is no label representing the target object in a target object area of the image of the unlabeled data, or
- the target model is configured to identify image categories and to identify image contents, the contents comprise:
- people, animals, plants, buildings and natural scenes, the labeled data in the training data are images that are labeled with category information, the unlabeled data in the training data are images that are not labeled with category information, or
- the target model is configured to process textual information, where the labeled data in the training dataset comprises text and corresponding labels, the unlabeled data comprises not labeled text.
An electronic device, comprising:
- 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, and when the instructions are executed by the at least one processor, the at least one processor is configured to:
- obtain training data for training a target model, wherein the training data comprises labeled data and unlabeled data;
- obtain a first output result by the target model based on the labeled data;
- obtain a second output result by the target model based on the unlabeled data;
- and
- obtain an optimized target model by optimizing the target model based on the first output result and the second output result;
- wherein obtaining the optimized target model by optimizing the target model based on the first output result and the second output result, comprises:
- calculating a first loss value based on the first output result;
- calculating a second loss value based on the second output result;
- and obtaining the optimized target model by optimizing the target model based on the first loss value and the second loss value, wherein calculating the first loss value based on the first output result, comprises:
- calculating the first loss value based on a valid number of the labeled data, the first output result and labels for the labeled data, wherein the valid number of the labeled data is calculated based on part of the labeled data satisfying a preset condition, wherein the valid number (the number of representative samples) of the labeled data is
- e
- c
- l
- =
- (
- 1
- -
- β
- N
- c
- s
- ,
- l
- )
- /
- (
- 1
- -
- β
- )
- ,
- wherein β=(Ns,l−l)/Ns,l, wherein the first loss value is
- CE
- softmax
- (
- z
- s
- ,
- l
- ,
- y
- s
- ,
- l
- )
- =
- -
- 1
- -
- β
- 1
- -
- β
- N
- c
- s
- ,
- l
-
- log
-
- (
- exp
-
- (
- z
- y
- s
- ,
- l
- )
- ∑
- i
- =
- 0
- C
-
- exp
-
- (
- z
- i
- s
- ,
- l
- )
- )
- ,
- N
- c
- s
- ,
- l
- is a number of labeled data for each category, Ns,l is a total number of the labeled data, C is a number of categories, θ is variable parameter of the target model,
- x
- i
- l
- is sample of labeled data,
- wherein the target model is configured to identify a target object, and the labeled data in the training data are images containing the target object, the label represents that the target object is present in a target object area of the image of the labeled data, the unlabeled data in the training data is an image containing the target object, and there is no label representing the target object in a target object area of the image of the unlabeled data, or
- the target model is configured to identify image categories and to identify image contents, the contents comprise:
- people, animals, plants, buildings and natural scenes, the labeled data in the training data are images that are labeled with category information, the unlabeled data in the training data are images that are not labeled with category information, or
- the target model is configured to process textual information, where the labeled data in the training dataset comprises text and corresponding labels, the unlabeled data comprises not labeled text.
A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are configured to cause a computer to implement a method for generating a model, the method comprising:
- obtaining training data for training a target model, wherein the training data comprises labeled data and unlabeled data;
- obtaining a first output result by the target model based on the labeled data;
- obtaining a second output result by the target model based on the unlabeled data;
- and
- obtaining an optimized target model by optimizing the target model based on the first output result and the second output result;
- wherein obtaining the optimized target model by optimizing the target model based on the first output result and the second output result, comprises:
- calculating a first loss value based on the first output result;
- calculating a second loss value based on the second output result;
- and obtaining the optimized target model by optimizing the target model based on the first loss value and the second loss value, wherein calculating the first loss value based on the first output result, comprises:
- calculating the first loss value based on a valid number of the labeled data, the first output result and labels for the labeled data, wherein the valid number of the labeled data is calculated based on part of the labeled data satisfying a preset condition, wherein the valid number (the number of representative samples) of the labeled data is
- e
- c
- l
- =
- (
- 1
- -
- β
- N
- c
- s
- ,
- l
- )
- /
- (
- 1
- -
- β
- )
- ,
- wherein β=(Ns,l−l)/Ns,l, wherein the first loss value is
- CE
- softmax
- (
- z
- s
- ,
- l
- ,
- y
- s
- ,
- l
- )
- =
- -
- 1
- -
- β
- 1
- -
- β
- N
- c
- s
- ,
- l
-
- log
-
- (
- exp
-
- (
- z
- y
- s
- ,
- l
- )
- ∑
- i
- =
- 0
- C
-
- exp
-
- (
- z
- i
- s
- ,
- l
- )
- )
- ,
- N
- c
- s
- ,
- l
- is a number of labeled data for each category, Ns,l is
- a total number of the labeled data, C is a number of categories, θ is variable parameter of the target model,
- x
- i
- l
- is sample of labeled data,
- wherein the target model is configured to identify a target object, and the labeled data in the training data are images containing the target object, the label represents that the target object is present in a target object area of the image of the labeled data, the unlabeled data in the training data is an image containing the target object, and there is no label representing the target object in a target object area of the image of the unlabeled data, or
- the target model is configured to identify image categories and to identify image contents, the contents comprise:
- people, animals, plants, buildings and natural scenes the labeled data in the training data are images that are labeled with category information, the unlabeled data in the training data are images that are not labeled with category information, or
- the target model is configured to process textual information, where the labeled data in the training dataset comprises text and corresponding labels, the unlabeled data comprises not labeled text.
Dependencies are inferred from the claim text.