Model training method, snore recognition method and related equipment
By iteratively training the feature extractor and domain classifier, and utilizing labeled and unlabeled data, a snoring recognition model is generated. This solves the problem of low recognition accuracy caused by differences in recording equipment and environmental acoustics, achieving highly accurate snoring recognition while protecting user privacy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING XISOUND TECH
- Filing Date
- 2026-03-12
- Publication Date
- 2026-05-19
AI Technical Summary
Existing snoring recognition models have low accuracy due to differences in recording equipment and ambient acoustics.
By iteratively training the feature extractor and domain classifier using labeled and unlabeled data, and adjusting the gradients in opposite directions, a snoring recognition model is generated, reducing the impact of environmental differences.
It improves the accuracy of snoring detection, reduces the impact of differences in recording equipment and room acoustics, and protects acoustic privacy without requiring user annotation.
Smart Images

Figure CN122067564A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information processing technology, and in particular to a model training method, a snoring recognition method, and related equipment. Background Technology
[0002] Snoring is a rough, rattling sound that accompanies breathing after falling asleep. During sleep, factors such as relaxed throat muscles and collapsed throat tissues can cause obstruction or poor ventilation in the upper airway. When airflow is obstructed, the soft tissues of the airway vibrate, producing sound.
[0003] In related technologies, snoring recognition models are often trained using public datasets and then directly applied to users' snoring. However, due to the differences between the recording equipment and room acoustics of the public dataset and the recording equipment and room acoustics of the user's environment, the accuracy of the snoring recognition model in recognizing the user's snoring is relatively low. Summary of the Invention
[0004] This application provides a model training method, a snoring recognition method, and related equipment, which can solve the problem of low accuracy in snoring recognition of existing snoring recognition methods.
[0005] In a first aspect, embodiments of this application provide a model training method for training a preset model, the preset model including a feature extractor, a label classifier, and a domain classifier, the method comprising: Obtain a training dataset, which includes labeled data and unlabeled data. The labels are used to indicate whether the corresponding data is snoring, and the unlabeled data is related to the current environment. The preset model is trained iteratively multiple times based on the training dataset until the target conditions are met, resulting in the trained preset model. A snoring recognition model is generated based on the feature extractor and label classifier included in the trained preset model. The iterative training includes: The labeled data and the unlabeled data are input into the feature extractor for feature extraction, and the first feature vector corresponding to the labeled data and the second feature vector corresponding to the unlabeled data are output by the feature extractor. The first feature vector is input into the label classifier for label classification, and the parameters of the label classifier and the feature extractor are tuned according to the output of the label classifier to obtain the first label classifier and the first feature extractor. The first feature vector and the second feature vector are input into the domain classifier for domain classification, and the parameters of the domain classifier and the first feature extractor are tuned according to the output of the domain classifier to obtain the first domain classifier and the second feature extractor. The parameter tuning gradient directions of the domain classifier and the first feature extractor are opposite. The target conditions include: The label classifier included in the trained preset model converges, and the error of the output result of the domain classifier included in the trained preset model is greater than a preset value.
[0006] Optionally, the first feature vector is input into the label classifier for label classification, and the label classifier and the feature extractor are tuned according to the output of the label classifier to obtain a first label classifier and a first feature extractor, including: The first feature vector is input into the label classifier for label classification, and the snoring classification prediction value output by the label classifier is obtained; Based on the snoring classification prediction value and the label of the labeled data corresponding to the first feature vector, calculate the first loss value; Based on the first loss value, the parameter tuning of the label classifier and the feature extractor is performed to obtain the first label classifier and the first feature extractor.
[0007] Optionally, the first feature vector and the second feature vector are input into the domain classifier for domain classification, and the parameters of the domain classifier and the first feature extractor are tuned according to the output of the domain classifier to obtain a first domain classifier and a second feature extractor, including: The first feature vector and the second feature vector are input into the domain classifier for domain classification, and the first domain prediction value corresponding to the first feature vector and the second domain prediction value corresponding to the second feature vector are output by the domain classifier. The second loss value is calculated based on the first domain prediction value, the second domain prediction value, the domain to which the data corresponding to the first feature vector belongs, and the domain to which the data corresponding to the second feature vector belongs. Based on the second loss value, the parameters of the domain classifier and the first feature extractor are tuned to obtain the first domain classifier and the second feature extractor.
[0008] Optionally, the preset model further includes a gradient inversion layer; The step of tuning the first feature extractor based on the second loss value to obtain the second feature extractor includes: Calculate the parameter tuning gradient based on the second loss value; The gradient inversion layer inverts the parameter tuning gradient to obtain the inverted gradient, which is the opposite of the parameter tuning gradient. The first feature extractor is tuned based on the inverted gradient to obtain the second feature extractor.
[0009] Optionally, after obtaining the first label classifier, the first domain classifier, and the second feature extractor, the iterative training further includes: Calculate the total loss value based on the first loss value and the second loss value; Based on the total loss value, the parameters of the first label classifier, the first domain classifier, and the second feature extractor are tuned to obtain the second label classifier, the second domain classifier, and the third feature extractor.
[0010] Optionally, obtaining the training dataset includes: Obtain an initial dataset, which includes initial labeled data and initial unlabeled data, wherein the initial labeled data is labeled data and the initial unlabeled data is unlabeled data; The initial labeled data and initial unlabeled data in the initial dataset are preprocessed to obtain the training dataset. The preprocessing includes at least one of the following: Pre-intensification; Frame-by-frame windowing.
[0011] Secondly, embodiments of this application also provide a snoring recognition method, the method comprising: Acquire the data to be tested; The data to be detected is input into the snoring recognition model for snoring recognition, and the snoring recognition result output by the snoring recognition model is obtained. The snoring recognition model is a model trained according to the model training method described in the first aspect.
[0012] Thirdly, embodiments of this application also provide a model training apparatus for training a preset model, the preset model including a feature extractor, a label classifier, and a domain classifier, the apparatus comprising: The first acquisition module is used to acquire a training dataset, which includes labeled data and unlabeled data. The labels are used to indicate whether the corresponding data is snoring, and the unlabeled data is related to the current environment. The training module is used to iteratively train the preset model based on the training dataset until the target conditions are met, and then obtain the trained preset model. The generation module is used to generate a snoring recognition model based on the feature extractor and label classifier included in the trained preset model. The iterative training includes: The labeled data and the unlabeled data are input into the feature extractor for feature extraction, and the first feature vector corresponding to the labeled data and the second feature vector corresponding to the unlabeled data are output by the feature extractor. The first feature vector is input into the label classifier for label classification, and the parameters of the label classifier and the feature extractor are tuned according to the output of the label classifier to obtain the first label classifier and the first feature extractor. The first feature vector and the second feature vector are input into the domain classifier for domain classification, and the parameters of the domain classifier and the first feature extractor are tuned according to the output of the domain classifier to obtain the first domain classifier and the second feature extractor. The parameter tuning gradient directions of the domain classifier and the first feature extractor are opposite. The target conditions include: The label classifier included in the trained preset model converges, and the error of the output result of the domain classifier included in the trained preset model is greater than a preset value.
[0013] Fourthly, embodiments of this application also provide a snoring recognition device, the device comprising: The second acquisition module is used to acquire the data to be detected; The recognition module is used to input the data to be detected into the snoring recognition model to perform snoring recognition and obtain the snoring recognition result output by the snoring recognition model. The snoring recognition model is a model trained according to the model training method described in the first aspect.
[0014] Fifthly, embodiments of this application also provide an electronic device, including a processor, a memory, and a computer program stored in the memory and executable on the processor. When executed by the processor, the computer program implements the steps of the model training method as described in the first aspect, or the steps of the snoring recognition method as described in the second aspect.
[0015] In a sixth aspect, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the model training method as described in the first aspect, or the steps of the snoring recognition method as described in the second aspect.
[0016] In a seventh aspect, a computer program product is provided, including computer instructions that, when executed by a processor, implement the steps of the model training method as described in the first aspect, or the steps of the snoring recognition method as described in the second aspect.
[0017] In this embodiment, through iterative training, the ability of the trained label classifier to distinguish the categories of features, the ability of the first feature extractor to identify the categories of features, and the ability of the domain classifier to distinguish the environmental source of the samples are improved. Since the parameter tuning gradient directions of the domain classifier and the first feature extractor are opposite and the unlabeled data is associated with the current environment in which the model is deployed, the ability of the second feature extractor to extract the domain-independent common acoustic features of the sound samples in the current environment can also be improved. This reduces the impact of differences in recording equipment and room acoustics caused by different environments in which the model is deployed on the snoring recognition model, thereby improving the accuracy of snoring recognition. Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a flowchart of the model training method provided in the embodiments of this application; Figure 2 This is a structural diagram of the preset model provided in the embodiments of this application; Figure 3 This is a structural diagram of the snoring recognition model provided in the embodiments of this application; Figure 4 This is a flowchart of the snoring recognition method provided in the embodiments of this application; Figure 5 This is a structural diagram of the model training device provided in the embodiments of this application; Figure 6 This is a structural diagram of the snoring recognition device provided in the embodiments of this application; Figure 7 This is a structural diagram of the electronic device provided in the embodiments of this application. Detailed Implementation
[0020] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0021] This application provides a model training method, a snoring recognition method, and related equipment.
[0022] See Figure 1 , Figure 1 This is a flowchart of the model training method provided in the embodiments of this application, such as... Figure 1 As shown, it includes the following steps: Step 101: Obtain a training dataset, which includes labeled data and unlabeled data. The labels are used to indicate whether the corresponding data is snoring, and the unlabeled data is related to the current environment.
[0023] The training dataset includes sound samples, with labeled data consisting of snoring / non-snoring acoustic datasets collected in a standardized laboratory environment, each with precise category labels (snoring=1, non-snoring=0), covering laboratory samples from different devices and basic acoustic environments, providing supervised classification training basis for the model.
[0024] The unlabeled data consists of unlabeled acoustic samples collected in the current environment, which do not require user annotation and cover different house types, home recording equipment, and home scenarios with background noise. It closely matches the actual deployment environment and provides target environment samples for domain adversarial learning.
[0025] Both labeled and unlabeled data are acoustic signals in the same format (e.g., WAV format, with a uniform sampling rate of 16kHz), and the duration of a single sample is kept consistent (e.g., 1s / segment) to ensure that the model input dimension is uniform.
[0026] like Figure 2 As shown, the preset model includes a feature extractor, a label classifier, and a domain classifier. The function of each module in the preset model will be explained in the following description along with specific steps.
[0027] Step 102: Based on the training dataset, the preset model is trained iteratively multiple times until the target conditions are met, thus obtaining the trained preset model.
[0028] Step 103: Generate a snoring recognition model based on the feature extractor and label classifier included in the trained preset model.
[0029] like Figure 3 As shown, the snoring recognition model includes a feature extractor and a label classifier in the pre-trained model.
[0030] The iterative training includes: Step 1021: Input the labeled data and the unlabeled data into the feature extractor for feature extraction, and obtain the first feature vector corresponding to the labeled data and the second feature vector corresponding to the unlabeled data output by the feature extractor.
[0031] In step 1021, the feature extractor (G_f), as the core module of the preset model, is responsible for extracting domain-independent (domain-independent means that the acoustic features of the extracted labeled and unlabeled data are unrelated to the room acoustics of the environment in which the labeled and unlabeled data are located) common acoustic features from the sound samples. It is the basis for subsequent label classification and domain judgment. Its training objective is to ensure that the extracted features retain the class distinguishability of snoring / non-snoring while eliminating the environmental distribution differences between the "source domain to which the labeled data belongs" and the "target domain to which the unlabeled data belongs".
[0032] Step 1022: Input the first feature vector into the label classifier for label classification, and adjust the parameters of the label classifier and the feature extractor according to the output of the label classifier to obtain the first label classifier and the first feature extractor.
[0033] In step 1022, the label classifier (G_y) is a single-task classification module that is trained using only labeled data. Its core objective is to perform binary classification of the acoustic features output by the feature extractor into snoring / non-snoring sounds, minimize the classification error, and ensure the feature's ability to distinguish between categories.
[0034] After obtaining the output of the label classifier, the difference between the output of the label classifier and the labels corresponding to the labeled data can be used to adjust the parameters of the label classifier and the feature extractor, thereby improving the class discrimination ability of the first label classifier and the class recognition of the features extracted by the first feature extractor.
[0035] Step 1023: Input the first feature vector and the second feature vector into the domain classifier for domain classification, and adjust the parameters of the domain classifier and the first feature extractor according to the output of the domain classifier to obtain the first domain classifier and the second feature extractor. The parameter adjustment gradient directions of the domain classifier and the first feature extractor are opposite.
[0036] In step 1023, the domain classifier (G_d) is a domain discrimination module responsible for performing source domain / target domain binary classification on the features output by the feature extractor. Its core objective is to accurately distinguish the environmental source of the sample.
[0037] After obtaining the output of the domain classifier, the differences between the output of the domain classifier and the source domain corresponding to the labeled data and the target domain corresponding to the unlabeled data can be used to tune the parameters of the domain classifier and the first feature extractor. It should be noted that the tuning gradient directions of the domain classifier and the first feature extractor are opposite. That is, the first domain classifier obtained by tuning has a better ability to distinguish the environmental source of the sample, while the second feature extractor obtained by tuning has a better ability to extract domain-independent common acoustic features (the more domain-independent the extracted features are, the more difficult it is for the domain classifier to identify the environmental source of the features).
[0038] It should be noted that, in this embodiment, the label classifier in the snoring recognition model is the first label classifier in the trained preset model, and the feature extractor in the snoring recognition model is the second feature extractor in the trained preset model.
[0039] The target conditions in step 103 include: The label classifier included in the trained preset model converges, and the error of the output result of the domain classifier included in the trained preset model is greater than a preset value.
[0040] When the model's label classifier converges, it indicates that the label classifier has the required ability to distinguish the categories of features. When the error of the domain classifier's output is greater than the preset value, it indicates that the "domain independence" of the features extracted by the current feature extractor is so high that the domain classifier has difficulty distinguishing them, thus eliminating the environmental distribution differences between the source and target domains.
[0041] In the model training method of this application, through iterative training, the class discrimination ability of the trained label classifier is improved, the class recognition of the features extracted by the first feature extractor is improved, and the ability of the domain classifier to distinguish the environmental source of the samples is improved. At the same time, since the parameter tuning gradient directions of the domain classifier and the first feature extractor are opposite and the unlabeled data is associated with the current environment in which the model is deployed, the ability of the second feature extractor to extract the domain-independent common acoustic features of the sound samples in the current environment can also be improved. This can reduce the impact of differences in recording equipment and room acoustics caused by different environments in which the model is deployed on the snoring recognition model, thereby improving the accuracy of snoring recognition.
[0042] Optionally, the labeled data and the unlabeled data are input into the feature extractor for feature extraction, resulting in a first feature vector corresponding to the labeled data and a second feature vector corresponding to the unlabeled data, output by the feature extractor, including: Labeled data X_s (including label y_s) and unlabeled data X_t are randomly selected, and after unified preprocessing, they are input into the model. The feature extractor extracts features from X_s and X_t, and outputs the first feature vector F_s = G_f(X_s) and the second feature vector F_t = G_f(X_t).
[0043] Optionally, the first feature vector is input into the label classifier for label classification, and the label classifier and the feature extractor are tuned according to the output of the label classifier to obtain a first label classifier and a first feature extractor, including: The first feature vector is input into the label classifier for label classification, and the snoring classification prediction value output by the label classifier is obtained; Based on the snoring classification prediction value and the label of the labeled data corresponding to the first feature vector, calculate the first loss value; Based on the first loss value, the parameter tuning of the label classifier and the feature extractor is performed to obtain the first label classifier and the first feature extractor.
[0044] In this embodiment, the first feature vector F_s is input into the label classifier, and the output snoring classification prediction value hat{y_s} = G_y(F_s) is generated.
[0045] Based on the predicted snoring sound value hat{y_s} and the true label y_s, a first loss value (L_y) is calculated using cross-entropy loss, generating gradients only for the parameters of the label classifier and the feature extractor. For the label classifier, L_y is minimized through gradient descent to improve the accuracy of snoring / non-snoring classification and enhance the class discrimination ability of the first label classifier's features. For the feature extractor, L_y is minimized through gradient descent to improve the class discriminative power of the features extracted by the first feature extractor.
[0046] Optionally, the first feature vector and the second feature vector are input into the domain classifier for domain classification, and the parameters of the domain classifier and the first feature extractor are tuned according to the output of the domain classifier to obtain a first domain classifier and a second feature extractor, including: The first feature vector and the second feature vector are input into the domain classifier for domain classification, and the first domain prediction value corresponding to the first feature vector and the second domain prediction value corresponding to the second feature vector are output by the domain classifier. The second loss value is calculated based on the first domain prediction value, the second domain prediction value, the domain to which the data corresponding to the first feature vector belongs, and the domain to which the data corresponding to the second feature vector belongs. Based on the second loss value, the parameters of the domain classifier and the first feature extractor are tuned to obtain the first domain classifier and the second feature extractor.
[0047] In this embodiment, the first feature vector F_s and the second feature vector F_t are input into the domain classifier to obtain the first domain prediction value hat{d_s} = G_d(GRL(F_s)) and the second domain prediction value hat{d_t} = G_d(GRL(F_t)) output by the domain classifier. It can be understood that the domain labels of the labeled data and the unlabeled data are: source domain = 0, target domain = 1.
[0048] Based on the predicted values of the first domain, hat{d_s}, and the second domain, hat{d_t}, and the true domain labels, a second loss value L_d is calculated using cross-entropy loss. This generates a normal gradient for the parameters of the domain classifier and a backward gradient for the parameters of the first feature extractor. For the domain classifier, L_d is minimized through gradient descent, improving the classifier's ability to distinguish the environmental origin of samples. For the first feature extractor, the backward gradient, i.e., maximizing L_d, is used to "make G_d unable to distinguish the sample's domain origin," improving the second feature extractor's ability to extract domain-independent common acoustic features.
[0049] Optionally, such as Figure 3 As shown, the preset model further includes a gradient inversion layer; the step of tuning the first feature extractor based on the second loss value to obtain the second feature extractor includes: Calculate the parameter tuning gradient based on the second loss value; The gradient inversion layer inverts the parameter tuning gradient to obtain the inverted gradient, which is the opposite of the parameter tuning gradient. The first feature extractor is tuned based on the inverted gradient to obtain the second feature extractor.
[0050] In this embodiment, the gradient inversion layer is a parameterless core connection layer. During forward propagation, the output features of the feature extractor are not processed. During backward propagation, the gradient of the domain classifier is inverted and scaled by a fixed coefficient before being passed to the feature extractor. This enables adversarial training between the feature extractor and the domain classifier, thereby improving the ability of the second feature extractor to extract domain-independent common acoustic features.
[0051] By implementing an adversarial game between the feature extractor and the domain classifier through a parameterless gradient inversion layer, the feature extractor can autonomously learn general acoustic features that are "domain-independent and category-dependent". This eliminates the distribution differences between the source domain (laboratory) and the target domain (home) at the feature level, and completely solves the domain offset problem that causes the model to "not adapt" to local conditions.
[0052] Optionally, after obtaining the first label classifier, the first domain classifier, and the second feature extractor, the iterative training further includes: Calculate the total loss value based on the first loss value and the second loss value; Based on the total loss value, the parameters of the first label classifier, the first domain classifier, and the second feature extractor are tuned to obtain the second label classifier, the second domain classifier, and the third feature extractor.
[0053] In this embodiment, the first loss value and the second loss value can be summed to obtain the total loss value. The optimizer updates all trainable parameters of the model to achieve the goal of "improving the class discrimination ability of the trained label classifier, improving the class discrimination of the features extracted by the first feature extractor, and improving the ability of the domain classifier to distinguish the environmental source of the sample, while improving the ability of the first feature extractor to extract domain-independent common acoustic features".
[0054] It should be noted that, in this embodiment, the label classifier in the snoring recognition model is the second label classifier in the trained preset model, and the feature extractor in the snoring recognition model is the third feature extractor in the trained preset model.
[0055] Optionally, obtaining the training dataset includes: Obtain an initial dataset, which includes initial labeled data and initial unlabeled data, wherein the initial labeled data is labeled data and the initial unlabeled data is unlabeled data; The initial labeled data and initial unlabeled data in the initial dataset are preprocessed to obtain the training dataset. The preprocessing includes at least one of the following: Pre-intensification; Frame-by-frame windowing.
[0056] In this embodiment, pre-emphasis can be achieved by using a first-order high-pass filter to boost high-frequency signal components and compensate for high-frequency attenuation of the acoustic signal. Frame-by-frame windowing can be achieved by dividing the continuous acoustic signal into fixed-length frames and superimposing a preset window to reduce inter-frame spectral leakage. By preprocessing the initial dataset, the data quality of the obtained training dataset is improved, thereby enhancing the model training effect.
[0057] like Figure 4 As shown in the embodiments of this application, a snoring recognition method is also provided, the method comprising the following steps: Step 401: Obtain the data to be detected; Step 402: Input the data to be detected into the snoring recognition model for snoring recognition, and obtain the snoring recognition result output by the snoring recognition model. The snoring recognition model is based on... Figure 1 The model trained using the model training method described in the embodiment.
[0058] In the method of this embodiment, data is used Figure 1 The snoring recognition model trained by the model training method described in this embodiment is used to identify snoring from the data to be tested. Because the feature extractor has a good ability to extract domain-independent common acoustic features, it can reduce the impact of differences in recording equipment and room acoustics caused by different deployment environments on the snoring recognition model, thereby improving the accuracy of snoring recognition. Furthermore, in the above process, no user-provided labeled data is required; environmental adaptation is completed only using collected unlabeled samples. This avoids the tedious user labeling process and fundamentally protects the user's acoustic privacy, solving the privacy and operational pain points of existing technologies.
[0059] like Figure 5 As shown in the embodiments of this application, a model training apparatus is also provided for training a preset model, the preset model including a feature extractor, a label classifier, and a domain classifier, such as... Figure 5 As shown, the device 500 includes: The first acquisition module 501 is used to acquire a training dataset, which includes labeled data and unlabeled data. The labels are used to indicate whether the corresponding data is snoring, and the unlabeled data is related to the current environment. Training module 502 is used to perform multiple iterative training on the preset model based on the training dataset until the target conditions are met, and then obtain the trained preset model. The generation module 503 is used to generate a snoring recognition model based on the feature extractor and label classifier included in the trained preset model. Training module 502 is also used for: The labeled data and the unlabeled data are input into the feature extractor for feature extraction, and the first feature vector corresponding to the labeled data and the second feature vector corresponding to the unlabeled data are output by the feature extractor. The first feature vector is input into the label classifier for label classification, and the parameters of the label classifier and the feature extractor are tuned according to the output of the label classifier to obtain the first label classifier and the first feature extractor. The first feature vector and the second feature vector are input into the domain classifier for domain classification, and the parameters of the domain classifier and the first feature extractor are tuned according to the output of the domain classifier to obtain the first domain classifier and the second feature extractor. The parameter tuning gradient directions of the domain classifier and the first feature extractor are opposite. The target conditions include: The label classifier included in the trained preset model converges, and the error of the output result of the domain classifier included in the trained preset model is greater than a preset value.
[0060] Optionally, the training module 502 is also used for: The first feature vector is input into the label classifier for label classification, and the snoring classification prediction value output by the label classifier is obtained; Based on the snoring classification prediction value and the label of the labeled data corresponding to the first feature vector, calculate the first loss value; Based on the first loss value, the parameter tuning of the label classifier and the feature extractor is performed to obtain the first label classifier and the first feature extractor.
[0061] Optionally, the training module 502 is also used for: The first feature vector and the second feature vector are input into the domain classifier for domain classification, and the first domain prediction value corresponding to the first feature vector and the second domain prediction value corresponding to the second feature vector are output by the domain classifier. The second loss value is calculated based on the first domain prediction value, the second domain prediction value, the domain to which the data corresponding to the first feature vector belongs, and the domain to which the data corresponding to the second feature vector belongs. Based on the second loss value, the parameters of the domain classifier and the first feature extractor are tuned to obtain the first domain classifier and the second feature extractor.
[0062] Optionally, the preset model further includes a gradient inversion layer; the training module 502 is also used to: calculate the parameter tuning gradient based on the second loss value; The gradient inversion layer inverts the parameter tuning gradient to obtain the inverted gradient, which is the opposite of the parameter tuning gradient. The first feature extractor is tuned based on the inverted gradient to obtain the second feature extractor.
[0063] Optionally, the training module 502 is also used for: Calculate the total loss value based on the first loss value and the second loss value; Based on the total loss value, the parameters of the first label classifier, the first domain classifier, and the second feature extractor are tuned to obtain the second label classifier, the second domain classifier, and the third feature extractor.
[0064] Optionally, the first acquisition module 501 is further configured to: Obtain an initial dataset, which includes initial labeled data and initial unlabeled data, wherein the initial labeled data is labeled data and the initial unlabeled data is unlabeled data; The initial labeled data and initial unlabeled data in the initial dataset are preprocessed to obtain the training dataset. The preprocessing includes at least one of the following: Pre-intensification; Frame-by-frame windowing.
[0065] The model training device 500 of this application embodiment can achieve Figure 1 All steps of the model training method shown in the embodiment achieve the same beneficial effects, and will not be repeated here to avoid repetition.
[0066] See Figure 6 , Figure 6 This is a structural diagram of a snoring recognition device provided in one embodiment of this application. Figure 6 As shown, the device 600 includes: The second acquisition module 601 acquires the data to be detected; The recognition module 602 inputs the data to be detected into the snoring recognition model for snoring recognition, and obtains the snoring recognition result output by the snoring recognition model. The snoring recognition model is based on... Figure 1 The model trained using the model training method shown in the embodiment.
[0067] The snoring recognition device 600 of this application embodiment can achieve Figure 4 All steps of the snoring recognition method shown in the embodiments achieve the same beneficial effects, and will not be repeated here to avoid repetition.
[0068] This application also provides an electronic device. Since the principle by which the electronic device solves the problem is similar to the model training method or snoring recognition method in this application, the implementation of this electronic device can refer to the implementation of the above-described model training method or snoring recognition method; repeated details will not be elaborated further. Figure 7 As shown, the electronic device according to an embodiment of this application includes: a processor 700, configured to read a program from a memory 720 and execute the following processes: Obtain a training dataset, which includes labeled data and unlabeled data. The labels are used to indicate whether the corresponding data is snoring, and the unlabeled data is related to the current environment. The preset model is trained iteratively multiple times based on the training dataset until the target conditions are met, resulting in the trained preset model. A snoring recognition model is generated based on the feature extractor and label classifier included in the trained preset model. The iterative training includes: The labeled data and the unlabeled data are input into the feature extractor for feature extraction, and the first feature vector corresponding to the labeled data and the second feature vector corresponding to the unlabeled data are output by the feature extractor. The first feature vector is input into the label classifier for label classification, and the parameters of the label classifier and the feature extractor are tuned according to the output of the label classifier to obtain the first label classifier and the first feature extractor. The first feature vector and the second feature vector are input into the domain classifier for domain classification, and the parameters of the domain classifier and the first feature extractor are tuned according to the output of the domain classifier to obtain the first domain classifier and the second feature extractor. The parameter tuning gradient directions of the domain classifier and the first feature extractor are opposite. The target conditions include: The label classifier included in the trained preset model converges, and the error of the output result of the domain classifier included in the trained preset model is greater than a preset value.
[0069] Among them, Figure 7 In this context, the bus architecture can include any number of interconnected buses and bridges, specifically linking various circuits together, represented by one or more processors (processor 700) and memory (memory 720). The bus architecture can also link various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. The bus interface provides the interface. Processor 700 is responsible for managing the bus architecture and general processing, and memory 720 can store data used by processor 700 during operation.
[0070] Optionally, the processor 700 is configured to read the program from the memory 720 and execute the following processes: The first feature vector is input into the label classifier for label classification, and the snoring classification prediction value output by the label classifier is obtained; Based on the snoring classification prediction value and the label of the labeled data corresponding to the first feature vector, calculate the first loss value; Based on the first loss value, the parameter tuning of the label classifier and the feature extractor is performed to obtain the first label classifier and the first feature extractor.
[0071] Optionally, the processor 700 is configured to read the program from the memory 720 and execute the following processes: The first feature vector and the second feature vector are input into the domain classifier for domain classification, and the first domain prediction value corresponding to the first feature vector and the second domain prediction value corresponding to the second feature vector are output by the domain classifier. The second loss value is calculated based on the first domain prediction value, the second domain prediction value, the domain to which the data corresponding to the first feature vector belongs, and the domain to which the data corresponding to the second feature vector belongs. Based on the second loss value, the parameters of the domain classifier and the first feature extractor are tuned to obtain the first domain classifier and the second feature extractor.
[0072] Optionally, the processor 700 is configured to read the program from the memory 720 and execute the following processes: The step of tuning the first feature extractor based on the second loss value to obtain the second feature extractor includes: Calculate the parameter tuning gradient based on the second loss value; The gradient inversion layer inverts the parameter tuning gradient to obtain the inverted gradient, which is the opposite of the parameter tuning gradient. The first feature extractor is tuned based on the inverted gradient to obtain the second feature extractor.
[0073] Optionally, the processor 700 is configured to read the program from the memory 720 and execute the following processes: Calculate the total loss value based on the first loss value and the second loss value; Based on the total loss value, the parameters of the first label classifier, the first domain classifier, and the second feature extractor are tuned to obtain the second label classifier, the second domain classifier, and the third feature extractor.
[0074] Optionally, the processor 700 is configured to read the program from the memory 720 and execute the following processes: Obtain an initial dataset, which includes initial labeled data and initial unlabeled data, wherein the initial labeled data is labeled data and the initial unlabeled data is unlabeled data; The initial labeled data and initial unlabeled data in the initial dataset are preprocessed to obtain the training dataset. The preprocessing includes at least one of the following: Pre-intensification; Frame-by-frame windowing.
[0075] Optionally, the processor 700 is configured to read the program from the memory 720 and execute the following processes: Acquire the data to be tested; The data to be detected is input into the snoring recognition model for snoring recognition, and the snoring recognition result output by the snoring recognition model is obtained. The snoring recognition model is based on... Figure 1 The model trained using the model training method shown in the embodiment.
[0076] This application also provides a computer-readable storage medium storing a computer program. When executed by a processor, this computer program implements the various processes of the above-described model training method or snoring recognition method embodiments, achieving the same technical effects. To avoid repetition, further details are omitted here. The computer-readable storage medium may include read-only memory (ROM), random access memory (RAM), a magnetic disk, or an optical disk.
[0077] This application also provides a computer program product, including computer instructions. When executed by a processor, these computer instructions implement the various processes of the above-described model training method or snoring recognition method embodiments and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0078] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0079] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0080] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A model training method, characterized in that, The method is used to train a preset model, which includes a feature extractor, a label classifier, and a domain classifier. Obtain a training dataset, which includes labeled data and unlabeled data. The labels are used to indicate whether the corresponding data is snoring, and the unlabeled data is related to the current environment. The preset model is trained iteratively multiple times based on the training dataset until the target conditions are met, resulting in the trained preset model. A snoring recognition model is generated based on the feature extractor and label classifier included in the trained preset model. The iterative training includes: The labeled data and the unlabeled data are input into the feature extractor for feature extraction, and the first feature vector corresponding to the labeled data and the second feature vector corresponding to the unlabeled data are output by the feature extractor. The first feature vector is input into the label classifier for label classification, and the parameters of the label classifier and the feature extractor are tuned according to the output of the label classifier to obtain the first label classifier and the first feature extractor. The first feature vector and the second feature vector are input into the domain classifier for domain classification, and the parameters of the domain classifier and the first feature extractor are tuned according to the output of the domain classifier to obtain the first domain classifier and the second feature extractor. The parameter tuning gradient directions of the domain classifier and the first feature extractor are opposite. The target conditions include: The label classifier included in the trained preset model converges, and the error of the output result of the domain classifier included in the trained preset model is greater than a preset value.
2. The method according to claim 1, characterized in that, The first feature vector is input into the label classifier for label classification, and the label classifier and the feature extractor are tuned according to the output of the label classifier to obtain the first label classifier and the first feature extractor, including: The first feature vector is input into the label classifier for label classification, and the snoring classification prediction value output by the label classifier is obtained; Based on the snoring classification prediction value and the label of the labeled data corresponding to the first feature vector, calculate the first loss value; Based on the first loss value, the parameter tuning of the label classifier and the feature extractor is performed to obtain the first label classifier and the first feature extractor.
3. The method according to claim 2, characterized in that, The first feature vector and the second feature vector are input into the domain classifier for domain classification, and the parameters of the domain classifier and the first feature extractor are tuned based on the output of the domain classifier to obtain the first domain classifier and the second feature extractor, including: The first feature vector and the second feature vector are input into the domain classifier for domain classification, and the first domain prediction value corresponding to the first feature vector and the second domain prediction value corresponding to the second feature vector are output by the domain classifier. The second loss value is calculated based on the first domain prediction value, the second domain prediction value, the domain to which the data corresponding to the first feature vector belongs, and the domain to which the data corresponding to the second feature vector belongs. Based on the second loss value, the parameters of the domain classifier and the first feature extractor are tuned to obtain the first domain classifier and the second feature extractor.
4. The method according to claim 3, characterized in that, The preset model also includes a gradient inversion layer; The step of tuning the first feature extractor based on the second loss value to obtain the second feature extractor includes: Calculate the parameter tuning gradient based on the second loss value; The gradient inversion layer inverts the parameter tuning gradient to obtain the inverted gradient, which is the opposite of the parameter tuning gradient. The first feature extractor is tuned based on the inverted gradient to obtain the second feature extractor.
5. The method according to claim 4, characterized in that, After obtaining the first label classifier, the first domain classifier, and the second feature extractor, the iterative training further includes: Calculate the total loss value based on the first loss value and the second loss value; Based on the total loss value, the parameters of the first label classifier, the first domain classifier, and the second feature extractor are tuned to obtain the second label classifier, the second domain classifier, and the third feature extractor.
6. The method according to any one of claims 1 to 5, characterized in that, The acquisition of the training dataset includes: Obtain an initial dataset, which includes initial labeled data and initial unlabeled data, wherein the initial labeled data is labeled data and the initial unlabeled data is unlabeled data; The initial labeled data and initial unlabeled data in the initial dataset are preprocessed to obtain the training dataset. The preprocessing includes at least one of the following: Pre-intensification; Frame-by-frame windowing.
7. A method for snoring recognition, characterized in that, The method includes: Acquire the data to be tested; The data to be detected is input into the snoring recognition model for snoring recognition, and the snoring recognition result output by the snoring recognition model is obtained. The snoring recognition model is a model trained by the model training method according to any one of claims 1 to 6.
8. A model training device, characterized in that, The device is used to train a preset model, the preset model including a feature extractor, a label classifier, and a domain classifier, and includes: The first acquisition module is used to acquire a training dataset, which includes labeled data and unlabeled data. The labels are used to indicate whether the corresponding data is snoring, and the unlabeled data is related to the current environment. The training module is used to iteratively train the preset model based on the training dataset until the target conditions are met, and then obtain the trained preset model. The generation module is used to generate a snoring recognition model based on the feature extractor and label classifier included in the trained preset model. The iterative training includes: The labeled data and the unlabeled data are input into the feature extractor for feature extraction, and the first feature vector corresponding to the labeled data and the second feature vector corresponding to the unlabeled data are output by the feature extractor. The first feature vector is input into the label classifier for label classification, and the parameters of the label classifier and the feature extractor are tuned according to the output of the label classifier to obtain the first label classifier and the first feature extractor. The first feature vector and the second feature vector are input into the domain classifier for domain classification, and the parameters of the domain classifier and the first feature extractor are tuned according to the output of the domain classifier to obtain the first domain classifier and the second feature extractor. The parameter tuning gradient directions of the domain classifier and the first feature extractor are opposite. The target conditions include: The label classifier included in the trained preset model converges, and the error of the output result of the domain classifier included in the trained preset model is greater than a preset value.
9. A snoring recognition device, characterized in that, The device includes: The second acquisition module is used to acquire the data to be detected; The recognition module is used to input the data to be detected into the snoring recognition model to perform snoring recognition and obtain the snoring recognition result output by the snoring recognition model. The snoring recognition model is a model trained by the model training method according to any one of claims 1 to 6.
10. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when executed by the processor, the computer program implements the steps of the model training method as described in any one of claims 1 to 6, or implements the steps of the snoring recognition method as described in claim 7.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the model training method as described in any one of claims 1 to 6, or the steps of the snoring recognition method as described in claim 7.
12. A computer program product, characterized in that, It includes computer instructions that, when executed by a processor, implement the steps of the model training method as described in any one of claims 1 to 6, or the steps of the snoring recognition method as described in claim 7.