CN111881948A - Training method and device of neural network model, and data classification method and device - Google Patents

Training method and device of neural network model, and data classification method and device Download PDF

Info

Publication number
CN111881948A
CN111881948A CN202010661797.5A CN202010661797A CN111881948A CN 111881948 A CN111881948 A CN 111881948A CN 202010661797 A CN202010661797 A CN 202010661797A CN 111881948 A CN111881948 A CN 111881948A
Authority
CN
China
Prior art keywords
data
neural network
network model
training
target
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
CN202010661797.5A
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.)
Mashang Consumer Finance Co Ltd
Original Assignee
Mashang Consumer Finance 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 Mashang Consumer Finance Co Ltd filed Critical Mashang Consumer Finance Co Ltd
Priority to CN202010661797.5A priority Critical patent/CN111881948A/en
Publication of CN111881948A publication Critical patent/CN111881948A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Artificial Intelligence (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Evolutionary Computation (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Software Systems (AREA)
  • Mathematical Physics (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Computing Systems (AREA)
  • Molecular Biology (AREA)
  • General Health & Medical Sciences (AREA)
  • Evolutionary Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Analysis (AREA)

Abstract

The application provides a training method and a device of a neural network model and a data classification method and a device, wherein the method comprises the following steps: determining first target data from first type data in the sample data; the sample data further comprises a second type of data; inputting the first target data and the second class data serving as first training samples into an initial neural network model for training to obtain a first neural network model; testing the first neural network model by taking first residual data from the first type of data after the first target data is removed as a first test sample to obtain a test result; performing model training for N times based on the first neural network model and a training sample determined according to the second type of data and the test sample to obtain a first target neural network model; the training samples comprise second-class data and target data, and the accuracy of classifying the data by using the model trained by the unbalanced data is improved.

Description

Training method and device of neural network model, and data classification method and device
Technical Field
The invention relates to the field of computers, in particular to a training method and device of a neural network model and a data classification method and device.
Background
Image classification is a fundamental task in computer vision, where, for the classification of balance data, the accuracy of classification by deep learning for certain specific models has exceeded the best level for humans; however, for unbalanced image data, in deep learning classification, the existing method for processing unbalanced images at the data level includes: 1) oversampling, namely directly and repeatedly copying less data in the unbalanced image data, and stopping copying when the data is almost the same as other sample data so as to realize image data balance; the method is simple and easy to operate, but the data overfitting condition exists in many times; 2) under-sampling, i.e. sample extraction is performed on more types of unbalanced image data according to a certain rule, and the method stops until the sample amount is close to that of less types of unbalanced image data, but the method has the problem of information reduction. Therefore, in the prior art, due to the fact that sample data in the deep learning model is over-fitted or information is reduced, the accuracy rate of classifying data by using the model after unbalanced data is trained is low.
Disclosure of Invention
The embodiment of the application aims to provide a training method and device for a neural network model and a data classification method and device, and can solve the problem that in the prior art, the accuracy of classifying data by using a model trained by unbalanced data is low.
In order to solve the technical problem, the present application is implemented as follows:
in a first aspect, an embodiment of the present application provides a data classification method, including:
determining first target data from first class data in sample data, wherein the sample data further comprises second class data, the quantity of the first class data is greater than that of the second class data, and the absolute value of the difference between the quantity of the first target data and the quantity of the second class data is less than a preset threshold;
inputting the first target data and the second type data as a first training sample into an initial neural network model for training to obtain a first neural network model;
taking first residual data in the first type of data after the first target data is removed as a first test sample to test the first neural network model to obtain a test result, wherein the test result comprises a first correctly predicted result and a first incorrectly predicted result;
performing model training for N times based on the first neural network model and a training sample determined according to the second type of data and the test sample to obtain a first target neural network model, wherein N is an integer greater than or equal to 1;
the neural network model obtained by the current model training is used as an object of the next model training, the current training sample comprises the second type data and target data, data corresponding to a correct prediction result and data corresponding to an incorrect prediction result of the last model testing are collected according to a preset proportion in a test sample of the last model testing to obtain the current target data, and the test sample of the current model training is obtained by removing the target data determined by each model training from the first type data.
In a second aspect, an embodiment of the present application provides a training apparatus for a neural network model, including:
the device comprises a determining module, a judging module and a judging module, wherein the determining module is used for determining first target data from first class data in sample data, the sample data further comprises second class data, the quantity of the first class data is greater than that of the second class data, and the absolute value of the difference between the quantity of the first target data and the quantity of the second class data is smaller than a preset threshold;
the first training module is used for inputting the first target data and the second type data as first training samples into an initial neural network model for training to obtain a first neural network model;
the testing module is used for testing the first neural network model by taking first residual data obtained after the first target data in the first type of data are removed as a first testing sample to obtain a testing result, wherein the testing result comprises a first correctly predicted result and a first wrongly predicted result;
the second training module is used for carrying out model training for N times based on the first neural network model and a training sample determined according to the second type of data and the test sample to obtain a first target neural network model, wherein N is an integer greater than or equal to 1;
the neural network model obtained by the current model training is used as an object of the next model training, the current training sample comprises the second type data and target data, data corresponding to a correct prediction result and data corresponding to an incorrect prediction result of the last model testing are collected according to a preset proportion in a test sample of the last model testing to obtain the current target data, and the test sample of the current model training is obtained by removing the target data determined by each model training from the first type data.
In a third aspect, an embodiment of the present application provides a data classification method, including: acquiring unbalanced data to be classified; inputting the data to be classified into a classification neural network model for classification to obtain a classification result; wherein, the classification neural network model is obtained by training the training method of the neural network model according to the first aspect.
In a fourth aspect, an embodiment of the present application provides an apparatus for classifying data, including: the acquisition module is used for acquiring data to be classified; the classification module is used for inputting the data to be classified into a classification neural network model for classification to obtain a classification result; wherein, the classification neural network model is obtained by training the training method of the neural network model according to the first aspect.
In a fifth aspect, the present application provides an electronic device, which includes a processor, a memory, and a program or instructions stored on the memory and executable on the processor, and when executed by the processor, the program or instructions implement the steps of the method according to the first aspect or the third aspect.
In a sixth aspect, the present application provides a readable storage medium, on which a program or instructions are stored, which when executed by a processor implement the steps of the method according to the first or third aspect.
In the application, a classification neural network model for classifying unbalanced data to be classified is obtained by performing dynamic training for N times by using unbalanced sample data, wherein a training sample comprises second-class data and target data, the target data comprises data corresponding to a correct prediction result and data corresponding to an incorrect prediction result of a last model test, which are acquired according to a preset proportion, in a test sample of a last test model; it can be seen that the data of each training includes the data corresponding to the correct result of prediction and the data corresponding to the wrong result of prediction in the test sample of the last model test, thereby ensuring the integrity of the training data, and being capable of training the data corresponding to the wrong result of prediction in a targeted manner, continuously converging the model, strengthening learning the wrong data of recognition, avoiding the over-sampling defect and the under-sampling defect of the prior art, improving the accuracy of classifying the data by the trained first target neural network model, and solving the problem of low accuracy of classifying the data by the model trained by using unbalanced data in the prior art.
Drawings
FIG. 1 is a flow chart of a method of training a neural network model according to an embodiment of the present application;
FIG. 2 is a flow chart of a method of classifying data according to an embodiment of the present application;
FIG. 3 is a schematic structural diagram of a training apparatus for neural network models according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a data sorting apparatus according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terms first, second and the like in the description and in the claims of the present application 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 application are capable of operation in sequences other than those illustrated or described herein. In addition, "and/or" in the specification and claims means at least one of connected objects, a character "/" generally means that a preceding and succeeding related objects are in an "or" relationship.
Referring to fig. 1, fig. 1 is a flowchart of a method for training a neural network model according to an embodiment of the present application, and as shown in fig. 1, the method includes the steps of:
step S102, determining first target data from first class data in sample data, wherein the sample data further comprises second class data, and the quantity of the first class data is greater than that of the second class data; the absolute value of the difference between the quantity of the first target data and the quantity of the second type data is smaller than a preset threshold value;
it should be noted that sample data in the embodiment of the present application is unbalanced data, and the sample data in the embodiment of the present application includes first class data and second class data that are unbalanced with each other, which may be image data that are unbalanced with each other, or voice data or other data that are unbalanced with each other, such as: unbalanced structured digital data, unbalanced speech data, unbalanced text data, and the like. Of course, if some kind of data is classified, such as image data, the corresponding sample data to be trained should also be image data.
Therefore, taking image data as an example, the sample data in the embodiment of the present application includes 80 pieces of data of the first type, and 20 pieces of data of the second type; the amount of the first target data may be selected to be equal to the second type of data, i.e. 20 sheets as well. But it may also be that the amount of the first target data is 18, 19, 21 or 22, etc. when a floating range is reached, for example, when the preset threshold is 3. It should be noted that the value of the preset threshold may be adjusted according to the actual situation, that is, other values, such as 2 or 4, may also be used.
Step S104, inputting the first target data and the second class data as first training samples into an initial neural network model for training to obtain a first neural network model;
step S106, taking the first residual data from the first type of data after the first target data is removed as a first test sample to test the first neural network model to obtain a test result, wherein the test result comprises a first correctly predicted result and a first wrongly predicted result;
in step S106, if the sample data is taken as image data, the further sample data includes 80 pieces of first-class data and 20 pieces of second-class data, and the number of the first target data is 20 as an example, the number of the first remaining data is 60, so that the first remaining data with the number of 60 is taken as a test sample to test the first neural network model.
Step S108, performing model training for N times based on the first neural network model and a training sample determined according to the second type of data and the test sample to obtain a first target neural network model;
the neural network model obtained by the current model training is used as an object of the next model training, the current training sample comprises the second type data and target data, data corresponding to a correct prediction result and data corresponding to an incorrect prediction result of the last model testing are collected according to a preset proportion in a test sample of the last model testing to obtain the current target data, and the test sample of the current model training is obtained by removing the target data determined by each model training from the first type data.
The predetermined ratio is a ratio of a data amount corresponding to a result with a correct prediction to a data amount corresponding to a result with a wrong prediction, and is, for example, 5:5 or 4: 6.
As can be seen from the foregoing steps S102 to S108, in the present application, the first target neural network model for classifying data to be classified is obtained by performing N times of dynamic training using unbalanced sample data, where a training sample includes second type data and target data, and the target data includes data corresponding to a result of a correct prediction and data corresponding to a result of an incorrect prediction, which are acquired according to a preset ratio in a test sample of a last test model, of a last test model; it can be seen that the data of each training includes the data corresponding to the correct result of prediction and the data corresponding to the wrong result of prediction in the test sample of the last model test, thereby ensuring the integrity of the training data, being capable of training the data corresponding to the wrong result of prediction in a targeted manner, leading the model to be continuously converged, strengthening the learning of the data with the wrong recognition, avoiding the defect of overfitting caused by oversampling and the defect of incomplete information caused by undersampling in the prior art, leading the accuracy of classifying the data by the trained first target neural network model to be higher, and solving the problem of low accuracy of classifying the data by the model trained by utilizing unbalanced data in the prior art.
Optionally, the value of N in this embodiment is an integer, and N is 1 and 2 for example; of course, in other alternative embodiments of the present application, the value of N may also be 3 or another positive integer, and the flow is similar to that of N being 1 and 2.
Under the condition that the value of N is 1, the manner of obtaining the first target neural network model by performing the model training 1 time by using the first neural network model in the embodiment of the present application may include:
step S11, performing undersampling in the first test sample to obtain second target data, wherein the second target data comprises data corresponding to the result of correct prediction and data corresponding to the result of wrong prediction, which are sampled according to a first preset proportion, and the absolute value of the difference between the number of the second target data and the number of the second type of data is smaller than a preset threshold value;
if the sample data is image data, and the sample data includes 80 pieces of first class data and 20 pieces of second class data, for example, if the preset threshold is 0, the number of the second target data is 20, and if the preset threshold is 2, the number of the second target data may be 18, 19, 21 or 22. Assuming that the number of the second target data is 20 and the first predetermined ratio is 5:5, 10 data are respectively obtained from the first predicted correct data and the first predicted incorrect data to obtain the second target data.
Of course, the number of the sample data and the first preset ratio are all exemplified, and corresponding values may be taken according to actual situations in other application scenarios in the embodiment of the present application.
Step S12, inputting second target data and second class data serving as second training samples into the first neural network model for training to obtain a second neural network model, wherein the second neural network model is the first target neural network model;
if the second target data and the second type data in the step S11 are taken as examples, the second target data with the number of 20 and the second type data with the number of 20 are input as sample data to the first neural network model for training, so as to obtain a second neural network model.
Through the above steps S11 to S12, a second neural network model obtained after 1 training by using the first neural network model can be obtained, the second neural network model is trained based on unbalanced sample data, which avoids the over-fitting defect caused by over-sampling and the incomplete defect caused by under-sampling in the prior art, but in order to enable parameters in the second neural network model to be more optimized, the second neural network model can be continuously trained, that is, in the case that N is 2, the mode of obtaining the first target neural network model by 2 times of training the first neural network model in the embodiment of the present application may further be:
step S21, taking second residual data of the first type of data after the first target data and the second target data are removed as a second test sample to test the second neural network model to obtain a test result, wherein the test result comprises a second result with correct prediction and a second result with wrong prediction;
that is, before each training, the trained neural network model needs to be tested, and the test sample is the target data that needs to be removed from the first class of data each time before. In the 2 nd training process of the first neural network model, first target data and second target data need to be removed from the first class of data; if the first target data is 20 and the second target data is also 20, the first target data of 20 and the second target data of 20 are required to be removed from the first data of 80 to obtain a second test sample.
Step S22, performing undersampling in a second test sample to obtain third target data, wherein the third target data comprises data corresponding to a second correctly predicted result and data corresponding to a second incorrectly predicted result, which are sampled according to a second preset proportion, and the absolute value of the difference between the number of the third target data and the number of the second type of data is smaller than a preset threshold;
wherein the second predetermined ratio may be 5:5 or 3:7, etc. The above is merely an example, and in the embodiment of the present application, the training process may be adjusted accordingly.
Step S23, inputting third target data and second class data serving as third training samples into a second neural network model for training to obtain a third neural network model, wherein the third neural network model is the first target neural network model;
it should be noted that the third neural network model obtained after two times of training based on the first neural network model is already a preferred neural network model, that is, the third neural network model obtained after two times of training can perform more accurate classification on the corresponding data, and certainly, more training can be performed as needed.
It should be noted that, in the embodiment of the present application, the ratio of the first preset ratio to the second preset ratio is a ratio of the number of predicted correct data to the number of predicted incorrect data, and the ratio is less than or equal to 1.
Further, in another optional implementation manner of the embodiment of the present application, in order to make the final first target neural network model have a better effect on data classification, after performing N times of training based on the first neural network model to obtain the first target neural network model, the method of the embodiment of the present application further includes:
and step S31, training the first target neural network model by taking the first type of data and the second type of data as target training samples to obtain a second target neural network model.
It can be seen that, since the training data is dynamically adjusted according to the training result, the random sample deletion operation is performed on the category with better result (correctly predicted data), and the number of samples is increased on the category with poorer result (incorrectly predicted data), and then after the step S31, the first target neural network model is trained by using all the sample data, so that the first target neural network model is obtained, that is, the classification model is guaranteed to learn relevant information every time, and the over-fitting defect in the over-sampling and the incomplete information defect in the under-sampling are avoided. On the premise that the first target neural network model is preferably the third neural network model, the first target neural network model can be trained through the first class of data and the second class of data to obtain the second target neural network model, and the effect of classifying the data by the second target neural network model is optimal to compare with the first target neural network model.
The following describes, by way of example, a process of training a neural network model in conjunction with a specific implementation manner in an embodiment of the present application; in the present embodiment, the description will be given taking unbalanced image data as a training sample.
The method for training unbalanced image data provided in this embodiment includes:
in step S61, unbalanced image data is obtained, wherein the unbalanced image data includes two types of image data, sample data a (corresponding to the second type of data) and sample data B (corresponding to the first type of data).
Step S62, labeling the image data to obtain sample data A and sample data B; the number of sample data A is far smaller than that of sample data B.
Step S63, randomly randomizing and undersampling the sample data B to obtain sample data B' (corresponding to the first target data); the number of the sample data B 'is approximately equal to the number of the sample data a, that is, the absolute value of the difference between the number of the sample data B' and the number of the sample data a is smaller than the preset threshold.
In step S64, an initial neural network model is trained on the sample data B' and the sample data a obtained in step S63 and converged, resulting in model1 (corresponding to the first neural network model described above).
In step S65, model1 is used to predict sample data B that does not contain sample data B'.
In step S66, sample data B _ succ with correct prediction (corresponding to the data corresponding to the result of the first correct prediction) and sample data _ B _ fail with incorrect prediction (corresponding to the data corresponding to the result of the first incorrect prediction) are obtained.
In step S67, the data samples obtained in step S66 are randomly scrambled and undersampled, and sample data B ″ is obtained according to a ratio (corresponding to the first preset ratio) that sample data with correct prediction and sample data with incorrect prediction are 5:5, and the number of sample data B ″ is approximately equal to the number of sample data a.
At step S68, using model1 as a pre-training model, training samples (sample data B' and sample data A) are obtained from step S67, the model is trained and converged, resulting in model2 (corresponding to the second neural network model described above).
In step S69, model2 is used to predict samples in sample data B that do not contain sample data B 'and sample data B'.
Step S70, obtaining sample data B1_ succ (corresponding to the data corresponding to the second predicted correct result) with correct prediction and sample data B1_ fail (corresponding to the data corresponding to the second predicted wrong result) with wrong prediction;
step S71, randomly randomizing and undersampling the samples obtained in step S70, obtaining sample data B '"according to a ratio (corresponding to the second preset ratio) of correctly predicted sample data to incorrectly predicted sample data being 3:7, wherein the number of the sample data B'" is approximately equal to that of the sample data a;
step S72, obtaining training sample data B' and sample data A from step S71, training model2 and converging to obtain model3 (corresponding to the third neural network model).
Step S73, the model3 is trained through the sample data A and the sample data B, and a final model (a second target neural network model) is obtained.
As can be seen from the foregoing steps S61 to S73, in the specific embodiment of the present application, a dynamic sampling method is adopted, the training data is dynamically adjusted according to the training result, that is, the sample is randomly deleted for the better category, the number of samples is increased for the worse category (the specific addition and deletion processes are performed through the above two proportional relationships), and all samples are gradually used to train the neural network model, so as to ensure that the classified neural network model can learn the relevant information each time of learning, and avoid the over-fitting defect in the over-sampling and the incomplete information in the under-sampling in the prior art.
In another implementation manner of the embodiments of the present application, an embodiment of the present application further provides a data classification method, fig. 2 is a flowchart of the data classification method according to the embodiment of the present application, and as shown in fig. 2, the method includes the steps of:
step S202, acquiring data to be classified;
step S204, inputting data to be classified into a classification neural network model for classification to obtain a classification result;
the classification neural network model is a neural network model trained based on the method steps in fig. 1.
The data are classified by the neural network model trained based on the method steps in fig. 1, and in the process of classifying the neural network model, the training data are dynamically adjusted according to the training result aiming at unbalanced data samples, so that the over-fitting defect in over-sampling and the defect of incomplete information in under-sampling are avoided, and the accuracy of classifying the data by the first target neural network model is high.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method of the embodiments of the present application.
In the embodiment of the present application, a training device for a neural network model and a data classification device are further provided, and the devices are respectively used for implementing the embodiments in fig. 1 and fig. 2 in the foregoing embodiments, and are not described again after having been described. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Referring to fig. 3, fig. 3 is a schematic structural diagram of a training apparatus for a neural network model according to an embodiment of the present application, and as shown in fig. 3, the apparatus includes:
the determining module 32 is configured to determine first target data from first class data in sample data, where the sample data further includes second class data, the number of the first class data is greater than the number of the second class data, and an absolute value of a difference between the number of the first target data and the number of the second class data is smaller than a preset threshold;
the first training module 34 is configured to input the first target data and the second type data as first training samples into the initial neural network model for training, so as to obtain a first neural network model;
the test module 36 is configured to test the first neural network model by using the first residual data from the first type of data after the first target data is removed as a first test sample, so as to obtain a test result, where the test result includes a result with a correct first prediction and a result with a wrong first prediction;
the second training module 38 is configured to perform model training for N times based on the first neural network model and a training sample determined according to the second type of data and the test sample to obtain a first target neural network model;
the neural network model obtained by the current model training is used as an object of the next model training, the current training sample comprises the second type data and target data, data corresponding to a correct prediction result and data corresponding to an incorrect prediction result of the last model testing are collected according to a preset proportion in a test sample of the last model testing to obtain the current target data, and the test sample of the current model training is obtained by removing the target data determined by each model training from the first type data.
Optionally, in the case that the value of N is 1, the second training module 38 in this embodiment of the present application further includes: the first undersampling unit is used for undersampling in the first test sample to obtain second target data, wherein the second target data comprises data corresponding to a first correctly predicted result and data corresponding to a first incorrectly predicted result, which are sampled according to a first preset proportion, and the absolute value of the difference between the number of the second target data and the number of the second type of data is smaller than a preset threshold value; and the first training unit is used for inputting the second target data and the second class data as second training samples into the first neural network model for training to obtain a second neural network model, wherein the second neural network model is the first target neural network model.
Based on this, in the case that the value of N is 2, the second training module 38 in this embodiment may further include: the test unit is used for taking second residual data obtained after the first target data and the second target data of the first type of data are removed as a second test sample to test the second neural network model to obtain a test result, wherein the test result comprises a second result with correct prediction and a second result with wrong prediction; the second undersampling unit is used for undersampling in a second test sample to obtain third target data, wherein the third target data comprise data corresponding to a second correctly predicted result and data corresponding to a second wrongly predicted result, which are sampled according to a second preset proportion, and the absolute value of the difference between the number of the third target data and the number of the second type of data is smaller than a preset threshold value; and the second training unit is used for inputting third target data and second class data serving as third training samples into the second neural network model for training to obtain a third neural network model, wherein the third neural network model is the first target neural network model.
Optionally, the apparatus in this embodiment of the present application may further include: and the third training module is used for training the first target neural network model by taking the first class of data and the second class of data as target training samples to obtain a second target neural network model.
Optionally, the ratio of the first preset ratio to the second preset ratio in this embodiment of the application is a ratio of the number of data corresponding to the result with correct prediction to the number of data corresponding to the result with wrong second prediction, and the ratio is less than or equal to 1.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a data classification apparatus according to an embodiment of the present application, and as shown in fig. 4, the apparatus includes:
an obtaining module 42, configured to obtain data to be classified;
the classification module 44 is used for inputting the data to be classified into the classification neural network model for classification to obtain a classification result;
the classification neural network model is obtained by training based on the training method of the neural network model in fig. 1.
In the process of training the training method of the neural network model, aiming at unbalanced data samples, the data trained each time comprises the data corresponding to the correct result predicted in the test sample tested by the previous model and the data corresponding to the wrong result predicted, the integrity of the training data is ensured, the data corresponding to the wrong result predicted can be trained in a targeted manner, the model is converged continuously, the data with the wrong recognition is learned intensively, the defect that the information is incomplete due to over-sampling and under-sampling in the prior art is avoided, the accuracy of classifying the data by the trained classified neural network model is higher, and the problem that the accuracy of classifying the data by the model trained by using the unbalanced data in the prior art is low is solved.
Optionally, an embodiment of the present application further provides an electronic device, which includes a processor, a memory, and a program or an instruction stored in the memory and capable of running on the processor, where the program or the instruction is executed by the processor to implement each process of the data classification method embodiment, and can achieve the same technical effect, and details are not repeated here to avoid repetition.
It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and the non-mobile electronic devices described above.
The embodiment of the present application further provides a readable storage medium, where a program or an instruction is stored on the readable storage medium, and when the program or the instruction is executed by a processor, the program or the instruction implements each process of the data classification method embodiment, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here.
The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and so on.
It will be apparent to those skilled in the art that the modules or steps of the present application described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of multiple computing devices, and alternatively, they may be implemented by program code executable by a computing device, such that they may be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present application is not limited to any specific combination of hardware and software.
The above description is only a preferred embodiment of the present application and is not intended to limit the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (10)

1. A training method of a neural network model is characterized by comprising the following steps:
determining first target data from first class data in sample data, wherein the sample data further comprises second class data, the quantity of the first class data is greater than that of the second class data, and the absolute value of the difference between the quantity of the first target data and the quantity of the second class data is less than a preset threshold;
inputting the first target data and the second type data as a first training sample into an initial neural network model for training to obtain a first neural network model;
taking first residual data in the first type of data after the first target data is removed as a first test sample to test the first neural network model to obtain a test result, wherein the test result comprises a first correctly predicted result and a first incorrectly predicted result;
performing model training for N times based on the first neural network model and a training sample determined according to the second type of data and the test sample to obtain a first target neural network model, wherein N is an integer greater than or equal to 1;
the neural network model obtained by the current model training is used as an object of the next model training, the current training sample comprises the second type data and target data, data corresponding to a correct prediction result and data corresponding to an incorrect prediction result of the last model testing are collected according to a preset proportion in a test sample of the last model testing to obtain the current target data, and the test sample of the current model training is obtained by removing the target data determined by each model training from the first type data.
2. The method of claim 1, wherein under the condition that the value of N is 1, performing model training for 1 time by using the first neural network model to obtain a first target neural network model, comprises:
performing undersampling on the first test sample to obtain second target data, wherein the second target data comprise data corresponding to the first result with correct prediction and data corresponding to the result with wrong prediction, which are sampled according to a first preset proportion, and the absolute value of the difference between the number of the second target data and the number of the second type of data is smaller than a preset threshold;
and inputting the second target data and the second class of data serving as second training samples into the first neural network model for training to obtain a second neural network model, wherein the second neural network model is the first target neural network model.
3. The method of claim 2, wherein training the first neural network model2 times to obtain a first target neural network model when the value of N is 2 comprises:
taking second residual data obtained after the first target data and the second target data are removed from the first type of data as a second test sample to test the second neural network model to obtain a test result, wherein the test result comprises a second result with correct prediction and a second result with wrong prediction;
performing undersampling on the second test sample to obtain third target data, wherein the third target data comprise data corresponding to a second result which is correctly predicted and data corresponding to a second result which is incorrectly predicted, the data are sampled according to a second preset proportion, and the absolute value of the difference between the number of the third target data and the number of the second type of data is smaller than a preset threshold;
and inputting the third target data and the second class of data as a third training sample into the second neural network model for training to obtain a third neural network model, wherein the third neural network model is the first target neural network model.
4. A method as claimed in claim 2 or 3, characterized in that the method further comprises:
and taking the first type of data and the second type of data as target training samples to train the first target neural network model to obtain a second target neural network model.
5. The method according to claim 3, wherein the ratio of the first predetermined ratio to the second predetermined ratio is a ratio of a number of data corresponding to the result with correct prediction to a number of data corresponding to the result with wrong second prediction, and the ratio is less than or equal to 1.
6. A method of classifying data, comprising:
acquiring data to be classified;
inputting the data to be classified into a classification neural network model for classification to obtain a classification result;
wherein, the classification neural network model is obtained by training the training method of the neural network model according to any one of claims 1 to 5.
7. An apparatus for training a neural network model, comprising:
the device comprises a determining module, a judging module and a judging module, wherein the determining module is used for determining first target data from first class data in sample data, the sample data further comprises second class data, the quantity of the first class data is greater than that of the second class data, and the absolute value of the difference between the quantity of the first target data and the quantity of the second class data is smaller than a preset threshold;
the first training module is used for inputting the first target data and the second type data as first training samples into an initial neural network model for training to obtain a first neural network model;
the testing module is used for testing the first neural network model by taking first residual data obtained after the first target data in the first type of data are removed as a first testing sample to obtain a testing result, wherein the testing result comprises a first correctly predicted result and a first wrongly predicted result;
the second training module is used for carrying out model training for N times based on the first neural network model and a training sample determined according to the second type of data and the test sample to obtain a first target neural network model, wherein N is an integer greater than or equal to 1;
the neural network model obtained by the current model training is used as an object of the next model training, the current training sample comprises the second type data and target data, data corresponding to a correct prediction result and data corresponding to an incorrect prediction result of the last model testing are collected according to a preset proportion in a test sample of the last model testing to obtain the current target data, and the test sample of the current model training is obtained by removing the target data determined by each model training from the first type data.
8. An apparatus for classifying data, comprising:
the acquisition module is used for acquiring data to be classified;
the classification module is used for inputting the data to be classified into a classification neural network model for classification to obtain a classification result;
wherein, the classification neural network model is obtained by training the training method of the neural network model according to any one of claims 1 to 5.
9. An electronic device comprising a processor, a memory and a program or instructions stored on the memory and executable on the processor, the program or instructions, when executed by the processor, implementing the steps of a training method comprising a neural network model according to any one of claims 1-5, or the steps of a classification method of data according to any one of claim 6.
10. A readable storage medium, characterized in that it stores thereon a program or instructions which, when executed by a processor, carry out the steps of a training method comprising a neural network model according to any one of claims 1 to 5, or a classification method of data according to any one of claim 6.
CN202010661797.5A 2020-07-10 2020-07-10 Training method and device of neural network model, and data classification method and device Pending CN111881948A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010661797.5A CN111881948A (en) 2020-07-10 2020-07-10 Training method and device of neural network model, and data classification method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010661797.5A CN111881948A (en) 2020-07-10 2020-07-10 Training method and device of neural network model, and data classification method and device

Publications (1)

Publication Number Publication Date
CN111881948A true CN111881948A (en) 2020-11-03

Family

ID=73150110

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010661797.5A Pending CN111881948A (en) 2020-07-10 2020-07-10 Training method and device of neural network model, and data classification method and device

Country Status (1)

Country Link
CN (1) CN111881948A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112138394A (en) * 2020-10-16 2020-12-29 腾讯科技(深圳)有限公司 Image processing method, image processing device, electronic equipment and computer readable storage medium
CN112465043A (en) * 2020-12-02 2021-03-09 平安科技(深圳)有限公司 Model training method, device and equipment
CN112633370A (en) * 2020-12-22 2021-04-09 中国医学科学院北京协和医院 Detection method, device, equipment and medium for filamentous fungus morphology
CN113988165A (en) * 2021-10-22 2022-01-28 北京京东振世信息技术有限公司 Data acquisition method and device, electronic equipment and storage medium
CN115238837A (en) * 2022-09-23 2022-10-25 荣耀终端有限公司 Data processing method and device, electronic equipment and storage medium

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112138394A (en) * 2020-10-16 2020-12-29 腾讯科技(深圳)有限公司 Image processing method, image processing device, electronic equipment and computer readable storage medium
CN112465043A (en) * 2020-12-02 2021-03-09 平安科技(深圳)有限公司 Model training method, device and equipment
CN112465043B (en) * 2020-12-02 2024-05-14 平安科技(深圳)有限公司 Model training method, device and equipment
CN112633370A (en) * 2020-12-22 2021-04-09 中国医学科学院北京协和医院 Detection method, device, equipment and medium for filamentous fungus morphology
CN113988165A (en) * 2021-10-22 2022-01-28 北京京东振世信息技术有限公司 Data acquisition method and device, electronic equipment and storage medium
CN115238837A (en) * 2022-09-23 2022-10-25 荣耀终端有限公司 Data processing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN111881948A (en) Training method and device of neural network model, and data classification method and device
EP3678058A1 (en) Data sample label processing method and apparatus
CN109816032B (en) Unbiased mapping zero sample classification method and device based on generative countermeasure network
US11942074B2 (en) Learning data acquisition apparatus, model learning apparatus, methods and programs for the same
CN110634471B (en) Voice quality inspection method and device, electronic equipment and storage medium
CN108717519B (en) Text classification method and device
CN110263328B (en) Discipline capability type labeling method and device, storage medium and terminal equipment
CN110968689A (en) Training method of criminal name and law bar prediction model and criminal name and law bar prediction method
CN112995690B (en) Live content category identification method, device, electronic equipment and readable storage medium
CN111538668A (en) Mobile terminal application testing method, device, equipment and medium based on reinforcement learning
CN109800309A (en) Classroom Discourse genre classification methods and device
CN113535399A (en) NFV resource scheduling method, device and system
CN107704869B (en) Corpus data sampling method and model training method
CN110490056A (en) The method and apparatus that image comprising formula is handled
CN112100509B (en) Information recommendation method, device, server and storage medium
CN113609390A (en) Information analysis method and device, electronic equipment and computer readable storage medium
CN111488950B (en) Classification model information output method and device
JP2019159835A (en) Learning program, learning method and learning device
CN111813593A (en) Data processing method, equipment, server and storage medium
CN109829051B (en) Method and device for screening similar sentences of database
CN111950852A (en) User behavior analysis and guidance method and device, electronic equipment and readable storage device
CN113434630B (en) Customer service evaluation method, customer service evaluation device, terminal equipment and medium
CN110400560A (en) Data processing method and device, storage medium, electronic device
CN115906797A (en) Text entity alignment method, device, equipment and medium
CN106599312B (en) Knowledge base inspection method and device and terminal

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