Ship engine fault diagnosis method based on IWOA-CNN-Transform

By optimizing the hyperparameters of the CNN-Transformer model using the improved whale optimization algorithm, the problems of local feature extraction and strong hyperparameter dependence in ship engine fault diagnosis are solved, and more accurate fault identification and classification are achieved.

CN121327680APending Publication Date: 2026-01-13DALIAN MARITIME UNIVERSITY
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511506370.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-21
Publication Date
2026-01-13

Smart Images

  • Figure CN121327680A_ABST
    Figure CN121327680A_ABST
Patent Text Reader

Abstract

The invention discloses a ship engine fault diagnosis method based on IWOA-CNN-Transform, and the method comprises the steps: collecting the operation data of a ship engine in a normal state and a fault state, carrying out the preprocessing, constructing a data set, and dividing the data set into a training set and a verification set; the whale optimization algorithm is improved by introducing optimal neighborhood disturbance, adaptive weight and a variable spiral position updating strategy, and the improved whale optimization algorithm is constructed; constructing a CNN-Transform model, and optimizing hyper-parameters of the model by using an improved whale optimization algorithm to obtain an optimal hyper-parameter combination; and the CNN-Transform model is improved based on the optimal hyper-parameter combination, the training set is used for training, the verification set is used for evaluation, and prediction and diagnosis of the improved CNN-Transform model on engine fault classification are realized. According to the method, the accuracy and robustness of ship engine fault diagnosis can be effectively improved, and intelligent prediction and diagnosis of fault categories are realized.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to the technical field of ship transmitter fault diagnosis, and in particular to a ship engine fault diagnosis method based on IWOA-CNN-Transformer. BACKGROUND

[0002] A ship engine is a core power device for ship navigation propulsion and power supply, and plays an important role in the field of shipping. Due to its importance, if a fault occurs in the engine operation and is not discovered in time, not only serious economic losses may be caused, but also personnel life safety may be threatened. With the development of intelligent ships and the wide application of artificial intelligence technology, the research on state monitoring and fault diagnosis based on intelligent algorithms is continuously deepened, which promotes the update and iteration of the ship engine diagnosis method. However, due to the factors such as data scarcity, complex fault features, significant noise influence and insufficient labeling, the actual application still faces great challenges.

[0003] The thermodynamic parameters of the ship engine are complex and have high uncertainty. Although CNN is widely used in fault diagnosis, it is limited to local feature extraction and lacks modeling of global dependencies. Transformer can not only capture long-range temporal relationships, but also has multi-scale feature extraction capability, which can complement the short board of CNN in global modeling. At the same time, the performance of neural networks is highly dependent on the setting of hyperparameters. SUMMARY

[0004] The application provides a ship engine fault diagnosis method based on IWOA-CNN-Transformer to overcome the problem that fault diagnosis is limited to local feature extraction and highly dependent on hyperparameter setting.

[0005] In order to achieve the above-mentioned purpose, the technical scheme of the application is: A ship engine fault diagnosis method based on IWOA-CNN-Transformer, comprising: S1, obtaining running data of a ship engine in normal and fault states through a ship engine model, and preprocessing to obtain a preprocessed running data set; dividing the preprocessed running data set into a training set and a test set; S2, introducing optimal neighborhood disturbance, adaptive weight and variable spiral position update strategy to improve the whale optimization algorithm to obtain an improved whale optimization algorithm, namely IWOA algorithm; S3. Construct a CNN-Transformer model, optimize the hyperparameters of the CNN-Transformer model using the IWOA algorithm to obtain the optimal hyperparameter combination, and substitute it into the CNN-Transformer model to obtain the optimized CNN-Transformer model; the hyperparameters include the learning rate, the number of hidden layer nodes, and the number of iterations; S4. Train and optimize the CNN-Transformer model using the training set, and validate it using the test set to obtain the trained and optimized CNN-Transformer model; use the trained and optimized CNN-Transformer model to predict and diagnose ship engine fault categories.

[0006] Furthermore, the optimal neighborhood perturbation is used to determine whether to perturb the position of the optimal solution by comparing a random number with a set threshold. If the random number is less than the set threshold, perturbation is performed to obtain a new position of the candidate solution after perturbation; otherwise, the new position remains the position of the current optimal solution. The expression is:

