CN114492601A - Resource classification model training method and device, electronic equipment and storage medium - Google Patents

Resource classification model training method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114492601A
CN114492601A CN202210023291.0A CN202210023291A CN114492601A CN 114492601 A CN114492601 A CN 114492601A CN 202210023291 A CN202210023291 A CN 202210023291A CN 114492601 A CN114492601 A CN 114492601A
Authority
CN
China
Prior art keywords
classification
sample
resource
task
training
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.)
Pending
Application number
CN202210023291.0A
Other languages
Chinese (zh)
Inventor
申世伟
吴翔宇
杨帆
李家宏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology Co Ltd
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 Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202210023291.0A priority Critical patent/CN114492601A/en
Publication of CN114492601A publication Critical patent/CN114492601A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • 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/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches

Abstract

The disclosure relates to a method and a device for training a resource classification model, electronic equipment and a storage medium, relates to the technical field of computers, and at least solves the problem that the structure of the resource classification model in the related technology is complex. The method comprises the following steps: acquiring a training sample of each resource classification task in a plurality of resource classification tasks; the training samples comprise sample resources of corresponding resource classification tasks, classification task identifiers of the corresponding resource classification tasks and label information; inputting a training sample of each resource classification task in a plurality of resource classification tasks into a neural network model to obtain a classification prediction result corresponding to the training sample; updating parameters of the neural network model according to the classification prediction result corresponding to the training sample and the label information in the training sample; and performing iterative training on the updated neural network model until the neural network model meets the model convergence condition, and determining the converged neural network model as a first resource classification model.

Description

