Cough sound recognition method based on federal learning
Through the federated learning method, the client locally updates the model and uploads the feature extractor, which solves the problems of insufficient data volume and privacy leakage in traditional methods, improves the accuracy and training efficiency of cough sound recognition, and achieves accurate cough sound recognition. Sexuality and privacy protection.
Patent Information
- Application Number
- CN202410657637.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-26
- Publication Date
- 2024-09-10
AI Technical Summary
Traditional cough sound recognition methods require patients to wear equipment for long periods of time to record. The amount of data is insufficient and the risk of privacy leakage is high. Traditional federated learning is inefficient, making it difficult to train a robust model.
Using a method based on federated learning, the central server initializes the global model, and the client performs local data preprocessing and model updating. It uses dynamic regularization loss terms and state parameter aggregation methods to only upload the feature extractor to avoid data uploading and optimize training efficiency and Model generalization ability.
It achieves the accuracy and privacy protection of cough sound recognition, improves the generalization ability and training efficiency of the model, and avoids the problem of privacy leakage in data upload.
Smart Images

Figure CN118629434A
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of cough sound recognition and federated learning, and in particular to a cough sound recognition method based on federated learning. Background Art
[0002] Coughing is an important defense mechanism of the respiratory system. It has the protective effect of clearing foreign matter and secretions from the respiratory tract and is accompanied by sound. In medical research, coughing is often considered an important symptom of certain diseases, such as COVID-19. Cough diagnosis usually relies on the patient's subjective complaints or cough questionnaire assessments. In order to achieve an objective, accurate and reliable diagnosis, it is necessary to automatically identify cough sounds from audio data. Traditional cough recognition algorithms require medical institutions to arrange patients to wear relevant equipment for data collection and then conduct centralized machine learning training. In order to capture the real cough sound, patients need to wear relevant equipment for a long time and record continuously. Since the cough sound only occurs occasionally and lasts for a short time, most of the recorded audio clips are the patient's daily life and communication sounds. The small amount of data from a single hospital makes it difficult to train a robust model. The joint cough sound recognition training by multiple hospitals requires the aggregation of data from all parties, which may cause patient privacy leakage during the data upload process.
[0003] Federated learning is a distributed machine learning method, and its structure consists of a server and several clients. The cough sound recognition method based on federated learning described in the present invention includes a central server and multiple clients. The central server can be a more authoritative medical institution in the region, or a commissioned third-party company. Each client is a medical institution, and its cough sound data is composed of cough sound samples of its patients collected by each medical institution through equipment. Each client uses its own local data to train a model, and only sends the trained cough sound recognition model back to the server. The server aggregates the received client models to obtain a global model. In this process, the client's local sound data is not uploaded, which overcomes the problem of privacy leakage. At the same time, the present invention optimizes traditional federated learning from multiple angles to further improve the cough sound recognition effect. Summary of the invention
[0004] In view of the above-mentioned deficiencies in the prior art, the present invention provides a cough sound recognition method based on federated learning, comprising:
[0005] S1 The central server initializes the federated learning training environment and generates an initial global model;
[0006] The S2 client pre-processes the local audio clips containing coughing sounds and divides them into training data sets and test data sets;
[0007] The S3 central server uses an extraction strategy based on data value weight to extract some clients to participate in federated training and sends down the global model;
[0008] After receiving the global model, the client participating in this round of federated learning training S4 sets it as the initial local model and updates the local model using the model update strategy based on the dynamic regularization loss term, and sets the updated global model as the new local model to calculate its loss gradient weight;
[0009] After the S5 local model is updated, the client splits the model into two parts: the feature extractor and the fully connected layer. The feature extractor is uploaded to the server, and the fully connected layer is kept locally.
[0010] S6 The central server receives the feature extractor model uploaded by the client participating in the training, updates the global feature extractor model using the global model aggregation update method based on the state parameters, and then returns to step 3 until the global network model of the central server converges or reaches the specified number of training times.
[0011] Furthermore, the client preprocesses the local sound data, including but not limited to directly using the one-dimensional sound signal data as input, extracting the Mel-spectrogram features or Mel-cepstral coefficient features of the one-dimensional sound signal data as input, etc.
[0012] Furthermore, the client divides the local sound data into a training data set and a test data set in a ratio of 4:1.
[0013] Furthermore, the central server uses an extraction strategy based on data value weight to extract some clients to participate in federated learning. The formula is:
[0014] Furthermore, the client uses a model update strategy based on a dynamic regularization loss term during local training, including:
[0015] S1 constructs a dynamic regularization penalty loss function according to the global model newly received by the client, the local model being updated, and the loss gradient weight vector of the local model in the previous round of federated learning;
[0016] S2, the client calculates the total loss function through the cross entropy loss function and the dynamic regularization penalty loss function;
[0017] S3 trains the central server global model received by the client according to the cough sound data of the client and the principle of minimizing the total loss function, obtains updated model parameters and sets them as the client local model.
[0018] Furthermore, according to a method for cough recognition based on federated learning according to claim 5, it is characterized in that the dynamic regularization penalty loss function is:
[0019]
[0020] Among them, w k Indicates that the updated local model is being trained in the client; w t-1 Represents the original parameters of the global model sent by the central server; represents the loss gradient weight vector of the local model of the client in the previous round of federated learning; λ represents the regularization hyperparameter.
[0021] Furthermore, the objectives of the local model updated by the client are:
[0022]
[0023] Among them, x represents the input data, y represents the label corresponding to the input data, represents the weight of the local model of client k after the training of the tth round, represents the cross entropy loss function, represents the dynamic regularization penalty loss function.
[0024] Furthermore, according to a cough sound recognition method based on federated learning according to claim 6, it is characterized in that after the local training phase is completed, the client will reset the loss gradient weight vector of the local model.
[0025] Furthermore, when uploading the model to the server, the client splits the local model into a feature extractor part φ and a fully connected layer part θ.
[0026] Furthermore, after receiving the local model uploaded by the client participating in the training, the central server updates the global feature extractor model using a global model aggregation update method based on state parameters, and the formula is:
[0027]
[0028]
[0029] Among them, h t represents the state parameter of the central server, S t represents the set of clients participating in the training extracted by the central server in the tth round of federated learning, φ t represents the t-th round global feature extractor model aggregated by the central server, represents the local feature extractor model uploaded by client k in round t.
[0030] Furthermore, after receiving the global feature extractor model, the client will combine the locally retained fully connected layer model with the global feature extractor model to obtain the global model w.
[0031] Furthermore, the sound recognition model used by the central server and the client is a deep learning model, including but not limited to a CNN model, a C-BiLSTM model, and a Transformer model.
[0032] The advantage of the present invention is that it uses a federated learning method to identify cough sounds. Compared with traditional methods, it does not require the client to upload cough audio data to the central server, thus overcoming the privacy leakage problem that may occur during data upload. While ensuring the privacy and security of data from all parties, the value weight is used to extract the clients participating in the training to optimize the efficiency of federated learning training; the dynamic regularization method is used to update the model to improve the generalization ability of the model; a personalized local model is constructed using a model upload strategy that retains the local layer; and the server state parameters are used to aggregate the global model to improve the model convergence speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 The figure is a schematic diagram of the MFCC feature extraction process of cough sound data according to an embodiment of the present invention.
[0034] Figure 2 The present invention is a schematic diagram of a cough sound recognition method framework based on federated learning.
[0035] Figure 3 The present invention is a flowchart of a cough sound recognition method based on federated learning.
[0036] Figure 2 In the figure, 1 is the central server distributing the global model, 2 is the client updating the local model, 3 is the client splitting the model and uploading the feature extraction layer, and 4 is the central server updating the aggregated global model. DETAILED DESCRIPTION
[0037] The technical solutions in the embodiments of the present invention are described clearly and completely below. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. 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.
[0038] The cough sound recognition method based on federated learning described in the present invention includes a central server and multiple clients. The central server can be a more authoritative medical institution in the region, or a commissioned third-party company. The clients are various medical institutions, and their cough sound data are composed of cough sound samples of their patients collected by each medical institution through equipment.
[0039] The present invention provides a method for cough recognition based on federated learning, comprising the following steps:
[0040] The central server initializes the federated learning training environment and generates an initial global model;
[0041] The initial global model generated by the central server used in this embodiment is a C-BiLSTM model, which includes five convolution modules, two BiLSTM modules and two fully connected modules. Each convolution module consists of a two-dimensional convolution layer, a ReLU activation function layer and a maximum pooling layer. Each BiLSTM module contains only one BiLSTM layer. The first fully connected module contains a fully connected linear layer and a ReLU activation function layer, and the second fully connected module contains a fully connected linear layer and a Sigmoid layer.
[0042] The output of the model is a vector of length 1000, representing 1000 frames of length 10 milliseconds in a 10-second cough segment. Each value in the vector is mapped to the interval of 0 to 1 through the final Sigmoid layer. If a value is greater than 0.5, it means that the frame corresponding to the value is a cough frame, otherwise it is a non-cough frame.
[0043] After the initial global model is generated, the client preprocesses the local cough sound data and divides it into training data set and test data set.
[0044] The sound data preprocessing method used in this embodiment is to extract the MFCC feature map of the cough sound. The cough sound data preprocessing method is as follows: Figure 1 As shown, the specific steps are as follows:
[0045] The first step is segmentation. The daily life sounds of patients recorded by the recording device are long and need to be segmented before MFCC feature extraction. Therefore, the long recording is segmented into 10-second units.
[0046] The second step is pre-emphasis. The purpose of pre-emphasis is to enhance the high frequency part, make the spectrum of the signal flat, keep it in the entire frequency band from low frequency to high frequency, and use the same signal-to-noise ratio to find the spectrum. The implementation method is to use a first-order filter to apply the pre-emphasis filter to the sound signal x. The formula is:
[0047] y(t)=x(t)-αx(t-1)
[0048] Where α is the filter coefficient and is set to 0.97.
[0049] The third step is framing. The cough sound sample signal x is divided into frames with a size of 25 milliseconds and a step length of 10 milliseconds (overlapping 15 milliseconds), that is, each 10-second cough sound segment can be divided into 1000 frames.
[0050] The fourth step is windowing. After dividing the signal into frames, multiply each frame by a window function, such as a Hamming window. This increases the continuity of the left and right ends of the frame, offsets the FFT assumption (the data is infinite), and reduces spectral leakage. The form of the Hamming window is as follows:
[0051]
[0052] Among them, 0≤n≤N-1, N is the window length.
[0053] The fifth step is fast Fourier transform. Since it is usually difficult to see the characteristics of the signal in the time domain, it is usually converted into energy distribution in the frequency domain for observation. Different energy distributions can represent the characteristics of different sounds. Therefore, after multiplying the Hamming window, each frame must be subjected to fast Fourier transform to obtain the energy distribution in the spectrum. The frequency spectrum of each frame is obtained by fast Fourier transforming the frame signal after frame division and windowing. The power spectrum of the sound signal is obtained by taking the modulus square of the frequency spectrum of the speech signal.
[0054] Step 6: Filter with a triangular bandpass filter. Filter the energy spectrum through a set of Mel-scale triangular filter banks. Define a filter bank with M filters (the number of filters is close to the number of critical bands). The filter used is a triangular filter with a center frequency of f(m). The response at the center frequency is 1 and decreases linearly toward 0 until it reaches the center frequency of two adjacent filters, where the response is 0. The interval between each f(m) widens as the value of m increases. In this example, M is set to 40. The frequency response of the triangular filter is defined as
[0055]
[0056] Step 7: Discrete cosine transform. Calculate the logarithmic energy of each filter bank output as:
[0057]
[0058] The logarithmic energy s(m) is transformed by discrete cosine transform (DCT) to obtain the MFCC coefficients:
[0059]
[0060] After data processing is completed, the client divides the local data into training data set and test data set in a ratio of 4:1, and uploads the data volume information of the local training data set to the server. The central server constructs a weight vector based on the information uploaded by the client.
[0061] After the federated learning training begins, the central server uses an extraction strategy based on data value weight to extract some clients to participate in the federated learning. The formula is:
[0062]
[0063] Among them, s k is the probability weight of client k being selected to participate in federated learning, β is the combined weight hyperparameter, |D k | is the number of cough sound data sample training sets in client k, K is the total number of clients connected to the central server, and |D| is the average number of cough sound training samples per client, which is obtained by dividing the number of training set samples of all clients by the total number of clients.
[0064] After receiving the global model sent by the central server, the extracted client uses the model update strategy based on the dynamic regularization loss term to perform local personalized training. The steps are as follows:
[0065] In the first step, the client receives the global model and directly sets it as the new local model when t=1; when t>1, the received global model is the global feature extractor model, which is combined with the local fully connected layer to obtain a new local model, and then the local cough sound data is sent to the model to start local training.
[0066] In the second step, the client constructs a dynamic regularization penalty loss function based on the received global model, the local model being updated, and the loss gradient weight vector of the local model in the previous round of federated learning. The formula is:
[0067]
[0068] Among them, w k Indicates that the updated local model is being trained in the client; w t-1 Represents the original parameters of the global model sent by the central server; represents the loss gradient weight vector of the local model of the client in the previous round of federated learning; λ represents the regularization hyperparameter, and in this example, λ is set to 0.1. If the client is selected for federated training for the first time, set
[0069] In the third step, the client uses the stochastic gradient descent algorithm to update the local model. The goal of updating the local model is:
[0070]
[0071] Among them, x represents the input data, y represents the label corresponding to the input data, represents the weight of the local model of client k after the training of the tth round, represents the cross entropy loss function, represents the dynamic regularization penalty loss function.
[0072] In the fourth step, the client will update the local loss gradient weight vector based on the updated local model, the local model obtained from the previous round of federated learning training, and the global model received before the update. The formula is:
[0073]
[0074] in, is the client local loss gradient weight vector of the tth round, λ is the regularization hyperparameter, and in this example, λ is set to 0.1. is the client local model parameter in round t, w t-1 It is the global model obtained by central server aggregation in round t-1.
[0075] After the local training is completed, the client splits the local model into the feature extractor part φ and the fully connected layer part θ, and only uploads the feature extractor part φ to the central server, retaining the fully connected layer part θ.
[0076] After the central server receives the local model uploaded by the client participating in the training, it uses the global model aggregation update method based on the state parameter to update the global feature extractor model. The formula is:
[0077]
[0078]
[0079] Among them, h t represents the state parameter of the central server, S t represents the set of clients participating in the training extracted by the central server in the tth round of federated learning, φ t represents the t-th round global feature extractor model aggregated by the central server, represents the local feature extractor model uploaded by client k in the tth round, μ is the state parameter weight, and in this embodiment, μ=0.1 is set.
[0080] After aggregating the new global model, the central server starts a new round of federated training until the global network model of the central server converges or reaches the specified number of training times.
[0081] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.
Claims
1. A cough recognition method based on federated learning, It is characterized in that This method connects multiple clients containing cough sound data through a central server, and multiple clients coordinate and conduct federated learning training in parallel. The specific steps of this method include the following: S1 The central server initializes the federated learning training environment and generates an initial global model; The S2 client pre-processes the local audio clips containing coughing sounds and divides them into training data sets and test data sets; The S3 central server uses an extraction strategy based on data value weight to extract some clients to participate in federated training and sends down the global model; After receiving the global model, the client participating in this round of federated learning training S4 sets it as the initial local model and updates the local model using the model update strategy based on the dynamic regularization loss term, and sets the updated global model as the new local model to calculate its loss gradient weight; After the S5 local model is updated, the client splits the model into two parts: a feature extractor and a fully connected layer. The feature extractor is uploaded to the server, and the fully connected layer is kept locally. S6 The central server receives the feature extractor model uploaded by the client participating in the training, updates the global feature extractor model using the global model aggregation update method based on the state parameter, and then returns to step 3 until the global network model of the central server converges or reaches the specified number of training times.
2. According to the method for cough recognition based on federated learning in claim 1, Features: In step 2, the client preprocesses the local cough sound data, including but not limited to directly using the one-dimensional audio signal data as input, extracting the Mel-spectrogram features or Mel-cepstral coefficient features of the one-dimensional audio signal data as input, etc.
3. According to the cough sound recognition method based on federated learning in claim 1, Features: In step 2, the client needs to divide the local cough sound data into a training data set and a test data set.
4. The cough sound recognition method based on federated learning according to claim 1, Features: The central server uses an extraction strategy based on data value weight to extract some clients to participate in federated learning. The formula is: Among them, s k is the probability weight of client k being selected to participate in federated learning, β is the combined weight hyperparameter, |D k | is the number of cough sound data sample training sets in client k, K is the total number of clients connected to the central server, and |D| is the average number of cough sound training samples per client, which is obtained by dividing the number of training set samples of all clients by the total number of clients.
5. The cough sound recognition method based on federated learning according to claim 1, Features: The model update strategy based on the dynamic regularization loss term in step 5 includes: S1 constructs a dynamic regularization penalty loss function according to the global model newly received by the client, the local model being updated, and the loss gradient weight vector of the local model in the previous round of federated learning; S2, the client calculates the total loss function through the cross entropy loss function and the dynamic regularization penalty loss function; S3 trains the central server global model received by the client according to the cough sound data of the client and the principle of minimizing the total loss function, obtains updated model parameters and sets them as the client local model.
6. The cough sound recognition method based on federated learning according to claim 5, It is characterized in that The dynamic regularization penalty loss function is: Among them, w k Indicates that the updated local model is being trained in the client; w t-1 Represents the original parameters of the global model sent by the central server; represents the loss gradient weight vector of the local model of the client in the previous round of federated learning; λ represents the regularization hyperparameter.
7. The cough sound recognition method based on federated learning according to claim 1, It is characterized in that The goals of the client-side updated local model are: Among them, x represents the input data, y represents the label corresponding to the input data, represents the weight of the local model of client k after the training of the tth round, represents the cross entropy loss function, represents the dynamic regularization penalty loss function.
8. The cough sound recognition method based on federated learning according to claim 1, It is characterized in that After the local training phase is completed, the client will reset the loss gradient weight vector of the local model.
9. The cough sound recognition method based on federated learning according to claim 1, It is characterized in that When uploading the model to the server, the client splits the local model into a feature extractor part φ and a fully connected layer part θ, and only uploads the feature extractor part φ.
10. The cough sound recognition method based on federated learning according to claim 1, It is characterized in that The global model aggregation update method based on state parameters described in step 7 is used to update the global feature extractor model, and its formula is: Among them, h t represents the state parameter of the central server, S t represents the set of clients participating in the training extracted by the central server in the tth round of federated learning, φ t represents the t-th round global feature extractor model aggregated by the central server, represents the local feature extractor model uploaded by client k in round t.
11. The cough sound recognition method based on federated learning according to claim 1, Features: After receiving the global feature extractor model, the client uses the locally retained fully connected layer model to combine with the global feature extractor model to obtain the global model w.
12. The cough sound recognition method based on federated learning according to claim 1, Features: The cough sound recognition model used by the central server and the client is a deep learning model, including but not limited to a CNN model, a C-BiLSTM model, and a Transformer model.
13. The cough sound recognition method based on federated learning according to claim 1, Features: The cough sound data label used by the client is a strong label, which includes whether there is a cough sound in each audio segment, and the start and end time of each cough sound in the audio segment.
Citation Information
Cited By
Voiceprint recognition method based on federal learning
CN119479658A
A voiceprint recognition method based on federated learning
CN119479658B
Alarm data processing method based on semantic weighted federated learning
CN122116542A