[0007] In the formula, The new position of the candidate solution is generated based on the current optimal solution and the random perturbation; This represents the position of the optimal solution in the current iteration. It is a random vector; These are random numbers used to determine whether to perform a perturbation; This represents the current iteration number; The expression for the adaptive weight is:

[0008] In the formula, For adaptive weights; This represents the maximum number of iterations. The variable spiral position update strategy is used to obtain the position of the candidate solution in the next iteration, and its expression is:

[0009]

[0010] In the formula, This is the scaling factor for the helical motion; This is the position of the whale in the next iteration, i.e., the position of the next candidate solution; This represents the distance between the current iteration whale and the current iteration leader whale, which is the distance between the current iteration candidate solution and the current iteration optimal solution. These are random numbers used to adjust the period of the spiral curve.

[0011] Furthermore, the specific steps for predicting and diagnosing ship engine fault categories using a trained and optimized CNN-Transformer model include: S311. Input the running dataset into the CNN network model, obtain the local spatial features in the running dataset, and output the first feature representation through the fully connected layer of the CNN network model; S312. The first feature representation is passed through the embedding layer and encoded according to the position to obtain the second feature representation; S313. Based on the second feature representation, the context-aware deep features are output through the multi-head attention mechanism of the Transformer encoder and the feedforward neural network. S314. The context-aware deep features are integrated with average pooling and fully connected layers to obtain the number of fault categories. Based on the number of fault categories, the probability of the running data belonging to the fault category is obtained through the softmax function, and the prediction and diagnosis results of the engine fault category are output.

[0012] Furthermore, the expression for the multi-head attention mechanism is:

[0013] In the formula, This is the output of the multi-head attention mechanism; These are respectively query, key, and value; Let i be the i-th head, where... ; k The total number of heads; For a trainable weight matrix; To be k The function for concatenating the output of the size; The calculation for each head is as follows:

[0014] In the formula, These are the weight matrices for the query, key, and value, respectively. For attention functions.

[0015] Furthermore, in the multi-head attention mechanism, attention is calculated separately within each head, expressed as:

[0016] In the formula, d for K The dimension; T This is a transpose.

[0017] Furthermore, the IWOA algorithm optimizes the hyperparameters of the CNN-Transformer model to obtain the optimal hyperparameter combination. The specific steps include: S321. Initialize the population and IWOA parameters, randomly generate a candidate solution population in the solution space, calculate the fitness value of each individual in the population, and obtain the initial optimal solution and the position of the initial optimal solution. S322. Calculate adaptive weights based on the current iteration number to incorporate the variable spiral position update strategy; S323. In the current iteration, the optimal solution position is obtained based on the adaptive weight and variable spiral position update strategy; S324. Based on the location of the optimal solution, the optimal neighborhood perturbation is used to obtain the location of the new candidate solution after perturbation; S325. Calculate the fitness value of the new candidate solution after perturbation to obtain the updated optimal solution position: If the fitness value of the new candidate solution after perturbation is greater than the fitness value of the optimal solution, then the updated position of the optimal solution is the position of the new candidate solution after perturbation; otherwise, the updated position of the optimal solution is the position of the optimal solution. S326: Based on the updated optimal solution position, repeat S322-S325 for the next iteration until the number of iterations reaches the specified maximum value, and output the optimal solution corresponding to the updated optimal solution position as the optimal hyperparameter combination of the optimization result.

