Sleep staging method and system based on adaptive reaggregation and double prototype comparison
By introducing adaptive reaggregation and 2-prototype comparison technology in automatic sleep staging model, the problem of data heterogeneity and privacy protection in multi-organization collaboration is solved, and more accurate and robust sleep staging is achieved, ensuring data privacy security and high generalization.
Patent Information
- Application Number
- CN202411176365.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-12-03
AI Technical Summary
The existing automatic sleep staging model in multi-institutional collaboration has caused catastrophic forgetting and generalization capabilities in insufficient data heterogeneity and privacy protection regulations, making it difficult to achieve accurate and robust sleep staging.
Adopting the method based on adaptive reaggregation and 2-prototype comparison, local task knowledge is introduced in the initialization process of local model, and the local initialization process is optimized through the collaborative utilization of global model and local historical model, and the internal class is enhanced through the dual-prototype comparison learning module. Consistency and discrimination, ensuring inter-agency knowledge sharing that ensures data privacy and security.
It improves the accuracy and robustness of sleep staging, obtains higher accuracy and generalization, solves the problem of insufficient data between institutions driven by data, and ensures data privacy and security.
Smart Images

Figure CN119055192A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of machine learning, and in particular to a sleep staging method based on adaptive reaggregation and dual-prototype comparison and a sleep staging system based on adaptive reaggregation and dual-prototype comparison. Background Art
[0002] Sleep is vital to humans and plays a key role in restoring physical strength and regulating emotions. In recent years, the number of people suffering from sleep disorders has increased dramatically, and sleep disorders have increasingly become a prominent public health issue. Sleep staging reveals the physiological characteristics of related sleep disorders and is an important step in the process of sleep quality assessment and diagnosis of sleep-related diseases. It has become a focus of recent research. According to the manual of the American Academy of Sleep Medicine (AASM), sleep can be divided into five stages: wakefulness (W), non-rapid eye movement stage 1 (N1), N2, N3, and rapid eye movement (REM) stage.
[0003] In order to complete the sleep staging task, polysomnography (PSG) or other related physiological signals are divided into 30-second periods and then classified into five different sleep stages by clinicians or advanced automatic staging technology. PSG is regarded as the gold standard for comprehensive sleep assessment, monitoring multiple physiological signals simultaneously, including electroencephalogram (EEG), electrooculogram (EOG), electromyogram (EMG), electrocardiogram (ECG), etc. Among them, EEG is the key because it captures the electrical activity of the brain, and its significant characteristics, namely frequency, amplitude and waveform pattern, are significantly different in different sleep stages. In addition, the increasing popularity of portable sleep monitoring devices has promoted sleep staging research based on single-channel EEG signals, so the present invention also conducts research based on single-channel EEG signals. Initially, sleep staging was performed manually by sleep technicians, however, the manual staging process is time-consuming and labor-intensive and susceptible to human error. Taking the above factors into consideration, in recent years, research on automatic sleep staging based on original single-channel EEG signals has been carried out in full swing. In fact, most existing automatic sleep staging models based on deep learning methods are mainly data-driven. Given that the amount of sleep data available to a single institution is limited and cannot meet the data requirements for training high-performance models, collaboration with other institutions is essential to improve model performance.
[0004] Traditional centralized collaboration is to directly share data from various institutions to build an automatic sleep staging model with higher generalization performance. However, due to the high sensitivity of sleep data and increasingly stringent global privacy protection regulations, the traditional centralized collaboration method is no longer applicable. Federated learning aims to achieve inter-institutional collaboration while maintaining data privacy, resolving the conflict between data privacy and large-scale data analysis. Specifically, federated learning implicitly expands data resources and promotes knowledge sharing between clients through model aggregation. Generally, in each iteration of federated learning, the local model is initialized as the global model obtained in the previous iteration, and then the local model is updated based on the respective local datasets. However, due to differences in equipment and data collection conditions, various medical institutions may show significant heterogeneity in data distribution and patient demographics. Although directly initializing the local model as the global model of the previous iteration can introduce external task knowledge, this approach often ignores the unique features and task knowledge inherent in the local dataset. This oversight can lead to severe catastrophic forgetting, which limits the generalization ability of the final federated global model and its adaptability to the diversity of data from different institutions. Summary of the invention
[0005] In view of the above problems, the present invention provides a sleep staging method and system based on adaptive reaggregation and dual prototype comparison. By introducing an adaptive aggregation strategy for local model initialization, local task knowledge is introduced in the local model initialization process, the local initialization process is optimized, catastrophic forgetting is avoided, and the global model and the local historical model are used in a coordinated manner to retain local task-specific information and reduce the improper influence of global knowledge. Prototype consistency comparison and prototype distinguishability comparison are performed through a dual prototype comparison learning module, which enhances the unification of intra-class knowledge and improves the distinguishability of each stage. Under the premise of ensuring the privacy and security of each institution's data, this method promotes the implicit enhancement of each institution's data and the sharing of task knowledge between institutions, solves the problem of insufficient data of each institution under data-driven, and obtains a federal global model with higher accuracy and stronger generalization, thereby improving the accuracy and robustness of sleep staging.
[0006] To achieve the above object, the present invention provides a sleep staging method based on adaptive re-aggregation and dual prototype comparison, comprising:
[0007] An automatic sleep staging model based on a single-channel EEG signal is used as the backbone network of the server and each client. The server randomly initializes the global model and sends it to the client, and the client initializes the local model based on the local data set.
[0008] In a new round of federated training, the client determines an adaptive aggregation weight based on the performance results of the global model of the previous round and the local historical model of the previous round on the corresponding local data set, and aggregates the global model and the local historical model according to the adaptive aggregation weight to obtain a local initial model of the current round;
[0009] Using the global model and the local history model to extract prototypes from the local data set, and performing adaptive aggregation according to the adaptive aggregation weight to obtain a local unbiased prototype;
[0010] Extracting a local prototype using the local initial model, performing a double prototype comparison between the local prototype and the local unbiased prototype, optimizing the local initial model, and obtaining a local optimized model;
[0011] The client sends the local optimization model to the server, and the server performs federation aggregation on the received local optimization model to obtain a federated global model;
[0012] The federated training process is iterated repeatedly until a preset maximum number of federated training rounds is reached to obtain a federated global sleep staging model, and the sleep data is classified into sleep stages using the federated global sleep staging model.
[0013] In the above technical solution, preferably, the client determines an adaptive aggregation weight based on the performance results of the global model of the previous round and the local historical model of the previous round on the corresponding local data set, and aggregates the global model and the local historical model according to the adaptive aggregation weight. The specific process includes:
[0014] In the tth round of training, client k receives the global model of the previous round of federated training from the server At the same time, keep the local historical model of the previous round
[0015] According to the global model and the local history model On the current client k, the local dataset D k The cross entropy obtained from making predictions and Determine the global model The weight of The local history model The weight of The expression of cross entropy is: w (c) is the weight coefficient of sleep stage c when calculating cross entropy loss, y i(c) is the label of the i-th sample, is the corresponding prediction result;
[0016] The global model is transformed according to the adaptive aggregation weight and the local history model Perform aggregation to obtain the local initial model of the current round
[0017] In the above technical solution, preferably, the process of using the global model and the local history model to extract the prototype of the local data set, and adaptively aggregating the local unbiased prototype according to the adaptive aggregation weight includes:
[0018] Using the global model The prototype extracted from the local data set is in, To utilize the global model The prototype of sleep stage c extraction, Represented by Parameterized function for extracting embedding representation, N k(c) is the sample set belonging to the cth sleep stage on client k;
[0019] Using the local history model The prototype extracted from the local data set is
[0020] The extracted prototypes are aggregated according to the adaptive aggregation weights to obtain a local unbiased prototype
[0021]
[0022] In the above technical solution, preferably, the local prototype is extracted by using the local initial model, the local prototype and the local unbiased prototype are compared with each other, the local initial model is optimized to obtain a local optimized model, and the specific process includes:
[0023] Using the local initial model Perform local prototype extraction and obtain
[0024]
[0025] Maximize the local prototype of the same sleep stage c and locally unbiased prototype The similarity between them is minimized, corresponding to the local prototypes of different sleep stages and locally unbiased prototype The similarity between , where c≠j;
[0026] Local prototype and locally unbiased prototype The consistency comparison loss between
[0027] Where cosSim(·) is the cosine similarity between the local prototype and the local unbiased prototype, and τ is the temperature parameter;
[0028] Local prototype and locally unbiased prototype The distinguishability contrast loss between
[0029]
[0030] The objective loss function of the local model training of each client is: in, The local initial model Cross-loss entropy on local datasets;
[0031] Based on the target loss function, the local initial model Update to get the local optimization model
[0032] In the above technical solution, preferably, the received local optimization models are federated and aggregated to obtain a federated global model, and the specific process includes:
[0033] After the tth round of local training is completed, the server receives the local model from the client. Use the classic aggregation method FedAvg to federate the local model and obtain the federated global model Among them, N is the total amount of data of all clients, N k is the sample size on the kth client.
[0034] The present invention further proposes a sleep staging system based on adaptive reaggregation and dual-prototype comparison, which uses the sleep staging method based on adaptive reaggregation and dual-prototype comparison disclosed in any one of the above technical solutions, including:
[0035] A staging model initialization module, which is used to use an automatic sleep staging model based on a single-channel EEG signal as a backbone network of a server and each client, wherein the server randomly initializes a global model and sends it to the client, and the client initializes a local model based on a local data set;
[0036] A model adaptive aggregation module, which is used for, in a new round of federated training, the client determines an adaptive aggregation weight based on the performance results of the global model of the previous round and the local historical model of the previous round on the corresponding local data set, and aggregates the global model and the local historical model according to the adaptive aggregation weight to obtain a local initial model of the current round;
[0037] A prototype adaptive aggregation module, used to extract prototypes from the local data set using the global model and the local historical model, and to adaptively aggregate according to the adaptive aggregation weight to obtain a local unbiased prototype;
[0038] A dual prototype comparison and optimization module, used for extracting a local prototype using the local initial model, performing a dual prototype comparison between the local prototype and the local unbiased prototype, optimizing the local initial model, and obtaining a local optimized model;
[0039] A model federation aggregation module, configured for the client to send the local optimization model to the server, and the server to perform federation aggregation on the received local optimization model to obtain a federated global model;
[0040] The sleep staging execution module is used to repeatedly iterate the federated training process until a preset maximum number of federated training rounds is reached, thereby obtaining a federated global sleep staging model, and using the federated global sleep staging model to perform sleep staging on sleep data.
[0041] In the above technical solution, preferably, the model adaptive aggregation module is specifically used to:
[0042] In the tth round of training, client k receives the global model of the previous round of federated training from the server At the same time, keep the local historical model of the previous round
[0043] According to the global model and the local history model On the current client k, the local dataset D k The cross entropy obtained from making predictions and Determine the global model The weight of The local history model The weight of The expression of cross entropy is: w (c) is the weight coefficient of sleep stage c when calculating cross entropy loss, y i(c) is the label of the i-th sample, is the corresponding prediction result;
[0044] The global model is transformed according to the adaptive aggregation weight and the local history model Perform aggregation to obtain the local initial model of the current round
[0045] In the above technical solution, preferably, the prototype adaptive aggregation module is specifically used for:
[0046] Using the global model The prototype extracted from the local data set is in, To utilize the global model The prototype of sleep stage c extraction, Represented by Parameterized function for extracting embedding representation, N k(c) is the sample set belonging to the cth sleep stage on client k;
[0047] Using the local history model The prototype extracted from the local data set is
[0048] The extracted prototypes are aggregated according to the adaptive aggregation weights to obtain a local unbiased prototype
[0049]
[0050] In the above technical solution, preferably, the dual prototype comparison and optimization module is specifically used for:
[0051] Using the local initial model Perform local prototype extraction and obtain
[0052]
[0053] Maximize the local prototype of the same sleep stage c and locally unbiased prototype The similarity between them is minimized, corresponding to the local prototypes of different sleep stages and locally unbiased prototype The similarity between , where c≠j;
[0054] Local prototype and locally unbiased prototype The consistency comparison loss between
[0055] Where cosSim(·) is the cosine similarity between the local prototype and the local unbiased prototype, and τ is the temperature parameter;
[0056] Local prototype and locally unbiased prototype The distinguishability contrast loss between
[0057]
[0058] The objective loss function of the local model training of each client is: in, The local initial model Cross-loss entropy on local datasets;
[0059] Based on the target loss function, the local initial model Update to get the local optimization model
[0060] In the above technical solution, preferably, the model federation aggregation module is specifically used for:
[0061] After the tth round of local training is completed, the server receives the local model from the client. Use the classic aggregation method FedAvg to federate the local model and obtain the federated global model Among them, N is the total amount of data of all clients, N k is the sample size on the kth client.
[0062] Compared with the prior art, the beneficial effects of the present invention are as follows: by introducing an adaptive aggregation strategy for local model initialization, the global model and the local history model are used in a coordinated manner, and by introducing local task knowledge in the local model initialization process, the local initialization process is optimized, catastrophic forgetting is avoided, and the weight value of the re-aggregation is adaptively determined based on the confidence of the global model and the local history model on the local private data set. Then, the global model and the local history model are aggregated according to the weight value to obtain a local initial model. Next, the global model and the local history model are used to extract prototypes from the local data respectively, and the local unbiased prototype is obtained by aggregation based on the re-aggregation weight value, which retains the local task-specific information and reduces the improper influence of global knowledge.
[0063] Furthermore, in order to solve the inherent confusion between sleep stages, prototype consistency comparison and prototype distinguishability comparison are performed through a dual prototype comparison learning module. Prototype consistency comparison ensures the consistency between the local prototype extracted based on the local initialization model and the local unbiased prototype, which enhances the unification of intra-class knowledge. Prototype distinguishability comparison strengthens the distinguishability between different sleep stages and improves the distinguishability of each stage. This method promotes the implicit enhancement of data from each institution and the sharing of task knowledge between institutions while ensuring the privacy and security of data from each institution. It solves the problem of insufficient data from each institution under data-driven conditions, and obtains a more accurate and more generalizable federated global model, which improves the accuracy and robustness of sleep staging. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] Figure 1 A schematic flow chart of a sleep staging method based on adaptive re-aggregation and dual prototype comparison disclosed in an embodiment of the present invention;
[0065] Figure 2 A schematic diagram of an algorithm framework of a sleep staging method based on adaptive re-aggregation and dual prototype comparison disclosed in an embodiment of the present invention;
[0066] Figure 3 A schematic diagram of the principle of unbiased prototype acquisition and dual prototype comparison disclosed in an embodiment of the present invention;
[0067] Figure 4 A schematic diagram of a module of a sleep staging system based on adaptive re-aggregation and dual-prototype comparison disclosed in an embodiment of the present invention.
[0068] In the figure, the corresponding relationship between each component and the reference numeral is as follows:
[0069] 1. Stage model initialization module, 2. Model adaptive aggregation module, 3. Prototype adaptive aggregation module, 4. Dual prototype comparison and optimization module, 5. Model federation aggregation module, 6. Sleep stage execution module. DETAILED DESCRIPTION
[0070] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0071] The present invention is further described in detail below in conjunction with the accompanying drawings:
[0072] like Figure 1 and Figure 2 As shown, a sleep staging method based on adaptive re-aggregation and dual prototype comparison provided by the present invention includes:
[0073] The automatic sleep staging model based on single-channel EEG signals is used as the backbone network of the server and each client. The server randomly initializes the global model and sends it to the client, and the client initializes the local model based on the local data set.
[0074] In a new round of federated training, the client determines the adaptive aggregation weight based on the performance results of the global model of the previous round and the local historical model of the previous round on the corresponding local data set, and aggregates the global model and the local historical model according to the adaptive aggregation weight to obtain the local initial model of the current round;
[0075] The global model and the local history model are used to extract the prototype of the local data set, and the local unbiased prototype is obtained by adaptive aggregation according to the adaptive aggregation weight.
[0076] The local prototype is extracted by using the local initial model, the local prototype is compared with the local unbiased prototype, the local initial model is optimized, and the local optimized model is obtained;
[0077] The client sends the local optimization model to the server, and the server performs federation aggregation on the received local optimization model to obtain a federated global model.
[0078] The federated training process is iterated repeatedly until a preset maximum number of federated training rounds is reached to obtain a federated global sleep staging model, and the sleep data is classified into sleep stages using the federated global sleep staging model.
[0079] In this implementation, an adaptive aggregation strategy for local model initialization is introduced, the global model and the local history model are used in synergistic manner, and local task knowledge is introduced in the local model initialization process to optimize the local initialization process, avoid catastrophic forgetting, and adaptively determine the re-aggregation weight value based on the confidence of the global model and the local history model on the local private data set. Then, the global model and the local history model are aggregated according to the weight value to obtain a local initial model. Next, the global model and the local history model are used to extract prototypes from the local data respectively, and the local unbiased prototype is obtained by aggregation based on the re-aggregation weight value, which retains the local task-specific information and reduces the improper influence of global knowledge.
[0080] Furthermore, in order to solve the inherent confusion between sleep stages, prototype consistency contrast (PCC) and prototype distinguishability contrast (PDC) are performed through a dual prototype contrast learning module. Prototype consistency contrast PCC aims to enhance the consistency between the local prototype extracted based on the local initialization model and the local unbiased prototype obtained based on the re-aggregation weight, thereby enhancing the unification of intra-class knowledge. Prototype distinguishability contrast PDC aims to minimize the similarity between local prototypes corresponding to different sleep stages and improve the distinguishability and separability of each stage. This method promotes the implicit enhancement of data from each institution and the sharing of task knowledge between institutions while ensuring the privacy and security of data from each institution. It solves the problem of insufficient data from each institution under data-driven conditions, and obtains a federated global model with higher accuracy and stronger generalization, thereby improving the accuracy and robustness of sleep staging.
[0081] Specifically, the present invention enhances local task knowledge during the local model initialization process, and synergistically utilizes the historical local model and the global model to balance the guiding role of local and global knowledge on local training. At the same time, considering the confusion problem between sleep stages, the present invention designs a dual prototype comparison module to solve it, while strengthening the consistency of knowledge within a class, and improving the distinguishability of knowledge between classes.
[0082] At the beginning of local training, a historical local model is introduced to enhance local task knowledge, thereby avoiding catastrophic forgetting caused by directly initializing the local model as a global model. Based on the performance of the historical local model and the global model on the local data set, the adaptive aggregation weight is determined to better balance the guiding role of local task knowledge and global knowledge. After the local model is initialized, the local training is optimized through the dual prototype comparison module to alleviate the confusion problem between different sleep stages. By comparing the local prototype with the local unbiased prototype obtained based on the adaptive aggregation weight, the consistency of knowledge within the same stage class is enhanced; at the same time, the local prototypes corresponding to different stages are compared to improve the separability of each stage and enhance the identifiability of knowledge between different stage classes. In this way, a local model with better performance is obtained, and a federated global model with stronger accuracy and generalization is obtained to complete automatic sleep staging.
[0083] Local training mainly includes two stages: local model initialization and local model optimization.
[0084] (1) Local model initialization and training
[0085] The present invention improves the performance of local models by optimizing the initialization and training process of local models, thereby obtaining a federated global model with higher accuracy and stronger generalization. First, before the formal federated training, the server initializes the federated global model and distributes it to each client. Each client initializes a local model based on local data and uses it for subsequent federated training. After the federated training officially starts, each client determines an adaptive aggregation weight based on the performance of the global model and the local model of the previous round on the local data set. According to the weight, the global model and the local model of the previous round are aggregated to obtain the local initial model of the current round. Then, the prototype is extracted from the local data using the global model and the local historical model, and adaptive aggregation is performed to obtain a local unbiased prototype; at the same time, the local prototype is extracted using the obtained local initial model.
[0086] (2) Local model optimization
[0087] The local initial model is optimized by comparing the two prototypes. A local model with better performance is obtained and uploaded to the server. Finally, after receiving the local models updated by each client, the server performs traditional federation aggregation to obtain a federated global model. The above process is repeated until the maximum number of federated training rounds is reached.
[0088] In the implementation process, the sleep staging method based on adaptive reaggregation and dual prototype comparison disclosed in the above embodiment specifically includes the following five steps:
[0089] Step 1: Initialization of global and local models
[0090] Before the first round of federated training (i.e., round 0 of federated learning), the client and server initialize the local model and the global model respectively. Specifically, the server randomly initializes the global model, marked as And distributed to each client; the client initializes its own local model based on local private data, marked as Where K represents the number of clients. Existing studies have developed a large number of automatic sleep staging models based on raw single-channel EEG signals. In the present invention, following the traditional federated architecture, the client and server use the same network structure as the backbone network, that is, both use the classic automatic sleep staging model AttnSleepNet.
[0091] Step 2: Local model initialization based on adaptive reaggregation
[0092] In order to avoid catastrophic forgetting caused by directly initializing the local model as a federated global model, the present invention introduces a local history model in the local model initialization process, thereby enhancing the guidance of local task knowledge while sharing external task knowledge. The specific process includes:
[0093] When a new round of federated training (the tth round of federated training) starts, client k receives the global model of the previous round of federated training from the server. At the same time, keep the local historical model of the previous round
[0094] Based on the performance of the two on the local data set, the adaptive aggregation weight is determined. Specifically, according to the global model and local history models On the current client k, the local dataset D k The cross entropy obtained from making predictions and Determine the global model The weight of Local history model The weight of The expression of cross entropy is: w (c) is the weight coefficient of sleep stage c when calculating cross entropy loss, y i(c) is the label of the i-th sample, is the corresponding prediction result;
[0095] According to the above adaptive aggregation weights, the global model and local history models Perform aggregation to obtain the local initial model of the current round The value is and Represents the global model assigned to the previous round and local models Adaptive aggregation weights.
[0096] Step 3: Obtain local unbiased prototype and local prototype
[0097] like Figure 3As shown, in order to optimize the local initial model obtained in step 2, the present invention uses the knowledge encapsulated in the prototype to guide subsequent local training. Prototypes usually represent the main features of a class or cluster. In the context of federated learning, prototypes provide various abstract knowledge while maintaining compliance with privacy protocols. To address the confusion between sleep stages, the present invention uses dual prototype comparison to optimize the obtained local initial model. Taking into account the differences between clients, the traditional method of aggregating local prototypes extracted from different clients to obtain a global prototype and guide local model training lacks the personalized knowledge required to provide comprehensive optimization guidance for each client. Based on the adaptive aggregation weights obtained in step 2, the prototypes extracted from the global federated model and the local historical model based on local data are aggregated to obtain a local unbiased prototype.
[0098] The specific process of this step includes:
[0099] Using the global model The prototype extracted from the local data set can be expressed as in, To use the global model The corresponding prototype extracted for sleep stage c, Represented by Parameterized function for extracting embedding representation, N k(c) is the sample set belonging to the cth sleep stage on client k, where C=5 represents 5 corresponding sleep stages;
[0100] Similarly, using the local history model Extract the prototype of the local data set as
[0101] According to the adaptive aggregation weights obtained in step 2, the extracted prototypes are aggregated to obtain a local unbiased prototype
[0102] Step 4: Compare the two prototypes and optimize the local model
[0103] like Figure 3 As shown in the figure, local training is optimized through a dual prototype contrast learning module, which consists of two key components. On the one hand, prototype consistency contrast focuses on maintaining the consistency between the local prototype and the unbiased prototype corresponding to the same stage. On the other hand, prototype distinguishability contrast aims to reduce the similarity between prototypes corresponding to different sleep stages, thereby increasing their separation and improving the discriminability of inter-class knowledge. In this way, the inherent confusion between sleep stages is alleviated. Specifically, the similarity between the local prototype and the unbiased prototype of the same sleep stage is strengthened (i.e., maximizing and while reducing the similarity between local and unbiased prototypes corresponding to different sleep stages (i.e., minimizing and similarity, c≠j).
[0104] The specific process of this step includes:
[0105] Using local initial model Perform local prototype extraction and obtain
[0106]
[0107] Maximize the local prototype of the same sleep stage c and locally unbiased prototype The similarity between them is minimized, corresponding to the local prototypes of different sleep stages and locally unbiased prototype The similarity between , where c≠j;
[0108] Local prototype and locally unbiased prototype The consistency comparison loss between Among them, C = 5 represents the category of sleep stage, sim (c) (·) measure the similarity between prototypes, Among them, cosSim(·) is the cosine similarity between the local prototype and the local unbiased prototype, τ is the temperature parameter, and in the implementation process, the value of τ can be set to 0.5;
[0109] Local prototype and locally unbiased prototype The distinguishability contrast loss between
[0110]
[0111] The objective loss function of local model training for each client is: in, The local initial model Cross-loss entropy on local datasets;
[0112] Based on the target loss function, the local initial model Update to get the local optimization model
[0113] Step 5: The server aggregates the local models to obtain the global model
[0114] At the end of the tth round of federated training, based on step 4, each client obtains an updated local model And send it to the server. The server is responsible for aggregating local models to obtain a federated global model. The specific process includes:
[0115] After the tth round of local training is completed, the server receives the local model from the client. Use the classic aggregation method FedAvg to federate the local model and obtain the federated global model Among them, N is the total amount of data of all clients, N k is the sample size on the kth client;
[0116] After that, the federated global model of round t is distributed to each client for round t+1 training. The above process is repeated until the maximum number of training rounds T is reached.
[0117] like Figure 4 As shown, the present invention further proposes a sleep staging system based on adaptive reaggregation and dual-prototype comparison, which applies the sleep staging method based on adaptive reaggregation and dual-prototype comparison disclosed in any one of the above embodiments, including:
[0118] The staging model initialization module 1 is used to use the automatic sleep staging model based on the single-channel EEG signal as the backbone network of the server and each client. The server randomly initializes the global model and sends it to the client, and the client initializes the local model based on the local data set;
[0119] Model adaptive aggregation module 2, used in a new round of federated training, the client determines the adaptive aggregation weight based on the performance results of the global model of the previous round and the local historical model of the previous round on the corresponding local data set, and aggregates the global model and the local historical model according to the adaptive aggregation weight to obtain the local initial model of the current round;
[0120] The prototype adaptive aggregation module 3 is used to extract the prototype of the local data set by using the global model and the local historical model, and adaptively aggregate the local unbiased prototype according to the adaptive aggregation weight;
[0121] The dual prototype comparison and optimization module 4 is used to extract the local prototype by using the local initial model, perform dual prototype comparison between the local prototype and the local unbiased prototype, optimize the local initial model, and obtain the local optimized model;
[0122] The model federation aggregation module 5 is used for the client to send the local optimization model to the server, and the server performs federation aggregation on the received local optimization model to obtain a federated global model;
[0123] The sleep staging execution module 6 is used to repeatedly iterate the federated training process until a preset maximum number of federated training rounds is reached, to obtain a federated global sleep staging model, and to perform sleep staging on the sleep data using the federated global sleep staging model.
[0124] In the above implementation, preferably, the model adaptive aggregation module 2 is specifically used for:
[0125] In the tth round of training, client k receives the global model of the previous round of federated training from the server At the same time, keep the local historical model of the previous round
[0126] According to the global model and local history models On the current client k, the local dataset D k The cross entropy obtained from making predictions and Determine the global model The weight of Local history model The weight of The expression of cross entropy is: w (c) is the weight coefficient of sleep stage c when calculating cross entropy loss, y i(c) is the label of the i-th sample, is the corresponding prediction result;
[0127] The global model is transformed according to the adaptive aggregation weights and local history models Perform aggregation to obtain the local initial model of the current round
[0128] In the above implementation, preferably, the prototype adaptive aggregation module 3 is specifically used for:
[0129] Using the global model Extract the prototype of the local data set as in, To use the global model The prototype of sleep stage c extraction, Represented by Parameterized function for extracting embedding representation, N k(c) is the sample set belonging to the cth sleep stage on client k;
[0130] Using local history models Extract the prototype of the local data set as
[0131]
[0132] Aggregate the extracted prototypes according to the adaptive aggregation weights to obtain local unbiased prototypes
[0133]
[0134] In the above implementation, preferably, the dual prototype comparison and optimization module 4 is specifically used for:
[0135] Using local initial model Perform local prototype extraction and obtain
[0136]
[0137] Maximize the local prototype of the same sleep stage c and locally unbiased prototype The similarity between them is minimized, corresponding to the local prototypes of different sleep stages and locally unbiased prototype The similarity between , where c≠j;
[0138] Local prototype and locally unbiased prototype The consistency comparison loss between
[0139] Where cosSim(·) is the cosine similarity between the local prototype and the local unbiased prototype, and τ is the temperature parameter;
[0140] Local prototype and locally unbiased prototype The distinguishability contrast loss between
[0141]
[0142]
[0143] The objective loss function of local model training for each client is: in, The local initial model Cross-loss entropy on local datasets;
[0144] Based on the target loss function, the local initial model Update to get the local optimization model
[0145] In the above implementation, preferably, the model federation aggregation module 5 is specifically used for:
[0146] After the tth round of local training is completed, the server receives the local model from the client. Use the classic aggregation method FedAvg to federate the local model and obtain the federated global model Among them, N is the total amount of data of all clients, N k is the sample size on the kth client.
[0147] According to the sleep staging system based on adaptive reaggregation and dual-prototype comparison disclosed in the above-mentioned embodiment, the functions to be implemented by each module thereof correspond to the steps of the sleep staging method based on adaptive reaggregation and dual-prototype comparison disclosed in the above-mentioned embodiment. During the implementation process, specific operations are performed with reference to the above-mentioned embodiment, which will not be repeated here.
[0148] According to the sleep staging method and system based on adaptive reaggregation and dual prototype comparison disclosed in the above embodiment, it is used together with other federated methods to perform sleep staging experiments on the sleep datasets Sleep-EDFx and SHHS, and the staging effect comparison data shown in Table 1 below are obtained.
[0149] Table 1 Comparison of the staging effects of the present invention and other federated methods on the sleep datasets Sleep-EDFx and SHHS
[0150]
[0151] As can be seen from Table 1, the method proposed in the present invention (Ours) achieves better staging effect on two public sleep datasets, the SHHS dataset and the Sleep-EDFx dataset, compared with other federated methods (such as FedAvg, FPL, FedAw, etc.).
[0152] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A sleep staging method based on adaptive reaggregation and dual prototype comparison, characterized in that: include: An automatic sleep staging model based on a single-channel EEG signal is used as the backbone network of the server and each client. The server randomly initializes the global model and sends it to the client, and the client initializes the local model based on the local data set. In a new round of federated training, the client determines an adaptive aggregation weight based on the performance results of the global model of the previous round and the local historical model of the previous round on the corresponding local data set, and aggregates the global model and the local historical model according to the adaptive aggregation weight to obtain a local initial model of the current round; Using the global model and the local history model to extract prototypes from the local data set, and performing adaptive aggregation according to the adaptive aggregation weight to obtain a local unbiased prototype; Extracting a local prototype using the local initial model, performing a double prototype comparison between the local prototype and the local unbiased prototype, optimizing the local initial model, and obtaining a local optimized model; The client sends the local optimization model to the server, and the server performs federation aggregation on the received local optimization model to obtain a federated global model; The federated training process is iterated repeatedly until a preset maximum number of federated training rounds is reached to obtain a federated global sleep staging model, and the sleep data is classified into sleep stages using the federated global sleep staging model.
2. The sleep staging method based on adaptive reaggregation and dual prototype comparison according to claim 1, characterized in that: The client determines an adaptive aggregation weight based on the performance results of the global model of the previous round and the local historical model of the previous round on the corresponding local data set, and aggregates the global model and the local historical model according to the adaptive aggregation weight. The specific process includes: In the tth round of training, client k receives the global model of the previous round of federated training from the server At the same time, keep the local historical model of the previous round According to the global model and the local history model On the current client k, the local dataset D k The cross entropy obtained from making predictions and Determine the global model The weight is The local history model The weight is The expression of cross entropy is: w (c) is the weight coefficient of sleep stage c when calculating cross entropy loss, y i(c) is the label of the i-th sample, is the corresponding prediction result; The global model is transformed according to the adaptive aggregation weight and the local history model Perform aggregation to obtain the local initial model of the current round 3. The sleep staging method based on adaptive reaggregation and dual prototype comparison according to claim 2, characterized in that: The process of extracting a prototype from the local data set by using the global model and the local history model, and performing adaptive aggregation according to the adaptive aggregation weight to obtain a local unbiased prototype specifically includes: Using the global model The prototype extracted from the local data set is in, To utilize the global model The prototype of sleep stage c extraction, Represented by Parameterized function for extracting embedding representation, N k(c) is the sample set belonging to the cth sleep stage on client k; Using the local history model The prototype extracted from the local data set is The extracted prototypes are aggregated according to the adaptive aggregation weights to obtain a local unbiased prototype 4. The sleep staging method based on adaptive reaggregation and dual prototype comparison according to claim 3, characterized in that: The local prototype is extracted by using the local initial model, the local prototype is compared with the local unbiased prototype, and the local initial model is optimized to obtain a local optimized model. The specific process includes: Using the local initial model Perform local prototype extraction and obtain Maximize the local prototype of the same sleep stage c and locally unbiased prototype The similarity between them is minimized, corresponding to the local prototypes of different sleep stages and locally unbiased prototype The similarity between , where c≠j; Local prototype and locally unbiased prototype The consistency comparison loss between Where cosSim(·) is the cosine similarity between the local prototype and the local unbiased prototype, and τ is the temperature parameter; Local prototype and locally unbiased prototype The discriminability contrast loss between The objective loss function of the local model training of each client is: in, The local initial model Cross-loss entropy on local datasets; Based on the target loss function, the local initial model Update to get the local optimization model 5. The sleep staging method based on adaptive reaggregation and dual prototype comparison according to claim 4, characterized in that: The received local optimization models are federated and aggregated to obtain a federated global model. The specific process includes: After the tth round of local training is completed, the server receives the local model from the client. Use the classic aggregation method FedAvg to federate the local model and obtain the federated global model Among them, N is the total amount of data of all clients, N k is the sample size on the kth client.
6. A sleep staging system based on adaptive reaggregation and dual prototype comparison, characterized in that: The sleep staging method based on adaptive reaggregation and dual prototype comparison as claimed in any one of claims 1 to 5 is applied, comprising: A staging model initialization module, which is used to use an automatic sleep staging model based on a single-channel EEG signal as a backbone network of a server and each client, wherein the server randomly initializes a global model and sends it to the client, and the client initializes a local model based on a local data set; A model adaptive aggregation module, which is used for, in a new round of federated training, the client determines an adaptive aggregation weight based on the performance results of the global model of the previous round and the local historical model of the previous round on the corresponding local data set, and aggregates the global model and the local historical model according to the adaptive aggregation weight to obtain a local initial model of the current round; A prototype adaptive aggregation module, used to extract prototypes from the local data set using the global model and the local historical model, and to adaptively aggregate according to the adaptive aggregation weight to obtain a local unbiased prototype; A dual prototype comparison and optimization module, used for extracting a local prototype using the local initial model, performing a dual prototype comparison between the local prototype and the local unbiased prototype, optimizing the local initial model, and obtaining a local optimized model; A model federation aggregation module, configured for the client to send the local optimization model to the server, and the server to perform federation aggregation on the received local optimization model to obtain a federated global model; The sleep staging execution module is used to repeatedly iterate the federated training process until a preset maximum number of federated training rounds is reached, thereby obtaining a federated global sleep staging model, and using the federated global sleep staging model to perform sleep staging on sleep data.
7. The sleep staging system based on adaptive reaggregation and dual prototype comparison according to claim 6, characterized in that: The model adaptive aggregation module is specifically used for: In the tth round of training, client k receives the global model of the previous round of federated training from the server At the same time, keep the local historical model of the previous round According to the global model and the local history model On the current client k, the local dataset D k The cross entropy obtained from making predictions and Determine the global model The weight is The local history model The weight is The expression of cross entropy is: w (c) is the weight coefficient of sleep stage c when calculating cross entropy loss, y i(c) is the label of the i-th sample, is the corresponding prediction result; The global model is transformed according to the adaptive aggregation weight and the local history model Perform aggregation to obtain the local initial model of the current round 8. The sleep staging system based on adaptive reaggregation and dual prototype comparison according to claim 7, characterized in that: The prototype adaptive aggregation module is specifically used for: Using the global model The prototype extracted from the local data set is in, To utilize the global model The prototype of sleep stage c extraction, Represented by Parameterized function for extracting embedding representation, N k(c) is the sample set belonging to the cth sleep stage on client k; Using the local history model The prototype extracted from the local data set is The extracted prototypes are aggregated according to the adaptive aggregation weights to obtain a local unbiased prototype 9. The sleep staging system based on adaptive reaggregation and dual prototype comparison according to claim 8, characterized in that: The dual prototype comparison and optimization module is specifically used for: Using the local initial model Perform local prototype extraction and obtain Maximize the local prototype of the same sleep stage c and locally unbiased prototype The similarity between them is minimized, corresponding to the local prototypes of different sleep stages and locally unbiased prototype The similarity between , where c≠j; Local prototype and locally unbiased prototype The consistency comparison loss between Where cosSim(·) is the cosine similarity between the local prototype and the local unbiased prototype, and τ is the temperature parameter; Local prototype and locally unbiased prototype The discriminability contrast loss between The objective loss function of the local model training of each client is: in, The local initial model Cross-loss entropy on local datasets; Based on the target loss function, the local initial model Update to get the local optimization model 10. The sleep staging system based on adaptive reaggregation and dual prototype comparison according to claim 9, characterized in that: The model federation aggregation module is specifically used for: After the tth round of local training is completed, the server receives the local model from the client. Use the classic aggregation method FedAvg to federate the local model and obtain the federated global model Among them, N is the total amount of data of all clients, N k is the sample size on the kth client.
