Fault diagnosis method for proton exchange membrane fuel cell based on improved adam algorithm optimized resnet34
By optimizing the ResNet34 network model using the improved Adam algorithm and combining it with the sparrow search algorithm, the problem of fault diagnosis in proton exchange membrane fuel cell systems was solved, achieving efficient and accurate fault identification and classification, and improving the stability and lifespan of the system.
Patent Information
- Application Number
- CN202310991678.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-07
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2043-08-07
Smart Images

Figure CN117095204B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of fault detection technology, and specifically to a fault diagnosis method for proton exchange membrane fuel cells based on an improved Adam algorithm and optimized ResNet34. Background Technology
[0002] A proton exchange membrane fuel cell (PEMFC) is a device that generates electricity through a chemical reaction. It uses hydrogen as fuel, decomposing hydrogen into protons and electrons through a proton exchange membrane (PEM), and then converting the electrons into an electric current using membrane electrodes. Due to its high efficiency, high power density, zero emissions, low operating temperature, and fast load response, it has been widely used in automobiles, solar power systems, mobile devices, and other fields. However, PEMFCs also face many challenges, including irreversible damage caused by flooding and membrane dryness failures, leading to shortened lifespan. Therefore, finding more reliable fault diagnosis methods is of great significance for the protection of PEMFCs and the future development of the industry.
[0003] Existing fuel cell fault diagnosis technologies can be categorized into model-based, data-driven, and experimental testing-based methods based on their diagnostic principles. Model-based methods require establishing accurate physical and mathematical models of the PEMFC (Potentially Magnetic Environment Fuel Cell). However, PEMFCs are complex nonlinear systems with multiple physics fields and multiple parameters, making it difficult to establish fault models. Experimental testing-based methods require measuring various PEMFC parameters, which may require additional sensors and instruments and are susceptible to noise and interference. Compared to the former two methods, data-driven methods can utilize machine learning techniques to automatically extract fault features and patterns from historical data. They do not rely on physical models or experimental equipment and can adapt to various fault types and scenarios, offering significant advantages.
[0004] While data-driven fault diagnosis offers advantages such as speed and accuracy, conventional machine learning struggles to handle high-dimensional data and nonlinear relationships. Sometimes, manual selection of appropriate features and algorithms is necessary, leading to low accuracy and susceptibility to human error. Existing fault diagnosis methods cannot accurately classify the state of locomotive proton exchange membrane fuel cell systems, cannot guarantee their stable operation, cannot reduce power losses caused by faults, cannot prevent irreversible damage to the fuel cell system, and cannot extend their healthy operating time. Summary of the Invention
[0005] Purpose of the invention: To address the problems existing in the prior art, this invention provides a fault diagnosis method for proton exchange membrane fuel cells based on deep neural networks.
[0006] Technical scheme: The application provides a proton exchange membrane fuel cell fault diagnosis method based on an improved Adam algorithm optimized ResNet34, comprising the following steps:
[0007] S100, a plurality of variables of a proton exchange membrane fuel cell system during operation are obtained, a plurality of characteristic signal images under different states of the fuel cell are obtained after screening and normalization to form a sample set, and the sample set is divided into a training set and a test set;
[0008] S200, the collected characteristic signal images are preprocessed;
[0009] S300, a ResNet34 network model is built, the ResNet34 network model is composed of 5 layers of structure plus a last global average pooling layer, a full link layer and a softmax;
[0010] S400, the optimizer uses an improved Adam algorithm, reconstructs the initial weight by using a sparrow search algorithm, and optimizes the ResNet34 by using the Adam optimization algorithm;
[0011] S500, the processed characteristic signal images are input into the optimized ResNet34 network model to train and classify the feature maps, obtain the fault category, and realize the fault diagnosis of the proton exchange membrane fuel cell system.
[0012] Further, the step S200 of preprocessing the collected characteristic signal images comprises the following steps:
[0013] S201, the original images are randomly cropped in the training set, and the cropped images are scaled to 224x224 pixels in size;
[0014] S202, the images are horizontally flipped with a probability of 0.5 in the training set;
[0015] S203, the images are normalized in the training set, so that the pixel values conform to the normal distribution;
[0016] S204, the images are scaled to 256x256 pixels in size in the test set;
[0017] S205, the images are center cropped in the test set, so that the size is 224x224 pixels;
[0018] S206, the images are normalized in the test set, so that the pixel values conform to the normal distribution.
[0019] Further, the step S300 of building the ResNet34 network model comprises the following steps:
[0020] The S301 ResNet34 network model's first layer in its 5-layer structure consists of an input layer, a convolutional layer, and a max pooling layer. The convolutional layer uses a 7x7 kernel with a stride of 2, has 64 output channels, and uses 3x3 zero padding to maintain size. The max pooling layer uses a 3x3 pooling kernel with a stride of 2.
[0021] The S302 ResNet34 network model's second layer in its 5-layer structure consists of 3 residual modules, each of which includes two 3x3 convolutional layers with 64 output channels.
[0022] The S303 ResNet34 network model's third layer in its 5-layer structure comprises four sub-layers. The first sub-layer is a downsampling residual module, consisting of a 3x3 convolutional layer with a stride of 2 and 128 output channels. This is followed by another 3x3 convolutional layer with a stride of 1 and 128 output channels. The other three sub-layers are residual modules, each consisting of two 3x3 convolutional layers with a stride of 1 and 128 output channels each.
[0023] The S304, the fourth layer in the 5-layer ResNet34 network model, contains 6 sub-layers. The first sub-layer is a downsampling residual module, which includes a 3x3 convolutional layer with a stride of 2 and 256 output channels. It is followed by another 3x3 convolutional layer with a stride of 1 and 256 output channels. The other 5 sub-layers are residual modules, each of which includes two 3x3 convolutional layers with a stride of 1 and 256 output channels.
[0024] The S305 ResNet34 network model's fifth layer in its five-layer structure comprises three sub-layers. The first sub-layer is a downsampling residual module, consisting of a 3x3 convolutional layer with a stride of 2 and 512 output channels, followed by another 3x3 convolutional layer with a stride of 1 and 512 output channels. The other two sub-layers are residual modules, each consisting of two 3x3 convolutional layers with a stride of 1 and 512 output channels each.
[0025] S306, the last residual block of ResNet34 is connected to a global average pooling layer, which averages all values of each channel of the feature map to obtain a feature vector;
[0026] S307 feeds the feature vector into a fully connected layer and uses softmax for classification or regression tasks.
[0027] Furthermore, step S400 uses the Sparrow Search algorithm to reconstruct the initial weights of the Adam algorithm, including the following steps:
[0028] 1) Initialize a group of sparrows, including discoverers, followers, and vigilant ones; the position of each sparrow represents a network weight, and the sparrow group can be expressed as:
[0029]
[0030] where d represents the dimension of the variables of the problem to be optimized, and n represents the number of sparrow populations;
[0031] 2) For each sparrow, calculate its fitness, also known as the objective function value, that is, use this weight to train the ResNet34 network and calculate its accuracy or loss value on the training set;
[0032] 3) Update the positions of the discoverers, followers, and vigilant ones; the update of the discoverer's position is expressed as:
[0033]
[0034] where, X i,j represents the position of the sparrow individual, i is the current iteration number ite rmax is the maximum iteration number, α is a random number within [0, 1], R2 (R2 ∈ [0, 1]) and ST (ST ∈ [0.5, 1]) respectively represent the early warning value and the safety value, Q is a random number subject to the normal distribution, and L is a 1×d matrix where each element is 1;
[0035] When R2 ≥ ST, it indicates that some sparrows have discovered danger. At this time, the discoverer value converges and should move to a safe position, that is, the discoverer randomly moves to the vicinity of the current position according to the normal distribution; when R2 < ST, it indicates that there is no danger in the current environment, and the discoverer can conduct a large-scale search operation. As the population generation increases, the value range of the
[0036] term will decrease accordingly, and the distribution of the values will become more uniform, that is, the value corresponding to each dimension of the sparrow individual will decrease;
[0037]
[0038] Among the population, excluding the discoverers, the remaining sparrows are all followers; the update of the followers' positions is described as follows: p where, X [[ID=3⑧]] worst is the currently optimal position occupied by the discoverer, X + is the current global worst position, n is the population size, A is a 1×d matrix, and each element is randomly assigned 1 or -1. The definition of A +
[0039] A T = A T (AA -1 ) -1
[0040] When , it indicates that the ith follower state with lower fitness value is poor, and needs to fly to other places to forage;
[0041] In the sparrow population, the number of sparrows with an alarm mechanism accounts for 10% to 20% of the total number, and the position is randomly generated, and the position update formula is as follows:
[0042]
[0043] Wherein, X best is the current global optimal position, β is the step control parameter, which is a random number obeying normal distribution with mean value 0 and variance 1, K is a random number in [-1, 1], f is the fitness value, f g and f w are the current optimal and worst fitness values respectively, and ε is a constant to avoid denominator 0;
[0044] When f i > f g , it indicates that the sparrow is at the edge of the population at this time, and is extremely vulnerable to predators; X best indicates that the sparrow at this position is the best position in the population and is very safe; f i = f g , which indicates that the sparrow in the middle of the population realizes the danger and needs to approach other sparrows to minimize their risk of being preyed upon; K indicates the direction of sparrow movement and is also a step control parameter;
[0045] 4) Calculate the fitness value again, sort the sparrows according to the fitness value, and select a part of sparrows with better fitness value for breeding; In the breeding process, the weight of each sparrow is randomly disturbed, and a new sparrow population is generated;
[0046] 5) Repeat steps 2), 3) and 4) using the new sparrow population until the set number of iterations is reached or the stopping criterion is met;
[0047] 6) Select the sparrow with the highest fitness value from the final bird population, and take its position as the optimized better weight value.
[0048] Further, the step 400 of optimizing the ResNet34 using the Adam optimization algorithm comprises the steps of:
[0049] 1) Initialize the first moment m0, the second moment v0 and the step number t to be 0, the first moment decay coefficient β1=0.9, the second moment decay coefficient β2=0.999, the learning rate α=0.001, ∈=10 -8 , and θ is the input parameter, that is, the better weight value after the sparrow search algorithm is converted.
[0050] 2) Find the optimal weight θ by calculating as follows:
[0051]
[0052] m t = beta1 * m t-1 + (1-beta1) * g t
[0053]
[0054]
[0055]
[0056]
[0057] Where g t is the gradient of the objective function, m t is the first moment, v t is the second moment, and are the bias correction terms for m t and v t , respectively, and θ t is the optimal weight;
[0058] 3) Update the weights between the convolutional layer and the fully connected layer to improve the performance of the network.
[0059] The beneficial effects of the technical solution are:
[0060] 1) The present application proposes a novel fault detection method for proton exchange membrane fuel cell systems, which uses the ResNet34 network model capable of deep learning to solve the difficulty of traditional machine learning in handling high-dimensional data and nonlinear relationships, and avoids errors caused by human interference.
[0061] 2) The optimizer proposed in the present application uses the improved Adam algorithm, reconstructs the initial weight using the sparrow search algorithm, and then uses the Adam optimization algorithm to optimize ResNet34, greatly accelerating the convergence speed and improving the optimization effect.
[0062] 3) Compared with existing proton exchange membrane fuel cell fault diagnosis methods, the present application can accurately diagnose membrane dry fault, waterlogging fault, normal state and unknown state, and the recognition rate is better than traditional machine learning methods such as support vector machine (SVM). BRIEF DESCRIPTION OF DRAWINGS
[0063] Figure 1 is a flowchart of the proton exchange membrane fuel cell system fault diagnosis method of the present application.
[0064] Figure 2 It is the whole structure diagram of ResNet34 network model of the application;
[0065] Figure 3 It is the complete network model of ResNet34 of the application;
[0066] Figure 4 It is the structure diagram of the optimizer of the application;
[0067] Figure 5 It is the structure diagram of the residual module of the application. DETAILED DESCRIPTION
[0068] In order to make the purpose, technical scheme and advantages of the application more clear, the application will be further described below in combination with the drawings.
[0069] The application uses ResNet34 network model to diagnose PEMFC flooding failure, membrane dry failure, normal state and unknown state, which specifically includes the following steps:
[0070] S100, a 100kW EC type PEMFC system is used to obtain multiple variables of the PEMFC system during operation, and after screening and normalization, 1000 groups of feature signal images of the PEMFC under different states are obtained as a sample set.
[0071] The system contains multiple sensors to detect multiple variables such as stack voltage, current, cathode / anode level outlet / inlet pressure, temperature, etc. After screening and normalization, 1000 groups of signal images of the fuel cell under flooding failure, membrane dry failure, normal state and unknown state are obtained as a sample set, including the steps of:
[0072] S101, the multi-sensor data of the proton exchange membrane fuel cell system and the current system state class during the locomotive operation are collected.
[0073] S102, after screening and normalization, 1000 groups of feature signal images of the fuel cell under flooding failure, membrane dry failure, normal state and unknown state are obtained as a sample set. Among them, the training set is 200 groups of flooding failure, membrane dry failure, normal state and unknown state. The test set is 50 groups of flooding failure, membrane dry failure, normal state and unknown state.
[0074] S200, the collected feature signal images are preprocessed to improve the generalization ability of the model and reduce the occurrence of overfitting.
[0075] To preprocess the collected feature signal images, improve the generalization ability of the model and reduce the occurrence of overfitting, the image needs to be data augmented and regularized. Using data augmentation and other methods in the training set can increase the diversity of data, improve the robustness of the model, and reduce the overfitting of the model to the training data. However, in the test set, data augmentation and other methods may make the distribution of test data inconsistent with that of training data, resulting in poor performance of the test set. Therefore, in the test set, data augmentation and other methods are not used, but the same regularization method as the training set is used, which can ensure that the data distribution of the test set is consistent with that of the training set, thereby ensuring the generalization ability of the model on unknown data. Including steps:
[0076] S201, in the training set, the original image is randomly cropped using python language transforms.RandomResizedCrop(224), and the cropped image is scaled to 224x224 pixels.
[0077] S202, in the training set, use transforms.RandomHorizontalFlip() to horizontally flip the image with a probability of 0.5.
[0078] S203, in the training set, use transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) to normalize the image, so that its pixel value conforms to the normal distribution, where [0.485, 0.456, 0.406] and [0.229, 0.224, 0.225] represent the mean and standard deviation of the image in three channels respectively.
[0079] S204, in the test set, use transforms.Resize(256) to scale the image to 256x256 pixels.
[0080] S205, in the test set, use transforms.CenterCrop(224) to center crop the image to make its size 224x224 pixels.
[0081] S206, in the test set, use transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) to normalize the image, so that its pixel value conforms to the normal distribution, where [0.485, 0.456, 0.406] and [0.229, 0.224, 0.225] represent the mean and standard deviation of the image in three channels respectively.
[0082] S300, build ResNet34 network model. ResNet34 network model is composed of 5 layers of structure plus the last global average pooling layer, full link layer and softmax, see attached Figure 2 With attached Figure 3 .
[0083] S301, the first layer of the 5-layer structure of the ResNet34 network model is composed of an input layer, a convolutional layer, and a maximum value pooling layer.
[0084] S3011, the input image of the input layer has a size of 224x224x3, that is, a 224x224 pixel color image of 3 channels.
[0085] S3012, the convolutional layer uses a 7x7 convolutional kernel with a stride of 2 and an output channel number of 64. The output size is 112x112x64. The layer uses 3x3 zero padding to maintain the size. The convolution is calculated by the following convolution formula:
[0086]
[0087] In the formula, K i,j is the weight of the i-th row and j-th column of the convolutional kernel, X r+j,c+j is the coordinate value of the r+j-th row and c+j-th column of the input feature map; f r,c is the coordinate value of the r-th row and c-th column of the output feature map; and b is the bias term.
[0088] S3013, the maximum value pooling layer uses a 3x3 pooling kernel with a stride of 2 to reduce the size of the feature map, and the output size is 56x56x64.
[0089] S302, the second layer of the 5-layer structure of the ResNet34 network model contains 3 residual module groups, each of which includes two 3x3 convolutional layers with an output channel number of 64 and an output size of 56x56x64. Among them, the residual module increases the short circuit mechanism between each two layers, which can transmit gradient information from shortcut to the next layer, see attached Figure 5 , which greatly reduces the parameter amount of the deep network and improves the convergence speed. The residual unit can be represented as:
[0090] y l = h(x l ) + F(x l , W l )
[0091] x l+1 = f(y l )
[0092] Where x land x l+1 respectively, where we note that each residual unit generally contains multiple layers. F is the residual function, representing the learned residual, while h(x l )=x l represents the identity mapping, and f is the ReLU activation function. Based on the above equation, the learned feature from the shallow layer l to the deep layer is obtained as:
[0093]
[0094] S303, the third layer in the 5-layer structure of the ResNet34 network model contains 4 sub-layers, the first sub-layer is a down-sampling residual module, including a 3x3 convolutional layer with a stride of 2 and an output channel number of 128, followed by a 3x3 convolutional layer with a stride of 1 and an output channel number of 128. The other 3 sub-layers are residual modules, each of which includes two 3x3 convolutional layers with a stride of 1 and an output channel number of 128, and the output size is 28x28x128.
[0095] S304, the fourth layer in the 5-layer structure of the ResNet34 network model contains 6 sub-layers, the first sub-layer is a down-sampling residual module, including a 3x3 convolutional layer with a stride of 2 and an output channel number of 256, followed by a 3x3 convolutional layer with a stride of 1 and an output channel number of 256. The other 5 sub-layers are residual modules, each of which includes two 3x3 convolutional layers with a stride of 1 and an output channel number of 256, and the output size is 14x14x256.
[0096] S305, the fifth layer in the 5-layer structure of the ResNet34 network model contains 3 sub-layers, the first sub-layer is a down-sampling residual module, including a 3x3 convolutional layer with a stride of 2 and an output channel number of 512, followed by a 3x3 convolutional layer with a stride of 1 and an output channel number of 512. The other 2 sub-layers are residual modules, each of which includes two 3x3 convolutional layers with a stride of 1 and an output channel number of 512, and the output size is 7x7x512.
[0097] S306, the last residual block of ResNet34 is connected to a global average pooling layer, which averages all values of each channel of the feature map to obtain a feature vector.
[0098] S307, this feature vector is sent to a fully connected layer, which uses softmax to do classification or regression tasks.
[0099] S400, the optimizer uses the improved Adam algorithm, see Appendix Figure 4, the initial weights of which are reconstructed by sparrow search algorithm, and then the ResNet34 is optimized by Adam optimization algorithm.
[0100] S401, reconstructing the initial weights of the Adam algorithm by using the sparrow search algorithm, including the following steps:
[0101] 1) initializing a group of sparrows, including discoverers, followers and sentinels. The position of each sparrow represents a network weight. The sparrow population can be represented as:
[0102]
[0103] where d represents the dimension of the variables to be optimized, and n represents the number of sparrow populations.
[0104] 2) for each sparrow, calculate its fitness (also known as objective function value), that is, train the ResNet34 network using the weight and calculate its accuracy or loss value on the training set.
[0105] 3) update the positions of discoverers, followers and sentinels. The discoverer position update is expressed as:
[0106]
[0107] X i,j The position of the sparrow individual is expressed as i is the current iteration number iter max is the maximum iteration number, a is a random number in [0, 1], R2 (R2 ∈ [0, 1]) and ST (ST ∈ [0.5, 1]) represent the warning value and safety value respectively, Q is a random number subject to normal distribution, and L is a 1 × d matrix, where each element is 1.
[0108] When R2 ≥ ST, it indicates that some sparrows have discovered danger, at which time the discoverer value converges and should move to the safe position, that is, the discoverer moves to the current position nearby according to the normal distribution. When R2 < ST, it indicates that there is no danger in the current environment, and the discoverer can perform a large-scale search operation. As the population algebra increases, The value range of the term will decrease accordingly, and the distribution of the value will become more uniform, that is, the value of each dimension of the sparrow individual will decrease.
[0109] The discoverer is removed from the population, and the remaining sparrows are followers. The position update of the follower is described as follows:
[0110]
[0111] where X p is the optimal position currently occupied by the discoverer, and X worstLet n be the current worst-case position, n be the population size, and A be a 1×d matrix, where each element is randomly assigned a value of 1 or -1. + The definition is as follows:
[0112] A + =A T (AA T ) -1
[0113] when This indicates that the i-th follower with a lower fitness value is in a poor state and needs to fly to other places to forage.
[0114] In sparrow populations, sparrows with a vigilance mechanism account for 10% to 20% of the total population, and their positions are randomly generated. The position update formula is as follows:
[0115]
[0116] Where X best The current global optimal position is given by β, which is a step size control parameter whose value is a random number following a normal distribution with a mean of 0 and a variance of 1. K is a random number within the range [-1, 1], and f is the fitness value. g and f w ε represents the current best and worst fitness values, respectively, and ε is a constant to avoid the denominator being 0.
[0117] When f i >f g This indicates that the sparrows are currently on the fringes of their population and are extremely vulnerable to predators. X best This indicates that this location is the best and safest spot for the sparrows in the population. i =f g This indicates that sparrows in the middle of the population are aware of danger and need to move closer to other sparrows to minimize their risk of being preyed upon. K represents the direction of the sparrow's movement and is also a step size control parameter.
[0118] 4) Calculate the fitness again, rank the sparrows according to their fitness, and select a subset of sparrows with better fitness for breeding. During the breeding process, randomly perturb the weight of each sparrow and generate a new sparrow population.
[0119] 5) Repeat steps 2), 3) and 4) using a new sparrow population until the set number of iterations is reached or the stopping criterion is met.
[0120] 6) Select the bird with the highest fitness from the final bird population and use its position as the optimized weight.
[0121] S402, using Adam optimization algorithm to optimize ResNet34, including steps:
[0122] 1) Initialize the first moment m0, the second moment v0 and the step number t are all 0, the first moment attenuation coefficient β1=0.9, the second moment attenuation coefficient β2=0.999, the learning rate α=0.001, ∈=10 -8 , θ is the input parameter, that is, the optimal weight value after the sparrow search algorithm.
[0123] 2) Find the optimal weight value θ by the following calculation.
[0124]
[0125] m t =β1·m t-1 +(1-β1)·g t
[0126]
[0127]
[0128]
[0129]
[0130] Where, g t is the gradient of the objective function, m t is the first moment, v t is the second moment, And m t and v t are the bias correction terms, θ t is the optimal weight value.
[0131] 3) Update the weight between the convolution layer and the fully connected layer, so as to improve the performance of the network.
[0132] S500, input the processed feature signal image into ResNet34 network model to train and classify the feature map, obtain the fault category, and then realize the fault diagnosis of proton exchange membrane fuel cell system. Including steps:
[0133] S501, send 200 groups of feature signal images of waterlogging fault, membrane dry fault, normal state and unknown state in the training set into ResNet34 network model for training;
[0134] S502, 50 groups of feature signal images of water flooding failure, membrane dry failure, normal state and unknown state are randomly mixed in the test set, and the 200 groups of feature signal images are input into the ResNet34 network model for fault diagnosis classification.
[0135] Embodiment: In this embodiment, 1000 data samples are extracted from the locomotive, each data sample contains 12-dimensional multi-sensor data, and each data sample has a sample label belonging to it, representing four kinds of locomotive state classes, which are water flooding failure, membrane dry failure, normal state and unknown state. The 1000 data samples are divided into training set and test set in the ratio of 4:1. ResNet34 optimized by improved Adam algorithm is used to update the model parameters of the data in the training set. The test set data is used to evaluate the performance of the final model after all iterations are completed. The test results show that for the test set containing 200 data samples, the diagnosis results are all correct, see Table 1:
[0136] Table 1 is the comparison of diagnosis results of the present application and other network models
[0137]
[0138] Compared with other traditional diagnosis methods, the proposed diagnosis method has very high fault classification accuracy of the locomotive proton exchange membrane fuel cell system.
[0139] The above embodiments are only for illustrating the technical concept and characteristics of the present application, the purpose is to enable those skilled in the art to understand the content of the present application and to implement it, and cannot limit the protection scope of the present application. Any equivalent transformation or modification made according to the spirit and essence of the present application shall be covered within the protection scope of the present application.
Claims
1. A method for fault diagnosis of a proton exchange membrane fuel cell based on optimization of ResNet34 using an improved Adam algorithm, characterized in that, The method comprises the following steps: S100, obtaining multiple variables of a proton exchange membrane fuel cell system during operation, obtaining multiple sets of feature signal images in different states of the fuel cell through screening and normalization, and dividing the multiple sets of feature signal images into a training set and a test set; S200, preprocessing the collected feature signal images; S300, building a ResNet34 network model, the ResNet34 network model being composed of five layers of structures, a global average pooling layer, a full link layer and a softmax; S400, using an improved Adam algorithm in an optimizer, reconstructing initial weights of the Adam algorithm by using a sparrow search algorithm, and optimizing the ResNet34 by using the Adam optimization algorithm; S500, inputting the processed feature signal images into the optimized ResNet34 network model to train and classify feature maps, obtaining a fault category, and thus realizing fault diagnosis of the proton exchange membrane fuel cell system.
2. The method of claim 1, wherein the method is based on an improved Adam algorithm to optimize ResNet34 for PEMFC fault diagnosis. The preprocessing of the collected feature signal images in the step S200 comprises the following steps: S201, randomly cropping the original images in the training set, and scaling the cropped images to 224x224 pixels in size; S202, horizontally flipping the images in the training set with a probability of 0.5; S203, normalizing the images in the training set so that the pixel values conform to a normal distribution; S204, scaling the images in the test set to 256x256 pixels in size; S205, center-cropping the images in the test set so that the size is 224x224 pixels; S206, normalizing the images in the test set so that the pixel values conform to a normal distribution.
3. The method of claim 1, wherein the method is based on an improved Adam algorithm to optimize ResNet34 for PEMFC fault diagnosis. The building of the ResNet34 network model in the step S300 comprises the following steps: S301, the first layer of the five layers of structures of the ResNet34 network model is composed of an input layer, a convolution layer and a maximum value pooling layer; the convolution layer uses a 7x7 convolution kernel with a step of 2 and outputs 64 channels, and uses 3x3 zero padding to maintain the size; the maximum value pooling layer uses a 3x3 pooling kernel with a step of 2; S302, the second layer of the five layers of structures of the ResNet34 network model comprises three residual module groups, and each residual module group comprises two 3x3 convolution layers with an output channel number of 64; S303, the third layer of the five layers of structures of the ResNet34 network model comprises four sub-layers, the first sub-layer is a down-sampling residual module, including a 3x3 convolution layer with a step of 2 and an output channel number of 128; the following is connected with a 3x3 convolution layer with a step of 1 and an output channel number of 128; the other three sub-layers are residual modules, each residual module comprises two 3x3 convolution layers with a step of 1 and an output channel number of 128; S304, the fourth layer in the five-layer structure of the ResNet34 network model includes six sub-layers, the first sub-layer is a down-sampling residual module, including a 3x3 convolutional layer with a step of 2 and an output channel number of 256; followed by a 3x3 convolutional layer with a step of 1 and an output channel number of 256; the other five sub-layers are residual modules, each residual module includes two 3x3 convolutional layers with a step of 1 and an output channel number of 256; S305, the fifth layer in the five-layer structure of the ResNet34 network model includes three sub-layers, the first sub-layer is a down-sampling residual module, including a 3x3 convolutional layer with a step of 2 and an output channel number of 512, followed by a 3x3 convolutional layer with a step of 1 and an output channel number of 512; the other two sub-layers are residual modules, each residual module includes two 3x3 convolutional layers with a step of 1 and an output channel number of 512; S306, the last residual block of ResNet34 is connected to a global average pooling layer, which averages all values of each channel of the feature map to obtain a feature vector; S307, the feature vector is sent to a fully connected layer for classification or regression tasks using softmax.
4. The method of claim 1, wherein the method is based on an improved Adam algorithm to optimize ResNet34 for PEMFC fault diagnosis. The step S400 of reconstructing the initial weight of the Adam algorithm using the sparrow search algorithm includes the following steps: 1) initialize a group of sparrows, including discoverers, followers and sentinels; the position of each sparrow represents a network weight, and the sparrow population can be represented as: where d represents the dimension of the variables to be optimized, and n represents the number of sparrow populations; 2) for each sparrow, calculate its fitness, also known as the objective function value, i.e. train the ResNet34 network using the weight and calculate its accuracy or loss value on the training set; 3) update the positions of the discoverers, followers and sentinels; the position update of the discoverer is expressed as: wherein X i,j The position of the sparrow individual is expressed, i is the current iteration number iter max is the maximum iteration number, a is a random number in [0, 1], R2(R2∈[0, 1]) and ST(ST∈[0.5, 1]) respectively express the early warning value and the safety value, Q is a random number subject to normal distribution, and L is a 1×d matrix, wherein each element is 1; When R2≥ST, it indicates that part of the sparrow has found danger, at this time the finder value convergence should move to the safe position, that is, the finder moves to the current position near the normal distribution; when R2<ST, it indicates that the current environment does not exist danger, and the finder can carry out a wide range of search operations, and with the increase of population algebra, The value range of the item will decrease, and the distribution of the value will become more uniform, that is, the value corresponding to each dimension of the sparrow individual will decrease; Remove the discoverer from the population, and the remaining sparrows are followers; the position update of the follower is described as follows: where X p is the best position found so far, X worst is the worst position found so far, n is the population size, A is a 1 x d matrix with each element randomly assigned to be either 1 or -1, and A + is defined as follows: A + = A T (AA T ) -1 When indicates that the ith follower state is poor, with a low fitness value, and needs to fly to other places to forage. In the sparrow population, the number of sparrows with alarm mechanism accounts for 10% to 20% of the total number, and the position is randomly generated, and the position update formula is as follows: where X best is the current global optimum position, β is a step size control parameter, which is a random number obeying normal distribution with mean 0 and variance 1, K is a random number in [-1, 1], f is the fitness value, f g and f w are the current best and worst fitness values, respectively, and ε is a constant to avoid denominator 0. When f i f g represents that the sparrow at this time is on the edge of the population and is extremely vulnerable to predators; X best represents that the sparrow at this position is the best position in the population and is very safe;f i = f g , it indicates that the sparrow in the middle of the population is aware of the danger and needs to be close to other sparrows to minimize their risk of being preyed upon; K represents the direction of the sparrow movement and is also a step control parameter; 4) calculate the fitness again, sort the sparrows according to the fitness, and select a part of sparrows with better fitness for breeding; in the breeding process, the weight of each sparrow is randomly disturbed, and a new sparrow population is generated; 5) repeat steps 2), 3) and 4) using the new sparrow population until the set number of iterations is reached or the stopping criterion is met; 6) select the bird with the highest fitness from the final bird population, and use its position as the optimized optimal weight.
5. The method of claim 4, wherein the improved Adam algorithm-based optimization of ResNet34 is used for the diagnosis of the PEMFC fault. In step 400, the ResNet34 is optimized using the Adam optimization algorithm, including the following steps: 1) Initialize the first moment m0, the second moment v0 and the step number t are all 0, the first moment attenuation coefficient β1=0.9, the second moment attenuation coefficient β2=0.999, the learning rate α=0.001, k=10 -8 θ is an input parameter, that is, the optimal weight value optimized by the sparrow search algorithm; 2) find the optimal weight θ by calculating: m t = β1· m t-1 + (1 - β1)· g t where g t is the gradient of the objective function, m t is the first moment, v t is the second moment, and are the bias correction terms for m t and v t respectively, θ t is the optimal weight; 3) update the weights between the convolutional layer and the fully connected layer to improve the performance of the network.