Photoplethysmography signal generation method based on MC-GAN network
Generating realistic photoplethysmographic pulse wave signals through the MC-GAN network solves the problems of insufficient data and category imbalance, improves the performance of cardiac abnormality detection, and achieves more accurate cardiac abnormality detection.
Patent Information
- Application Number
- CN202410797851.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-06-20
AI Technical Summary
Insufficient photoplethysmography PPG data and class imbalance problems affect the classification performance of deep learning algorithms in cardiac abnormality detection.
Using the photoplethysmographic signal generation method based on MC-GAN network, by constructing the generation model G and the discrimination model D, and introducing the convolution block attention mechanism and the multi-head attention mechanism, a realistic simulated photoplethysm pulse wave signal is generated to solve the problem of data Solve the problem of deficiencies and improve the robustness and generalization performance of the model through adversarial training.
It effectively generates diverse and realistic simulated photoplethysm wave signals, enhances the representation ability and classification accuracy of the model, improves the problems of insufficient data and class imbalance, and improves the performance of cardiac abnormality detection.
Smart Images

Figure CN118364300B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of signal processing technology, and in particular to the field of photoplethysmography signal generation and synthesis based on a MC-GAN network. Background Art
[0002] Cardiovascular disease is the number one disease threatening human health, and the number of cardiovascular disease patients worldwide is increasing year by year.
[0003] The formation and changes of photoplethysmography (PPG) are affected by the functional state of the heart, blood, and arterial vessels, and contain physiological and pathological information of the cardiovascular system. The extraction and analysis of photoplethysmography (PPG) has potential application value for early warning and real-time monitoring of cardiovascular diseases. However, traditional photoplethysmography (PPG) analysis methods rely on manual interpretation, which is time-consuming and subjective. With the popularization of automatic photoplethysmography (PPG) diagnosis technology, the accuracy and efficiency of diagnosis have been improved, and it also allows algorithms to be embedded in mobile devices (such as mobile phones) to easily diagnose and collect photoplethysmography (PPG) through wearable monitoring devices to monitor patients' abnormal conditions in real time. In recent years, many studies have adopted deep learning algorithms to classify photoplethysmography (PPG) to detect cardiac abnormalities, and have made significant progress. However, due to the characteristics of medical data, such as limited data acquisition, there are problems such as insufficient photoplethysmography (PPG) data and class imbalance, which may affect the performance of photoplethysmography (PPG) classifiers. Therefore, how to effectively deal with the problems of insufficient data and class imbalance is one of the main problems faced by the photoplethysmography (PPG) signal classification algorithm based on deep learning. Summary of the invention
[0004] The present invention aims at the problem of insufficient photoplethysmography (PPG) data and imbalanced categories in the prior art. To solve the above technical problems, the present invention is implemented through the following technical solutions:
[0005] The present invention proposes a method for generating a photoplethysmogram signal based on a MC-GAN network, the method comprising the following steps:
[0006] S1, preprocessing the photoplethysmogram signal data to obtain preprocessed photoplethysmogram signal data, and saving the preprocessed photoplethysmogram signal data to a corresponding folder;
[0007] S2. Based on the preprocessed photoplethysmography signal data obtained in S1, a generation model G and a discrimination model D are constructed based on the DCGAN model. A convolutional block attention mechanism and a multi-head attention mechanism are introduced into the generation model G and the discrimination model D to capture feature information in the synthetic sample. The constructed generation model G and the discrimination model D constitute an MC-GAN network.
[0008] The generative model G is used to generate photoplethysmography signal data of a real MC-GAN network;
[0009] The identification model D is used to receive real samples and synthetic samples generated by the generation model G;
[0010] S3. Use the generative model G constructed in the MC-GAN network to generate realistic photoplethysmographic signals.
[0011] Further, a preferred embodiment is provided, wherein the preprocessing of the photoplethysmography signal data in S1 comprises the following steps:
[0012] S1.1, preprocessing the photoplethysmography signal data by wavelet transform;
[0013] S1.2, normalizing the preprocessed photoplethysmographic signal after wavelet transformation in S1;
[0014] S1.3, the photoplethysmography signal after preprocessing uses the extreme slope method to identify the first extreme point of each cycle, and the single-cycle photoplethysmography signal of all samples is intercepted with the first extreme point as the center;
[0015] S1.4. Save the single-cycle photoplethysmogram signals of all samples into corresponding folders.
[0016] Furthermore, a preferred embodiment is provided, wherein the generation model G includes a Bi-LSTM layer module, a multi-head attention mechanism module and a convolutional block attention mechanism module, wherein the Bi-LSTM layer module includes a Bi-LSTM layer, and the convolutional block attention mechanism module includes at least one transposed convolution sequence module.
[0017] Further, a preferred embodiment is provided, wherein the step of constructing the generation model G in S2 comprises the following steps:
[0018] The input tensor data is passed into the Bi-LSTM layer to obtain the tensor data processed by the Bi-LSTM layer module;
[0019] The output tensor data of the Bi-LSTM layer module is processed by the multi-head attention mechanism module to obtain the attention-weighted result x 1;
[0020] The output of the multi-head attention mechanism module is passed to the transposed convolution sequence module for processing to obtain the processed result x 11 ;
[0021] The output tensor data of the Bi-LSTM layer module is processed through the convolution block attention mechanism module to obtain the attention-weighted result x 2 ;
[0022] The output of the convolution block attention mechanism module is passed to the transposed convolution sequence module for processing to obtain the processed result x 12 ;
[0023] x 11 With x 12 Merge and get the merged result x 3 ; The combined result x 3 Output is performed to complete the construction of the generation model G.
[0024] Further, a preferred embodiment is provided, wherein the method for constructing the identification model D in S2 is:
[0025] Receive the input tensor data, pass the input tensor data into the first transposed convolution sequence module, and get the output data x after the convolution layer and activation function processing. 21 ;
[0026] The tensor data is passed into the convolution block attention mechanism module for processing to obtain the output data x 22 ; x 22 The data is passed into the Bi-LSTM layer module for processing, and the output x of the Bi-LSTM layer module is obtained. 31 ;
[0027] x 31 Pass it into the multi-head attention module for processing to get the output data x 41 ; x 41 The data is passed into the convolution sequence module, processed by the convolution layer and activation function, and the identification model D is constructed.
[0028] Furthermore, a preferred implementation is provided, wherein S2 also includes a step of training the constructed generation model G and identification model D.
[0029] Furthermore, a preferred embodiment is provided, in S3, a real photoplethysmography signal based on the MC-GAN network is simulated and generated by minimizing the generative model and maximizing the discriminative model.
[0030] The minimization generation model is used to minimize the difference between the synthetic samples generated by the generation model and the real samples.
[0031] Minimize differences;
[0032] The maximization identification model is used to increase the accuracy of the identification model when classifying real samples and generated samples, and to achieve a dynamic balance between the generation model G and the identification model D.
[0033] Solution 2: A computer device includes a memory and a processor, wherein the memory stores a computer program. When the processor runs the computer program stored in the memory, the processor executes any one of the methods described in Solution 1.
[0034] Solution three: A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the method described in any one of Solution one.
[0035] The present invention is beneficial in that:
[0036] The present invention designs an MC-GAN network based on the DCGAN model, which includes two models, namely, a generation model G and a discrimination model D. The generation model G and the discrimination model D compete with each other through adversarial training, thereby promoting the generation model G to learn the distribution of data and generate realistic simulated photoplethysmogram signal PPG samples. At the same time, convolutional block attention mechanism and multi-head attention mechanism are added to the generation model G and the discrimination model to improve the representation ability of the network, so that the network can pay more attention to important areas or features, capture richer feature information, enhance the robustness and generalization performance of the network, and help the generation model G generate more diverse and realistic simulated photoplethysmogram signal PPG.
[0037] The present invention is also applicable to the field of medical signal generation and synthesis. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 Schematic diagram of signal changes during the preprocessing process in the photoplethysmography signal generation method based on the MC-GAN network described in Implementation Example 1.
[0039] Figure 2 Flow chart of the method for generating photoplethysmogram signals based on the MC-GAN network according to the first embodiment.
[0040] Figure 3 This is a schematic diagram of the final generation result of the photoplethysmography signal generation method based on the MC-GAN network described in Implementation Example 1. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solutions and advantages of the implementation methods of the present application clearer, the technical solutions in the implementation methods of the present application will be clearly and completely described below in conjunction with the drawings in the implementation methods of the present application. Obviously, the described implementation methods are only part of the implementation methods of the present application, not all of the implementation methods.
[0042] Embodiment 1: This embodiment provides a method for generating a photoplethysmogram signal based on a MC-GAN network, the method comprising the following steps:
[0043] S1, preprocessing the photoplethysmogram signal data to obtain preprocessed photoplethysmogram signal data, and saving the preprocessed photoplethysmogram signal data to a corresponding folder;
[0044] S2. Based on the preprocessed photoplethysmography signal data obtained in S1, a generation model G and a discrimination model D are constructed based on the DCGAN model. A convolutional block attention mechanism and a multi-head attention mechanism are introduced into the generation model G and the discrimination model D to capture feature information in the synthetic sample. The constructed generation model G and the discrimination model D constitute an MC-GAN network.
[0045] The generative model G is used to generate photoplethysmography signal data of a real MC-GAN network;
[0046] The identification model D is used to receive real samples and synthetic samples generated by the generation model G;
[0047] S3. Use the generative model G constructed in the MC-GAN network to generate realistic photoplethysmographic signals.
[0048] The generative adversarial networks (GAN) described in this embodiment include two sub-networks, a generation model G and a discrimination model D. The generation model G is used to obtain data distribution, and the discrimination model D is used to perform discrimination processing to determine whether the sample belongs to training data or generated data. The generation model G and the discrimination model D compete with each other through adversarial training, thereby promoting the distribution of model learning data and generating realistic simulated new samples. GAN has many applications, including image generation, image editing, speech synthesis, natural language processing and other fields.
[0049] At the same time, convolutional block attention mechanism and multi-head attention mechanism are added to the generation model G and the discrimination model to improve the representation ability of the network, so that the network can pay more attention to important areas or features, capture richer feature information, enhance the robustness and generalization performance of the network, and help the generation model G generate more diverse and realistic simulated photoplethysmogram signals PPG.
[0050] Embodiment 2: This embodiment further limits the method for generating a photoelectric volumetric pulse wave signal based on a MC-GAN network described in Embodiment 1. In S1, preprocessing the photoelectric volumetric pulse wave signal data includes the following steps:
[0051] S1.1, preprocessing the photoplethysmography signal data by wavelet transform;
[0052] S1.2, normalizing the preprocessed photoplethysmographic signal after wavelet transformation in S1;
[0053] S1.3, the photoplethysmography signal after preprocessing uses the extreme slope method to identify the first extreme point of each cycle, and the single-cycle photoplethysmography signal of all samples is intercepted with the first extreme point as the center;
[0054] S1.4. Save the single-cycle photoplethysmogram signals of all samples into corresponding folders.
[0055] Implementation method three. This implementation method is a further limitation of the photoelectric volumetric pulse wave signal generation method based on the MC-GAN network described in implementation method one. The generation model G includes a Bi-LSTM layer module, a multi-head attention mechanism module and a convolutional block attention mechanism module. The Bi-LSTM layer module includes a Bi-LSTM layer, and the convolutional block attention mechanism module includes at least one transposed convolution sequence module.
[0056] Embodiment 4: This embodiment further limits the method for generating photoelectric volumetric pulse wave signals based on the MC-GAN network described in Embodiment 3. The step of constructing the generation model G in S2 includes the following steps:
[0057] The input tensor data is passed into the Bi-LSTM layer to obtain the tensor data processed by the Bi-LSTM layer module;
[0058] The output tensor data of the Bi-LSTM layer module is processed by the multi-head attention mechanism module to obtain the attention-weighted result x 1 ;
[0059] The output of the multi-head attention mechanism module is passed to the transposed convolution sequence module for processing to obtain the processed result x 11 ;
[0060] The output tensor data of the Bi-LSTM layer module is processed through the convolution block attention mechanism module to obtain the attention-weighted result x 2 ;
[0061] The output of the convolution block attention mechanism module is passed to the transposed convolution sequence module for processing to obtain the processed result x 12 ;
[0062] x 11 With x 12 Merge and get the merged result x 3 ; The combined result x 3 Output is performed to complete the construction of the generation model G.
[0063] Embodiment 5: This embodiment further limits the method for generating photoelectric volumetric pulse wave signals based on the MC-GAN network described in Embodiment 4. The method for constructing the identification model D in S2 is:
[0064] Receive the input tensor data, pass the input tensor data into the first transposed convolution sequence module, and get the output data x after the convolution layer and activation function processing. 21 ;
[0065] The tensor data is passed into the convolution block attention mechanism module for processing to obtain the output data x 22 ; x 22 The data is passed into the Bi-LSTM layer module for processing, and the output x of the Bi-LSTM layer module is obtained. 31 ;
[0066] x 31 Pass it into the multi-head attention module for processing to get the output data x 41 ; x 41 The data is passed into the convolution sequence module, processed by the convolution layer and activation function, and the identification model D is constructed.
[0067] Embodiment 6: This embodiment further limits the method for generating photoplethysmographic signals based on the MC-GAN network described in Embodiment 1, and S2 also includes the step of training the constructed generation model G and identification model D.
[0068] Embodiment 7: This embodiment further limits the method for generating a photoplethysmogram signal based on the MC-GAN network described in Embodiment 1. In S3, a real photoplethysmogram signal based on the MC-GAN network is simulated and generated by minimizing the generation model and maximizing the discrimination model.
[0069] The minimization generation model is used to minimize the difference between the synthetic samples generated by the generation model and the real samples.
[0070] Minimize differences;
[0071] The maximization identification model is used to increase the accuracy of the identification model when classifying real samples and generated samples, and to achieve a dynamic balance between the generation model G and the identification model D.
[0072] Embodiment 8: This embodiment proposes a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor runs the computer program stored in the memory, the processor executes the method described in any one of embodiments 1 to 7.
[0073] Embodiment 9: This embodiment proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the method described in any one of embodiments 1 to 7 are implemented.
[0074] Embodiment 10: This embodiment provides an example, which is used to explain the above embodiments 1 to 9. The specific example is as follows:
[0075] See also Figures 1 to 3 To explain this embodiment, first of all, the purpose of the present invention is to propose a method for generating photoelectric volumetric pulse wave signals based on a MC-GAN network, which can effectively extract the characteristic information of PPG and enable the generation model G to generate a more realistic analog signal.
[0076] See also Figure 1 As shown, this embodiment preprocesses the photoelectric volumetric pulse wave signal PPG. The preprocessing process mainly includes three parts: the first part, wavelet transforms the original signal to remove noise; the second part, normalizes the signal after wavelet transform; the third part, uses the extreme slope method on the normalized signal to identify the first extreme point of the waveform, takes the first extreme point as the center, samples 100 points forward, samples 200 points backward, and intercepts the single-cycle photoelectric volumetric pulse wave signal of all samples, where, Figure 1 In the example, peaks and onsets are lists of the peaks and valleys in the signal detected by the extreme slope method.
[0077] See also Figure 2 As shown in the figure, using the MC-GAN network model to generate the photoplethysmogram signal PPG mainly includes the following contents:
[0078] The generation model G receives some random noise tensors that follow the standard normal distribution as input, and generates some synthetic samples similar to real data through modules such as Bi-LSTM layer module, multi-head attention mechanism module, convolution block attention mechanism, etc. Among them, MUSE is the attention mechanism module, CBAM is the CBAM attention mechanism module, R is the real sample, and F is the synthetic sample. The identification model D receives synthetic samples generated by the generator and samples from real data, and tries to distinguish them through modules such as convolution blocks and attention mechanism modules.
[0079] Data preprocessing specifically includes the following steps:
[0080] S1.1. Use wavelet transform to preprocess the photoplethysmography signal. The wavelet base used in this example is sym8, and the number of wavelet decomposition layers is 6.
[0081] S1.2. Normalize the signal after wavelet transformation. This example uses the min-max method.
[0082] S1.3. For the preprocessed photoplethysmogram signal, the extreme slope method is used to identify the first extreme point of each cycle. With the first extreme point as the center, 100 points are sampled forward and 200 points are sampled backward to intercept the single-cycle photoplethysmogram signal of all samples.
[0083] S1.4. Save the single-cycle photoplethysmogram in the corresponding folder for later use.
[0084] The construction of the generative model G specifically includes the following steps:
[0085] Step 1: Import the libraries you need to use, including torch, torch.nn, and numpy.
[0086] Step 2: Define a class named Generator, initialize the function __init__(), accept the input dimension inp_dim, hidden unit dimension hidden_dim and LSTM layer number num_layers as parameters; use super().__init__() to call the constructor of the parent class nn.Module; set the parameters of the neural network: number of layers num_layers, hidden unit dimension hidden_dim;
[0087] Step 3: Define a bidirectional LSTM layer with input dimension inp_dim, hidden unit dimension hidden_dim, and number of layers num_layers. In this example, input dimension inp_dim = 100, hidden unit dimension hidden_dim = 200, number of layers num_layers = 2, and bidirectional = True.
[0088] Step 4: Define a multi-head attention mechanism module called MUSEAttention to capture the global and local features of the signal. Define a class named Depth_Pointwise_Conv1d, initialize the function __init__(), accept the number of input channels in_ch, the number of output channels out_ch and the convolution kernel size k as parameters; use super().__init__() to call the constructor of the parent class nn.Module; if the convolution kernel size k is equal to 1, create a depth-separable convolution layer depth_conv, and set the depth-separable convolution layer to the identity mapping nn.Identity(), that is, no convolution operation is performed; otherwise, define a depth-separable convolution layer depth_conv, where in_channels=in_ch, out_channels=in_ch, groups=in_ch, kernel_size=k, padding=k / / 2; create a pointwise convolution layer pointwise_conv, where in_channels=in_ch, out_channels=out_ch, kernel_size=1, groups=1; use the forward propagation method forward(self, x), receives an input tensor x, first passes the input tensor x through the depthwise separable convolution layer depth_conv for depthwise convolution operation; then passes the result of the depthwise convolution through the pointwise convolution layer pointwise_conv for pointwise convolution operation to obtain the final output out3.Define a class named MUSEAttention, initialize the function __init__(), accept d_model (input dimension of the model), d_k (dimension of the query vector), d_v (dimension of the numeric vector), h (number of attention heads) as parameters; use super(MUSEAttention, self).__init__() to call the constructor of the parent class nn.Module; define four linear transformation layers fc_q, fc_k, fc_v, fc_o, which are used to map the input tensor to the multi-head attention space; define three depth-separable convolutional layers conv1, conv3, conv5, which are used to perform convolution operations on the output of the multi-head attention; define the dynamic parameter dy_paras, which is used to dynamically fuse the outputs of different convolutional layers; define the softmax activation function softmax; define the initialization model parameter function init_weights, initialize the weight parameters of the model, initialize the weight parameters of the convolutional layer with kaiming normal distribution, initialize the weight parameters of the batch normalization layer with constants, and initialize the weight parameters of the linear layer with normal distribution; use the forward propagation method forward(self, queries, keys, values), accepts the input queries, keys, values tensors, maps the input queries, keys, values tensors to the multi-head attention space through three linear transformation layers fc_q, fc_k, fc_v, then transforms the shape of the mapped tensor, calculates the attention weight att, and scales it by dividing it by the square root of self.d_k, performs softmax and dropout operations on the attention weight; multiplies the attention weight by values, and performs dimension permutation and reshape operations to obtain the output out1; performs dimension permutation and reshape operations on the values tensor to obtain a new tensor v2; performs softmax operation on the dynamic parameters dy_paras and converts them into learnable parameters; uses the dynamic parameters to perform weighted summation on the outputs of different convolutional layers to obtain out2;.
[0089] Add out1 and attention output out2 to get the final output out3.
[0090] Step 5: Define a convolutional block attention mechanism module called CBAM to capture the correlation of features from different dimensions. Define a class named ChannelAttention, initialize the function __init__(), and accept in_planes, ratio as input parameters; use super(ChannelAttention, self).__init__() to call the constructor of the parent class nn.Module; define the adaptive average pooling layer avg_pool and the adaptive maximum pooling layer max_pool to extract the global average and global maximum from the input feature map; define the convolution layers fc1 and fc2 to learn the correlation between channels and enable the network to better focus; create activation functions relu and sigmoid; use the forward propagation method forward(self, x) to accept the input tensor x, and perform adaptive average pooling and adaptive maximum pooling on the input tensor x through avg_pool to obtain the global average and global maximum; convolve and nonlinearly transform the global average and global maximum through fc1 and relu; convolve the transformed result through fc2 to obtain two changed results; add the two transformed results to obtain the weighted sum; map the weighted sum to 0 to 1 through the sigmoid activation function , as the channel attention weight. Define a class named SpatialAttention, initialize the function __init__(), and accept kernel_size as the input parameter; use super(SpatialAttention, self).__init__() to call the constructor of the parent class nn.Module; define a one-dimensional convolution layer conv1, with 2 input channels, 1 output channel, kernel size kernel_size, padding size, and no bias parameter; define a Sigmoid activation function to represent the attention weight; use the forward propagation method forward(self, x), accept the input tensor x, calculate the mean of the input tensor x along the first dimension, calculate the maximum value of the input tensor x along the first dimension, concatenate the mean and maximum values together, concatenate along the first dimension, input the concatenated tensor into the defined convolution layer conv1 for convolution operation, pass the convolution output through the Sigmoid activation function, get the final attention weight x, and return x.Define a class named CBAM, initialize the function __init__(), accept in_planes, ratio, kernel_size as parameters; use super(CBAM, self).__init__() to call the constructor of the parent class nn.Module; create a Channel Attention module instance and save it in self.ca; create a Spatial Attention module instance and save it in self.sa; use the forward propagation method forward(self, x), accept the input tensor x, multiply the input tensor x and the result after Channel Attention processing, get the weighted result of Channel Attention, and save it in out1; multiply out1 and the result after SpatialAttention module processing to get the final result, save it in out2, and return out2.Define a class named ResidualCBAM, initialize the function __init__(), accept in_planes, out_planes, stride, padding, ratio, kernel_size as parameters; use super(ResidualCBAM, self).__init__() to call the constructor of the parent class nn.Module; create three convolutional layers conv1, conv2, conv3 for feature extraction, create three Batch Normalization layers bn1, bn2, bn3 for normalizing the output of the convolutional layer to accelerate model training, create an activation function relu, the downsample parameter is used to perform downsampling in the residual connection to match the dimension. If it is not None, it means that downsampling is required. Create a CBAM module instance and save it in self.cbam to introduce the attention mechanism of CBAM; use the forward propagation method forward(self, x), accepts input tensor x, saves input tensor x as identity for residual connection, performs convolution operation through the first convolution layer conv1, then passes through batch normalization bn1 and activation function relu, then passes through the second convolution layer conv2 for convolution operation, then passes through batch normalization bn2 and activation function relu, and finally passes through the third convolution layer conv3 for convolution operation, then passes through batch normalization bn3. If there is a downsampling function downsample, the input tensor x is downsampled to match the dimension of the output out2 after convolution, the convolution output out2 is added to the residual identity, and then through the activation function relu, the output out2 is returned, and the output out2 after the residual connection is applied to the CBAM module to obtain the final output out3.
[0091] Step 6: Define a transposed convolution sequence module conv1, which includes 3 transposed convolution layers, 3 batch normalization layers and 3 ReLU activation functions, which is used to process the output of the MUSEAttention module and the bidirectional LSTM layer.
[0092] Step 7: Define a transposed convolution sequence module conv2, which contains 3 transposed convolution layers, 3 batch normalization layers and 3 ReLU activation functions to process the output after feature fusion.
[0093] Step 8: Use the forward propagation method forward(self, input) to accept the input input, pass the input input into the LSTM layer for forward propagation, and get the LSTM output x 11; Process the output x of LSTM through the multi-head attention mechanism module MUSEAttention 11 , and get the attention-weighted result x 2 ; The output of the multi-head attention mechanism module MUSEAttention is passed to the transposed convolution sequence module conv1 for processing to obtain the processed result x 12 ; Process the output x of LSTM through the convolutional block attention mechanism module CBAM 12 , and get the attention-weighted result x 2 ; The output of the convolution block attention mechanism module CBAM is passed to the transposed convolution sequence module conv1 for processing to obtain the processed result x 12 ; x 11 With x 12 Merge and get the merged result x 3 ; The combined result x 3 Output is performed and the combined result is passed into the transposed convolution output module conv2 to obtain the final output result output of the generator.
[0094] The construction of the identification model D specifically includes the following steps:
[0095] Step 1: Import the libraries you need to use, including torch, torch.nn, and numpy.
[0096] Step 2: Define a class called Discriminator and initialize the function __init__(); use super().__init__() to call the constructor of the parent class nn.Module;
[0097] Step 3: Define a convolution sequence module conv1, which includes 4 convolutional layers, 4 batch normalization layers, 4 LeakyReLU activation functions and 4 Dropout layers for processing data.
[0098] Step 4: Define a convolutional block attention mechanism module called CBAM to capture the correlation of features from different dimensions. Define a class named ChannelAttention, initialize the function __init__(), and accept in_planes, ratio as input parameters; use super(ChannelAttention, self).__init__() to call the constructor of the parent class nn.Module; define the adaptive average pooling layer avg_pool and the adaptive maximum pooling layer max_pool to extract the global average and global maximum from the input feature map; define the convolution layers fc1 and fc2 to learn the correlation between channels and enable the network to better focus; create activation functions relu and sigmoid; use the forward propagation method forward(self, x), accept the input tensor x, and perform adaptive average pooling and adaptive maximum pooling on the input tensor x through avg_pool to obtain the global average and global maximum; convolve and nonlinearly transform the global average and global maximum through fc1 and relu; convolve the transformed result through fc2 to obtain two changed results; add the two transformed results to obtain the weighted sum; map the weighted sum to 0 to 1 through the sigmoid activation function , as the channel attention weight. Define a class named SpatialAttention, initialize the function __init__(), and accept kernel_size as the input parameter; use super(SpatialAttention, self).__init__() to call the constructor of the parent class nn.Module; define a one-dimensional convolution layer conv1, with 2 input channels, 1 output channel, kernel size kernel_size, padding size, and no bias parameter; define a Sigmoid activation function to represent the attention weight; use the forward propagation method forward(self, x), accept the input tensor x, calculate the mean of the input tensor x along the first dimension, calculate the maximum value of the input tensor x along the first dimension, concatenate the mean and maximum values together, concatenate along the first dimension, input the concatenated tensor into the defined convolution layer conv1 for convolution operation, pass the convolution output through the Sigmoid activation function, get the final attention weight x, and return x.Define a class named CBAM, initialize the function __init__(), accept in_planes, ratio, kernel_size as parameters; use super(CBAM, self).__init__() to call the constructor of the parent class nn.Module; create a Channel Attention module instance and save it in self.ca; create a Spatial Attention module instance and save it in self.sa; use the forward propagation method forward(self, x), accept the input tensor x, multiply the input tensor x and the result after Channel Attention processing, get the weighted result of Channel Attention, and save it in out2; multiply out2 and the result after SpatialAttention module processing to get the final result, save it in out1, and return out1.Define a class named ResidualCBAM, initialize the function __init__(), accept in_planes, out_planes, stride, padding, ratio, kernel_size as parameters; use super(ResidualCBAM, self).__init__() to call the constructor of the parent class nn.Module; create three convolutional layers conv1, conv2, conv3 for feature extraction, create three Batch Normalization layers bn1, bn2, bn3 for normalizing the output of the convolutional layer to accelerate model training, create an activation function relu, the downsample parameter is used to perform downsampling in the residual connection to match the dimension. If it is not None, it means that downsampling is required. Create a CBAM module instance and save it in self.cbam to introduce the attention mechanism of CBAM; use the forward propagation method forward(self, x), accepts input tensor x, saves input tensor x as identity for residual connection, performs convolution operation through the first convolution layer conv1, then passes through batch normalization bn1 and activation function relu, then passes through the second convolution layer conv2 for convolution operation, then passes through batch normalization bn2 and activation function relu, and finally passes through the third convolution layer conv3 for convolution operation, then passes through batch normalization bn3. If there is a downsampling function downsample, the input tensor x is downsampled to match the dimension of the output out2 after convolution, the convolution output out2 is added to the residual identity, and then through the activation function relu, the output out2 is returned, and the output out2 after the residual connection is applied to the CBAM module to obtain the final output out2.
[0099] Step 5: Define a bidirectional LSTM layer with input dimension inp_dim, hidden unit dimension hidden_dim, and number of layers num_layers. In this example, input dimension inp_dim = 512, hidden unit dimension hidden_dim = 256, number of layers num_layers = 2, and bidirectional = True.
[0100] Step 6: Define a multi-head attention mechanism module called MUSEAttention to capture the global and local features of the signal. Define a class named Depth_Pointwise_Conv1d, initialize the function __init__(), accept the number of input channels in_ch, the number of output channels out_ch and the convolution kernel size k as parameters; use super().__init__() to call the constructor of the parent class nn.Module; if the convolution kernel size k is equal to 1, create a depth-separable convolution layer depth_conv, and set the depth-separable convolution layer to the identity mapping nn.Identity(), that is, no convolution operation is performed; otherwise, define a depth-separable convolution layer depth_conv, where in_channels=in_ch, out_channels=in_ch, groups=in_ch, kernel_size=k, padding=k / / 2; create a pointwise convolution layer pointwise_conv, where in_channels=in_ch, out_channels=out_ch, kernel_size=1, groups=1; use the forward propagation method forward(self, x), receives an input tensor x, first passes the input tensor x through the depthwise separable convolution layer depth_conv for depthwise convolution operation; then passes the result of the depthwise convolution through the pointwise convolution layer pointwise_conv for pointwise convolution operation to obtain the final output out2.Define a class named MUSEAttention, initialize the function __init__(), accept d_model (input dimension of the model), d_k (dimension of the query vector), d_v (dimension of the numeric vector), h (number of attention heads) as parameters; use super(MUSEAttention, self).__init__() to call the constructor of the parent class nn.Module; define four linear transformation layers fc_q, fc_k, fc_v, fc_o, which are used to map the input tensor to the multi-head attention space; define three depth-separable convolutional layers conv1, conv3, conv5, which are used to perform convolution operations on the output of the multi-head attention; define the dynamic parameter dy_paras, which is used to dynamically fuse the outputs of different convolutional layers; define the softmax activation function softmax; define the initialization model parameter function init_weights, initialize the weight parameters of the model, initialize the weight parameters of the convolutional layer with kaiming normal distribution, initialize the weight parameters of the batch normalization layer with constants, and initialize the weight parameters of the linear layer with normal distribution; use the forward propagation method forward(self, queries, keys, values), accepts the input queries, keys, values tensors, maps the input queries, keys, values tensors to the multi-head attention space through three linear transformation layers fc_q, fc_k, fc_v, then transforms the shape of the mapped tensor, calculates the attention weight att, and scales it by dividing it by the square root of self.d_k, performs softmax and dropout operations on the attention weight; multiplies the attention weight by values, and performs dimension permutation and reshape operations to obtain the output out2; performs dimension permutation and reshape operations on the values tensor to obtain a new tensor v2; performs softmax operation on the dynamic parameters dy_paras and converts them into learnable parameters; uses the dynamic parameters to perform weighted summation on the outputs of different convolutional layers to obtain out2;.
[0101] Add out1 and attention output out2 to get the final output out3.
[0102] Step 7: Define a convolution sequence module conv2, which includes 2 convolution layers, 1 batch normalization layer, 1 LeakyReLU activation function and 1 Dropout layer. The last convolution layer uses the Sigmoid activation function.
[0103] Step 8: Use the forward propagation method forward(self, x) to accept the input tensor x. Pass the input tensor x into the first convolution sequence module, and after a series of convolution layers and activation functions, get the output data x 1 ; x 1 The convolution block attention module CBAM is passed in for processing to obtain the output data x 22 ; x 22 Pass it into the LSTM layer for processing to get the output x of the LSTM layer 31 ; x 31 The multi-head attention module MUSEAttention is passed in for processing to obtain the output data x 41 ; x 41 The data is passed into the convolution sequence module conv2, and processed by a series of convolution layers and activation functions to obtain the final output result output.
[0104] Model training specifically includes the following steps:
[0105] Step 1: Import the libraries required for model training, including torch, torch.nn, torch.optim, numpy, pandas, os, and Matplotlib.
[0106] Step 2: Define a Dataset class to create a training dataset, and use DataLoader to convert the dataset into an iterable data loader. The initialization function __init__() accepts the dataset root directory path root and seed value seed as input parameters; the build_dataset method is used to build the dataset, and the minmax_normalize method is used to perform minimum-maximum normalization; __len__ returns the length of the dataset; __getitem__ obtains the data point with index idx in the dataset and returns the data point and its corresponding target; a data loader trainloader is created using the torch.utils.data.DataLoader function to pass data to the model for training.
[0107] Step 3: Create discriminator (netD) and generator (netG) model instances and move them to the appropriate device (GPU or CPU). The discriminator is instantiated using the Discriminator class and the generator is instantiated using the Generator class.
[0108] Step 4: Define the loss function and use the binary cross entropy loss function (BCELoss) as the loss function of the discriminator.
[0109] Step 5: Initialize the optimizer and use the Adam optimizer to initialize the optimizers of the discriminator and generator (optimizerD and optimizerG) respectively. In this example, the learning rate is set to 0.002.
[0110] Step 6: Training loop. Training is performed through nested loops. The outer loop controls the number of training epochs, and the inner loop is used to traverse each batch of data in the data loader trainloader. In the loop of each batch, data is loaded step by step through trainloader, loading one batch of data at a time. Move the loaded real data data to the device (GPU or CPU) and get the size b_size of the current batch. Update the discriminator: create a label tensor label to represent the label of the real data, that is, fill it with real_label; reset the gradient of the discriminator to zero; forward propagate the real data through the discriminator netD to obtain the output output of the discriminator for the real data, and reshape its view into a one-dimensional tensor; use the discriminator's output of the real data and the real label to calculate the loss errD_real, that is, the loss of the real data; back propagate to calculate the loss errD_real of the real data and update the parameters of the discriminator; calculate the mean D_x of the discriminator's output of the real data to observe the discriminator's ability to discriminate the real data. Processing generated data: Create a noise tensor noise that obeys a standard normal distribution as the input of the generator. In our example, noise = 100; generate fake data fake through the generator netG; create a label tensor label to represent the label of the generated data, that is, fill it with fake_label; forward propagate the generated data through the discriminator netD to obtain the output output of the discriminator on the generated data, and reshape its view into a one-dimensional tensor; use the discriminator's output on the generated data and the generated label to calculate the loss errD_fake, that is, the loss of the generated data; back propagate to calculate the loss errD_fake of the generated data and update the parameters of the discriminator; calculate the mean D_G_z1 of the discriminator's output on the generated data to observe the training effect of the generator. Update the generator: reset the gradient of the generator to zero; create a label tensor label to represent the target of the generator, that is, fill it with real_label; forward propagate the generated data through the discriminator netD to obtain the output of the discriminator on the generated data output, and reshape its view into a one-dimensional tensor; use the discriminator's output on the generated data and the real label to calculate the generator's loss errG; back propagate to calculate the generator's loss errG and update the generator's parameters; calculate the mean D_G_z2 of the discriminator's output on the generated data to observe the training effect of the generator. After completing a training iteration, output the training status of the current epoch and batch, including the discriminator and generator losses, and the mean of the discriminator's output on the real data and generated data.
[0111] Step 7: After each epoch, save the current model parameters through the save_models function. At the same time, after each epoch, use Matplotlib to draw the curves of the generator and discriminator loss changing with epoch and display them.
[0112] The operation of generating a false signal includes the following steps:
[0113] Step 1: Import the modules you need to use, including pandas, torch, and a custom generator model.
[0114] Step 2: Use the torch.cuda.is_available() function to determine whether there is an available GPU. If so, use the GPU device, otherwise use the CPU device.
[0115] Step 3: Initialize the generator model netG and move it to the specified device.
[0116] Step 4: Use the torch.load() function to load the previously saved model parameters and optimizer state. The loaded content includes the state dictionary of the generator and discriminator, as well as the state dictionary of the optimizer.
[0117] Step 5: Set the generator model netG to verification mode netG.eval() and generate a noise vector noise.
[0118] Step 6: Use the generator model netG to generate fake data corresponding to the noise vector noise, move the generated fake data from the GPU to the CPU, and use the detach() method to separate the calculation graph to ensure that there is no gradient impact on the generator; draw and save the image of the generated fake data, save the image as a PNG file, and save the signal data as a CSV file for subsequent analysis and use.
[0119] The above steps are followed to complete the photoelectric volumetric pulse wave signal generation method based on the MC-GAN network.
[0120] This implementation is based on the GAN network and proposes an improved MC-GAN network, introducing a convolutional block attention mechanism and a multi-head attention mechanism to capture richer feature information, thereby generating a more realistic simulation signal.
[0121] Figure 1Any process or method description in the flowchart described in or otherwise described herein can be understood as representing a module, fragment or portion of a code including one or more executable instructions for implementing the steps of a custom logic function or process, and the scope of the preferred embodiment of the present invention includes other implementations, in which the functions may be performed in a substantially simultaneous manner or in a reverse order according to the functions involved, which should be understood by a person skilled in the art of the present invention. The logic and / or steps represented in the flowchart or otherwise described herein illustrate the possible implementation architecture, functions and operations of the apparatus and methods according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for implementing the specified logic function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It is also noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions. For example, it can be considered as an ordered list of executable instructions for implementing logical functions, which can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or used in conjunction with these instruction execution systems, devices or apparatuses.
[0122] Therefore, it is proved that the error between the position observer's estimate of the slave's expected position and the actual expected position is stably convergent, which proves the effectiveness of the position observer design. Therefore, the problem that the slave cannot determine its own expected position due to the lack of communication between the slave and the host is solved. The estimated value of the expected position of each slave by each position observer is input as the expected input to the backstepping controller of each slave, and it is controlled to reach the expected position of the slave determined by the host and the expected formation, so as to realize the coordinated control of the UAV formation.
[0123] For the purposes of the present specification, "computer-readable medium" may be any device that can contain, store, communicate, propagate or transmit a program for use in an instruction execution system, device or apparatus or in conjunction with such instruction execution systems, devices or apparatuses. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection portion (electronic device) with one or N wirings, a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program may be printed, because the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting or processing in other suitable ways as necessary, and then stored in a computer memory. It should be understood that various parts of the present invention may be implemented in hardware, software, firmware or a combination thereof. In the above embodiments, N steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one of the following technologies known in the art or a combination thereof: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0124] Those skilled in the art will appreciate that the above are only preferred embodiments of the present invention, and the various embodiments of the present disclosure and / or the features described in the claims may be combined or combined in various ways, even if such combinations or combinations are not explicitly described in the present disclosure. It is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art may still modify the technical solutions described in the aforementioned embodiments, or perform equivalent substitutions on some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention shall be included in the protection scope of the present invention.
[0125] Although preferred embodiments of the present invention have been described, additional changes and modifications may be made to these embodiments by those skilled in the art once the basic inventive concepts are known. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention. Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for generating photoplethysmographic signals based on a MC-GAN network, characterized in that: The method comprises the following steps: S1, preprocessing the photoplethysmogram signal data to obtain preprocessed photoplethysmogram signal data, and saving the preprocessed photoplethysmogram signal data to a corresponding folder; S2. Based on the preprocessed photoplethysmography signal data obtained in S1, a generation model G and a discrimination model D are constructed based on the DCGAN model. A convolutional block attention mechanism and a multi-head attention mechanism are introduced into the generation model G and the discrimination model D to capture feature information in the synthetic sample. The constructed generation model G and the discrimination model D constitute an MC-GAN network. The generative model G is used to generate photoplethysmography signal data of a real MC-GAN network; The identification model D is used to receive real samples and synthetic samples generated by the generation model G; S3, using the generative model G constructed in the MC-GAN network to generate realistic photoplethysmographic signals; The generation model G includes a Bi-LSTM layer module, a multi-head attention mechanism module and a convolution block attention mechanism module, the Bi-LSTM layer module includes a Bi-LSTM layer, and the convolution block attention mechanism module includes at least one transposed convolution sequence module; The construction of the generative model G in S2 includes the following steps: The input tensor data is passed into the Bi-LSTM layer to obtain the tensor data processed by the Bi-LSTM layer module; The output tensor data of the Bi-LSTM layer module is processed by the multi-head attention mechanism module to obtain the attention-weighted result x1; The output of the multi-head attention mechanism module is passed to the transposed convolution sequence module for processing to obtain the processed result x 11 ; The output tensor data of the Bi-LSTM layer module is processed through the convolution block attention mechanism module to obtain the attention-weighted result x2; The output of the convolution block attention mechanism module is passed to the transposed convolution sequence module for processing to obtain the processed result x 12 ; x 11 With x 12 Merge to obtain the merged result x3; output the merged result x3 to complete the construction of the generation model G; The method for constructing the identification model D in S2 is: Receive the input tensor data, pass the input tensor data into the first transposed convolution sequence module, and get the output data x after the convolution layer and activation function processing. 21 ; The tensor data is passed into the convolution block attention mechanism module for processing to obtain the output data x 22 ; x 22 The data is passed into the Bi-LSTM layer module for processing, and the output x of the Bi-LSTM layer module is obtained. 31 ; x 31 Pass it into the multi-head attention module for processing to get the output data x 41 ; x 41 The data is passed into the convolution sequence module, processed by the convolution layer and activation function, and the identification model D is constructed.
2. The method for generating photoplethysmogram signals based on the MC-GAN network according to claim 1, characterized in that: The preprocessing of the photoplethysmography signal data in S1 includes the following steps: S1.1, preprocessing the photoplethysmography signal data by wavelet transform; S1.2, normalizing the preprocessed photoplethysmographic signal after wavelet transformation in S1; S1.3, the photoplethysmography signal after preprocessing uses the extreme slope method to identify the first extreme point of each cycle, and the single-cycle photoplethysmography signal of all samples is intercepted with the first extreme point as the center; S1.
4. Save the single-cycle photoplethysmogram signals of all samples into corresponding folders.
3. The method for generating photoplethysmogram signals based on the MC-GAN network according to claim 1, characterized in that: S2 also includes the step of training the constructed generation model G and identification model D.
4. The method for generating photoplethysmogram signals based on the MC-GAN network according to claim 1, characterized in that: In S3, the real photoplethysmogram signal based on the MC-GAN network is simulated and generated by minimizing the generation model and maximizing the discrimination model. The minimization generation model is used to minimize the difference between the synthetic samples generated by the generation model and the real samples; The maximization identification model is used to increase the accuracy of the identification model when classifying real samples and generated samples, and to achieve a dynamic balance between the generation model G and the identification model D.
5. A computer device comprising a memory and a processor, characterized in that: A computer program is stored in the memory. When the processor runs the computer program stored in the memory, the processor executes the method according to any one of claims 1 to 4.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