[0018] Beneficial effects: This invention provides a fault diagnosis method for marine engines based on IWOA-CNN-Transformer. By constructing a CNN-Transformer model, it fully utilizes the powerful local feature extraction capability of the CNN network model and the excellent global dependency capture capability of the Transformer model. It can learn more discriminative features from complex engine operation data, thereby achieving more accurate and reliable identification and classification of fault modes. An improved whale optimization algorithm is developed by introducing optimal neighborhood perturbation, adaptive weights, and a variable spiral position update strategy. This improved whale optimization algorithm effectively balances global exploration and local exploitation capabilities, avoiding premature convergence. Its powerful optimization ability is used to automatically optimize the key hyperparameters of the CNN-Transformer model, overcoming the blindness and suboptimal nature of manual hyperparameter tuning, enabling the model to converge to its optimal performance state more quickly. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a flowchart illustrating the process of diagnosing marine engine faults according to the present invention. Figure 2 This is a simulation model of the Wärtsilä9L34DF marine engine in an embodiment of the present invention; Figure 3 This is a diagram of the CNN model framework in an embodiment of the present invention; Figure 4 This is a diagram of the Transformer model framework in an embodiment of the present invention; Figure 5 This is a diagram of the CNN-Transformer model framework in an embodiment of the present invention; Figure 6 The graphs show the convergence of the single-peak test functions for the five optimization algorithms in this embodiment of the invention. Figure 7 The above are convergence graphs of the multi-peak test functions for the five optimization algorithms in this embodiment of the invention. Figure 8 This is a diagram of the IWOA-CNN-Transformer model framework in an embodiment of the present invention; Figure 9 This is a comparison diagram of the fault classification confusion matrix in an embodiment of the present invention; Figure 10 This is a comparison chart of the test results of five optimization models in the embodiments of the present invention. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0022] This embodiment provides a method for diagnosing ship engine faults based on IWOA-CNN-Transformer, such as Figure 1 As shown, it includes: S1. Using a ship engine model, obtain operational data of the ship engine under normal and fault conditions, and preprocess it to obtain a preprocessed operational dataset; divide the preprocessed operational dataset into a training set and a test set. S2. By introducing optimal neighborhood perturbation, adaptive weights, and variable spiral position update strategy, the whale optimization algorithm is improved, resulting in the improved whale optimization algorithm, namely the IWOA algorithm. S3. Construct a CNN-Transformer model, optimize the hyperparameters of the CNN-Transformer model using the IWOA algorithm to obtain the optimal hyperparameter combination, and substitute it into the CNN-Transformer model to obtain the optimized CNN-Transformer model; the hyperparameters include the learning rate, the number of hidden layer nodes, and the number of iterations; S4. Train and optimize the CNN-Transformer model using the training set, and validate it using the test set to obtain the trained and optimized CNN-Transformer model; use the trained and optimized CNN-Transformer model to predict and diagnose ship engine fault categories.

[0023] In a specific embodiment, such as Figure 2 As shown, using the Wärtsilä 9L34DF marine diesel engine as a verification example, a marine engine model with parameters as shown in Table 1 was constructed. Through the marine engine model, the operating data of the marine engine under normal and fault conditions were obtained. Among them, the increased valve clearance, delayed fuel injection timing, blockage of cold air pipeline and wear of turbocharger impeller were taken as fault conditions. Different degrees of simulation were carried out for each type of fault condition, generating 300 sets of sample data containing 23-dimensional features, which were divided into training set and verification set in an 8:2 ratio. Table 1. Main performance parameters of the Wärtsilä 9L34DF diesel engine

[0024] Specifically, the preprocessing includes noise addition and normalization.

[0025] Preferably, the optimal neighborhood perturbation, based on the global search phase, applies a small random perturbation to the current optimal solution to guide the algorithm to further explore the potential solution space of the optimal solution's neighborhood, thereby effectively avoiding the algorithm from getting trapped in local optima. The optimal neighborhood perturbation is used to determine whether to perturb the position of the optimal solution by comparing a random number with a set threshold. If the random number is less than the set threshold, perturbation is performed to obtain a new position of the candidate solution after perturbation; otherwise, the new position remains the position of the current optimal solution. The expression is:

[0026] In the formula, The new position of the candidate solution is generated based on the current optimal solution and the random perturbation; This represents the position of the optimal solution in the current iteration. It is a random vector; These are random numbers used to determine whether to perform a perturbation; This represents the current iteration number; The adaptive weights decrease as the number of iterations increases, making the algorithm more inclined to global exploration in the early stages and gradually transition to local exploration in the later stages. The expression for the adaptive weighting function is:

