Model training method, sleep quality detection method, device, equipment and medium
By dividing historical sleep feature sequences and training recursive neural network model, the problem of inaccurate sleep quality detection in intelligent sleep devices is solved, the accuracy and efficiency of detection are improved, and the user experience is improved.
Patent Information
- Application Number
- CN202411136189.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-12-13
AI Technical Summary
The existing smart sleep devices respond slowly to data processing and inaccurate detection in sleep quality detection, resulting in poor user experience.
By obtaining the historical sleep feature sequence and dividing it into multiple consecutive sleep feature subsequence segments, the target sleep feature vector is determined, and the recursive neural network model is used for training to generate a more accurate and stable sleep quality detection model.
The accuracy and efficiency of sleep quality detection are improved, and the generated model can more accurately evaluate the user's sleep quality and improve the user experience.
Smart Images

Figure CN119112100A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of sleep detection technology, and in particular to a model training method, a sleep quality detection method, a device, a equipment and a medium. Background Art
[0002] Sleep plays a vital role in all aspects of the human body. For example, it can eliminate physical and brain fatigue, eliminate stress, prevent diseases, improve memory and work and study efficiency, etc. Therefore, good sleep is the guarantee for people's normal study and life.
[0003] At present, the sensors commonly used in smart sleep monitors include heart rate sensors, breathing sensors, acceleration sensors, etc. These sensors use different non-invasive technologies to collect sleep-related physiological data, such as heart rate, breathing rate, body movement, etc. The collected sleep data is processed and analyzed to obtain the user's sleep quality, but the current data processing response is slow and the user's sleep quality detection is not accurate enough, resulting in a poor user experience.
[0004] Therefore, in order to improve the accuracy of sleep quality detection, designing a sleep quality detection model is an urgent problem to be solved. Summary of the invention
[0005] The main purpose of this application is to provide a model training method, sleep quality detection method, device, equipment and medium, aiming to improve the accuracy and efficiency of training sleep quality detection model, thereby improving the accuracy of sleep quality detection.
[0006] In a first aspect, the present application provides a model training method, wherein the sleep quality detection method comprises the following steps:
[0007] Acquire a historical sleep feature sequence, and divide the historical sleep feature sequence into a plurality of continuous sleep feature subsequences;
[0008] Dividing the plurality of sleep characteristic subsequences into a plurality of sleep characteristic subsequence segments, wherein the number of sleep characteristic subsequences in each of the sleep characteristic subsequence segments is the same;
[0009] Determine a target sleep feature vector corresponding to each of the sleep feature subsequence segments;
[0010] When the number of the target sleep feature vectors reaches a preset number, training a preset recursive neural network model according to the preset number of target sleep feature vectors to obtain a sleep quality detection model;
[0011] When the number of the target sleep feature vectors is less than a preset number, the method returns to the step of acquiring a historical sleep feature sequence and dividing the historical sleep feature sequence into a plurality of continuous sleep feature subsequences.
[0012] In a second aspect, the present application further provides a sleep quality detection method, the sleep quality detection method comprising:
[0013] Obtain the user's sleep data to be detected;
[0014] Inputting the sleep data to be detected into the sleep quality detection model to perform sleep quality detection to obtain sleep scores of multiple sleep cycles, wherein the sleep quality detection model is trained according to the model training method described in any embodiment of the present application;
[0015] Based on the preset weight parameter value and the sleep scores of the multiple sleep cycles, a sleep quality detection result of the user is determined.
[0016] In a third aspect, the present application further provides a sleep quality detection device, the sleep quality detection device comprising an acquisition module, a division module, a determination module and a training module, wherein:
[0017] The acquisition module is used for historical sleep feature sequences;
[0018] The division module is used to divide the historical sleep feature sequence into a plurality of continuous sleep feature subsequences;
[0019] The division module is further used to divide the multiple sleep characteristic subsequences into multiple sleep characteristic subsequence segments, wherein the number of sleep characteristic subsequences in each of the sleep characteristic subsequence segments is the same;
[0020] The determination module is used to determine the target sleep feature vector corresponding to each of the sleep feature subsequence segments;
[0021] The training module is used to train a preset recursive neural network model according to the preset number of target sleep feature vectors to obtain a sleep quality detection model when the number of the target sleep feature vectors reaches a preset number;
[0022] The division module is further configured to return to the step of obtaining a historical sleep feature sequence and dividing the historical sleep feature sequence into a plurality of continuous sleep feature subsequences when the number of the target sleep feature vectors is less than a preset number.
[0023] In a fourth aspect, the present application also provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the steps of the model training method as described above are implemented, and / or the steps of the sleep quality detection method as described above are implemented.
[0024] In a fifth aspect, the present application also provides a computer-readable storage medium, on which a computer program is stored, wherein when the computer program is executed by a processor, the steps of the model training method as described above are implemented, and / or the steps of the sleep quality detection method as described above are implemented.
[0025] The present application provides a model training method, a sleep quality detection method, an apparatus, a device and a medium. The present application obtains a historical sleep feature sequence and divides the historical sleep feature sequence into a plurality of continuous sleep feature subsequences; then divides the plurality of sleep feature subsequences into a plurality of sleep feature subsequence segments, wherein the number of sleep feature subsequences in each sleep feature subsequence segment is the same; determines the target sleep feature vectors corresponding to each sleep feature subsequence segment; when the number of target sleep feature vectors reaches a preset number, trains a preset recursive neural network model according to the preset number of target sleep feature vectors to obtain a sleep quality detection model; when the number of target sleep feature vectors is less than the preset number, returns to execute the steps of obtaining the historical sleep feature sequence and dividing the historical sleep feature sequence into a plurality of continuous sleep feature subsequences. In the present application, by dividing the historical sleep feature sequence, the temporal nature of the sleep feature can be effectively improved, thereby improving the accuracy and efficiency of constructing the target sleep feature vector, and then training the recursive neural network model based on the target sleep feature vector, so that the generated sleep quality detection model is more accurate and stable, thereby effectively improving the accuracy of sleep quality detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0027] Figure 1 A flowchart of a sleep quality detection method provided in an embodiment of the present application;
[0028] Figure 2 for Figure 1 A schematic diagram of the sub-steps of the sleep quality detection method in FIG.
[0029] Figure 3 A flowchart of a sleep quality detection method provided in an embodiment of the present application;
[0030] Figure 4 A schematic block diagram of a model training device provided in an embodiment of the present application;
[0031] Figure 5 A schematic block diagram of a sleep quality detection device provided in an embodiment of the present application;
[0032] Figure 6 A schematic block diagram of the structure of a computer device provided in an embodiment of the present application.
[0033] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0034] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0035] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0036] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0037] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0038] The embodiments of the present application provide a model training method, a sleep quality detection method, an apparatus, a device and a medium. The sleep quality detection method can be applied to a computer device, which can be an electronic device such as a mobile phone, a tablet computer, a laptop computer, a desktop computer, a personal digital assistant and a wearable device.
[0039] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0040] Please refer to Figure 1 , Figure 1 A flowchart of a model training method provided in an embodiment of the present application.
[0041] like Figure 1 As shown, the sleep quality detection method includes steps S101 to S105.
[0042] Step S101: Acquire a historical sleep feature sequence, and divide the historical sleep feature sequence into a plurality of continuous sleep feature subsequences.
[0043] The historical sleep feature sequence includes a time series and a sleep feature value, and each time series corresponds to a sleep feature value. It should be noted that the sleep feature value can be set according to the time situation, and the embodiment of the present invention does not specifically limit this. For example, the sleep feature value can be a user's breathing feature value, brain wave feature value, and pulse feature value.
[0044] For example, the user's brain waves are collected by an EEG sensor, and then the collected time series and the corresponding brain waves are associated to generate a sleep characteristic value. For another example, the user's heart rate signal is collected by a heart rate sensor, and then the collected time series and the corresponding heart rate signal are associated to generate a sleep characteristic value.
[0045] It should be noted that the historical sleep feature sequence is the sleep feature sequence of the user before the current time point. For example, the current time is 0:00 on June 5, 2024, and the historical sleep feature sequence can be the sleep feature sequence from 0:00 on June 4, 2024 to 0:00 on June 4, 2024.
[0046] In some embodiments, the historical sleep feature sequence is divided by a preset time step and a preset sequence duration to obtain a plurality of continuous sleep feature subsequences, wherein the time series length of each sleep feature subsequence is equal to the preset sequence duration. The preset time step and the preset sequence duration can be set according to actual conditions, and the embodiment of the present invention does not specifically limit this. For example, the preset time step can be set to 1, and the preset sequence duration is set to 4. By dividing the historical sleep feature sequence, it is beneficial to generate a suitable target sleep feature vector, thereby improving the accuracy and efficiency of the sleep quality detection model training.
[0047] Exemplarily, the historical sleep feature sequence is a one-dimensional time series signal with a length of 100, and the historical sleep feature sequence includes [x1, x2, x3, ..., x100], the preset time step is 1 and the preset sequence duration is 4, and the sleep feature subsequences obtained by dividing the historical sleep feature sequence according to the preset time step 1 and the preset sequence duration 4 include [x1, x2, x3, x4], [x2, x3, x4, x5], [x3, x4, x5, x6], ..., [x97, x98, x99, x100].
[0048] Exemplarily, the historical sleep feature sequence is a one-dimensional time series signal with a length of 100, and the historical sleep feature sequence includes [x1, x2, x3, ..., x100], the preset time step is 2 and the preset sequence duration is 4, and the sleep feature subsequences obtained by dividing the historical sleep feature sequence according to the preset time step 2 and the preset sequence duration 4 include [x1, x2, x3, x4], [x3, x4, x5, x6], [x5, x6, x7, x8], ..., [x97, x98, x99, x100].
[0049] Step S102: Divide the multiple sleep characteristic subsequences into multiple sleep characteristic subsequence segments, wherein the number of sleep characteristic subsequences in each of the sleep characteristic subsequence segments is the same.
[0050] The number of sleep characteristic subsequences in the sleep characteristic subsequence segment may be set according to actual conditions, and the embodiment of the present invention does not specifically limit this. For example, the number of the sleep characteristic subsequences may be 3.
[0051] In some embodiments, multiple sleep feature subsequences are divided to obtain multiple sleep feature subsequence segments. By dividing the sleep feature subsequences to form sleep feature subsequence segments, the sleep feature subsequences can be effectively folded, thereby improving the efficiency and accuracy of training the sleep quality detection model.
[0052] Exemplarily, the number of sleep feature subsequences in the sleep feature subsequence segment is set to 3, and the sleep feature subsequences include [x1, x2, x3, x4], [x2, x3, x4, x5], [x3, x4, x5, x6], ..., [x97, x98, x99, x100]. The sleep feature subsequences are divided based on the number of sleep feature subsequences 3 to obtain a plurality of sleep feature subsequence segments, which include sleep feature subsequence segment 1 {[x 1, [x2, x3, x4], [x2, x3, x4, x5], [x3, x4, x5, x6]}, sleep characteristic subsequence segment 2 {[x4, x5, x6, x7], [x5, x6, x7, x8], [x6, x7, x8, x9]}, ..., sleep characteristic subsequence segment 32 {[x94, x95, x96, x97], [x95, x96, x97, x98,], [x96, x97, x98, x99]}.
[0053] Exemplarily, the number of sleep characteristic subsequences in the sleep characteristic subsequence segment is set to 4, and the sleep characteristic subsequences include [x1, x2, x3, x4], [x2, x3, x4, x5], [x3, x4, x5, x6], ..., [x97, x98, x99, x100]. The sleep characteristic subsequence is divided based on the number of sleep characteristic subsequences 4 to obtain a plurality of sleep characteristic subsequence segments, which include sleep characteristic subsequence segment 1 {[x1, x2, x3, x4], [x2, x3, x4, x5] , [x3, x4, x5, x6], [x4, x5, x6, x7]}, sleep characteristic subsequence segment 2 {[x5, x6, x7, x8], [x6, x7, x8, x9], [x7, x8, x9, x10], [x8, x9, x10, x11]}, …, sleep characteristic subsequence segment 25 {[x94, x95, x96, x97], [x95, x96, x97, x98, ], [x96, x97, x98, x99], [x97, x98, x99, x100]}.
[0054] Step S103: determining a target sleep feature vector corresponding to each of the sleep feature subsequence segments.
[0055] Among them, the sleep feature subsequence includes multiple dimensions, and the dimensions of the sleep feature subsequence are determined by the sequence length of the sleep feature subsequence. For example, if the sequence length of the sleep feature subsequence is 4, then the sleep feature subsequence has 4 dimensions, that is, the sleep feature subsequence includes [x1, x2, x3, x4], where x1 represents the first dimension, x2 represents the second dimension, x3 represents the third dimension, and x4 represents the fourth dimension.
[0056] In some embodiments, the sleep feature values of the same dimension of each sleep feature subsequence in the sleep feature subsequence segment are averaged to obtain the sleep feature mean of each dimension; the maximum sleep feature value of each dimension in the sleep feature subsequence segment is obtained, and the sleep feature mean of each dimension is divided by the maximum sleep feature value of each dimension to obtain the target sleep feature value of each dimension; the sleep feature sequence is reconstructed for the target sleep feature value of each dimension to obtain the target sleep feature vector corresponding to the sleep feature subsequence segment. Reconstruction based on the sleep feature values of each dimension in the sleep feature subsequence can accurately obtain the target sleep feature vector, which greatly improves the efficiency and accuracy of model training.
[0057] Exemplarily, the sleep feature subsequence segment is {[x1, x2, x3, x4], [x2, x3, x4, x5], [x3, x4, x5, x6]}, the first dimension x1, x2 and x3 are averaged to obtain a first mean m1; the second dimension x2, x3 and x4 are averaged to obtain a second mean m2; the third dimension x3, x4 and x5 are averaged to obtain a third mean m3; the fourth dimension x4, x5 and x6 are averaged to obtain a third mean m4; The fourth mean value m4 is calculated; the maximum value of the first dimension x1, x2 and x3 is obtained to obtain the first maximum value n1, the maximum value of the second dimension x2, x3 and x4 is obtained to obtain the second maximum value n2, the maximum value of the third dimension x3, x4 and x5 is obtained to obtain the third maximum value n3, the maximum value of the fourth dimension x4, x5 and x6 is obtained to obtain the fourth maximum value n4; the first mean value m1 is divided by the first maximum value n1 to obtain the target sleep characteristic value of the first dimension Divide the second mean m2 by the second maximum n2 to obtain the target sleep feature value of the second dimension Divide the third mean m3 by the third maximum value n3 to obtain the target sleep characteristic value of the third dimension Divide the fourth mean m4 by the fourth maximum n4 to obtain the target sleep feature value of the fourth dimension Target sleep feature value for the first dimension Target sleep feature value of the second dimension Target sleep characteristic value of the third dimension and the target sleep characteristic value of the fourth dimension Reconstruct the sleep feature sequence and obtain the target sleep feature vector corresponding to the sleep feature subsequence segment:
[0058] Step S104: When the number of the target sleep feature vectors reaches a preset number, a preset recursive neural network model is trained according to the preset number of target sleep feature vectors to obtain a sleep quality detection model.
[0059] Among them, the preset number can be set according to actual conditions, and the embodiment of the present invention does not make specific limitations on this. For example, the preset number can be set to 1000. The more target sleep feature vectors are used for training, the more accurate the trained sleep quality detection model will be.
[0060] In some embodiments, Figure 2 As shown, step S104 includes sub-steps S1041 to S1044.
[0061] Sub-step S1041 : selecting a target sleep feature vector from the preset number of target sleep feature vectors as target sample data.
[0062] A target sleep feature vector is randomly selected from a preset number of target sleep feature vectors as target sample data, and the target sleep feature vector is marked as used data, thereby avoiding repeated use and increasing redundant model training process.
[0063] Sub-step S1042: input the target sample data into the recursive neural network model for training to obtain a sleep cycle score.
[0064] Among them, the sleep cycle includes the wakeful period, non-rapid eye movement stage 1, non-rapid eye movement stage 2, non-rapid eye movement stage 3 and rapid eye movement stage.
[0065] It should be noted that the recursive neural network model can be selected according to actual conditions, and the embodiment of the present invention does not specifically limit this, for example: Recursive Neural Tensor Network, Matrix-Vector Recursive Network and Tree LSTM, etc.
[0066] In some embodiments, the target sample data is input into a recursive neural network model to identify the sleep cycle scores to obtain each sleep cycle score.
[0067] Exemplarily, the target sample data is input into the recurrent neural network model to discriminate the sleep cycle scores, and the awake period scores are 1.5, non-rapid eye movement 1 is 0.8, non-rapid eye movement 2 is 0.7, non-rapid eye movement 3 is 0.2, and rapid eye movement is 0.1.
[0068] Exemplarily, the target sample data is input into the recurrent neural network model to discriminate the sleep cycle scores, and the awake period scores are 1.2, non-rapid eye movement 1 is 0.7, non-rapid eye movement 2 is 0.8, non-rapid eye movement 3 is 0.3 and rapid eye movement is 0.2.
[0069] Sub-step S1043: determining whether the recursive neural network model has converged according to the sleep cycle score.
[0070] Among them, if the recursive neural network model converges, it is determined that the recursive neural network model has been trained; if the recursive neural network model does not converge, it is determined that the recursive neural network model has not been trained, and it is necessary to continue to input target sample data for model training.
[0071] In some embodiments, the loss value of the recursive neural network model is determined according to the sleep cycle score; when the loss value is less than or equal to a preset threshold, the recursive neural network model is determined to have converged. When the loss value is greater than the preset threshold, it is determined that the recursive neural network model has not converged. The preset threshold can be set according to actual conditions, and the embodiment of the present invention does not specifically limit this. For example, the preset threshold can be set to 0.001.
[0072] Sub-step S1044: When the recursive neural network model has not converged, continue to execute the step of selecting a target sleep feature vector from the preset number of target sleep feature vectors as target sample data until the recursive neural network model converges to obtain a sleep quality detection model.
[0073] If it is determined that the recursive neural network model has not converged, the step of selecting a target sleep feature vector from a preset number of target sleep feature vectors as target sample data is continued until the recursive neural network model converges to obtain a sleep quality detection model. By cyclically using the target sleep feature vector to train the recursive neural network model, a sleep quality detection model can be accurately generated, making the generated sleep quality detection model more accurate and stable.
[0074] Step S105 : when the number of the target sleep feature vectors is less than a preset number, return to the step of obtaining a historical sleep feature sequence and dividing the historical sleep feature sequence into a plurality of continuous sleep feature subsequences.
[0075] When the number of target sleep feature vectors is less than a preset number, it is determined that the number of target sleep feature vectors is insufficient, then the steps of obtaining the historical sleep feature sequence and dividing the historical sleep feature sequence into multiple continuous sleep feature subsequences are continued to supplement more target sleep feature vectors, so as to train a more accurate sleep quality detection model.
[0076] The model training method provided in the above embodiment obtains a historical sleep feature sequence and divides the historical sleep feature sequence into multiple continuous sleep feature subsequences; then divides the multiple sleep feature subsequences into multiple sleep feature subsequence segments, wherein the number of sleep feature subsequences in each sleep feature subsequence segment is the same; determines the target sleep feature vector corresponding to each sleep feature subsequence segment; when the number of target sleep feature vectors reaches a preset number, trains the preset recursive neural network model according to the preset number of target sleep feature vectors to obtain a sleep quality detection model; when the number of target sleep feature vectors is less than the preset number, returns to execute the steps of obtaining the historical sleep feature sequence and dividing the historical sleep feature sequence into multiple continuous sleep feature subsequences. In the present application, by dividing the historical sleep feature sequence, the temporal nature of the sleep feature can be effectively improved, thereby improving the accuracy and efficiency of constructing the target sleep feature vector, and then the recursive neural network model is trained based on the target sleep feature vector, so that the generated sleep quality detection model is more accurate and stable, thereby effectively improving the accuracy of sleep quality detection.
[0077] Please refer to Figure 3 , Figure 3 A flowchart of a sleep quality detection method provided in an embodiment of the present application.
[0078] like Figure 3 As shown, the sleep quality detection method includes steps S201 to S203.
[0079] Step S201: Obtain the user's sleep data to be detected.
[0080] The sleep data to be detected of the user is obtained, and the sleep data to be detected includes a sleep feature sequence of the user over a period of time. For example, the sleep data to be detected is a sleep feature sequence of the user for one night.
[0081] Step S202: input the sleep data to be detected into the sleep quality detection model to perform sleep quality detection to obtain sleep scores of multiple sleep cycles. The sleep quality detection model is trained according to the model training method described in any embodiment of the present application.
[0082] In some embodiments, the sleep data to be detected is input into a sleep quality detection model for sleep quality detection to obtain sleep scores of multiple sleep cycles, wherein the sleep scores of the sleep cycles include the sleep score of the awake period, the sleep score of the non-rapid eye movement 1 period, the sleep score of the non-rapid eye movement 2 period, the sleep score of the non-rapid eye movement 3 period, and the sleep score of the rapid eye movement period.
[0083] It should be noted that after the sleep scores of each sleep cycle are obtained, the sleep scores of each sleep cycle are normalized to improve the efficiency and accuracy of subsequent determination of sleep quality detection results.
[0084] Exemplarily, the sleep data to be tested is input into the sleep quality detection model for sleep quality detection, and the awake period score is obtained as 1.2, non-rapid eye movement 1 is 0.7, non-rapid eye movement 2 is 0.8, non-rapid eye movement 3 is 0.3 and rapid eye movement period is 0.2.
[0085] Step S203: determining a sleep quality detection result of the user based on a preset weight parameter value and the sleep scores of the multiple sleep cycles.
[0086] Among them, the preset weight parameter value includes multiple sub-weight parameters, which can be set according to actual conditions. The embodiment of the present invention does not specifically limit this. For example, the first sub-weight parameter is 0.2, the second weight parameter is 0.3, the third sub-weight parameter is 0.2, the fourth sub-weight parameter is 0.2 and the fifth sub-weight parameter is 0.1.
[0087] In some embodiments, the sub-weight parameter is multiplied by the sleep score of the corresponding sleep cycle to obtain multiple sleep quality scores; the multiple sleep quality scores are added to obtain a target sleep quality score; and the sleep quality detection result corresponding to the target sleep quality score is determined according to the mapping relationship between the preset sleep quality score and the sleep quality detection result. Among them, the sleep quality detection result includes high-quality sleep quality, good sleep quality, general sleep quality, poor sleep quality and very poor sleep quality. By calculating the sub-weight parameter and the sleep score of the corresponding sleep cycle, the sleep quality score can be accurately obtained, and then the sleep quality of the user can be accurately matched based on the sleep quality score, which greatly improves the efficiency and accuracy of sleep quality detection.
[0088] It should be noted that the mapping relationship is established in advance based on a preset sleep quality score and a sleep quality detection result. The mapping relationship can be set according to actual conditions, and the embodiment of the present invention does not specifically limit this.
[0089] Exemplarily, the sleep quality detection model can also be applied to the field of medical technology. The doctor obtains the patient's sleep data to be tested, and inputs the sleep data to be tested into the sleep quality detection model for sleep quality detection, which can accurately determine the patient's sleep scores for multiple sleep cycles; based on the preset weight parameter value and the sleep scores of multiple sleep cycles, the patient's sleep quality detection results are determined.
[0090] The above-mentioned sleep quality detection method includes: obtaining the user's sleep data to be detected; inputting the sleep data to be detected into the sleep quality detection model for sleep quality detection, which can accurately obtain the sleep scores of multiple sleep cycles; based on the preset weight parameter value and the sleep scores of multiple sleep cycles, determining the user's sleep quality detection result, which greatly improves the efficiency and accuracy of sleep quality detection.
[0091] See also Figure 4 , Figure 4 A schematic block diagram of a model training device provided in an embodiment of the present application.
[0092] like Figure 4 As shown, the model training device 300 includes an acquisition module 310, a division module 320, a determination module 330 and a training module 340, wherein:
[0093] The acquisition module 310 is used for historical sleep feature sequences;
[0094] The division module 320 is used to divide the historical sleep feature sequence into a plurality of continuous sleep feature subsequences;
[0095] The division module 320 is further configured to divide the plurality of sleep characteristic subsequences into a plurality of sleep characteristic subsequence segments, wherein the number of sleep characteristic subsequences in each of the sleep characteristic subsequence segments is the same;
[0096] The determination module 330 is used to determine the target sleep feature vector corresponding to each of the sleep feature subsequence segments;
[0097] The training module 340 is used to train a preset recursive neural network model according to the preset number of target sleep feature vectors to obtain a sleep quality detection model when the number of the target sleep feature vectors reaches a preset number;
[0098] The division module 320 is further configured to return to the step of obtaining a historical sleep feature sequence and dividing the historical sleep feature sequence into a plurality of continuous sleep feature subsequences when the number of the target sleep feature vectors is less than a preset number.
[0099] In some embodiments, the partitioning module 320 is further configured to:
[0100] The historical sleep feature sequence is divided according to a preset time step and a preset sequence duration to obtain a plurality of continuous sleep feature subsequences, wherein the time series length of each of the sleep feature subsequences is equal to the preset sequence duration.
[0101] The determination module 330 is further configured to:
[0102] Calculating the mean of the sleep characteristic values of the same dimension of each sleep characteristic subsequence in the sleep characteristic subsequence segment to obtain the mean of the sleep characteristics of each dimension;
[0103] Obtaining the maximum sleep characteristic value of each dimension in the sleep characteristic subsequence segment, and dividing the sleep characteristic mean of each dimension by the maximum sleep characteristic value of each dimension to obtain a target sleep characteristic value of each dimension;
[0104] A sleep feature sequence is reconstructed for the target sleep feature value of each dimension to obtain a target sleep feature vector corresponding to the sleep feature subsequence segment.
[0105] In some embodiments, the training module 340 is further configured to:
[0106] Selecting a target sleep feature vector from the preset number of target sleep feature vectors as target sample data;
[0107] Inputting the target sample data into the recursive neural network model for training to obtain a sleep cycle score;
[0108] Determining whether the recursive neural network model has converged according to the sleep cycle score;
[0109] When the recursive neural network model has not converged, the step of selecting a target sleep feature vector from the preset number of target sleep feature vectors as target sample data is continued until the recursive neural network model converges to obtain a sleep quality detection model.
[0110] In some embodiments, the training module 340 is further configured to:
[0111] Determining a loss value of the recurrent neural network model according to the sleep cycle score;
[0112] When the loss value is less than or equal to a preset threshold, it is determined that the recursive neural network model converges.
[0113] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-mentioned model training device can refer to the corresponding process in the aforementioned model training method embodiment, and will not be repeated here.
[0114] See also Figure 5 , Figure 5 A schematic block diagram of a sleep quality detection device provided in an embodiment of the present application.
[0115] like Figure 5 As shown, the sleep quality detection device 400 includes an acquisition module 410 and a generation module 420, wherein:
[0116] The acquisition module 410 is used to acquire the user's sleep data to be detected;
[0117] The generating module 420 is used to input the sleep data to be detected into the sleep quality detection model to perform sleep quality detection to obtain sleep scores of multiple sleep cycles, wherein the sleep quality detection model is trained according to the model training method described in any embodiment of the present application;
[0118] The generating module 420 is further configured to determine a sleep quality detection result of the user based on a preset weight parameter value and the sleep scores of the multiple sleep cycles.
[0119] In some embodiments, the generating module 420 is further configured to:
[0120] Multiplying the sub-weight parameter by the corresponding sleep score of the sleep cycle to obtain a plurality of sleep quality scores;
[0121] performing an addition operation on the multiple sleep quality scores to obtain a target sleep quality score;
[0122] The sleep quality detection result corresponding to the target sleep quality score is determined according to a preset mapping relationship between the sleep quality score and the sleep quality detection result.
[0123] It should be noted that those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the above-mentioned sleep quality detection device can refer to the corresponding process in the aforementioned sleep quality detection method embodiment, and will not be repeated here.
[0124] See also Figure 6 , Figure 6 A schematic block diagram of the structure of a computer device provided in an embodiment of the present application.
[0125] like Figure 6 As shown, the computer device 500 includes a processor 502 and a memory 503 connected via a system bus 501 , wherein the memory may include a storage medium and an internal memory.
[0126] The storage medium may store a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor may execute any one of the model training methods and / or the sleep quality detection method.
[0127] The processor 502 is used to provide computing and control capabilities and support the operation of the entire computer device.
[0128] The internal memory provides an environment for the operation of the computer program in the storage medium. When the computer program is executed by the processor, the processor can execute any sleep quality detection method.
[0129] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0130] It should be understood that the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0131] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0132] Acquire a historical sleep feature sequence, and divide the historical sleep feature sequence into a plurality of continuous sleep feature subsequences;
[0133] Dividing the plurality of sleep characteristic subsequences into a plurality of sleep characteristic subsequence segments, wherein the number of sleep characteristic subsequences in each of the sleep characteristic subsequence segments is the same;
[0134] Determine a target sleep feature vector corresponding to each of the sleep feature subsequence segments;
[0135] When the number of the target sleep feature vectors reaches a preset number, training a preset recursive neural network model according to the preset number of target sleep feature vectors to obtain a sleep quality detection model;
[0136] When the number of the target sleep feature vectors is less than a preset number, the method returns to the step of acquiring a historical sleep feature sequence and dividing the historical sleep feature sequence into a plurality of continuous sleep feature subsequences.
[0137] In one embodiment, when implementing the step of dividing the historical sleep feature sequence into a plurality of continuous sleep feature subsequences, the processor is configured to implement:
[0138] The historical sleep feature sequence is divided according to a preset time step and a preset sequence duration to obtain a plurality of continuous sleep feature subsequences, wherein the time series length of each of the sleep feature subsequences is equal to the preset sequence duration.
[0139] In one embodiment, the processor implements that the sleep characteristic subsequence includes multiple dimensions, each dimension includes a sleep characteristic value; and when determining the target sleep characteristic vector corresponding to each of the sleep characteristic subsequence segments, it is used to implement:
[0140] Calculating the mean of the sleep characteristic values of the same dimension of each sleep characteristic subsequence in the sleep characteristic subsequence segment to obtain the mean of the sleep characteristics of each dimension;
[0141] Obtaining the maximum sleep characteristic value of each dimension in the sleep characteristic subsequence segment, and dividing the sleep characteristic mean of each dimension by the maximum sleep characteristic value of each dimension to obtain a target sleep characteristic value of each dimension;
[0142] A sleep feature sequence is reconstructed for the target sleep feature value of each dimension to obtain a target sleep feature vector corresponding to the sleep feature subsequence segment.
[0143] In one embodiment, when the processor trains a preset recursive neural network model according to a preset number of target sleep feature vectors to obtain a sleep quality detection model, the processor is used to implement:
[0144] Selecting a target sleep feature vector from the preset number of target sleep feature vectors as target sample data;
[0145] Inputting the target sample data into the recursive neural network model for training to obtain a sleep cycle score;
[0146] Determining whether the recursive neural network model has converged according to the sleep cycle score;
[0147] When the recursive neural network model has not converged, the step of selecting a target sleep feature vector from the preset number of target sleep feature vectors as target sample data is continued until the recursive neural network model converges to obtain a sleep quality detection model.
[0148] In one embodiment, when the processor implements the step of determining whether the recursive neural network model converges according to the sleep cycle score, the processor is configured to implement:
[0149] Determining a loss value of the recurrent neural network model according to the sleep cycle score;
[0150] When the loss value is less than or equal to a preset threshold, it is determined that the recursive neural network model converges.
[0151] In one embodiment, the processor is configured to implement:
[0152] Obtain the user's sleep data to be detected;
[0153] Inputting the sleep data to be detected into the sleep quality detection model to perform sleep quality detection to obtain sleep scores of multiple sleep cycles, wherein the sleep quality detection model is trained according to the model training method described in any embodiment;
[0154] Based on the preset weight parameter value and the sleep scores of the multiple sleep cycles, a sleep quality detection result of the user is determined.
[0155] In one embodiment, when the processor implements that the preset weight parameter includes a plurality of sub-weight parameters, and determines the sleep quality detection result of the user based on the preset weight parameter value and the sleep scores of the plurality of sleep cycles, it is configured to implement:
[0156] Multiplying the sub-weight parameter by the corresponding sleep score of the sleep cycle to obtain a plurality of sleep quality scores;
[0157] performing an addition operation on the multiple sleep quality scores to obtain a target sleep quality score;
[0158] The sleep quality detection result corresponding to the target sleep quality score is determined according to a preset mapping relationship between the sleep quality score and the sleep quality detection result.
[0159] It should be noted that technical personnel in the relevant field can clearly understand that, for the convenience and conciseness of description, the specific working process of the computer device described above can refer to the corresponding process in the aforementioned model training method and / or sleep quality detection method embodiment, and will not be repeated here.
[0160] An embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. The computer program includes program instructions. The method implemented when the program instructions are executed can refer to the various embodiments of the model training method and / or sleep quality detection method of the present application.
[0161] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may be non-volatile or volatile. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc., equipped on the computer device.
[0162] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0163] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0164] It should be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0165] It should also be understood that the term "and / or" used in the present specification refers to any combination of one or more of the associated listed items and all possible combinations, including these combinations. It should be noted that, in this article, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system 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 system. In the absence of further restrictions, an element defined by the sentence "including a..." does not exclude the presence of other identical elements in the process, method, article or system including the element.
[0166] The serial numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments. The above description is only a specific implementation mode of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application.
Claims
1. A model training method, characterized in that: include: Acquire a historical sleep feature sequence, and divide the historical sleep feature sequence into a plurality of continuous sleep feature subsequences; Dividing the plurality of sleep characteristic subsequences into a plurality of sleep characteristic subsequence segments, wherein the number of sleep characteristic subsequences in each of the sleep characteristic subsequence segments is the same; Determine a target sleep feature vector corresponding to each of the sleep feature subsequence segments; When the number of the target sleep feature vectors reaches a preset number, training a preset recursive neural network model according to the preset number of target sleep feature vectors to obtain a sleep quality detection model; When the number of the target sleep feature vectors is less than a preset number, the method returns to the step of acquiring a historical sleep feature sequence and dividing the historical sleep feature sequence into a plurality of continuous sleep feature subsequences.
2. The model training method according to claim 1, characterized in that: The dividing the historical sleep feature sequence into a plurality of continuous sleep feature subsequences comprises: The historical sleep feature sequence is divided according to a preset time step and a preset sequence duration to obtain a plurality of continuous sleep feature subsequences, wherein the time series length of each of the sleep feature subsequences is equal to the preset sequence duration.
3. The model training method according to claim 1, characterized in that: The sleep characteristic subsequence includes multiple dimensions, each dimension includes a sleep characteristic value; and determining the target sleep characteristic vector corresponding to each of the sleep characteristic subsequence segments includes: Calculating the mean of the sleep characteristic values of the same dimension of each sleep characteristic subsequence in the sleep characteristic subsequence segment to obtain the mean of the sleep characteristics of each dimension; Obtaining the maximum sleep characteristic value of each dimension in the sleep characteristic subsequence segment, and dividing the sleep characteristic mean of each dimension by the maximum sleep characteristic value of each dimension to obtain a target sleep characteristic value of each dimension; A sleep feature sequence is reconstructed for the target sleep feature value of each dimension to obtain a target sleep feature vector corresponding to the sleep feature subsequence segment.
4. The model training method according to claim 1, characterized in that: The method of training a preset recursive neural network model according to a preset number of target sleep feature vectors to obtain a sleep quality detection model includes: Selecting a target sleep feature vector from the preset number of target sleep feature vectors as target sample data; Inputting the target sample data into the recursive neural network model for training to obtain a sleep cycle score; Determining whether the recursive neural network model has converged according to the sleep cycle score; When the recursive neural network model has not converged, the step of selecting a target sleep feature vector from the preset number of target sleep feature vectors as target sample data is continued until the recursive neural network model converges to obtain a sleep quality detection model.
5. The model training method according to claim 4, characterized in that: Determining whether the recursive neural network model converges according to the sleep cycle score includes: Determining a loss value of the recurrent neural network model according to the sleep cycle score; When the loss value is less than or equal to a preset threshold, it is determined that the recursive neural network model converges.
6. A sleep quality detection method, characterized in that: include: Obtain the user's sleep data to be detected; Inputting the sleep data to be detected into the sleep quality detection model to perform sleep quality detection to obtain sleep scores for multiple sleep cycles, wherein the sleep quality detection model is trained according to the model training method according to any one of claims 1 to 5; Based on the preset weight parameter value and the sleep scores of the multiple sleep cycles, a sleep quality detection result of the user is determined.
7. The sleep quality detection method according to claim 6, characterized in that: The preset weight parameter includes a plurality of sub-weight parameters, and determining the sleep quality detection result of the user based on the preset weight parameter value and the sleep scores of the plurality of sleep cycles includes: Multiplying the sub-weight parameter by the corresponding sleep score of the sleep cycle to obtain a plurality of sleep quality scores; performing an addition operation on the multiple sleep quality scores to obtain a target sleep quality score; The sleep quality detection result corresponding to the target sleep quality score is determined according to a preset mapping relationship between the sleep quality score and the sleep quality detection result.
8. A model training device, characterized in that: The model training device includes an acquisition module, a division module, a determination module and a training module, wherein: The acquisition module is used for historical sleep feature sequences; The division module is used to divide the historical sleep feature sequence into a plurality of continuous sleep feature subsequences; The division module is further used to divide the multiple sleep characteristic subsequences into multiple sleep characteristic subsequence segments, wherein the number of sleep characteristic subsequences in each of the sleep characteristic subsequence segments is the same; The determination module is used to determine the target sleep feature vector corresponding to each of the sleep feature subsequence segments; The training module is used to train a preset recursive neural network model according to the preset number of target sleep feature vectors to obtain a sleep quality detection model when the number of the target sleep feature vectors reaches a preset number; The division module is further configured to return to the step of obtaining a historical sleep feature sequence and dividing the historical sleep feature sequence into a plurality of continuous sleep feature subsequences when the number of the target sleep feature vectors is less than a preset number.
9. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, it implements the steps of the model training method as described in any one of claims 1 to 5 and / or implements the steps of the sleep quality detection method as described in any one of claims 6 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the model training method as described in any one of claims 1 to 5 and / or the steps of the sleep quality detection method as described in any one of claims 6 to 7 are implemented.
