A training method for a liquid detection model, a liquid detection method and a liquid detection device
By expanding the amount of training data, the accuracy of the liquid detection model is improved, and the problems of difficulty in determining liquid types and insufficient data in the prior art are solved.
Patent Information
- Application Number
- CN202210764936.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-29
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2042-06-29
AI Technical Summary
The existing liquid detection models have low accuracy when carefully classifying liquid types, making it difficult to determine the liquid types, resulting in insufficient training data and affecting the model accuracy.
By obtaining the original data set, including unlabeled data and labeled data, determining the labels that meet the adjustment conditions, and writing the liquid type labels in the labeled data into the unlabeled data, generating new labeled data, thereby expanding training Data volume improves model accuracy.
The amount of training data is increased, the accuracy of the liquid detection model is improved, and the problem of low accuracy is solved due to insufficient data.
Smart Images

Figure CN115130586B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a training method for a liquid detection model, a liquid detection method and a liquid detection device. Background Art
[0002] The microwave reflection method is a method for realizing liquid detection. Specifically, the detection data of the liquid to be tested is obtained by emitting microwaves to the liquid to be tested, and then the detection data is input into a pre-trained liquid detection model to determine the liquid type of the liquid to be tested.
[0003] In the prior art, due to the difficult-to-distinguish characteristics of liquids, it is difficult to determine the exact liquid type of a liquid when the liquid types are divided more finely. Even many liquids cannot be directly determined to which liquid type they belong, making it difficult to collect enough training data, resulting in a low accuracy rate of the trained liquid detection model. Summary of the invention
[0004] The purpose of the embodiments of the present invention is to provide a liquid detection model training method, liquid detection method and device to improve the accuracy of the trained liquid detection model. The specific technical solution is as follows:
[0005] In a first aspect, an embodiment of the present invention provides a method for training a liquid detection model, the method comprising:
[0006] Acquire an original data set, wherein the original data set includes: at least one unlabeled data and at least one labeled data; wherein each unlabeled data only includes characteristic information of detection data of any liquid; each labeled data includes: characteristic information of detection data of any liquid and a liquid type label; the detection data of each liquid is: detection data obtained by performing liquid detection on the liquid based on the microwave reflection principle;
[0007] From the at least one unlabeled data, determine the unlabeled data whose characteristic information meets the adjustment condition as the unlabeled data to be adjusted; wherein the adjustment condition includes matching the characteristic information in any labeled data;
[0008] Writing the liquid type label in the designated labeled data into the unlabeled data to be adjusted to obtain newly generated labeled data; wherein the characteristic information in the designated labeled data matches the characteristic information in the unlabeled data to be adjusted;
[0009] Based on the labeled data, the classification model to be trained is trained to obtain a trained liquid detection model.
[0010] In a second aspect, an embodiment of the present invention provides a liquid detection method, which is applied to a liquid detection device that performs liquid detection based on the microwave reflection principle, and the method includes:
[0011] Acquiring original detection data detected by the liquid detection device for the liquid to be detected;
[0012] Determining target feature information corresponding to the original detection data;
[0013] The target feature information is input into a liquid detection model to determine the liquid type of the liquid to be tested; wherein the liquid detection model is obtained by training using any of the liquid detection model training methods described in the first aspect.
[0014] In a third aspect, an embodiment of the present invention provides a training device for a liquid detection model, the device comprising:
[0015] A data set acquisition module is used to acquire an original data set, wherein the original data set includes: at least one unlabeled data and at least one labeled data; wherein each unlabeled data only includes characteristic information of detection data of any liquid; each labeled data includes: characteristic information of detection data of any liquid and a liquid type label; the detection data of each liquid is: detection data obtained by performing liquid detection on the liquid based on the microwave reflection principle;
[0016] A data determination module, configured to determine, from the at least one unlabeled data, unlabeled data whose characteristic information meets an adjustment condition as the unlabeled data to be adjusted; wherein the adjustment condition includes matching characteristic information in any labeled data;
[0017] A data adjustment module, used for writing the liquid type label in the specified labeled data into the unlabeled data to be adjusted to obtain newly generated labeled data; wherein the characteristic information in the specified labeled data matches the characteristic information in the unlabeled data to be adjusted;
[0018] The model training module is used to train the classification model to be trained based on the labeled data to obtain a trained liquid detection model.
[0019] In a fourth aspect, an embodiment of the present invention provides a liquid detection device, which is applied to a liquid detection device for liquid detection based on the microwave reflection principle, and the device includes:
[0020] A data acquisition module, used to acquire original detection data detected by the liquid detection device for the liquid to be detected;
[0021] An information determination module, used to determine target feature information corresponding to the original detection data;
[0022] The type determination module is used to input the target feature information into a liquid detection model to determine the liquid type of the liquid to be tested; wherein the liquid detection model is obtained by training using a training device for a liquid detection model described in any one of the third aspects.
[0023] In a fifth aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus;
[0024] Memory, used to store computer programs;
[0025] The processor is used to implement any method step described in the first aspect when executing a program stored in the memory.
[0026] In a sixth aspect, an embodiment of the present invention provides a liquid detection device, including a liquid detection position, a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus;
[0027] A liquid detection position, used to carry a container containing a liquid to be detected and to detect the liquid to be detected;
[0028] Memory, used to store computer programs;
[0029] The processor is used to implement any method step described in the second aspect when executing the program stored in the memory.
[0030] In a seventh aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of the first aspect or the second aspect are implemented.
[0031] Beneficial effects of the embodiments of the present invention:
[0032] A training method for a liquid detection model provided by an embodiment of the present invention can obtain an original data set, wherein the original data set includes: at least one unlabeled data and at least one labeled data; wherein each unlabeled data only includes characteristic information of the detection data of any liquid; each labeled data includes: characteristic information of the detection data of any liquid and a liquid type label; the detection data of each liquid is: detection data obtained by performing liquid detection on the liquid based on the principle of microwave reflection; from at least one unlabeled data, determine the unlabeled data whose characteristic information meets the adjustment condition as the unlabeled data to be adjusted; wherein the adjustment condition includes matching with the characteristic information in any labeled data; write the liquid type label in the specified labeled data into the unlabeled data to be adjusted to obtain newly generated labeled data, that is, use the liquid type label in the specified labeled data as the label of the unlabeled data to be adjusted; wherein the characteristic information in the specified labeled data matches the characteristic information in the unlabeled data to be adjusted; based on each labeled data, train the classification model to be trained to obtain a trained liquid detection model. Since it is possible to determine, from at least one unlabeled data, the unlabeled data whose characteristic information meets the adjustment conditions as the unlabeled data to be adjusted, and then write the liquid type label in the specified labeled data into the unlabeled data to be adjusted to obtain newly generated labeled data, the number of labeled data is increased, so that more data is available for training the detection model to be trained, thereby improving the accuracy of the trained liquid detection model.
[0033] On this basis, an embodiment of the present invention further provides a liquid detection method. The liquid detection model obtained by training using the liquid detection model training method provided by the embodiment of the present invention is used to perform liquid detection on the liquid to be tested, thereby improving the accuracy of liquid detection.
[0034] Of course, it is not necessary to achieve all of the advantages described above at the same time to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can also be obtained based on these drawings.
[0036] Figure 1 A flow chart of a method for training a liquid detection model provided in an embodiment of the present invention;
[0037] Figure 2Another flow chart of the training method of the liquid detection model provided by the embodiment of the present invention;
[0038] Figure 3 Another flow chart of the training method of the liquid detection model provided by the embodiment of the present invention;
[0039] Figure 4 Another flow chart of the training method of the liquid detection model provided by the embodiment of the present invention;
[0040] Figure 5 Another flow chart of the training method of the liquid detection model provided by the embodiment of the present invention;
[0041] Figure 6 Another flow chart of the training method of the liquid detection model provided by the embodiment of the present invention;
[0042] Figure 7 A flow chart of a liquid detection method provided by an embodiment of the present invention;
[0043] Figure 8 A schematic diagram of the structure of a training device for a liquid detection model provided by an embodiment of the present invention;
[0044] Fig. 9 A schematic diagram of the structure of a liquid detection device provided by an embodiment of the present invention;
[0045] Fig.10 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention;
[0046] Fig.11 This is a schematic diagram of the structure of a liquid detection device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field based on this application belong to the scope of protection of the present invention.
[0048] The following first introduces a training method for a liquid detection model provided by an embodiment of the present invention.
[0049] In specific applications, the training method of the liquid detection model provided by the embodiment of the present invention can be applied to various electronic devices, such as personal computers, servers, mobile phones and other devices with data processing capabilities. In addition, the training method of the liquid detection model provided by the embodiment of the present invention can be implemented by software, hardware or a combination of software and hardware.
[0050] In order to improve the accuracy of the trained liquid detection model, an embodiment of the present invention provides a method and device for training a liquid detection model.
[0051] The training method of the liquid detection model provided in the embodiment of the present invention may include:
[0052] Acquire an original data set, wherein the original data set includes: at least one unlabeled data and at least one labeled data; wherein each unlabeled data only includes characteristic information of detection data of any liquid; each labeled data includes: characteristic information of detection data of any liquid and a liquid type label; the detection data of each liquid is: detection data obtained by performing liquid detection on the liquid based on the microwave reflection principle;
[0053] Determine, from at least one unlabeled data, unlabeled data whose characteristic information meets an adjustment condition as the unlabeled data to be adjusted; wherein the adjustment condition includes matching characteristic information in any labeled data;
[0054] Writing the liquid type label in the designated labeled data into the unlabeled data to be adjusted to obtain newly generated labeled data; wherein the characteristic information in the designated labeled data matches the characteristic information in the unlabeled data to be adjusted;
[0055] Based on the labeled data, the classification model to be trained is trained to obtain a trained liquid detection model.
[0056] In the above scheme of the embodiment of the present invention, since the unlabeled data whose characteristic information meets the adjustment conditions is determined from at least one unlabeled data as the unlabeled data to be adjusted, and then the liquid type label in the specified labeled data is written into the unlabeled data to be adjusted, newly generated labeled data is obtained, that is, the liquid type label in the specified labeled data is used as the label of the unlabeled data to be adjusted, thereby increasing the number of labeled data, so that more data is used to train the detection model to be trained, thereby improving the accuracy of the trained liquid detection model.
[0057] The following will describe in detail the training method of the liquid detection model provided by the embodiment of the present invention in conjunction with the accompanying drawings.
[0058] like Figure 1 As shown, an embodiment of the present invention provides a method for training a liquid detection model, including steps S101-S104, wherein:
[0059] S101, obtaining an original data set, wherein the original data set includes: at least one unlabeled data and at least one labeled data;
[0060] Each unlabeled data only includes the characteristic information of the detection data of any liquid; each labeled data includes: the characteristic information of the detection data of any liquid and the liquid type label; the detection data of each liquid is: the detection data obtained by performing liquid detection on the liquid based on the microwave reflection principle;
[0061] Exemplarily, in the data collection stage, the emission signal S0 can be used to detect the sample liquid 1 of known liquid type to obtain the detection data S, and the feature extraction of the detection data S can be performed to obtain the feature information T. Among them, the liquid type label of the liquid type of the sample liquid is type 1, and the label data is (type 1, T) or (T, type 1).
[0062] The above detection data may be the detection data obtained by the liquid detection device using a single frequency microwave signal to measure the liquid. For example, the liquid detection device uses a 10HZ microwave signal to measure the liquid in the container, and the obtained reflection signal is f. Then, the liquid detection device may use the amplitude value and / or phase value of the reflection signal f as the detection data. In simple terms, after receiving the reflection signal f, the liquid detection device may determine the amplitude value and / or phase value of the reflection signal f. If the amplitude value or phase value is determined, the determined amplitude value and phase value may be used as the detection data. Alternatively, if the amplitude value and phase value are determined, the amplitude value and phase value may be combined into a vector or a complex number. For example, the detection data is a vector (a, b), where a is the amplitude value and b is the vector value. Alternatively, the detection data is a complex number z=c+di, where the amplitude value of the reflection signal f is The phase value of the reflected signal f is arctan(d / c). If the frequency of the reflected signal f is not fixed, the reflected signal f can be first decomposed into a combination of multiple frequency signals, and then for each frequency signal, the above-mentioned calculation method of the single-frequency microwave signal can be used to determine the detection data of the signal corresponding to each frequency.
[0063] The above detection data can also be liquid detection equipment can also use microwave signals of multiple frequencies to detect liquids. In this case, the detection data obtained by the liquid detection equipment for measuring the liquid can include detection data corresponding to each frequency. Exemplarily, the liquid detection equipment can use microwave signals of 10HZ, 20HZ, and 30HZ to detect liquids, and obtain detection data 1, detection data 2, and detection data 3 respectively. Then the above detection data can include detection data 1, detection data 2, and detection data 3.
[0064] In one example, during the data collection phase, the transmission signal S0 may be:
[0065]
[0066] Among them, A i =[A i1 ,A i2 ,...,A in ], P i =[P i1 ,P i2 ,...,P in ], m is the number of sample liquids, n is the number of microwave signals with different frequencies, A ij is the amplitude value of the jth microwave signal used for the i-th type of sample liquid, P ij is the phase value of the jth microwave signal used for the i-th type of sample liquid.
[0067] Detection data S:
[0068]
[0069] Where γ=[γ A ,γ P ] is the reflection coefficient of the sample liquid, γ A =[γ A1 ,γ A2 ,...,γ Am ] T , represents the reflection coefficient of each sample liquid for the signal amplitude dimension of the transmitted signal, γ P =[γ P1 ,γ P2 ,...,γ Pm ] T , represents the reflection coefficient of each sample liquid with respect to the signal phase dimension of the transmitted signal.
[0070] By performing feature engineering on the detection data S, the feature information of the detection data S can be obtained.
[0071] In the data collection stage, after obtaining the detection data of each liquid, the characteristic information of the detection data can be extracted;
[0072] If the detection data is a single detection data obtained by the liquid detection device using a single frequency microwave signal to measure the liquid, the single detection data can be processed according to a specified data processing method to obtain the first characteristic information. For example, if the detection data is the amplitude value of a single reflection signal, the amplitude value can be normalized to obtain a normalized value as the characteristic information. If the detection data is the amplitude value and phase value of a single reflection signal, the modulus value of a vector composed of the amplitude value and the phase value can be calculated as the characteristic information.
[0073] If the detection data is a plurality of detection data obtained by a liquid detection device measuring a liquid using microwave signals of multiple frequencies, the statistical characteristics of the detection data can be calculated as characteristic information; and / or, the waveform characteristics of the detection data as the frequency of the microwave signal changes can be determined as characteristic information.
[0074] At this time, the characteristic information includes statistical characteristics of the detection data and / or waveform characteristics of the detection data changing with the frequency of the microwave signal;
[0075] The statistical characteristics may include at least one of mean, variance, skewness, kurtosis, energy, root mean square, root square amplitude and peak-to-peak value.
[0076] As shown in Table 1, the calculation formulas for each statistical feature are:
[0077] Table 1
[0078]
[0079]
[0080] In the formulas in the table above, x i represents the i-th detection data among the detection data measured by the liquid detection device for each liquid, n represents the number of multiple detection data, x max is the detection data with the largest value among multiple detection data, x min It is the detection data with the smallest value among multiple detection data.
[0081] The waveform characteristics of the detection data changing with the frequency of the microwave signal are the waveform characteristics of the multiple detection data changing with the frequency of the microwave signal. In simple terms, in a coordinate system with the frequency of the microwave signal as the horizontal axis and the value of the detection data as the vertical axis, the characteristics of the multiple detection data changing with the frequency of the microwave signal.
[0082] In which, in the case where the detection data includes the amplitude value and / or phase value of the reflected signal received by the liquid detection device during liquid detection, if the detection data only includes the amplitude value or the phase value, then the value of the above-mentioned detection data is the amplitude value or the phase value; if the detection data includes the amplitude value and the phase value, then the value of the above-mentioned detection data can be any one of the amplitude value and the phase value, or the value of the detection data can also be the modulus value of the vector composed of the amplitude value and the phase value.
[0083] The above-mentioned unlabeled data only includes characteristic information of the detection data of any liquid, which means that the unlabeled data only contains characteristic information T, and it is unclear which type of liquid the characteristic information belongs to, and thus it is not suitable for training a neural network model.
[0084] In an embodiment of the present invention, in order to improve the accuracy of the liquid detection model obtained by training, a detection data set can be first obtained. Each detection data in the detection data set is detection data obtained by detecting a sample liquid. After the detection data set is obtained, feature extraction can be performed on each detection data in the detection data set to obtain feature information of each detection data. If the sample liquid of the detection data is a liquid of a known liquid type, the extracted feature information can be merged with the liquid type label of the known liquid type to generate labeled data of the known liquid type. If the sample liquid of the detection data is a liquid of an unknown liquid type, the extracted feature information is used as unlabeled data.
[0085] S102, determining, from at least one unlabeled data, unlabeled data whose characteristic information meets the adjustment condition as the unlabeled data to be adjusted;
[0086] The adjustment condition includes matching the characteristic information in any labeled data. Since liquids with the same characteristic information often belong to the same or similar liquid types, it means that the smaller the difference in characteristic information between two liquids, the more similar the two liquids are, and the more likely they are to belong to the same liquid type. Based on this, after acquiring the original data set, the embodiment of the present invention can determine the unlabeled data that matches the characteristic information in any labeled data based on the characteristic information in each unlabeled data and the characteristic information in the labeled data, as the unlabeled data that meets the adjustment condition.
[0087] There may be multiple ways to determine the unlabeled data to be adjusted. Exemplarily, at least one of the following ways may be included:
[0088] In the first method of adjusting the unlabeled data, for each unlabeled data, the feature distance in the feature space between the feature information contained in the unlabeled data and the feature information contained in each labeled data can be calculated, such as calculating the Euclidean distance, and then the feature distance between the feature information in any labeled data and the unlabeled data whose feature distance is less than the first specified feature distance is regarded as the unlabeled data that meets the adjustment conditions. The first specified feature distance threshold can be determined based on demand and experience.
[0089] In the second unlabeled data method to be adjusted, for each liquid type, the mean of the characteristic information contained in the labeled data belonging to the liquid type can be calculated as the baseline characteristic information of the liquid type, and then the characteristic distance between the characteristic information contained in each unlabeled data and the baseline characteristic information in the characteristic space is calculated, and the unlabeled data with a characteristic distance less than the second specified characteristic distance threshold is used as the unlabeled data matching the labeled data corresponding to the baseline characteristic information, that is, the unlabeled data that meets the adjustment conditions. The second specified characteristic distance threshold can be determined based on demand and experience.
[0090] In the third method of determining the unlabeled data to be adjusted, in order to improve the efficiency and accuracy of determining the unlabeled data to be adjusted, the embodiment of the present invention can also determine the unlabeled data to be adjusted by clustering. The details will be described in detail in subsequent embodiments and will not be repeated here.
[0091] S103, writing the liquid type label in the designated labeled data into the unlabeled data to be adjusted, to obtain newly generated labeled data; wherein the characteristic information in the designated labeled data matches the characteristic information in the unlabeled data to be adjusted;
[0092] After determining each unlabeled data to be adjusted, the liquid type label in the specified labeled data can be written into the unlabeled data to be adjusted to obtain newly generated labeled data, that is, the liquid type label in the specified labeled data is used as the label of the unlabeled data to be adjusted; wherein the characteristic information in the specified labeled data matches the characteristic information in the unlabeled data to be adjusted.
[0093] Exemplarily, unlabeled data 1 is: (characteristic information 1), and labeled data 2 is: (category A, characteristic information 2). Characteristic information 1 in unlabeled data 1 matches characteristic information 2 in labeled data 2. Then unlabeled data 1 is the unlabeled data to be adjusted, and labeled data 2 is the specified labeled data. The liquid type label "category A" in the specified labeled data (category A, characteristic information 2) can be written into the unlabeled data to be adjusted (characteristic information 1) to obtain the newly generated labeled data (category A, characteristic information 2). This expands the amount of identified data and solves the problem of insufficient amount of labeled data in related technologies due to the difficulty in classifying liquids.
[0094] S104, based on the labeled data, the classification model to be trained is trained to obtain a trained liquid detection model.
[0095] After the unlabeled data to be adjusted is converted into newly generated labeled data, the amount of labeled data is increased, so that the classification model to be trained can be trained based on each labeled data to obtain a trained liquid detection model.
[0096] Exemplarily, in one implementation method, the feature information in the labeled data can be used as the input of the classification model to be trained, and the liquid type label in the labeled data to which each feature information belongs can be used as calibration data, so that the feature information in each labeled data can be input into the classification model to be trained, and the classification result predicted by the classification model to be trained for the feature information is obtained, and then the loss function value is calculated based on the classification result and the calibration data, and the model parameters of the classification model to be trained are adjusted based on the loss function value until the number of training iterations reaches a specified training iteration threshold and / or the loss function value is less than a specified loss threshold, thereby obtaining a trained liquid detection model.
[0097] In order to further expand the amount of training data, the embodiment of the present invention can further determine the unlabeled data with high credibility from the unlabeled data that does not meet the adjustment conditions as pseudo-labeled data, and then use the pseudo-labeled data and labeled data to train the classification model to be trained to obtain the liquid detection model. The specific implementation method will be described in detail in the subsequent embodiments and will not be repeated here.
[0098] In the above scheme of the embodiment of the present invention, since the unlabeled data whose characteristic information meets the adjustment conditions is determined from at least one unlabeled data as the unlabeled data to be adjusted, and then the liquid type label in the specified labeled data is written into the unlabeled data to be adjusted, newly generated labeled data is obtained, that is, the liquid type label in the specified labeled data is used as the label of the unlabeled data to be adjusted, thereby increasing the number of labeled data, so that more data is used to train the detection model to be trained, thereby improving the accuracy of the trained liquid detection model.
[0099] In order to improve the efficiency and accuracy of the unlabeled data to be adjusted, the embodiment of the present invention can also determine the unlabeled data to be adjusted by clustering. Among them, any clustering algorithm such as k-means (K means) clustering algorithm, hierarchical clustering algorithm, SOM (Self-Organizing Maps) clustering algorithm and FCM (Fuzzy C-Means) clustering algorithm can be used to cluster the unlabeled data in the original data set. Optionally, in order to determine the unlabeled data to be adjusted, such as Figure 2As shown, the embodiment of the present invention provides a method for training a liquid detection model. The above step S102 may include steps S201-S203, wherein:
[0100] S201, for each liquid type represented by a liquid type label in at least one labeled data, select a labeled data from the labeled data having the liquid type label of the liquid type as the reference data of the liquid type;
[0101] In order to improve the accuracy of determining the unlabeled data to be adjusted, the embodiment of the present invention can also determine the liquid type to which the unlabeled data belongs by clustering. Optionally, for each liquid type represented by the liquid type label in at least one labeled data, a labeled data can be selected from the labeled data with the liquid type label of the liquid type as the baseline data of the liquid type. Optionally, for each liquid type, a labeled data can be selected from the labeled data with the liquid type label of the liquid type with equal probability as the baseline data of the liquid type, or based on the feature distance between each feature information, the labeled data with the shortest total feature distance between the contained feature information and other feature information can be selected as the baseline data of the liquid type.
[0102] In this embodiment, the characteristic information in the determined reference data of each liquid type may be used as an initial clustering center for clustering.
[0103] S202, clustering the data in the original data set based on the characteristic information in each data in the original data set and the characteristic distance between the cluster center of each liquid type, to obtain a cluster corresponding to each liquid type;
[0104] Wherein, the cluster center of each liquid type includes characteristic information in the benchmark data of the liquid type;
[0105] In one implementation, the characteristic distance between the characteristic information in each data of the original data set and the characteristic information in the baseline data of each liquid type can be calculated, and then the characteristic information in each data of the original data set can be clustered based on the calculated distance. For example, for each liquid type, the labeled data and / or unlabeled data corresponding to the characteristic information whose characteristic distance with the characteristic information of the baseline data of the liquid type is less than a third specified characteristic distance is used as the data in the cluster corresponding to the liquid type.
[0106] In another implementation, the cluster centers of liquid types can be continuously iteratively updated. At this time, the characteristic information in the benchmark data of each liquid type mentioned above is the initial cluster center. At this time, one labeled data or unlabeled data can be selected from the labeled data and unlabeled data in the original data set as the data to be clustered, and the characteristic distance between the characteristic information in the data to be clustered and the cluster center of the cluster cluster corresponding to each liquid type is calculated, and the data to be clustered is added to the cluster cluster to which the cluster center that satisfies the minimum characteristic distance belongs. For the cluster cluster to which the data to be clustered is added, the cluster center of the cluster cluster is updated based on the characteristic information in each data contained in the cluster cluster, and the step of selecting one labeled data or unlabeled data from the labeled data and unlabeled data in the original data set as the data to be clustered is returned to execute until all the labeled data and unlabeled data in the original data set are clustered.
[0107] After the clustering of each data in the original data set is completed, it is also possible to first determine whether the clustering result meets the preset clustering end condition. If not, return to execute the step of selecting a labeled data as the baseline data of the liquid type from the labeled data with the liquid type label of the liquid type for each liquid type represented by the liquid type label in at least one labeled data, until the clustering result meets the clustering end condition.
[0108] In one implementation, the clustering end condition may include at least one of the following conditions:
[0109] 1. The proportion of labeled data and unlabeled data in the edge area of each cluster is less than the specified ratio threshold;
[0110] The smaller the proportion of labeled data and unlabeled data in the edge area of the cluster, the more concentrated the labeled data and unlabeled data contained in each cluster, and the better the clustering effect. Therefore, when the proportion of labeled data and unlabeled data in the edge area of each cluster is less than the specified ratio threshold, it can be determined that the clustering result meets the preset clustering end condition. The edge area of the cluster can be divided according to experience and needs, and the specified ratio threshold can be determined according to experience and needs.
[0111] 2. The difference between the number of labeled data and unlabeled data in any two clusters is less than the specified number threshold;
[0112] When the difference between the number of labeled data and unlabeled data in any two clusters is less than the specified number threshold, it means that the number of labeled data and unlabeled data in different clusters is small and the clustering effect is good. Therefore, when the difference between the number of labeled data and unlabeled data in any two clusters is less than the specified number threshold, it can be determined that the clustering result meets the preset clustering end condition. The above specified number threshold can be determined based on experience and needs.
[0113] 3. The number of clustering iterations is not less than the specified clustering iteration threshold.
[0114] In order to ensure that clustering can eventually obtain a result instead of falling into infinite iterations, the clustering result can be determined to meet the preset clustering end condition when the clustering iteration number is not less than the specified clustering iteration number threshold. The above specified clustering iteration number threshold can be determined based on experience and needs.
[0115] S203, selecting unlabeled data that meets a preset matching condition from the unlabeled data included in the cluster corresponding to each liquid type as the unlabeled data whose characteristic information meets the adjustment condition;
[0116] After clustering is completed, the characteristic information of the labeled data and the unlabeled data in the same cluster is the same or, after obtaining the cluster corresponding to each liquid type, the unlabeled data that meets the preset matching conditions can be selected from the unlabeled data contained in the cluster corresponding to each liquid type as the unlabeled data whose characteristic information meets the adjustment conditions.
[0117] In one implementation, for each liquid type, all unlabeled data in the cluster corresponding to the liquid type may be determined as unlabeled data that meets a preset matching condition.
[0118] Alternatively, in order to further improve the accuracy of the unlabeled data determined to meet the adjustment conditions, the unlabeled data whose characteristic distance between the characteristic information contained therein and the cluster center of the cluster to which it belongs may be the smallest or less than a specified distance threshold; and / or, after verifying the liquid type using a preset verification method, the unlabeled data may be determined to belong to the liquid type corresponding to the cluster to which it belongs, and be determined as the unlabeled data that meets the adjustment conditions.
[0119] For some unlabeled data, the characteristic information contained therein is the characteristic information of the detection data obtained by detecting the liquid of the verifiable liquid type. Among them, the liquid of the verifiable liquid type can be a liquid with clear properties, such as: water, alcohol, DDV (an organophosphorus pesticide), petroleum, etc., so that after determining the possible liquid type, the determined possible liquid type can be queried and verified to determine whether the liquid of the verifiable liquid type belongs to the determined possible liquid type. The above-mentioned preset verification method can be a manual verification method, such as manually querying data to determine whether the liquid type to which the liquid of the verifiable liquid type belongs belongs to the liquid type corresponding to the cluster to which it belongs.
[0120] Exemplarily, if the cluster corresponding to liquid type 1 contains unlabeled data 3, it can be determined by manually consulting materials or other means whether the liquid to which unlabeled data 3 belongs belongs to liquid type 1, or whether the liquids included in liquid type 1 include the liquid to which unlabeled data 3 belongs. If it is determined that the liquid to which unlabeled data 3 belongs belongs to liquid type 1, or the liquids included in liquid type 1 include the liquid to which unlabeled data 3 belongs, then the unlabeled data 3 belongs to the liquid type corresponding to the cluster.
[0121] Correspondingly, the above-specified labeled data is labeled data that belongs to the same cluster as the selected unlabeled data.
[0122] In the above scheme of the embodiment of the present invention, the accuracy of the liquid detection model obtained through training can be improved, and further, by clustering, the unlabeled data that meets the adjustment conditions can be quickly and accurately determined.
[0123] based on Figure 2 The embodiment shown, as Figure 3 As shown, the embodiment of the present invention provides a training method for a liquid detection model, which may further include steps S301-S305 after the above step S103 and before the above step S104, wherein:
[0124] S301, constructing a plurality of labeled data sets based on the labeled data; wherein each labeled data set includes at least one labeled data;
[0125] After obtaining the newly generated labeled data, in order to further increase the amount of data for training the detection model, the embodiment of the present invention can also determine the unlabeled data with high credibility from the unlabeled data that do not meet the adjustment conditions as pseudo-labeled data. Specifically, multiple labeled data sets can be constructed based on each labeled data; wherein each labeled data set includes at least one labeled data.
[0126] Optionally, each labeled data may be sampled to construct multiple labeled data sets. The embodiment of the present invention does not limit the specific sampling method. For example, a specified number of labeled data may be taken out from each labeled data by random sampling to form a labeled data set. Exemplarily, the labeled data includes labeled data 1, labeled data 2, labeled data 3, labeled data 4, labeled data 5, and labeled data 6. Then, labeled data 1, labeled data 2, and labeled data 3 may be selected to construct labeled data set 1; labeled data 3, labeled data 4, and labeled data 5 may be selected to construct labeled data set 2; labeled data 4, labeled data 5, and labeled data 6 may be selected to construct labeled data set 3.
[0127] S302, for each identified data set, using feature information and liquid type labels in the labeled data in the identified data set to train at least one basic liquid detection model;
[0128] After obtaining multiple labeled data sets, for each labeled data set, the classification model to be trained can be trained based on the feature information and liquid type labels in the labeled data in the labeled data set to obtain a basic liquid detection model.
[0129] Exemplarily, the labeled data sets include: labeled data set 1, labeled data set 2, and labeled data set. Then, labeled data set 1 can be used to treat the classification model for training to obtain basic liquid detection model 1; labeled data set 2 can be used to treat the classification model for training to obtain basic liquid detection model 2; labeled data set 3 can be used to treat the classification model for training to obtain basic liquid detection model 3.
[0130] S303, for each unlabeled data that has not been adjusted, input feature information in the unlabeled data into at least one basic liquid detection model to obtain the liquid type corresponding to the unlabeled data output by the at least one basic liquid detection model;
[0131] After obtaining at least one basic liquid detection model, for each unlabeled data that has not been adjusted, the characteristic information in the unlabeled data can be input into at least one basic liquid detection model, so that the liquid type of the unlabeled data can be detected using at least one basic liquid detection model to obtain the liquid type corresponding to the unlabeled data output by the at least one basic liquid detection model.
[0132] Exemplarily, the above example is continued to explain that at least one basic liquid detection model includes basic liquid detection model 1, basic liquid detection model 2 and basic liquid detection model 3. Then each unlabeled data that has not been adjusted includes unlabeled data 1, unlabeled data 2 and unlabeled data 3. For unlabeled data 1, unlabeled data 1 can be input into basic liquid detection model 1 to obtain the detection result liquid type 11 output by basic liquid detection model 1; unlabeled data 1 can be input into basic liquid detection model 2 to obtain the detection result liquid type 12 output by basic liquid detection model 21; unlabeled data 1 can be input into basic liquid detection model 3 to obtain the detection result liquid type 13 output by basic liquid detection model 1, then liquid type 11, liquid type 12 and liquid type 13 are the liquid types corresponding to unlabeled data 1. The same is true for unlabeled data 2 and unlabeled data 3 and will not be repeated.
[0133] S304, for each unlabeled data that has not been adjusted, determining the number of models output by at least one basic liquid detection model, in which the liquid type corresponding to the unlabeled data is the same type;
[0134] After obtaining the liquid type corresponding to each unlabeled data without data adjustment, the number of models output by at least one basic liquid detection model in which the liquid type corresponding to the unlabeled data is the same type can be determined. Exemplarily, for the unlabeled data 1 in the above example, the corresponding liquid types include liquid type 11, liquid type 12, and liquid type 13. If liquid type 11 and liquid type 12 are both liquid type A, and liquid type 13 is liquid type B, then the number of models in which the liquid type corresponding to the unlabeled data 1 is the same type is 2; if liquid type 11, liquid type 12, and liquid type 13 are all liquid type A, then the number of models in which the liquid type corresponding to the unlabeled data 1 is the same type is 3.
[0135] S305, for each unlabeled data that has not been adjusted, if the number of models of the unlabeled data exceeds a preset number threshold, pseudo-label data is generated, and the pseudo-label data includes the unlabeled data and a liquid type label of the liquid type corresponding to the unlabeled data.
[0136] For each unlabeled data that has not been adjusted, if the number of models of the unlabeled data exceeds a preset number threshold, it means that the credibility of the unlabeled data belonging to the same liquid type is high, so that pseudo-labeled data can be generated, and the pseudo-labeled data includes the unlabeled data and the liquid type label of the liquid type corresponding to the unlabeled data. Among them, the liquid type corresponding to each unlabeled data that has not been adjusted is the liquid type corresponding to the unlabeled data output by at least one basic liquid detection model, or the liquid type with the highest proportion among the input liquid types.
[0137] At this time, if Figure 4 As shown, the above step S104 may include steps S401-S402, wherein:
[0138] S401, constructing a training data set including labeled data and pseudo-labeled data;
[0139] Among them, the training data set includes the feature information in each labeled data and each pseudo-labeled data, and the liquid type label corresponding to each feature information; the liquid type label corresponding to each feature information is: the liquid type label in the labeled data or pseudo-labeled data to which the feature information belongs.
[0140] After obtaining the pseudo-label data of each liquid type, the obtained pseudo-label data may be merged with the labeled data in the labeled data set to generate a training data set.
[0141] S402, using the training data set, training the classification model to be trained to obtain a trained liquid detection model.
[0142] In one implementation, sample data can be selected from a training data set as training data, and then the training data is input into a classification model to be trained to obtain a type prediction result output by the classification model to be trained, and based on the liquid type label and type prediction result contained in the training data, the loss function value of the classification model to be trained is calculated, and the model parameters of the classification model to be trained are adjusted based on the loss function value, and it is determined whether the number of training iterations of the classification model to be trained reaches a specified training iteration number threshold. If so, the classification model to be trained is used as a trained liquid detection model, otherwise, the step of selecting sample data from the training data set as training data is returned. The specified training iteration number threshold can be determined according to actual needs.
[0143] In another implementation, the training data set may include at least one feature information subset, and each feature information subset includes feature information in at least one labeled data and / or unlabeled data.
[0144] At this time, a feature information subset to be used can be selected from at least one feature information subset, and then the feature information in the feature information subset to be used can be input into the classification model to be trained to obtain the type prediction result output by the classification model to be trained, and the loss function value of the classification model to be trained is calculated based on the liquid type label and type prediction result corresponding to the feature information in the feature information subset to be used, and the model parameters of the classification model to be trained are adjusted based on the loss function value, and it is determined whether the classification model to be trained meets the preset training end condition; if the classification model to be trained meets the preset training end condition, the classification model to be trained is used as a trained liquid detection model; or, if the classification model to be trained does not meet the preset training end condition, it returns to execute the selection of the feature information subset to be used from at least one feature information subset. Wherein, the above-mentioned preset training end condition includes: the number of training iterations reaches a specified training iteration number threshold, and / or the loss function value is less than a specified loss threshold.
[0145] In the case where each of the above-mentioned feature information subsets includes multiple feature information, since the credibility of the labeled data is higher, and the credibility of the pseudo-label data is lower than that of the labeled data, the training weight of the labeled data can be increased. At this time, for each feature information in the feature information subset to be used, based on the liquid type label corresponding to the feature information and the type prediction result for the feature information, the loss value corresponding to the feature information can be calculated, and then the loss value corresponding to each feature information in the feature information subset to be used is weighted and summed according to the weights set in advance for the labeled data and the pseudo-label data, so as to obtain the loss function value of the classification model to be trained. Optionally, the weight of the labeled data is greater than the weight of the pseudo-label data.
[0146] In the above scheme of the embodiment of the present invention, the accuracy of the liquid detection model obtained by training can be improved, and the amount of data for training the detection model can be further increased, thereby further improving the accuracy of the liquid detection model obtained by training.
[0147] like Figure 5 As shown, the embodiment of the present invention provides a training method for a liquid detection model, which can perform feature engineering on the data in the liquid database to obtain an original data set S T Use the sample data (labeled data and unlabeled data) in the original data set and related prior knowledge to determine the number of liquid types k (determine the number of types) into which the liquid is divided, and divide the sample data into labeled data S Tl and unlabeled data S Tu .
[0148] Select seeds (cluster centers), that is, select k labeled data and use the feature information contained in them as the initial cluster centers. Use the initial cluster centers to cluster the labeled data and unlabeled data. T The sample data in is divided into k categories, that is, k clusters are obtained. It is judged whether the clustering result meets the preset clustering end condition, that is, whether it meets the index. If the clustering end condition is met, the classification is determined, that is, the clustering result is output, and based on the clustering result, a multi-classification model is trained, that is, the trained liquid detection model; if the clustering end condition is not met, the initial cluster center is re-selected (seeds are re-taken) and clustering is performed again. Among them, the preset clustering end condition can have multiple optional forms, one of which is to determine whether the edge is sparse enough, and the other is whether the number of data in each cluster is close.
[0149] From the final clustering results, verifiable unlabeled data are selected, and the verified unlabeled data are manually determined as new labeled data, and the unverifiable unlabeled data and unverifiable unlabeled data that fail the verification are combined into an unlabeled data set. The feature information contained in the verifiable unlabeled data is the feature information of the detection data obtained by detecting the liquid of the verifiable liquid type.
[0150] Semi-supervised clustering can be used for preliminary labeling, which greatly increases the amount of data contained in the labeled dataset without the need for a lot of initial labeled data. However, its effect is limited, and other algorithms can be used to continue labeling and model training.
[0151] Based on this, on the basis of the above embodiments, Figure 6 As shown, the embodiment of the present invention provides a training method for a liquid detection model, which can perform feature engineering on a liquid database to obtain an original data set S T , and then by adopting Figure 5 The same semi-supervised clustering classification method as shown in the embodiment is used to obtain labeled data S Tl , unlabeled data S Tu And the new label data S obtained by semi-supervised clustering Tp , merge the new labeled data into the labeled data set, that is, combine the verified unlabeled data with the original labeled data into a labeled data set, and obtain the final labeled data set S Tlp There will be a labeled dataset S Tlp Perform two different samplings to obtain data combination 1S Tlp1 Combined with data 2S Tlp2 , two combinations are used for model training to obtain model 1 and model 2. The unlabeled data is input into model 1 and model 2 respectively to obtain pseudo-labeled data 1S p1and pseudo-label data 2S p2 The obtained data contains the data itself and the labels generated by the model. p1 and pseudo-label data 2S p2 Compare and get the data S with the same judgment result p There will be label data S Tlp and S p Combine them to get data combination 3 as the final training data set S train .
[0152] By training S train Perform training and optionally constrain the loss function: loss total =λ1loss tlp +λ2loss p Among them, loss total is the overall loss function, loss tlp is the loss value of labeled data, loss p is the loss value of pseudo-label data. The above loss values are all calculated after the microwave signal features are calculated, which is related to the properties of the microwave signal. λ1 is the weighted value of the loss value of the labeled data, and λ2 is the weighted value of the loss value of the pseudo-label data. Generally, let λ1>λ2 to increase the impact of the labeled data on the training results. The final multi-classification model is obtained.
[0153] In the above scheme of the embodiment of the present invention, since the unlabeled data whose characteristic information meets the adjustment conditions is determined from at least one unlabeled data as the unlabeled data to be adjusted, and then the liquid type label in the specified labeled data is written into the unlabeled data to be adjusted, newly generated labeled data is obtained, that is, the liquid type label in the specified labeled data is used as the label of the unlabeled data to be adjusted, thereby increasing the number of labeled data, so that more data is used to train the detection model to be trained, thereby improving the accuracy of the trained liquid detection model.
[0154] Based on the training method of the liquid detection model provided in the above embodiment of the present invention, Figure 7 As shown, an embodiment of the present invention further provides a liquid detection method, which is applied to a liquid detection device for liquid detection based on the microwave reflection principle, including steps S701-S703, wherein:
[0155] S701, obtaining original detection data detected by the liquid detection device for the liquid to be detected;
[0156] The above original detection data may be detection data obtained by the liquid detection device for measuring the liquid to be tested. The above detection data may be detection values obtained by the liquid detection device using microwaves of a fixed frequency to measure the liquid to be tested. For example, the liquid detection device uses microwaves of 10 Hz to measure the liquid to be tested, and the obtained measurement signal is signal f. Then, the liquid detection device determines the amplitude value and / or phase value of signal f, and based on the amplitude value and / or phase value, determines the detection value obtained by the liquid detection device using microwaves of 10 Hz to measure the liquid to be tested.
[0157] Specifically, for signal f, if signal f is a single-frequency signal, the amplitude value and phase value of signal f can be determined, and then the amplitude value and phase value can be combined into a vector as the detection value obtained by measuring the liquid to be tested. Of course, it should be noted that in addition to converting signal f into a vector, other methods can also be used to transform signal f. For example, f can also be converted into a complex number z=a+bi. In this case, the amplitude value of signal f can be The phase value of signal f may be arctan(b / a). If the frequency of signal f is not fixed, signal f may be first decomposed into a combination of multiple fixed frequency signals, and then for each fixed frequency signal, the above-mentioned calculation method of single frequency signal is used to determine the detection data of signal f.
[0158] Optionally, the detection data may also be a plurality of detection values obtained by the liquid detection device using microwaves of various frequencies to measure the liquid to be detected. Exemplarily, the liquid detection device uses microwaves of 10 Hz, 20 Hz, and 30 Hz to measure the liquid to be detected, and obtains detection value 1, detection value 2, and detection value 3, respectively. Then the detection data may be {detection value 1, detection value 2, detection value 3}.
[0159] When using microwaves of various frequencies to detect the liquid to be tested, the test data can be expressed in the following form:
[0160]
[0161] Among them, S is the detection data, A i =[A i1 ,A i2 ,...,A in ], P i =[P i1 ,P i2 ,...,P in ], m is the number of liquids to be tested, n is the number of microwaves of different frequencies, A ij is the amplitude value of the measurement signal obtained by using the jth frequency for the i-th type of liquid to be tested, P ijis the phase value of the measurement signal obtained by using the jth frequency for the i-th type of liquid to be tested.
[0162] S702, determining target feature information corresponding to the original detection data;
[0163] After obtaining the original test data of the liquid to be tested, the target feature information corresponding to the original test data can be determined. Optionally, feature extraction can be performed on the original test data to obtain initial feature information, and then based on the initial feature information, the target feature information corresponding to the original test data can be determined.
[0164] For feature extraction of the original detection data, reference may be made to the relevant description of feature extraction in the aforementioned embodiment, which will not be described in detail in the embodiment of the present invention. Optionally, in the case where the detection data includes multiple detection values, the feature information of each detection data may include at least one of statistical features and waveform features. The statistical features may include at least one of mean, variance, skewness, kurtosis, energy, root mean square, root square amplitude and peak-to-peak value.
[0165] After the initial feature information is extracted from the original detection data, the target feature information corresponding to the original detection data may be further determined based on the initial feature information.
[0166] Optionally, in an implementation method of target feature information, the initial feature information may be used as the target feature information corresponding to the original detection data, which means that the feature information extracted by performing feature extraction on the original detection data may be used as the target feature information corresponding to the original detection data.
[0167] Alternatively, in another implementation method of the target feature information, in order to improve the detection accuracy, the original detection data can be compensated based on the initial feature information, and features can be extracted from the compensated detection data, and the extracted feature information can be used as the target feature information corresponding to the original detection data.
[0168] The above-mentioned supplementation to the original detection data may include at least one of device consistency compensation and / or width consistency compensation.
[0169] In short, the compensation of the original detection data based on the initial feature information may include at least one of the following two methods:
[0170] The first type of device consistency compensation can determine the device compensation information corresponding to the initial characteristic information based on the first corresponding relationship between the characteristic information of the preset liquid and the device compensation information; and compensate the original detection data using the determined device compensation information; wherein the device compensation information corresponding to the characteristic information of each liquid is: the difference information between the detection data measured by the reference device and the liquid detection device for the liquid;
[0171] Among them, device consistency compensation is the compensation for the difference in data measured between the target detection device and the reference device; the target detection device is a liquid detection device that detects the liquid to be tested, and the reference device is a liquid detection device used when training the liquid detection model. In simple terms, since the liquid detection model is trained based on the detection data collected by the reference device, and since there are consistency issues with different target detection devices, that is, the detection data collected by different target detection devices for the same liquid may be different, the detection data collected by the target detection device may be different from the detection data collected by the reference device, resulting in inaccurate detection results for the liquid to be tested. In order to eliminate or reduce device consistency differences, device consistency compensation can be performed.
[0172] The second type of size consistency compensation can use a predetermined second correspondence to determine the size compensation information corresponding to the specified characteristic information and the specified size information; use the determined size compensation information to compensate the original detection data; wherein the second correspondence is used to characterize the correspondence between the characteristic information of the detection data, the size information of the container and the size compensation information of the detection data; the specified size information includes the initial characteristic information or the characteristic information of the detection data after the device compensates the original detection data based on the initial characteristic information; the specified size information is the size information of the container containing the liquid to be detected;
[0173] The above-mentioned size consistency compensation is for the liquid with characteristic information of the original detection data, and the compensation for the difference in data measured in a container with reference size information and a container with target size information, wherein the reference size information is the size information of the container used when training the liquid detection model, and the target size information is the size information of the container containing the liquid to be tested. In simple terms, due to the different reflection conditions of microwaves in containers with different size information, the detection data measured for the same liquid in containers with different size information are often different, resulting in inaccurate final detection results. In order to eliminate or reduce width consistency differences, width consistency compensation can be performed. The size information of the above-mentioned container can be the width information of the container.
[0174] It should be emphasized that when the original inspection data is supplemented for device consistency and compensated for size consistency at the same time, the original data can be compensated for either one first and then the other, for example, supplemented for device consistency first and then compensated for size consistency.
[0175] S703, inputting the target characteristic information into the liquid detection model to determine the liquid type of the liquid to be detected.
[0176] Among them, the above-mentioned liquid detection model is: obtained by training using the training method of any liquid detection model provided in the embodiments of the present invention. The specific training method can refer to the content of the aforementioned embodiments, and the embodiments of the present invention will not be repeated here.
[0177] In the above scheme of the embodiment of the present invention, the liquid detection model obtained by training using the liquid detection model training method provided by the embodiment of the present invention is used to perform liquid detection on the liquid to be detected, thereby improving the accuracy of liquid detection.
[0178] Corresponding to the training method of the liquid detection model provided in the above embodiment of the present invention, as Figure 8 As shown, an embodiment of the present invention further provides a training device for a liquid detection model, the device comprising:
[0179] The data set acquisition module 801 is used to acquire an original data set, wherein the original data set includes: at least one unlabeled data and at least one labeled data; wherein each unlabeled data only includes characteristic information of detection data of any liquid; each labeled data includes: characteristic information of detection data of any liquid and a liquid type label; the detection data of each liquid is: detection data obtained by performing liquid detection on the liquid based on the microwave reflection principle;
[0180] The data determination module 802 is used to determine, from the at least one unlabeled data, unlabeled data whose characteristic information meets the adjustment condition as the unlabeled data to be adjusted; wherein the adjustment condition includes matching the characteristic information in any labeled data;
[0181] The data adjustment module 803 is used to write the liquid type label in the specified labeled data into the unlabeled data to be adjusted to obtain newly generated labeled data; wherein the characteristic information in the specified labeled data matches the characteristic information in the unlabeled data to be adjusted;
[0182] The model training module 804 is used to train the classification model to be trained based on the labeled data to obtain a trained liquid detection model.
[0183] Optionally, the data determination module includes:
[0184] a data selection submodule, for selecting, for each liquid type represented by the liquid type label in the at least one labeled data, a labeled data from the labeled data having the liquid type label of the liquid type as the reference data of the liquid type;
[0185] A data clustering submodule, for clustering the data of the original data set based on the characteristic information of each data of the original data set and the characteristic distance between the cluster center of each liquid type, to obtain a cluster corresponding to each liquid type; wherein the cluster center of each liquid type includes the characteristic information in the benchmark data of the liquid type;
[0186] A data selection submodule, used to select unlabeled data that meets a preset matching condition from the unlabeled data contained in the cluster corresponding to each liquid type as the unlabeled data whose characteristic information meets the adjustment condition;
[0187] Correspondingly, the specified labeled data is labeled data that belongs to the same cluster as the selected unlabeled data.
[0188] Optionally, the unlabeled data satisfying the preset matching condition includes:
[0189] The unlabeled data whose feature information contained has the smallest feature distance with the cluster center of the cluster or is less than the specified distance threshold; and / or,
[0190] After the liquid type is verified using a preset verification method, it is determined that the unlabeled data belongs to the liquid type corresponding to the cluster.
[0191] Optionally, the model training module is specifically used to construct multiple labeled data sets based on each labeled data; wherein each labeled data set includes at least one labeled data; for each labeled data set, at least one basic liquid detection model is trained using the feature information and liquid type label in the labeled data in the labeled data set; for each unlabeled data that has not been adjusted, the feature information in the unlabeled data is input into at least one basic liquid detection model to obtain the liquid type corresponding to the unlabeled data output by at least one basic liquid detection model; for each unlabeled data that has not been adjusted, the liquid type corresponding to the unlabeled data output by at least one basic liquid detection model is determined. The number of models with the same type of liquid type; if the number of models exceeds a preset number threshold, pseudo-label data is generated, and the pseudo-label data includes the unlabeled data and the liquid type label of the liquid type corresponding to the unlabeled data; a training data set including each labeled data and each pseudo-label data is constructed; wherein the training data set includes the feature information in each labeled data and each pseudo-label data, and the liquid type label corresponding to each feature information; the liquid type label corresponding to each feature information is: the liquid type label in the labeled data or pseudo-label data to which the feature information belongs; using the training data set, the classification model to be trained is trained to obtain a trained liquid detection model.
[0192] Optionally, the training data set includes at least one feature information subset, and each feature information subset includes feature information in at least one labeled data and / or unlabeled data;
[0193] The model training module is specifically used to select a feature information subset to be used from the at least one feature information subset; input the feature information in the feature information subset to be used into the classification model to be trained to obtain the type prediction result output by the classification model to be trained; calculate the loss function value of the classification model to be trained based on the liquid type label corresponding to the feature information in the feature information subset to be used and the type prediction result; adjust the model parameters of the classification model to be trained based on the loss function value; determine whether the classification model to be trained meets the preset training end condition; if the classification model to be trained meets the preset training end condition, then use the classification model to be trained as a trained liquid detection model; or, if the classification model to be trained does not meet the preset training end condition, return to execute the step of selecting the feature information subset to be used from the at least one feature information subset; wherein the preset training end condition includes: the number of training iterations reaches a specified training iteration number threshold, and / or the loss function value is less than a specified loss threshold.
[0194] Optionally, the model training module is specifically used to calculate, for each feature information in the feature information subset to be used, a loss value corresponding to the feature information based on the liquid type label corresponding to the feature information and a type prediction result for the feature information; and perform weighted summation of the loss values corresponding to each feature information in the feature information subset to be used according to weights pre-set for labeled data and pseudo-label data to obtain the loss function value of the classification model to be trained.
[0195] Optionally, the data selection submodule is also used to determine whether the clustering result meets a preset clustering end condition before selecting the unlabeled data that meets the preset matching condition from the unlabeled data contained in the cluster cluster corresponding to each liquid type as the unlabeled data whose characteristic information meets the adjustment condition; if not, calling the data clustering submodule to execute the step of selecting a labeled data from the labeled data with the liquid type label of the liquid type as the baseline data of the liquid type for each liquid type represented by the liquid type label in the at least one labeled data, until the clustering result meets the clustering end condition.
[0196] Optionally, the clustering termination condition includes at least one of the following conditions: the proportion of labeled data and unlabeled data in the edge area of each cluster is less than a specified proportion threshold; the difference in the number of labeled data and unlabeled data in any two clusters is less than a specified number threshold; the number of clustering iterations is not less than a specified clustering iteration threshold.
[0197] Optionally, the data clustering submodule is specifically used to select a labeled data or unlabeled data from the labeled data and unlabeled data in the original data set as the data to be clustered; calculate the characteristic distance between the characteristic information in the data to be clustered and the cluster center of the cluster corresponding to each liquid type; add the data to be clustered to the cluster to which the cluster center satisfies the minimum characteristic distance; for the cluster to which the data to be clustered is added, based on the characteristic information in each data contained in the cluster, update the cluster center of the cluster; return to execute the step of selecting a labeled data or unlabeled data from the labeled data and unlabeled data in the original data set as the data to be clustered, until the labeled data and unlabeled data in the original data set are all clustered.
[0198] In the above scheme of the embodiment of the present invention, since the unlabeled data whose characteristic information meets the adjustment conditions is determined from at least one unlabeled data as the unlabeled data to be adjusted, and then the liquid type label in the specified labeled data is written into the unlabeled data to be adjusted to obtain newly generated labeled data, the amount of labeled data is increased, so that more data is used to train the detection model to be trained, thereby improving the accuracy of the trained liquid detection model.
[0199] Corresponding to the liquid detection method provided by the above embodiment of the present invention, as Fig. 9 As shown, an embodiment of the present invention further provides a liquid detection device, which is applied to a liquid detection device for liquid detection based on the microwave reflection principle, and the device includes:
[0200] The data acquisition module 901 is used to acquire the original detection data detected by the liquid detection device for the liquid to be detected;
[0201] An information determination module 902 is used to determine target feature information corresponding to the original detection data;
[0202] The type determination module 903 is used to input the target feature information into a liquid detection model to determine the liquid type of the liquid to be tested; wherein the liquid detection model is obtained by training with a training device of any liquid detection model provided in an embodiment of the present invention.
[0203] Optionally, the information determination module includes:
[0204] An information extraction submodule is used to extract features from the original detection data to obtain initial feature information;
[0205] An information determination submodule is used to use the initial feature information as the target feature information corresponding to the original detection data; or, based on the initial feature information, compensate the original detection data, perform feature extraction on the compensated detection data, and use the extracted feature information as the target feature information corresponding to the original detection data.
[0206] Optionally, the information determination submodule is specifically used to determine the device compensation information corresponding to the initial characteristic information based on the first corresponding relationship between the characteristic information of the preset liquid and the device compensation information; and to compensate the original detection data using the determined device compensation information; wherein the device compensation information corresponding to the characteristic information of each liquid is: the difference information between the detection data measured by the reference device and the liquid detection device for the liquid; and / or,
[0207] Using a predetermined second correspondence, determine the size compensation information corresponding to the specified characteristic information and the specified size information; use the determined size compensation information to compensate the original detection data; wherein the second correspondence is used to characterize the correspondence between the characteristic information of the detection data, the size information of the container and the size compensation information of the detection data; the specified size information includes the initial characteristic information or the characteristic information of the detection data after the original detection data is compensated by the device based on the initial characteristic information; the specified size information is the size information of the container containing the liquid to be detected.
[0208] In the above scheme of the embodiment of the present invention, the liquid detection model obtained by training using the liquid detection model training method provided by the embodiment of the present invention is used to perform liquid detection on the liquid to be detected, thereby improving the accuracy of liquid detection.
[0209] The embodiment of the present invention further provides an electronic device, such as Fig.10 As shown, it includes a processor 1001, a communication interface 1002, a memory 1003 and a communication bus 1004, wherein the processor 1001, the communication interface 1002, and the memory 1003 communicate with each other through the communication bus 1004.
[0210] Memory 1003, used for storing computer programs;
[0211] The processor 1001 is used to implement the following steps when executing the program stored in the memory 1003:
[0212] Acquire an original data set, wherein the original data set includes: at least one unlabeled data and at least one labeled data; wherein each unlabeled data only includes characteristic information of detection data of any liquid; each labeled data includes: characteristic information of detection data of any liquid and a liquid type label; the detection data of each liquid is: detection data obtained by performing liquid detection on the liquid based on the microwave reflection principle;
[0213] From the at least one unlabeled data, determine the unlabeled data whose characteristic information meets the adjustment condition as the unlabeled data to be adjusted; wherein the adjustment condition includes matching the characteristic information in any labeled data;
[0214] Writing the liquid type label in the designated labeled data into the unlabeled data to be adjusted to obtain newly generated labeled data; wherein the characteristic information in the designated labeled data matches the characteristic information in the unlabeled data to be adjusted;
[0215] Based on the labeled data, the classification model to be trained is trained to obtain a trained liquid detection model.
[0216] The embodiment of the present invention also provides a liquid detection device, such as Fig.11 As shown, it includes a liquid detection position 1101, a processor 1102, a communication interface 1103, a memory 1104 and a communication bus 1105, wherein the processor 1102, the communication interface 1103, and the memory 1104 communicate with each other through the communication bus 1105.
[0217] The liquid detection position 1101 is used to carry a container containing a liquid to be detected and detect the liquid to be detected;
[0218] Memory 1104, used for storing computer programs;
[0219] The processor 1102 is used to implement the following steps when executing the program stored in the memory 1104:
[0220] Acquiring original detection data detected by the liquid detection device for the liquid to be detected;
[0221] Determining target feature information corresponding to the original detection data;
[0222] The target feature information is input into a liquid detection model to determine the liquid type of the liquid to be tested; wherein the liquid detection model is obtained by training using any of the liquid detection model training methods provided in the embodiments of the present invention.
[0223] The communication bus mentioned in the above electronic equipment and liquid detection equipment can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0224] The communication interface is used for communication between the above electronic device and other devices.
[0225] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0226] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0227] In another embodiment provided by the present invention, a computer-readable storage medium is also provided, in which a computer program is stored. When the computer program is executed by a processor, the training method of any of the above-mentioned liquid detection models or the steps of the liquid detection method are implemented.
[0228] In another embodiment provided by the present invention, a computer program product comprising instructions is also provided, which, when executed on a computer, enables the computer to execute any of the liquid detection model training methods or liquid detection methods in the above embodiments.
[0229] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0230] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0231] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for devices, electronic devices, computer storage media, and computer program products, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0232] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A training method for a liquid detection model, characterized in that: The method comprises: Acquire an original data set, wherein the original data set includes: at least one unlabeled data and at least one labeled data; wherein each unlabeled data only includes characteristic information of detection data of any liquid; each labeled data includes: characteristic information of detection data of any liquid and a liquid type label; the detection data of each liquid is: detection data obtained by performing liquid detection on the liquid based on the microwave reflection principle; From the at least one unlabeled data, determine the unlabeled data whose characteristic information meets the adjustment condition as the unlabeled data to be adjusted; wherein the adjustment condition includes matching the characteristic information in any labeled data; Writing the liquid type label in the designated labeled data into the unlabeled data to be adjusted to obtain newly generated labeled data; wherein the characteristic information in the designated labeled data matches the characteristic information in the unlabeled data to be adjusted; Based on the labeled data, the classification model to be trained is trained to obtain a trained liquid detection model.
2. The method according to claim 1, characterized in that The step of determining, from the at least one unlabeled data, unlabeled data whose characteristic information meets the adjustment condition comprises: For each liquid type represented by the liquid type label in the at least one labeled data, select a labeled data from the labeled data having the liquid type label of the liquid type as the reference data of the liquid type; Based on the characteristic information in each data of the original data set and the characteristic distance between the cluster center of each liquid type, clustering the data of the original data set to obtain a cluster corresponding to each liquid type; wherein the cluster center of each liquid type includes the characteristic information in the benchmark data of the liquid type; Selecting unlabeled data that meets a preset matching condition from the unlabeled data included in the cluster corresponding to each liquid type as the unlabeled data whose characteristic information meets the adjustment condition; Correspondingly, the specified labeled data is labeled data that belongs to the same cluster as the selected unlabeled data.
3. The method according to claim 2, characterized in that The unlabeled data that meets the preset matching conditions includes: The unlabeled data whose feature information contained has the smallest feature distance with the cluster center of the cluster or is less than the specified distance threshold; and / or, After the liquid type is verified using a preset verification method, it is determined that the unlabeled data belongs to the liquid type corresponding to the cluster.
4. The method according to claim 3, characterized in that After writing the liquid type label in the designated labeled data into the unlabeled data to be adjusted to obtain newly generated labeled data, and before training the classification model to be trained based on each labeled data to obtain a trained liquid detection model, the method further includes: Based on the labeled data, multiple labeled data sets are constructed; wherein each labeled data set includes at least one labeled data; For each identified data set, using feature information and liquid type labels in the labeled data in the identified data set to train at least one basic liquid detection model; For each unlabeled data that has not been adjusted, input feature information in the unlabeled data into at least one basic liquid detection model to obtain the liquid type corresponding to the unlabeled data output by the at least one basic liquid detection model; For each unlabeled data that has not been adjusted, determine the number of models output by at least one basic liquid detection model that have the same liquid type as the unlabeled data; If the number of models exceeds a preset number threshold, pseudo label data is generated, wherein the pseudo label data includes the unlabeled data and a liquid type label of the liquid type corresponding to the unlabeled data; The method of training the classification model to be trained based on the labeled data to obtain the trained liquid detection model includes: Constructing a training data set including each labeled data and each pseudo-labeled data; wherein the training data set includes feature information in each labeled data and each pseudo-labeled data, and a liquid type label corresponding to each feature information; the liquid type label corresponding to each feature information is: the liquid type label in the labeled data or pseudo-labeled data to which the feature information belongs; The training data set is used to train the classification model to be trained to obtain a trained liquid detection model.
5. The method according to claim 4, characterized in that The training data set includes at least one feature information subset, each feature information subset includes feature information in at least one labeled data and / or unlabeled data; The method of using the training data set to train the classification model to be trained to obtain a trained liquid detection model includes: Selecting a feature information subset to be used from the at least one feature information subset; Inputting the feature information in the feature information subset to be used into the classification model to be trained, and obtaining the type prediction result output by the classification model to be trained; Calculating the loss function value of the classification model to be trained based on the liquid type label corresponding to the feature information in the feature information subset to be used and the type prediction result; Adjusting the model parameters of the classification model to be trained based on the loss function value; Determining whether the classification model to be trained meets a preset training end condition; If the classification model to be trained meets the preset training end condition, the classification model to be trained is used as the trained liquid detection model; or, If the classification model to be trained does not meet the preset training end condition, returning to the step of selecting a feature information subset to be used from the at least one feature information subset; The preset training end condition includes: the number of training iterations reaches a specified training iteration threshold, and / or the loss function value is less than a specified loss threshold.
6. The method according to claim 5, characterized in that Each feature information subset includes a plurality of feature information; The calculating the loss function value of the classification model to be trained based on the liquid type label corresponding to the feature information in the feature information subset to be used and the type prediction result includes: For each feature information in the feature information subset to be used, based on the liquid type label corresponding to the feature information and the type prediction result for the feature information, calculate the loss value corresponding to the feature information; According to the weights pre-set for the labeled data and the pseudo-labeled data, the loss values corresponding to the feature information in the feature information subset to be used are weighted and summed to obtain the loss function value of the classification model to be trained.
7. The method according to any one of claims 2 to 6, characterized in that: Before selecting the unlabeled data satisfying the preset matching condition from the unlabeled data contained in the cluster corresponding to each liquid type as the unlabeled data whose characteristic information meets the adjustment condition, the method further includes: Determine whether the clustering result meets the preset clustering end condition; If not satisfied, return to the step of selecting a labeled data as the reference data of the liquid type from the labeled data having the liquid type label for each liquid type represented by the liquid type label in the at least one labeled data, until the clustering result satisfies the clustering end condition.
8. The method according to claim 7, characterized in that The clustering end condition includes at least one of the following conditions: The proportion of labeled data and unlabeled data in the edge area of each cluster is less than the specified ratio threshold; The difference between the number of labeled data and unlabeled data in any two clusters is less than the specified number threshold; The number of clustering iterations is not less than the specified clustering iteration threshold.
9. The method according to claim 2, characterized in that: The method of clustering the data of the original data set based on the characteristic information of each data of the original data set and the characteristic distance between the cluster center of each liquid type to obtain a cluster cluster corresponding to each liquid type includes: Selecting one labeled data or one unlabeled data from the labeled data and the unlabeled data in the original data set as data to be clustered; Calculating the characteristic distance between the characteristic information in the data to be clustered and the cluster center of each cluster corresponding to each liquid type; Adding the data to be clustered to the cluster to which the cluster center that satisfies the minimum characteristic distance belongs; For the cluster added with the data to be clustered, based on the feature information in each data included in the cluster, updating the cluster center of the cluster; Return to the step of selecting one labeled data or one unlabeled data from the labeled data and the unlabeled data in the original data set as the data to be clustered, until both the labeled data and the unlabeled data in the original data set are clustered.
10. A liquid detection method, characterized in that: A liquid detection device for liquid detection based on the microwave reflection principle, the method comprising: Acquiring original detection data detected by the liquid detection device for the liquid to be detected; Determining target feature information corresponding to the original detection data; The target feature information is input into a liquid detection model to determine the liquid type of the liquid to be tested; wherein the liquid detection model is obtained by training using the liquid detection model training method described in any one of claims 1-9.
11. The method according to claim 10, characterized in that The determining of target feature information corresponding to the original detection data includes: Performing feature extraction on the original detection data to obtain initial feature information; The initial feature information is used as the target feature information corresponding to the original detection data; or, based on the initial feature information, the original detection data is compensated, and features are extracted from the compensated detection data, and the extracted feature information is used as the target feature information corresponding to the original detection data.
12. The method according to claim 11, characterized in that The compensating the original detection data based on the initial feature information includes: Based on a preset first correspondence between characteristic information of the liquid and device compensation information, determine device compensation information corresponding to the initial characteristic information; use the determined device compensation information to compensate the original detection data; wherein the device compensation information corresponding to the characteristic information of each liquid is: difference information between the detection data measured by the reference device and the liquid detection device for the liquid; and / or, Using a predetermined second correspondence, determine the size compensation information corresponding to the specified characteristic information and the specified size information; use the determined size compensation information to compensate the original detection data; wherein the second correspondence is used to characterize the correspondence between the characteristic information of the detection data, the size information of the container and the size compensation information of the detection data; the specified size information includes the initial characteristic information or the characteristic information of the detection data after the original detection data is compensated by the device based on the initial characteristic information; the specified size information is the size information of the container containing the liquid to be detected.
13. A training device for a liquid detection model, characterized in that: The device comprises: A data set acquisition module is used to acquire an original data set, wherein the original data set includes: at least one unlabeled data and at least one labeled data; wherein each unlabeled data only includes characteristic information of detection data of any liquid; each labeled data includes: characteristic information of detection data of any liquid and a liquid type label; the detection data of each liquid is: detection data obtained by performing liquid detection on the liquid based on the microwave reflection principle; A data determination module, configured to determine, from the at least one unlabeled data, unlabeled data whose characteristic information meets an adjustment condition as the unlabeled data to be adjusted; wherein the adjustment condition includes matching characteristic information in any labeled data; A data adjustment module, used for writing the liquid type label in the specified labeled data into the unlabeled data to be adjusted to obtain newly generated labeled data; wherein the characteristic information in the specified labeled data matches the characteristic information in the unlabeled data to be adjusted; The model training module is used to train the classification model to be trained based on the labeled data to obtain a trained liquid detection model.
14. A liquid detection device, characterized in that: A liquid detection device for liquid detection based on the microwave reflection principle, the device comprising: A data acquisition module, used to acquire original detection data detected by the liquid detection device for the liquid to be detected; An information determination module, used to determine target feature information corresponding to the original detection data; A type determination module is used to input the target feature information into a liquid detection model to determine the liquid type of the liquid to be tested; wherein the liquid detection model is obtained by training using the training device for the liquid detection model described in claim 13.
15. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 9 when executing a program stored in a memory.
16. A liquid detection device, characterized in that: It includes a liquid detection unit, a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; A liquid detection position, used to carry a container containing a liquid to be detected and to detect the liquid to be detected; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 10-12 when executing a program stored in a memory.
17. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps of any one of claims 1-9 or 10-12 are implemented.