[0027] In the formula, For adaptive weights; This represents the maximum number of iterations. In the early stages of iteration, the adaptive weight parameter is set to a large value to enhance the algorithm's global search capability; as the iteration progresses, it is gradually reduced to strengthen the local search capability, making the search process more focused on the region near the optimal solution, thereby achieving higher-precision convergence. The variable spiral position update strategy is used to obtain the position of the candidate solution in the next iteration by using the spiral radius and variable step size, and the expression is:

[0028]

[0029] In the formula, This is the scaling factor for the helical motion; This is the position of the whale in the next iteration, i.e., the position of the next candidate solution; This represents the distance between the current iteration whale and the current iteration leader whale, which is the distance between the current iteration candidate solution and the current iteration optimal solution. These are random numbers used to adjust the period of the spiral curve; The spiral radius is the distance a candidate solution rotates around the optimal solution, determining how far the candidate solution is from the optimal solution. In the whale optimization algorithm, the leader whale is usually the optimal solution found in the current iteration. D Leader ( t )=| X * ( t )- X ( t | is the distance between the current whale and the leading whale, i.e., the spiral radius; The variable step size determines the distance that a candidate solution moves on the spiral curve each time. Controlling the change of helix radius as the helix curve contracts, To generate periodic changes in the spiral curve, causing the position to move along the spiral path, a variable step size strategy typically varies with the number of iterations. Dynamic changes, It is a variable step size.

[0030] Specifically, such as Figure 5 As shown, the CNN-Transformer model in this embodiment consists of a CNN network model and an encoder of a Transformer model; Among them, such as Figure 3 As shown, the CNN network model includes an input layer, convolutional layers, pooling layers, fully connected layers, and an output layer; like Figure 4 As shown, the Transformer model includes an encoder, a decoder, and an attention mechanism; Preferably, the specific steps for predicting and diagnosing ship engine fault categories using a trained and optimized CNN-Transformer model include: S311. Input the running dataset into the CNN network model, obtain the local spatial features in the running dataset, and output the first feature representation through the fully connected layer of the CNN network model; S312. The first feature representation is passed through the embedding layer and encoded according to the position to obtain the second feature representation; S313. Based on the second feature representation, the context-aware deep features are output through the multi-head attention mechanism of the Transformer encoder and the feedforward neural network. S314. The context-aware deep features are integrated with average pooling and fully connected layers to obtain the number of fault categories. Based on the number of fault categories, the probability of the running data belonging to the fault category is obtained through the softmax function, and the prediction and diagnosis results of the engine fault category are output.

[0031] Preferably, the expression for the multi-head attention mechanism is:

[0032] In the formula, This is the output of the multi-head attention mechanism; These are respectively query, key, and value; Let i be the i-th head, where... ; For a trainable weight matrix; To be k Output splicing of individual sizes; The calculation for each head is as follows:

[0033] In the formula, These are the weight matrices for the query, key, and value, respectively. For attention functions.

[0034] Preferably, in the multi-head attention mechanism, attention is calculated separately for each head, and the expression is:

[0035] In the formula, d is the dimension of K; T is the transpose.

[0036] Specifically, the Whale Optimization Algorithm (WOA) works by continuously updating the positions of individuals (i.e., whales) in a population, gradually bringing the entire population closer to the global optimum. Its position update mechanism is mainly divided into exploration and development phases. In the exploration phase, individual whales randomly select a target position and conduct a global search over a wider area to increase population diversity and the ability to escape local optima. In the development phase, whales perform local searches around the currently known optimal position to accelerate the convergence process and improve the accuracy of the solution. The update expression for the whale optimization algorithm is:

[0037] In the formula, X ( t+1 () represents the whale's position in the next iteration; X ( t () represents the current position of the whale; X r ( t The locations of other randomly selected whales serve to guide the search; A The control parameter that determines the range of motion of a whale is a random variable with decreasing amplitude; C The control parameter for controlling the whale's positional offset is a uniformly distributed random variable; Among them, control parameters A and C The expression is:

[0038]

[0039] In the formula, r1 is a constant that decreases linearly from 2 to 0, used to control the search range; r1 and r2 are two random vectors with values ​​between [0,1]. During the development phase, whales will perform local searches based on the current location of their prey. The update formula is:

[0040] In the formula, X p ( t () represents the position of the current optimal solution, i.e., the optimal solution found so far; D =| C × X p (t )- X ( t )| represents the distance between the whale's current position and the optimal solution.

[0041] Preferably, the specific steps of the IWOA algorithm to optimize the hyperparameters of the CNN-Transformer model and obtain the optimal hyperparameter combination include: S321. Initialize the population and IWOA parameters, randomly generate a candidate solution population in the solution space, calculate the fitness value of each individual in the population, and obtain the initial optimal solution and the position of the initial optimal solution. S322. Calculate adaptive weights based on the current iteration number to incorporate the variable spiral position update strategy; S323. In the current iteration, the optimal solution position is obtained by updating the strategy according to the adaptive weight and variable spiral position, and by optimizing the parameters through a random search mechanism and a shrinking encirclement mechanism. The search mechanism and the shrinking encirclement mechanism are the default mechanisms of the WOA algorithm and are existing technologies; S324. Based on the location of the optimal solution, the optimal neighborhood perturbation is used to obtain the location of the new candidate solution after perturbation; The condition for performing optimal neighborhood perturbation is as follows: a random number is set, and the random number is compared with a set threshold. If the random number is less than the set threshold, the optimal solution of the current iteration is perturbed by optimal neighborhood perturbation, and the position of a new candidate solution after perturbation is generated near the optimal solution; otherwise, the position of the optimal solution is kept as the position of the candidate solution. S325. Calculate the fitness value of the new candidate solution after perturbation to obtain the updated optimal solution position: If the fitness value of the new candidate solution after perturbation is greater than the fitness value of the optimal solution, then the updated position of the optimal solution is the position of the new candidate solution after perturbation; otherwise, the updated position of the optimal solution is the position of the optimal solution. S326: Based on the updated optimal solution position, repeat S322-S325 for the next iteration until the number of iterations reaches the specified maximum value, and output the optimal solution corresponding to the updated optimal solution position as the optimal hyperparameter combination of the optimization result.

[0042] In a specific embodiment, the IWOA algorithm of this embodiment was compared with other commonly used swarm intelligence optimization algorithms to evaluate its global optimization capability; the selected algorithms included: IWOA, Particle Swarm Optimization (PSO), Grey Wolf Optimization (GWO), Dung Beetle Optimizer (DBO), and Sparrow Search Algorithm (SSA). Comparative experiments were conducted on typical benchmark functions, including the unimodal Sphere Function and the multimodal Ackley Function; each algorithm was run independently 100 times on each benchmark function, with a maximum number of iterations set to 1000, and the population size was uniformly set to 30.

[0043] Comparative experimental results are as follows Figure 6 to Figure 7 As shown, in the single-peak function test, the IWOA algorithm exhibits excellent convergence speed and accuracy, and can accurately approximate the global optimum. In the multi-peak function test, IWOA demonstrates the ability to effectively avoid getting trapped in local optima, and achieves fast convergence while maintaining accuracy. Overall, the test results clearly demonstrate the advantages of IWOA in terms of optimization accuracy and convergence speed.

[0044] In a specific embodiment, such as Figure 8 As shown, the constructed ship engine fault diagnosis model consists of a data preprocessing module, an IWOA hyperparameter optimization module, and a CNN-Transformer feature extraction module. The data preprocessing module is used to perform noise addition and normalization operations on the raw collected data to reduce the differences in units and enhance the generalization ability of the model; the dataset is divided into training set and test set to provide support for subsequent training and testing. The IWOA hyperparameter optimization module is used to update the population position in real time based on the individual fitness value through an iterative search mechanism, gradually improve the quality of the global solution, and finally determine the optimal hyperparameter combination and network structure. The CNN-Transformer feature extraction module is used to learn from the training set and make predictions using the test set to obtain the final classification result, thereby achieving accurate discrimination between the ship system status and fault category.

[0045] In a specific embodiment, the superiority of the ship engine fault diagnosis model is evaluated by using accuracy, precision, recall, and F1 score; and ablation experiments are conducted to verify the contribution of each component to the overall model performance and to observe the specific impact of key components (CNN, Transformer) on model performance. Six models were selected: CNN, Transformer, CNN-Transformer, IWOA-CNN, IWOA-Transformer, and IWOA-CNN-Transformer. After multiple experiments, the average value was taken, and the results are shown in Table 2. Table 2 Evaluation Results

[0046] According to Table 2, the accuracies of using CNN or Transformer models alone were 79.81% and 75.08%, respectively, indicating that a single model cannot fully capture data features. After introducing the CNN module into the Transformer, the accuracy increased to 90.05%, showing that CNN has a significant advantage in local feature extraction. However, adding the IWOA optimization algorithm only to the CNN-Transformer model did not further improve the performance, reflecting that the combined model still has limitations in long sequence dependency modeling. The CNN-Transformer model combined with IWOA optimization finally achieved the highest accuracy of 98.33% and performed well on all evaluation metrics, proving that the model has strong capabilities in both local and global feature extraction, and verifying the effectiveness and superiority of the IWOA-CNN-Transformer model. To evaluate the effectiveness of the proposed method, a confusion matrix visualization analysis was performed on the classification results; such as Figure 9 As shown, the confusion matrices of the comparison method and the ship engine fault diagnosis model of this embodiment are displayed, where each column represents the predicted category, each row represents the true category, and the diagonal represents the number of correctly classified samples. The results show that the ship engine fault diagnosis model of this embodiment can achieve high-precision classification in all fault categories, with a very small number of misclassified samples, and both accuracy and precision are high.

[0047] In a specific embodiment, the ship engine fault diagnosis model of this embodiment is compared with the combined model of four other optimization algorithms; the combined model of optimization algorithms includes: SSA-CNN-Transformer model, GWO-CNN-Transformer model, PSO-CNN-Transformer model and DBO-CNN-Transformer model. likeFigure 10 As shown in the test results of the five optimized models on the same test set, it can be seen that the IWOA-CNN-Transformer marine engine fault diagnosis model proposed in the embodiment has the best classification performance and can effectively distinguish fault types, while the detection performance of the other four methods is slightly worse. It is evident that the IWOA-CNN-Transformer model has significant advantages in classification performance and fault identification accuracy in marine engine system fault diagnosis.

[0048] The present invention has the following beneficial effects: The present invention provides a ship engine fault diagnosis method based on IWOA-CNN-Transformer. By constructing a CNN-Transformer model, it makes full use of the powerful local feature extraction capability of the CNN network model and the excellent global dependency capture capability of the Transformer model. It can learn more discriminative features from complex engine operation data, thereby achieving more accurate and reliable identification and classification of fault modes. An improved whale optimization algorithm is developed by introducing optimal neighborhood perturbation, adaptive weights, and a variable spiral position update strategy. This improved whale optimization algorithm effectively balances global exploration and local exploitation capabilities, avoiding premature convergence. Its powerful optimization ability is used to automatically optimize the key hyperparameters of the CNN-Transformer model, overcoming the blindness and suboptimal nature of manual hyperparameter tuning, enabling the model to converge to its optimal performance state more quickly.

[0049] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for diagnosing marine engine faults based on IWOA-CNN-Transformer, characterized in that, include: S1. Obtain the operating data of the ship engine under normal and fault conditions through the ship engine model, and preprocess it to obtain the preprocessed operating dataset. The preprocessed dataset is divided into a training set and a test set. S2. By introducing optimal neighborhood perturbation, adaptive weights, and variable spiral position update strategy, the whale optimization algorithm is improved, resulting in the improved whale optimization algorithm, namely the IWOA algorithm. S3. Construct a CNN-Transformer model, optimize the hyperparameters of the CNN-Transformer model using the IWOA algorithm to obtain the optimal hyperparameter combination, and substitute it into the CNN-Transformer model to obtain the optimized CNN-Transformer model; the hyperparameters include the learning rate, the number of hidden layer nodes, and the number of iterations; S4. Train and optimize the CNN-Transformer model using the training set, and validate it using the test set to obtain the trained and optimized CNN-Transformer model; use the trained and optimized CNN-Transformer model to predict and diagnose ship engine fault categories.

2. The method for diagnosing marine engine faults based on IWOA-CNN-Transformer according to claim 1, characterized in that, The optimal neighborhood perturbation is used to determine whether to perturb the position of the optimal solution by comparing a random number with a set threshold. If the random number is less than the set threshold, perturbation is performed to obtain a new position of the candidate solution after perturbation; otherwise, the new position remains the position of the current optimal solution. The expression is: In the formula, The new position of the candidate solution is generated based on the current optimal solution and the random perturbation; This represents the position of the optimal solution in the current iteration. It is a random vector; These are random numbers used to determine whether to perform a perturbation; This represents the current iteration number; The expression for the adaptive weight is: In the formula, For adaptive weights; This represents the maximum number of iterations. The variable spiral position update strategy is used to obtain the position of the candidate solution in the next iteration, and its expression is: In the formula, This is the scaling factor for the helical motion; This is the position of the whale in the next iteration, i.e., the position of the next candidate solution; This represents the distance between the current iteration whale and the current iteration leader whale, which is the distance between the current iteration candidate solution and the current iteration optimal solution. These are random numbers used to adjust the period of the spiral curve.

3. The method for fault diagnosis of marine engines based on IWOA-CNN-Transformer according to claim 1, characterized in that, The specific steps for predicting and diagnosing ship engine fault categories using a trained and optimized CNN-Transformer model include: S311. Input the running dataset into the CNN network model, obtain the local spatial features in the running dataset, and output the first feature representation through the fully connected layer of the CNN network model; S312. The first feature representation is passed through the embedding layer and encoded according to the position to obtain the second feature representation; S313. Based on the second feature representation, the context-aware deep features are output through the multi-head attention mechanism of the Transformer encoder and the feedforward neural network. S314. The context-aware deep features are integrated with average pooling and fully connected layers to obtain the number of fault categories. Based on the number of fault categories, the probability of the running data belonging to the fault category is obtained through the softmax function, and the prediction and diagnosis results of the engine fault category are output.

4. The method for fault diagnosis of marine engines based on IWOA-CNN-Transformer according to claim 3, characterized in that, The expression for the multi-head attention mechanism is: In the formula, This is the output of the multi-head attention mechanism; These are respectively query, key, and value; Let i be the i-th head, where... ; k The total number of heads; For a trainable weight matrix; To be k The function for concatenating the output of the size; The calculation for each head is as follows: In the formula, These are the weight matrices for the query, key, and value, respectively. For attention functions.

5. The method for fault diagnosis of marine engines based on IWOA-CNN-Transformer according to claim 4, characterized in that, In a multi-head attention mechanism, attention is calculated separately for each head, expressed as: In the formula, d for K The dimension; T This is a transpose.

6. The method for fault diagnosis of marine engines based on IWOA-CNN-Transformer according to claim 1, characterized in that, The IWOA algorithm optimizes the hyperparameters of a CNN-Transformer model to obtain the optimal hyperparameter combination. The specific steps include: S321. Initialize the population and IWOA parameters, randomly generate a candidate solution population in the solution space, calculate the fitness value of each individual in the population, and obtain the initial optimal solution and the position of the initial optimal solution. S322. Calculate adaptive weights based on the current iteration number to incorporate the variable spiral position update strategy; S323. In the current iteration, the optimal solution position is obtained based on the adaptive weight and variable spiral position update strategy; S324. Based on the location of the optimal solution, the optimal neighborhood perturbation is used to obtain the location of the new candidate solution after perturbation; S325. Calculate the fitness value of the new candidate solution after perturbation to obtain the updated optimal solution position: If the fitness value of the new candidate solution after perturbation is greater than the fitness value of the optimal solution, then the updated position of the optimal solution is the position of the new candidate solution after perturbation; otherwise, the updated position of the optimal solution is the position of the optimal solution. S326: Based on the updated optimal solution position, repeat S322-S325 for the next iteration until the number of iterations reaches the specified maximum value, and output the optimal solution corresponding to the updated optimal solution position as the optimal hyperparameter combination of the optimization result.

Citation Information

Cited By

  • RFE-ICCO-BP-based equipment engine fault diagnosis method

    CN121919676A