Resource classification model training method and device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and an apparatus for training a resource classification model, an electronic device, and a storage medium.
Background
In a natural language processing task, a situation that a plurality of classification tasks learn in parallel often occurs, that is, a plurality of classification learning tasks are fused into a neural network model, and the neural network model is trained into a resource classification model. In the related art, when a resource classification model is trained, different output networks are usually configured for different tasks to distinguish the different tasks, which results in a very complex structure of the finally obtained resource classification model.
Disclosure of Invention
The present disclosure provides a method and an apparatus for training a resource classification model, an electronic device, and a storage medium, so as to at least solve the problem of complex structure of the resource classification model in the related art. The technical scheme of the disclosure is as follows:
according to a first aspect of the embodiments of the present disclosure, there is provided a method for training a resource classification model, including: acquiring a training sample of each resource classification task in a plurality of resource classification tasks; the training samples comprise sample resources of corresponding resource classification tasks, classification task identifiers of the corresponding resource classification tasks and label information, and the label information is used for indicating reference classes of the sample resources in the corresponding training samples; inputting a training sample of each resource classification task in a plurality of resource classification tasks into a neural network model to obtain a classification prediction result corresponding to the training sample; the classification prediction result is determined according to the content characteristics of sample resources in the training sample and the classification rule of the task type corresponding to the classification task identification; updating parameters of the neural network model according to the classification prediction result corresponding to the training sample and the label information in the training sample; and performing iterative training on the updated neural network model until the neural network model meets the model convergence condition, and determining the converged neural network model as a first resource classification model.
In a possible implementation manner, inputting a training sample of each resource classification task in a plurality of resource classification tasks into a neural network model to obtain a classification prediction result corresponding to the training sample, including: inputting the training sample of each resource classification task into a neural network model, and executing the following steps through the neural network model: obtaining a content feature vector according to the sample resource of each resource classification task, wherein the content feature vector is used for representing the content feature of the sample resource of each resource classification task; obtaining a condition feature vector according to the classification task identifier of each resource classification task, wherein the condition feature vector is used for representing the classification rule of the classification task identifier of each resource classification task corresponding to the task type; the dimension of the conditional feature vector is the same as the dimension of the content feature vector; and determining a classification prediction result corresponding to the training sample according to the content feature vector and the condition feature vector.
In another possible implementation, the obtaining of the content feature vector according to the sample resource of each resource classification task includes: inputting a plurality of sample images into an image classification network for feature extraction to obtain a feature vector of each sample image; and inputting the feature vector of each sample image into the attention network, and performing feature interaction between every two sample images to obtain a content feature vector.
In another possible implementation manner, obtaining the conditional feature vector according to the classification task identifier of each resource classification task includes: determining a target line number according to the classification task identifier; and determining the content corresponding to the target line number in the preset dictionary matrix as a conditional feature vector.
In another possible implementation, the determining, by the neural network model, a classification prediction result corresponding to the training sample according to the content feature vector and the condition feature vector includes: executing a multi-head self-attention mechanism on the content characteristic vectors and the condition characteristic vectors to obtain joint vectors of the training samples; and inputting the joint vector into a multilayer deep neural network to obtain a classification prediction result corresponding to the training sample.
In another possible implementation, the determining, by the neural network model, a classification prediction result corresponding to the training sample according to the content feature vector and the condition feature vector includes: splicing the content characteristic vector and the condition characteristic vector to obtain a joint vector of the training sample; and inputting the joint vector into a multilayer deep neural network to obtain a classification prediction result corresponding to the training sample.
In another possible embodiment, the method further comprises: performing multi-task combined training on the neural network model according to the training sample of each resource classification task and the training sample of the newly added resource classification task to obtain a second resource classification model; the training samples of the newly added resource classification tasks comprise sample resources of the newly added resource classification tasks, classification task identifiers of the newly added resource classification tasks and newly added label information, and the second resource classification model is used for executing a plurality of resource classification tasks and the newly added resource classification tasks.
In another possible embodiment, the method further comprises: obtaining a prediction sample, wherein the prediction sample comprises a prediction sample image and a prediction task identifier; and inputting the prediction sample image and the prediction task identifier into the first resource classification model to obtain a prediction result.
In another possible implementation, inputting the prediction sample image and the prediction task identifier into the first resource classification model to obtain a prediction result, including: inputting the prediction sample image and the prediction task identifier into a first resource classification model to obtain prediction probability; and under the condition that the prediction probability is greater than or equal to a preset threshold value, determining the prediction sample as a positive sample of the task type corresponding to the prediction task identifier.
In another possible implementation, the obtaining a training sample of each resource classification task in a plurality of resource classification tasks includes: acquiring a training sample video of each resource classification task and label information corresponding to the training sample video, and determining a classification task identifier of each resource classification task; the following steps are carried out aiming at the training sample video of each resource classification task: acquiring a global image of a first preset frame number of a training sample video; and carrying out object detection on each frame of global image to obtain a local image with a second preset frame number, wherein the local image comprises an object part area, and the global image with the first preset frame number and the local image with the second preset frame number are sample resources of each resource classification task.
In another possible embodiment, the method further comprises: determining the number of matrix rows according to the number of tasks corresponding to the resource classification tasks; determining the number of matrix columns according to the dimension of a preset content feature vector; and obtaining a dictionary matrix according to the matrix row number, the matrix column number and a preset model.
In another possible embodiment, the method further comprises: updating a dictionary matrix according to a classification prediction result corresponding to a training sample and label information in the training sample in each iteration training process of the neural network model; and the updated dictionary matrix is used for determining the condition characteristic vector in the next iteration training of the neural network model.
According to a second aspect of the embodiments of the present disclosure, there is provided a training apparatus for a resource classification model, including: an acquisition module configured to perform acquiring a training sample for each of a plurality of resource classification tasks; the training samples comprise sample resources of corresponding resource classification tasks, classification task identifiers of the corresponding resource classification tasks and label information, and the label information is used for indicating reference classes of the sample resources in the corresponding training samples; the training module is configured to input a training sample of each resource classification task in the plurality of resource classification tasks into the neural network model to obtain a classification prediction result corresponding to the training sample; the classification prediction result is determined according to the content characteristics of sample resources in the training sample and the classification rule of the task type corresponding to the classification task identification; the updating module is configured to update parameters of the neural network model according to the classification prediction result corresponding to the training sample and the label information in the training sample; and the iteration module is configured to execute iterative training on the updated neural network model until the neural network model meets the model convergence condition, and determine that the converged neural network model is the first resource classification model.
In one possible embodiment, the training module is specifically configured to perform: inputting the training sample of each resource classification task into a neural network model, and executing the following steps through the neural network model: obtaining a content feature vector according to the sample resource of each resource classification task, wherein the content feature vector is used for representing the content feature of the sample resource of each resource classification task; obtaining a condition feature vector according to the classification task identifier of each resource classification task, wherein the condition feature vector is used for representing the classification rule of the classification task identifier of each sample resource task corresponding to the task type; the dimension of the conditional feature vector is the same as the dimension of the content feature vector; and determining a classification prediction result corresponding to the training sample according to the content feature vector and the condition feature vector.
In another possible embodiment, the sample resource includes a plurality of sample images, the neural network model includes at least an image classification network and a self-attention network, and the training module is specifically configured to perform: inputting a plurality of sample images into an image classification network for feature extraction to obtain a feature vector of each sample image; and inputting the feature vector of each sample image into the attention network, and performing feature interaction between every two sample images to obtain a content feature vector.
In another possible embodiment, the training module is specifically configured to perform: determining a target line number according to the classification task identifier; and determining the content corresponding to the target line number in the preset dictionary matrix as a conditional feature vector.
In another possible embodiment, the neural network model includes a multi-layer deep neural network, and the training module is specifically configured to perform: executing a multi-head self-attention mechanism on the content characteristic vectors and the condition characteristic vectors to obtain joint vectors of the training samples; and inputting the joint vector into a multilayer deep neural network to obtain a classification prediction result corresponding to the training sample.
In another possible embodiment, the neural network model includes a multi-layer deep neural network, and the training module is specifically configured to perform: splicing the content characteristic vector and the condition characteristic vector to obtain a joint vector of the training sample; and inputting the joint vector into a multilayer deep neural network to obtain a classification prediction result corresponding to the training sample.
In another possible embodiment, the training module is further configured to perform: performing multi-task combined training on the neural network model according to the training sample of each resource classification task and the training sample of the newly added resource classification task to obtain a second resource classification model; the training samples of the newly added resource classification tasks comprise sample resources of the newly added resource classification tasks, classification task identifiers of the newly added resource classification tasks and newly added label information, and the second resource classification model is used for executing a plurality of resource classification tasks and the newly added resource classification tasks.
In another possible implementation, the apparatus further includes a prediction module configured to perform: obtaining a prediction sample, wherein the prediction sample comprises a prediction sample image and a prediction task identifier; and inputting the prediction sample image and the prediction task identifier into the first resource classification model to obtain a prediction result.
In another possible embodiment, the prediction module is specifically configured to perform: inputting the prediction sample image and the prediction task identifier into a first resource classification model to obtain prediction probability; and under the condition that the prediction probability is greater than or equal to a preset threshold value, determining the prediction sample as a positive sample of the task type corresponding to the prediction task identifier.
In another possible implementation, the obtaining module is specifically configured to perform: acquiring a training sample video of each resource classification task and label information corresponding to the training sample video, and determining a classification task identifier of each resource classification task; the following steps are carried out aiming at the training sample video of each resource classification task: acquiring a global image of a first preset frame number of a training sample video; and carrying out object detection on each frame of global image to obtain a local image with a second preset frame number, wherein the local image comprises an object part area, and the global image with the first preset frame number and the local image with the second preset frame number are sample resources of each resource classification task.
In another possible implementation, the apparatus further includes a configuration module configured to perform: determining the number of matrix rows according to the number of tasks corresponding to the resource classification tasks; determining the number of matrix columns according to the dimension of a preset content feature vector; and obtaining a dictionary matrix according to the matrix row number, the matrix column number and a preset model.
In another possible implementation, the configuration module is further configured to perform: updating a dictionary matrix according to a classification prediction result corresponding to a training sample and label information in the training sample in each iteration training process of the neural network model; and the updated dictionary matrix is used for determining the condition characteristic vector in the next iteration training of the neural network model.
According to a third aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the method of the first aspect and any of its possible embodiments described above.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium, in which instructions, when executed by a processor of an electronic device, enable the electronic device to perform the method of any one of the above-mentioned first aspects and any one of its possible implementations.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer program product comprising computer instructions which, when run on an electronic device, cause the electronic device to perform the method of the first aspect and any of its possible implementations.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects: by configuring sample resources and classification task identifiers for training samples of each resource classification task and simultaneously inputting the sample resources and the classification task identifiers into the neural network, classification tasks of different sample resources are distinguished through different classification task identifiers, so that different output networks do not need to be configured for different classification tasks, and the technical problem that a model structure is complex in the prior art is solved. In addition, the neural network model is jointly optimized through a plurality of classification prediction results of a plurality of resource classification tasks, and the prediction effect of the model can be improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
FIG. 1 is a flow diagram illustrating a method of training a resource classification model in accordance with an exemplary embodiment;
FIG. 2 is a flow diagram illustrating another method of training a resource classification model in accordance with an exemplary embodiment;
FIG. 3 is a flow diagram illustrating another method of training a resource classification model in accordance with an exemplary embodiment;
FIG. 4 is a block diagram illustrating a method of training a resource classification model in accordance with an exemplary embodiment;
FIG. 5 is a block diagram illustrating a resource classification model training apparatus in accordance with an exemplary embodiment;
FIG. 6 is a block diagram illustrating an electronic device apparatus in accordance with an example embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
Before describing the resource classification model training method provided by the present disclosure in detail, the application scenario and implementation environment related to the present disclosure are briefly described.
First, a brief description is given of an application scenario to which the present disclosure relates.
In the related art, since different tasks or the same task in different areas need to be trained as multiple resource classification tasks, for example, a model is trained separately for each resource classification task, or multiple resource classification tasks are directly merged into a neural network model. Therefore, when the resource classification models of multiple resource classification tasks are trained, different output networks are usually configured for different tasks to distinguish the different tasks, which results in a very complex structure of the finally obtained resource classification model.
Specifically, when the resource classification model is trained, a sharing mechanism is mainly used for training, for example, a hard sharing mode of parameters, a soft sharing mode of parameters, a hierarchical sharing mode, a sharing-private mode, and the like are used for training.
In order to solve the above problems, the present disclosure provides a method for training a resource classification model, which configures sample resources and classification task identifiers for a training sample of each resource classification task, and inputs the sample resources and the classification task identifiers to a neural network at the same time, so as to distinguish classification tasks of different sample resources by using different classification task identifiers, thereby avoiding configuring different output networks for different classification tasks, and solving the technical problem of complex model structure in the prior art. In addition, the neural network model is jointly optimized through a plurality of classification prediction results of a plurality of resource classification tasks, and the prediction effect of the model can be improved.
Next, the following briefly describes an implementation environment (implementation architecture) related to the present disclosure.
The resource classification model training method provided by the embodiment of the disclosure can be applied to electronic equipment. The electronic device may be a terminal device or a server. The terminal device can be a smart phone, a tablet computer, a palm computer, a vehicle-mounted terminal, a desktop computer, a notebook computer and the like. The server may be any one server or server cluster, and the disclosure is not limited thereto.
In addition, it should be noted that the training sample information (including but not limited to training sample video information, image information of the training sample, classification task identifier, etc.) referred to in the present disclosure is information authorized by the user or sufficiently authorized by each party.
For the sake of understanding, the task processing method provided by the present disclosure is specifically described below with reference to the accompanying drawings.
FIG. 1 is a flow diagram illustrating a method of training a resource classification model for an electronic device, according to an example embodiment. As shown in fig. 1, the method for training the resource classification model includes the following steps:
in S101, a training sample of each resource classification task in a plurality of resource classification tasks is obtained; the training samples comprise sample resources of the corresponding resource classification tasks, classification task identifiers of the corresponding resource classification tasks and label information.
Wherein the label information is used to indicate a reference class of the training sample of each resource classification task.
Optionally, the reference category includes positive or negative examples.
In one embodiment, the class of training samples for each resource classification task includes a positive sample and a negative sample. That is, each resource classification task includes training examples of a positive example class and training examples of a negative example class. The training samples of the positive sample category comprise sample resources of corresponding resource classification tasks, classification task identifiers of the corresponding resource classification tasks and label information, and the label information is used for indicating that the training samples of the corresponding resource classification tasks are positive samples. The training samples of the negative sample category comprise sample resources of corresponding resource classification tasks, classification task identifiers of the corresponding resource classification tasks and label information, and the label information is used for indicating that the training samples of the corresponding resource classification tasks are negative samples.
In one embodiment, the plurality of resource classification tasks include a plurality of tasks with different task types, for example, a task (referred to as a first task) for identifying whether a sample resource has first content, a task (referred to as a second task) for identifying whether a sample resource has second content, and a task (referred to as a third task) for identifying whether a sample resource has third content, which belong to different task types. The first content, the second content and the third content are different contents.
In another embodiment, the plurality of resource classification tasks include tasks in different geographic areas, that is, one resource classification task is established for each of the different geographic areas. Wherein, the tasks in different geographic areas comprise tasks with the same task type in different geographic areas.
Optionally, different resource classification tasks have different training samples.
In S102, a training sample of each resource classification task in the plurality of resource classification tasks is input to the neural network model, so as to obtain a classification prediction result corresponding to the training sample.
And determining the classification prediction result according to the content characteristics of the sample resources in the training sample and the classification rule of the task type corresponding to the classification task identification.
Optionally, different task types have different classification rules. For example, the classification rule of the first task is to identify whether there is first content on the sample resource, the classification rule of the second task is to identify whether there is second content on the sample resource, and the classification rule of the third task is to identify whether there is third content on the sample resource.
Optionally, the electronic device inputs the training sample of each of the plurality of resource classification tasks into the neural network model, for example, the plurality of resource classification tasks includes a first task, a second task, and a third task, i.e., inputs the training sample of the first task, the training sample of the second task, and the training sample of the third task into the neural network model.
In one embodiment, a first task is taken as an example, and the first task includes a first training sample and a second training sample, where a category of the first training sample is a positive sample and a category of the second training sample is a negative sample. The neural network model determines a classification prediction result corresponding to a first training sample of a first task according to a sample resource of the first task and a classification task identifier of the first task in the first training sample, and determines a classification prediction result corresponding to a second training sample of the first task according to a sample resource of the first task and a classification task identifier of the first task in the second training sample. Further, the label information in the first training sample is used to indicate that the first training sample is a positive sample, and the label information in the second training sample is used to indicate that the second training sample is a negative sample.
In an embodiment, a training sample of each resource classification task is configured with a sample resource of each resource classification task and a classification task identifier of each resource classification task, and the sample resource of each resource classification task is associated with the classification task identifier of each resource classification task, that is, the classification task identifier of each resource classification task is used to characterize the resource classification task to be executed by the sample resource of each resource classification task.
In one embodiment, when the training sample of each resource classification task is input into the neural network model, the sample resource and the classification task identifier of each resource classification task may be combined into a pair and input into the neural network model.
In S103, parameters of the neural network model are updated according to the classification prediction result corresponding to the training sample and the label information in the training sample.
In one embodiment, after obtaining the classification prediction result corresponding to the training sample of each resource classification task, the electronic device determines the loss function value of the training sample of each resource classification task according to the classification prediction result corresponding to the training sample of each resource classification task and the label information in the training sample, and further obtains a plurality of loss function values of a plurality of resource classification tasks. Further, the electronic device determines an average loss function value of the plurality of loss function values, and updates a parameter of the neural network model.
In another embodiment, the electronic device calculates the loss function value by using the classification prediction result corresponding to the training sample of each resource classification task and the label information of the training sample of each resource classification task, for example, determines the loss function value by using a cross entropy loss function. The label information of the training sample of the first task may be a sample identifier "1", which represents that the training sample is a positive sample, that is, the training sample includes first content, and the sample identifier "0" represents that the training sample is a negative sample, that is, the training sample does not include the first content. The classification prediction result corresponding to the training sample may be "yes" or "no", and the first task is taken as an example for explanation, when the classification prediction result is "yes", the sample resource representing the training sample includes the first content, and when the classification prediction result is "no", the sample resource representing the training sample does not include the first content.
Alternatively, when the parameters of the neural network model are updated based on the classification prediction results corresponding to the training samples and the label information in the training samples, a back propagation and/or gradient descent method may be used.
In S104, iterative training is performed on the updated neural network model until the neural network model satisfies the model convergence condition, and the converged neural network model is determined to be the first resource classification model.
In an embodiment, in each iteration training process of the neural network model, the training samples of each resource classification task are the same, and at this time, the above S102 to S103 are iteratively performed on the updated neural network model, so as to implement iterative training on the neural network model.
In another embodiment, in each iteration process of the neural network model, the training samples of each resource classification task are different, and at this time, the above-mentioned S101 to S103 are iteratively performed on the updated neural network model, so as to implement iterative training on the neural network model.
In one embodiment, the model convergence condition includes convergence of the loss function values of the classification prediction results, that is, the difference between the loss function values of the two adjacent classification preset results is less than or equal to a preset threshold.
In another embodiment, the model convergence condition includes that the number of times of iteratively executing the above steps on the neural network model is greater than or equal to a preset iteration number.
It should be noted that, in the present application, the multi-task joint training of the neural network model is implemented through the above-mentioned S101 to S104, so as to obtain the first resource classification model capable of executing a plurality of resource classification tasks.
In the above embodiment, the training samples of each resource classification task are configured with the sample resources and the classification task identifiers, and are simultaneously input to the neural network, so that the classification tasks of different sample resources are distinguished through different classification task identifiers, and thus different output networks do not need to be configured for different classification tasks, and the technical problem of complex model structure in the prior art is solved. In addition, the neural network model is jointly optimized through a plurality of classification prediction results of a plurality of resource classification tasks, and the prediction effect of the model can be improved.
In one possible implementation, as shown in fig. 2 in conjunction with fig. 1, S102 includes:
s102 a: the training samples of each resource classification task are input into a neural network model, and the following S102b-S102d are performed by the neural network model.
S102 b: and obtaining a content feature vector according to the sample resource of each resource classification task, wherein the content feature vector is used for representing the content feature of the sample resource of each resource classification task.
Optionally, the neural network model performs feature extraction on the sample resources of each resource classification task to obtain a content feature vector of the sample resources of each resource classification task.
In one embodiment, the electronic device determines the dimension of the content feature vector to be D in advance, wherein D is a positive integer. For example, the sample resource includes M sample images (M is a positive integer), the neural network model performs feature extraction on the M sample images respectively to obtain M feature vectors, and a dimension of each feature vector is D. Based on the content feature vector, the content feature vector of the sample resource of each resource classification task is obtained in the dimension of M x D.
S102 c: and obtaining a condition feature vector according to the classification task identifier of each resource classification task, wherein the condition feature vector is used for representing the classification rule of the classification task identifier of each resource classification task corresponding to the task type.
Wherein the dimension of the conditional feature vector is the same as the dimension of the content feature vector. By configuring the condition feature vectors and the content feature vectors with the same dimensionality, when the condition feature vectors and the content feature vectors are correlated, the correlation between the condition feature vectors and the content feature vectors can be improved, and the accuracy of determining the classification prediction result according to the content feature vectors and the condition feature vectors is further improved.
Optionally, according to the target line number determined by the classification task identifier, acquiring an Embedding vector at a position corresponding to the target line number from a preset dictionary matrix, and obtaining a conditional feature vector.
S102 d: and determining a classification prediction result corresponding to the training sample according to the content feature vector and the condition feature vector.
Optionally, after the content feature vector and the condition feature vector of the training sample are associated, the content feature vector and the condition feature vector are input to a multi-layer Deep Neural Network (DNN) to obtain a classification prediction result corresponding to the training sample.
In the above embodiment, the classification prediction results corresponding to the training samples are determined according to the content feature vector characterizing the sample image and the condition feature vector characterizing the classification rule of the sample image, so that the determination of each classification prediction result conforms to the searching rule of the corresponding sample, and the accuracy of the prediction result is improved.
In another possible embodiment, the sample resource includes a plurality of sample images, the neural network model includes at least an image classification network and a self-attention network, and as shown in fig. 3 in conjunction with fig. 2, S102b includes S102b1-S102b 2.
In S102b1, a plurality of sample images are input to the image classification network to perform feature extraction, and a feature vector of each sample image is obtained.
In one embodiment, a plurality of sample images of a training sample are input into an image classification network, such as an initiation-v 3 or a response-50 d, and image feature extraction is performed to obtain feature vectors of the sample images. For example, D-dimensional feature vectors are preset, and if the number of sample images is M, M × D-dimensional feature vectors, that is, M D-dimensional feature vectors, are obtained in total.
In S102b2, the feature vector of each sample image is input from the attention network, and feature interaction between every two sample images is performed to obtain a content feature vector.
In one embodiment, the content feature vector may be determined by the reduce _ max method. Specifically, the feature vector of each sample image is input to an attention network (i.e., a Transformer network), for example, M D-dimensional feature vectors are input to the Transformer network, a feature interaction relationship between the M sample images is learned, M D-dimensional target feature vectors are obtained, and then, a maximum feature value corresponding to each dimension of the M target feature vectors is determined as a content feature vector, so as to obtain a D-dimensional content feature vector. In another implementation, the average value of each dimension of the M target feature vectors may be determined as a content feature vector, resulting in a content feature vector of D dimension.
In the above embodiment, after feature extraction is performed on each sample image, the obtained feature vector of each sample image is input to the attention network, and the feature interaction relationship between each sample image is learned, so that the expression capability of the content feature vector can be improved, and the feature vector can more accurately express the feature extraction of the sample image.
In another possible implementation, S102c includes: determining a target line number according to the classification task identifier; and determining the content corresponding to the target line number in the preset dictionary matrix as a conditional feature vector.
Optionally, according to the classification task identifier of each resource classification task, an Embedding vector, that is, a conditional feature vector, of each resource classification task is extracted.
In one embodiment, the dimension (T, D) of the dictionary matrix, T characterizing the number of tasks, D characterizing the dimension of the content feature vector. The classification task identifier of each resource classification task is a sequence number of each resource classification task in the plurality of resource classification tasks, a unique D-dimensional vector can be determined in the dictionary matrix according to the classification task identifier of each resource classification task, and the D-dimensional feature vector is an Embedding vector of each classification task identifier.
In the above embodiment, the conditional feature vector of the classification rule characterizing each resource classification task is determined according to the preset dictionary matrix and the classification task identifier, so that different classification rules are configured for the sample resource.
In another possible embodiment, the neural network model includes a deep neural network, S102d, including: executing a multi-head self-attention mechanism on the content characteristic vectors and the condition characteristic vectors to obtain joint vectors of the training samples; and inputting the joint vector into a multilayer deep neural network to obtain a classification prediction result corresponding to the training sample.
Optionally, when a multi-head self-attention mechanism (i.e., multi-head authentication) is performed on the content feature vector and the conditional feature vector, the conditional feature vector is taken as Query, and the content feature vector is taken as Key and Value, so that a conditional probability is realized: p (content feature vector | condition feature vector), that is, different condition feature vectors are activated, that is, the condition feature vector of the training sample activates the content feature vector of the training sample, and then the content feature vector of the training sample is associated with the condition feature vector.
In one embodiment, a linear transformation is performed on Query (i.e., a condition feature vector), Key (i.e., a content feature vector), and Value (i.e., a content feature vector), and then the linear transformation is input into a scaling point product attention (i.e., a self-attention network), a preset number of times (one end each time) is repeatedly performed, then the results of the scaling point product attention (i.e., a self-attention network) of the preset number of times are spliced, and a Value obtained by performing one linear transformation on the obtained splicing result is used as a result of a multi-head attention (i.e., a joint vector of a training sample).
Further, because the conditional feature vector of the training sample activates the content feature vector of the training sample, after the joint vector of the training sample is input into a multi-layer Deep Neural Network (DNN), the multi-layer Deep Neural network can execute a classification rule of the conditional feature vector representation on the content feature vector of the training sample, and then obtain a classification prediction result corresponding to the training sample.
In an embodiment, as shown in fig. 4, taking an example that the plurality of resource classification tasks includes 3 resource classification tasks, a training sample video of each resource classification task is subjected to a preset process, for example, a global image of N frames is obtained, object detection is performed, and a local image of T frames is obtained, so as to obtain M frames (M ═ N + T) sample resources (i.e., M sample images) of each resource classification task. Then, the M frame sample images and the classification task identifiers of each resource classification task are respectively input to different branches of the neural network model, wherein one branch is used for processing the M sample images, for example, feature extraction is performed on the M sample images to obtain feature vectors (for example, each feature vector is D-dimensional) of the M sample images, i.e., E1, E2, … …, Em, then the feature vectors of the M sample images are input to a self-attention network, e.g., a Transformer network, an interaction relationship among the M sample images is learned to obtain M target feature vectors, i.e., T1, T2, … …, Tm, and finally a maximum feature value corresponding to each dimension of the M target feature vectors is determined as a content feature vector of a training sample, so as to obtain a content feature vector of D-dimensional. The other branch is used for processing classification task identifiers, for example, the classification task identifier of the first task is 1, the classification task identifier of the second task is 1, and the classification task identifier of the third task is 2, so as to obtain a condition feature vector of a training sample of each resource classification task. And then, performing a self-attention mechanism on the content feature vector and the condition feature vector to obtain P (X | C), wherein X represents the content feature vector, and C represents the condition feature vector, so as to obtain a classification prediction result corresponding to the training sample.
As shown in fig. 4, taking the first task as an example, the sample resource of each resource classification task is obtained through object detection, where the left sample resource is a sample resource with first content and can be used as a positive sample of the first task, and the right sample resource is a sample resource without first content and can be used as a negative sample of the first task.
In the embodiment, the content feature vector and the condition feature vector are executed with a multi-head self-attention mechanism, so that the condition feature vector of the training sample activates the content feature vector of the training sample, the deep neural network obtains a classification prediction result by executing a classification rule of condition feature vector representation on the content feature vector, the prediction accuracy for the task type corresponding to the condition feature vector is higher, the joint vector of each resource classification task is input into one deep neural network, namely, a plurality of resource classification tasks share one deep neural network as an output network, and the model structure is prevented from being too complex.
In another possible embodiment, the neural network model includes a deep neural network, S102d, including: splicing the content characteristic vector and the condition characteristic vector to obtain a joint vector of the training sample; and inputting the joint vector into a multilayer deep neural network to obtain a classification prediction result corresponding to the training sample.
Optionally, the content feature vector and the condition feature vector are spliced to obtain a joint vector of the training sample, so that the content feature vector of the training sample is associated with the condition feature vector, and then after the joint vector of the training sample is input into a multi-layer Deep Neural Network (DNN), the Deep Neural network can execute a classification rule of condition feature vector representation on the content feature vector of the training sample, and further obtain a classification prediction result corresponding to the training sample.
In one embodiment, for example, the content feature vector is a D-dimensional feature vector, the condition feature vector is also a D-dimensional feature vector, and the content feature vector and the condition feature vector of the training sample are concatenated to obtain a feature vector of 2 × D dimensions of the joint feature vector.
In the embodiment, the content feature vectors and the condition vectors are spliced and input into the deep neural network, so that the deep neural network can execute the classification rules of the condition feature vector representation on the content feature vectors, and further obtain the classification prediction results, the prediction accuracy for the task types corresponding to the condition feature vectors is higher, and the joint vector of each resource classification task is input into one deep neural network, that is, a plurality of resource classification tasks share one deep neural network as an output network, thereby avoiding the excessively complex model structure and reducing the complexity of the model structure.
In another possible implementation, the method for training the resource classification model further includes: and performing multi-task combined training on the neural network model according to the training sample of each resource classification task and the training sample of the newly added resource classification task to obtain a second resource classification model. The training samples of the newly added resource classification tasks comprise sample resources of the newly added resource classification tasks, classification task identifiers of the newly added resource classification tasks and newly added label information, and the second resource classification model is used for executing a plurality of resource classification tasks and the newly added resource classification tasks.
And the newly added label information is used for indicating the reference category of the training sample of the newly added resource classification task.
In one embodiment, after the training of the resource classification task models is completed, for example, the training of 3 resource classification tasks, i.e., the first resource classification task, the second resource classification task, and the third resource classification task, has been completed. When training of a fourth task needs to be added, inputting training samples of the previous three resource classification tasks and training samples of a newly added resource classification task (for example, the fourth resource classification task) into the neural network model for retraining to obtain a second resource classification model, wherein the second resource classification model can execute the first resource classification task, the second resource classification task, the third resource classification task and the fourth resource classification task.
It should be noted that, when a plurality of resource classification tasks need to be added, for example, a fifth resource classification task and a sixth resource classification task are added, the training principle is the same as that when one resource classification task is added, and details are not described here.
In the above embodiment, when a new resource classification task needs to be added to the trained resource classification model, the multi-task joint training is performed on the neural network model again by combining the historical training samples and the training samples of the new resource classification task, so that the obtained resource classification model can simultaneously execute the new resource classification task and the historical resource classification task, the model has strong expansibility, and the new resource classification model uses the classification prediction result of the new resource classification task when performing model optimization, so that the model has good prediction effect.
In another possible implementation, the method for training the resource classification model further includes: obtaining a prediction sample, wherein the prediction sample comprises a prediction sample image and a prediction task identifier; and inputting the prediction sample image and the prediction task identifier into the first resource classification model to obtain a prediction result.
In one embodiment, after the resource classification model training is completed, the resource classification model trained by the prediction sample is used for testing so as to check the testing accuracy of the resource classification model. Specifically, the prediction sample image and the identifier of the prediction task to be executed by the prediction sample image (i.e., the prediction task identifier) are input into the resource classification model together, so as to obtain the prediction result output by the resource classification model and obtained after the task corresponding to the task identifier is executed on the prediction sample image.
It should be noted that the prediction task identifier is a classification task identifier in a training sample of any resource classification task. The prediction task identifies a task type that characterizes a resource classification task performed on the prediction sample image.
In the embodiment, when the prediction sample is predicted, the prediction sample image and the prediction task identifier are simultaneously input into the resource classification model, so that the prediction result output by the task model after the task corresponding to the task identifier is executed on the prediction sample image is obtained.
In another possible implementation, inputting the prediction sample image and the prediction task identifier into the first resource classification model to obtain a prediction result, including: inputting the prediction sample image and the prediction task identifier into a first resource classification model to obtain prediction probability; and under the condition that the prediction probability is greater than or equal to a preset threshold value, determining the prediction sample as a positive sample of the task type corresponding to the prediction task identifier.
Optionally, after the first resource classification model outputs prediction of the task type corresponding to the prediction task identifier on the prediction sample image, obtaining a prediction probability, and when the prediction probability is greater than or equal to a preset threshold (the preset threshold may be 0.75), determining that the prediction sample is a positive sample of the task type corresponding to the prediction task identifier, that is, determining that a prediction result of the prediction sample is "yes", for example, the task type corresponding to the prediction task identifier is a third task, and the fact that the prediction result is "yes" indicates that the prediction sample includes third content.
In the embodiment, whether the prediction sample is a positive sample or not is determined according to the relation between the prediction probability output by the resource classification model and the preset threshold, so that the two classification results of the prediction sample can be directly obtained according to the prediction probability, and the prediction result can be simply and visually expressed.
In another possible embodiment, S101 includes:
the method comprises the following steps: and acquiring a training sample video of each resource classification task and label information corresponding to the training sample video, and determining a classification task identifier of each resource classification task.
And the label information corresponding to the training sample video is the label information in the training sample in the S101.
In one embodiment, the training sample video for each resource classification task is used to determine sample resources in the training sample for each resource classification task.
Optionally, the training sample video includes a positive sample video and a negative sample video. That is, each resource classification task is configured with a positive sample video and a negative sample video. The positive sample video is used for determining a positive sample of each resource classification task, and the negative sample is used for determining a negative sample of each resource classification task.
In one embodiment, after training sample videos of a plurality of resource classification tasks are manually collected, the training sample videos are input to the electronic device, and the electronic device acquires the training sample video of each resource classification task.
In another embodiment, the electronic device pulls videos from different sources from the network as training sample videos for each resource classification task.
Alternatively, determining the classification task identification for each resource classification task may be performed by the electronic device. For example, the electronic device performs one-hot encoding (e.g., encoding to (0,1, …, T-1) for each resource classification task, where T is a positive integer greater than 1, and determines the encoding of each resource classification task as the classification task identification.
Optionally, the classification task identifier of each resource classification task may also be manually input to the electronic device, and at this time, the electronic device determines the manually input identifier of each resource classification task as the classification task identifier of the task.
And executing the following steps two to three aiming at the training sample video of each resource classification task:
step two: and acquiring a global image of a first preset frame number of the training sample video.
Optionally, the electronic device samples the training sample video to obtain a global image with a first preset frame number.
In one embodiment, each second of the training sample video is determined to be a frame, and the first preset number of frames is less than the total number of frames of the training sample video. For example, the training sample video has 20 frames, and the training sample video with 20 frames is sampled to obtain N frames of global images, where N may be any value greater than 1 and smaller than 20, for example, N may be equal to 10.
Step three: and carrying out object detection on each frame of global image to obtain a local image with a second preset frame number, wherein the local image comprises an object position area. And the global image with the first preset frame number and the local image with the second preset frame number are sample resources of each resource classification task.
Optionally, the electronic device performs object detection on each frame of global image to obtain a local image with a third preset frame number. Further, according to the local image with the third preset frame number of each frame of the global image, the local image with the second preset frame number is obtained.
In one embodiment, the electronic device performs object detection on each frame of global image, and determines the detected object region as a local image of the frame of global image. Further, when the number of the local images including the target region area is less than the third preset number of frames, the cover frame (i.e. the first frame of the video) of the training sample video of the task is used for complementing, for example, the third preset number of frames is 3, and the local image determined by the global image for object detection is 1, at this time, two cover frames are used for complementing the local image set corresponding to the global image.
Note that the target region on each local image is a region belonging to a different target. For example, when there are two objects (object a and object B) in the whole image, two local images can be obtained from the global image, where one local image includes the object region of object a, and the other local image includes the object region of object B, and when the third preset frame number is 3, it is necessary to use a cover frame to supplement the local image set corresponding to the global image.
In the embodiment, the sample resources are determined according to the global image of the training sample video and the local image including the object part area, the richness and the integrity of the sample resources are improved, the expression capacity of the content feature vector is further improved, and the classification prediction effect is more accurate.
In another possible implementation, the method for training the resource classification model further includes: determining the number of matrix rows according to the number of tasks corresponding to the resource classification tasks; determining the number of matrix columns according to the dimension of a preset content feature vector; and obtaining a dictionary matrix according to the matrix row number, the matrix column number and a preset model.
Optionally, after determining the number of matrix rows and the number of matrix columns, inputting the number of matrix rows and the number of matrix columns into a model for generating a dictionary matrix, so as to obtain the dictionary matrix.
In one embodiment, each row vector in the dictionary matrix characterizes a classification rule for a task. The row vectors of the field matrix correspond to the classification task identifiers one to one, that is, the vectors in the first row in the dictionary matrix are used to represent the classification rule of the task type corresponding to the task with the classification task identifier 1.
Optionally, obtaining a dictionary matrix according to the number of matrix rows, the number of matrix columns and a preset model, including: obtaining an initial dictionary matrix according to the matrix row number, the matrix column number and a preset model; and carrying out random initialization on the initial dictionary matrix to obtain the dictionary matrix.
In the above embodiment, the dimension of the dictionary matrix is determined according to the task number and the dimension of the content feature vector, so that the conditional feature vector obtained from the dictionary matrix according to the classification task identifier has the same dimension as the content feature vector, and the accuracy of the prediction result is further improved.
In another possible implementation, the method for training the resource classification model further includes: and updating the dictionary matrix according to the classification prediction result corresponding to the training sample and the label information in the training sample in each iteration training process of the neural network model. And the updated dictionary matrix is used for determining the condition characteristic vector in the next iteration training of the neural network model.
In one embodiment, after obtaining the classification prediction result corresponding to the training sample of each resource classification task, the electronic device determines the loss function value of the training sample of each resource classification task according to the classification prediction result corresponding to the training sample of each resource classification task and the label information in the training sample, and further obtains a plurality of loss function values of a plurality of resource classification tasks. Then, the dictionary matrix is updated based on the average value of the plurality of loss function values.
In another embodiment, the electronic device calculates the loss function value by using the classification prediction result corresponding to the training sample of each resource classification task and the label information of the training sample of each resource classification task, for example, determines the loss function value by using a cross entropy loss function. Then, the dictionary matrix is updated according to the obtained loss function values.
In the above embodiment, in each iteration training process of the neural network model, the dictionary matrix is updated according to the classification prediction result corresponding to the training sample and the label information in the training sample, so that the condition feature vector of the classification task identifier of each resource classification task is updated, and further the condition feature vector can more accurately express the classification rule of the classification task identifier corresponding to the task type, which is beneficial to improving the accuracy of the classification prediction result corresponding to the training sample, and further improving the training efficiency of the first resource classification model.
The scheme provided by the embodiment of the application is mainly introduced from the perspective of a method. To implement the above functions, it includes hardware structures and/or software modules for performing the respective functions. Those of skill in the art would readily appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is performed as hardware or computer software drives hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The embodiment of the disclosure also provides a device for training the resource classification model.
FIG. 5 is a block diagram illustrating a training apparatus for a resource classification model according to an exemplary embodiment. Referring to fig. 5, the training apparatus 500 of the resource classification model includes an obtaining module 501, a training module 502, an updating module 503, and an iterating module 504.
An obtaining module 501 configured to perform obtaining a training sample of each resource classification task of a plurality of resource classification tasks; the training samples comprise sample resources of corresponding resource classification tasks, classification task identifiers of the corresponding resource classification tasks and label information, and the label information is used for indicating reference classes of the sample resources in the corresponding training samples. For example, in conjunction with fig. 1, the obtaining module 501 may be configured to perform S101.
A training module 502 configured to input a training sample of each resource classification task of the plurality of resource classification tasks into the neural network model to obtain a classification prediction result corresponding to the training sample; and the classification prediction result is determined according to the content characteristics of the sample resources in the training sample and the classification rule of the task type corresponding to the classification task identification. For example, in connection with fig. 1, the training module 502 may be used to perform S102.
And an updating module 503 configured to update parameters of the neural network model according to the classification prediction result corresponding to the training sample and the label information in the training sample. For example, in conjunction with fig. 1, the update module 503 may be configured to perform S103.
An iteration module 504 configured to perform iterative training on the updated neural network model until the neural network model satisfies a model convergence condition, and determine that the converged neural network model is the first resource classification model. For example, in conjunction with fig. 1, the iteration module 504 may be used to perform S104.
In one possible implementation, the training module 502 is specifically configured to perform: inputting the training sample of each resource classification task into a neural network model, and executing the following steps through the neural network model: obtaining a content feature vector according to the sample resource of each resource classification task, wherein the content feature vector is used for representing the content feature of the sample resource of each resource classification task; obtaining a condition feature vector according to the classification task identifier of each resource classification task, wherein the condition feature vector is used for representing the classification rule of the classification task identifier of each sample resource task corresponding to the task type; the dimension of the conditional feature vector is the same as the dimension of the content feature vector; and determining a classification prediction result corresponding to the training sample according to the content feature vector and the condition feature vector.
In another possible implementation, the sample resource includes a plurality of sample images, the neural network model includes at least an image classification network and a self-attention network, and the training module 502 is specifically configured to perform: inputting a plurality of sample images into an image classification network for feature extraction to obtain a feature vector of each sample image; and inputting the feature vector of each sample image into the attention network, and performing feature interaction between every two sample images to obtain a content feature vector.
In another possible implementation, the training module 502 is specifically configured to perform: determining a target line number according to the classification task identifier; and determining the content corresponding to the target line number in the preset dictionary matrix as a conditional feature vector.
In another possible implementation, the neural network model includes a multi-layer deep neural network, and the training module 502 is specifically configured to perform: executing a multi-head self-attention mechanism on the content characteristic vectors and the condition characteristic vectors to obtain joint vectors of the training samples; and inputting the joint vector into a multilayer deep neural network to obtain a classification prediction result corresponding to the training sample.
In another possible implementation, the neural network model includes a multi-layer deep neural network, and the training module 502 is specifically configured to perform: splicing the content characteristic vector and the condition characteristic vector to obtain a joint vector of the training sample; and inputting the joint vector into a multilayer deep neural network to obtain a classification prediction result corresponding to the training sample.
In another possible implementation, the training module 502 is further configured to perform: performing multi-task combined training on the neural network model according to the training sample of each resource classification task and the training sample of the newly added resource classification task to obtain a second resource classification model; the training samples of the newly added resource classification tasks comprise sample resources of the newly added resource classification tasks, classification task identifiers of the newly added resource classification tasks and newly added label information, and the second resource classification model is used for executing a plurality of resource classification tasks and the newly added resource classification tasks.
In another possible implementation, the apparatus further includes a prediction module configured to perform: obtaining a prediction sample, wherein the prediction sample comprises a prediction sample image and a prediction task identifier; and inputting the prediction sample image and the prediction task identifier into the first resource classification model to obtain a prediction result.
In another possible embodiment, the prediction module is specifically configured to perform: inputting the prediction sample image and the prediction task identifier into a first resource classification model to obtain prediction probability; and under the condition that the prediction probability is greater than or equal to a preset threshold value, determining the prediction sample as a positive sample of the task type corresponding to the prediction task identifier.
In another possible implementation, the apparatus further includes an obtaining module configured to perform: acquiring a training sample video of each resource classification task and label information corresponding to the training sample video, and determining a classification task identifier of each resource classification task; the following steps are carried out aiming at the training sample video of each resource classification task: acquiring a global image of a first preset frame number of a training sample video; and carrying out object detection on each frame of global image to obtain a local image with a second preset frame number, wherein the local image comprises an object part area, and the global image with the first preset frame number and the local image with the second preset frame number are sample resources of each resource classification task.
In another possible implementation, the apparatus further includes a configuration module configured to perform: determining the number of matrix rows according to the number of tasks corresponding to the resource classification tasks; determining the number of matrix columns according to the dimension of a preset content feature vector; and obtaining a dictionary matrix according to the matrix row number, the matrix column number and a preset model.
In another possible embodiment, the configuration module is further configured to perform: updating a dictionary matrix according to a classification prediction result corresponding to a training sample and label information in the training sample in each iteration training process of the neural network model; and the updated dictionary matrix is used for determining the condition characteristic vector in the next iteration training of the neural network model.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
FIG. 6 is a block diagram illustrating an electronic device in accordance with an example embodiment. As shown in fig. 6, electronic device 600 includes, but is not limited to: a processor 601 and a memory 602.
The memory 602 is configured to store executable instructions of the processor 601. It is understood that the processor 601 is configured to execute instructions to implement the method for training the resource classification model shown in any one of fig. 1 to 4 in the above embodiments.
It should be noted that the electronic device structure shown in fig. 6 does not constitute a limitation of the electronic device, and the electronic device may include more or less components than those shown in fig. 6, or combine some components, or arrange different components, as will be understood by those skilled in the art.
The processor 601 is a control center of the electronic device, connects various parts of the whole electronic device by using various interfaces and lines, and performs various functions of the electronic device and processes data by running or executing software programs and/or modules stored in the memory 602 and calling data stored in the memory 602, thereby performing overall monitoring of the electronic device. Processor 601 may include one or more processing units; optionally, the processor 601 may integrate an application processor and a modem processor, wherein the application processor mainly handles operating systems, user interfaces, application programs, and the like, and the modem processor mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 601.
The memory 602 may be used to store software programs as well as various data. The memory 602 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program (such as a training module, an updating module, an iteration module, and the like) required by at least one functional module, and the like. Further, the memory 602 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
In an exemplary embodiment, the disclosed embodiment also provides a computer-readable storage medium including instructions, such as the memory 602 including instructions, which are executable by the processor 601 of the electronic device 600 to perform the method for training the resource classification model shown in any one of fig. 1 to 4 in the above-described embodiment.
In actual implementation, the processing functions of the obtaining module 501, the training module 502, the updating module 503 and the iterating module 504 may be implemented by the processor 601 shown in fig. 6 calling the program code in the memory 602. The specific implementation process may refer to the description of the training portion of the resource classification model shown in any one of fig. 1 to 4, which is not described herein again.
Alternatively, the computer-readable storage medium may be a non-transitory computer-readable storage medium, which may be, for example, a Read-Only Memory (ROM), a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
In an exemplary embodiment, the disclosed embodiment also provides a computer program product including one or more instructions that can be executed by the processor 601 of the electronic device 600 to perform the method for training the resource classification model shown in any one of fig. 1 to 4 in the above-described embodiments.
It should be noted that the instructions in the computer-readable storage medium or one or more instructions in the computer program product are executed by the processor 601 of the electronic device 600 to implement the processes of the embodiment of the verification method, and the technical effect same as the training method of the resource classification model shown in any one of fig. 1 to fig. 4 in the embodiment can be achieved, and in order to avoid repetition, details are not repeated here.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (10)

1. A method for training a resource classification model is characterized by comprising the following steps:
acquiring a training sample of each resource classification task in a plurality of resource classification tasks; the training samples comprise sample resources of corresponding resource classification tasks, classification task identifiers of the corresponding resource classification tasks and label information, and the label information is used for indicating reference classes of the training samples of the corresponding resource classification tasks;
inputting a training sample of each resource classification task in the plurality of resource classification tasks into a neural network model to obtain a classification prediction result corresponding to the training sample; the classification prediction result is determined according to the content characteristics of sample resources in the training sample and the classification rule of the task type corresponding to the classification task identification;
updating parameters of the neural network model according to the classification prediction result corresponding to the training sample and the label information in the training sample;
and performing iterative training on the updated neural network model until the neural network model meets the model convergence condition, and determining the converged neural network model as a first resource classification model.
2. The method of claim 1, wherein the inputting the training sample of each resource classification task of the plurality of resource classification tasks into a neural network model to obtain a classification prediction result corresponding to the training sample comprises:
inputting the training sample of each resource classification task into the neural network model, and executing the following steps through the neural network model:
obtaining a content feature vector according to the sample resource of each resource classification task, wherein the content feature vector is used for representing the content feature of the sample resource of each resource classification task;
obtaining a condition feature vector according to the classification task identifier of each resource classification task, wherein the condition feature vector is used for representing a classification rule of the classification task identifier of each resource classification task corresponding to the task type; the dimension of the conditional feature vector is the same as the dimension of the content feature vector;
and determining a classification prediction result corresponding to the training sample according to the content feature vector and the condition feature vector.
3. The method of claim 2, wherein the sample resources comprise a plurality of sample images, the neural network model comprises at least an image classification network and a self-attention network, and the classifying the sample resources of the task according to each resource to obtain a content feature vector comprises:
inputting the plurality of sample images into the image classification network for feature extraction to obtain a feature vector of each sample image;
and inputting the feature vector of each sample image into a self-attention network, and performing feature interaction between every two sample images to obtain the content feature vector.
4. The method according to claim 2, wherein obtaining a conditional feature vector according to the classification task identifier of each resource classification task comprises:
determining a target line number according to the classification task identifier;
and determining the content corresponding to the target line number in a preset dictionary matrix as the conditional feature vector.
5. The method of claim 2, wherein the neural network model comprises a multi-layer deep neural network, and the determining the classification prediction result corresponding to the training sample according to the content feature vector and the condition feature vector comprises:
executing a multi-head self-attention mechanism on the content feature vector and the condition feature vector to obtain a joint vector of the training sample;
and inputting the joint vector into the multilayer deep neural network to obtain a classification prediction result corresponding to the training sample.
6. The method of claim 2, wherein the neural network model comprises a multi-layer deep neural network, and the determining the classification prediction result corresponding to the training sample according to the content feature vector and the condition feature vector comprises:
splicing the content characteristic vector and the condition characteristic vector to obtain a joint vector of the training sample;
and inputting the joint vector into the multilayer deep neural network to obtain a classification prediction result corresponding to the training sample.
7. An apparatus for training a resource classification model, comprising:
an acquisition module configured to perform acquisition of a training sample for each of a plurality of resource classification tasks; the training samples comprise sample resources of corresponding resource classification tasks, classification task identifiers of the corresponding resource classification tasks and label information, and the label information is used for indicating the reference category of the training sample of each resource classification task;
the training module is configured to input a training sample of each resource classification task in the plurality of resource classification tasks into a neural network model to obtain a classification prediction result corresponding to the training sample; the classification prediction result is determined according to the content characteristics of sample resources in the training sample and the classification rule of the task type corresponding to the classification task identification;
the updating module is configured to update the parameters of the neural network model according to the classification prediction result corresponding to the training sample and the label information in the training sample;
and the iteration module is configured to execute iterative training on the updated neural network model until the neural network model meets a model convergence condition, and determine that the converged neural network model is a first resource classification model.
8. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the method of any one of claims 1 to 6.
9. A computer-readable storage medium, wherein instructions in the computer-readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the method of any of claims 1-6.
10. A computer program product, characterized in that it comprises computer instructions which, when run on an electronic device, cause the electronic device to perform the method according to any one of claims 1 to 6.
CN202210023291.0A 2022-01-10 2022-01-10 Resource classification model training method and device, electronic equipment and storage medium Pending CN114492601A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210023291.0A CN114492601A (en) 2022-01-10 2022-01-10 Resource classification model training method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210023291.0A CN114492601A (en) 2022-01-10 2022-01-10 Resource classification model training method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114492601A true CN114492601A (en) 2022-05-13

Family

ID=81509107

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210023291.0A Pending CN114492601A (en) 2022-01-10 2022-01-10 Resource classification model training method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114492601A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116340552A (en) * 2023-01-06 2023-06-27 北京达佳互联信息技术有限公司 Label ordering method, device, equipment and storage medium
CN116805253A (en) * 2023-08-18 2023-09-26 腾讯科技(深圳)有限公司 Intervention gain prediction method, device, storage medium and computer equipment

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116340552A (en) * 2023-01-06 2023-06-27 北京达佳互联信息技术有限公司 Label ordering method, device, equipment and storage medium
CN116805253A (en) * 2023-08-18 2023-09-26 腾讯科技(深圳)有限公司 Intervention gain prediction method, device, storage medium and computer equipment
CN116805253B (en) * 2023-08-18 2023-11-24 腾讯科技(深圳)有限公司 Intervention gain prediction method, device, storage medium and computer equipment

Similar Documents

Publication Publication Date Title
CN110347873B (en) Video classification method and device, electronic equipment and storage medium
CN110069709B (en) Intention recognition method, device, computer readable medium and electronic equipment
CN108304376B (en) Text vector determination method and device, storage medium and electronic device
CN113128478B (en) Model training method, pedestrian analysis method, device, equipment and storage medium
CN116049397B (en) Sensitive information discovery and automatic classification method based on multi-mode fusion
CN114492601A (en) Resource classification model training method and device, electronic equipment and storage medium
CN111931859B (en) Multi-label image recognition method and device
CN113449011A (en) Big data prediction-based information push updating method and big data prediction system
CN113449012A (en) Internet service mining method based on big data prediction and big data prediction system
CN111444677A (en) Reading model optimization method, device, equipment and medium based on big data
CN110781818A (en) Video classification method, model training method, device and equipment
CN112420125A (en) Molecular attribute prediction method and device, intelligent equipment and terminal
CN114896395A (en) Language model fine-tuning method, text classification method, device and equipment
CN113032676B (en) Recommendation method and system based on micro-feedback
CN113705402A (en) Video behavior prediction method, system, electronic device and storage medium
CN116756576B (en) Data processing method, model training method, electronic device and storage medium
CN116628177B (en) Interactive data processing method and system for network security platform
CN113742488B (en) Embedded knowledge graph completion method and device based on multitask learning
CN114898184A (en) Model training method, data processing method and device and electronic equipment
CN114328995A (en) Content recommendation method, device, equipment and storage medium
CN114625967A (en) User information mining method based on big data service optimization and artificial intelligence system
CN114398482A (en) Dictionary construction method and device, electronic equipment and storage medium
CN114170484A (en) Picture attribute prediction method and device, electronic equipment and storage medium
CN114528973A (en) Method for generating business processing model, business processing method and device
CN113407837A (en) Intelligent medical big data processing method based on artificial intelligence and intelligent medical system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination