Multi-task lstm battery capacity prediction method based on attention mechanism
By adopting the multi-task LSTM method based on the attention mechanism in lithium battery capacity prediction, processing historical data and combining it with the convolutional neural network, the accuracy problem of battery capacity prediction in complex environments is solved, and the prediction accuracy and model performance are improved. .
Patent Information
- Application Number
- CN202311407134.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2022-11-17
- Filing Date
- 2023-10-27
- Publication Date
- 2024-08-30
AI Technical Summary
Existing lithium battery capacity prediction methods are difficult to accurately predict in complex environments, especially due to the difficulty in sampling or feature extraction of historical current and voltage curves due to incomplete release of power.
A multi-task LSTM battery capacity prediction method based on the attention mechanism is used to process historical data through a sliding window. It combines a shared LSTM layer, a multi-dimensional convolutional neural network and a private LSTM layer, and uses the attention layer to weight the input data to perform multiple prediction tasks. Improve accuracy.
It improves the accuracy of battery capacity prediction and model performance, makes the prediction results more consistent with the actual environment, can effectively screen input and reduce noise, and enhances the prediction ability of the model.
Smart Images

Figure CN118566739A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of battery capacity prediction, and in particular to a multi-task LSTM battery capacity prediction method based on an attention mechanism. Background Art
[0002] In the prior art, lithium battery capacity prediction methods can be divided into two categories: model-based prediction methods and data-driven prediction methods. Model-based prediction methods mathematically model the complex physical and chemical reactions inside the battery to predict the battery capacity. However, this method requires a lot of prior knowledge, such as the physical and chemical principles of the battery and the main factors causing capacity decay. In a complex environment, it may be difficult to model the model internally. The data-driven prediction method directly uses the characteristic data such as current, voltage, temperature, etc. monitored by the battery during the charging and discharging process to predict the capacity without relying on the complex decay mechanism inside the battery. Both of these battery capacity prediction methods require sampling or extracting features from the complete charging and discharging current and voltage curves as the input prediction method of the model. However, when the battery is actually used, sometimes the power is not fully released, which makes it very difficult to sample or extract features from the historical current and voltage curves.
[0003] The information disclosed in this background technology section is only intended to deepen the understanding of the overall background technology of the present invention, and should not be regarded as acknowledging or suggesting in any form that the information constitutes the prior art already known to those skilled in the art. Summary of the invention
[0004] In order to solve the above technical problems, the present invention proposes a multi-task LSTM battery capacity prediction method based on attention mechanism to improve the prediction accuracy and improve the performance of the model.
[0005] To achieve the above object, the technical solution of the present invention is as follows:
[0006] A multi-task LSTM battery capacity prediction method based on attention mechanism includes the following steps:
[0007] Step 1: Data preprocessing and model building:
[0008] Collect historical battery capacity data C1, C2, ..., C total , and use a sliding window with a width of w to split the historical capacity data to obtain [C1,C2,...,C w ],[C2,C3,...,C w+1 ], ..., [C k ,C k+1 ,...,C k+w-1], ...; for the kth window data, its label value is k+w+p-2, k+w+p-1, and the actual capacity value C at the time k+w+p k+w+p-2 , C k+w+p-1 , C k+w+p After that, the data is normalized. For the k-th window data and its true value, the normalization process is to divide the capacity value at the previous moment, that is,
[0009]
[0010]
[0011] Step 2: Model calculation:
[0012] (2.1) Shared LSTM layer
[0013] Let c k represents the cell state at time k, C k represents the input data at time k, h k represents the hidden state of the output at time k. The LSTM cell at time k will receive three types of input information: c k-1 、h k-1 and C k ; These input information will first be sent to the forget gate and the memory gate for processing; the forget gate is used to forget information, which determines c k-1 Which information will be forgotten. The memory gate is used to filter h k-1 and C k The information that needs to be retained in the calculation process of the forget gate and the memory gate can be expressed as:
[0014] f k =σ(W f ·[h t-1 ,C t ]+b f )
[0015] i k =σ(W i ·[h k-1 ,C k ]+b i )
[0016] g k =tanh(W g ·[h k-1 ,C k ]+b g )
[0017] After the information is processed by the forget gate and the memory gate, the cell state c at time k k Will be updated accordingly:
[0018] ck =f k *c k-1 +i k *g k
[0019] Finally, the output goalkeeper h k-1 , C k and c k To integrate the information:
[0020] o k =σ(W o [h k-1 ,C k ]+b o )
[0021] h k =o k *tanh(c k )
[0022] Finally, we get the shared LSTM layer output vector
[0023] (2.2) Abstract feature extraction based on one-dimensional convolutional neural network:
[0024] This paper uses multiple one-dimensional convolutional layers to learn the output vector of the shared layer LSTM and convert it into feature sequences with different levels of abstraction; the input of the first one-dimensional convolutional layer is The input of the second and third convolutional layers is the hidden state of the output of the previous convolutional layer, that is, [U1,U2,...,U w ]; the calculation process of the convolutional layer is as follows:
[0025] The core idea of the convolutional layer is to learn the features of the input sequence through the convolution operation of the convolution kernel. Suppose the hidden state input from the previous neural network to the convolutional layer at a certain moment is:
[0026]
[0027] Set a series of convolution kernels as:
[0028]
[0029] The convolution operation can map the input sequence to the output space. Among them, s represents the size of the convolution kernel, n represents the dimension of the convolution kernel, which is equal to the dimension of the input sequence, and m represents the number of convolution kernels;
[0030] The convolution process is as follows Figure 1 shown.
[0031] When a convolution kernel successfully captures a certain feature, it will be activated by the activation function. In the convolution layer, multiple convolution kernels are used for parallel learning in order to capture features from multiple angles. The ReLU function is used as the activation function of the one-dimensional convolution layer; we add Batch Normalization
[19] to the one-dimensional convolution layer to improve the convergence speed and prevent overfitting; the convolution layer calculation process is expressed as:
[0032] R i =v i *H+b i
[0033] U = ReLU(BN(R))
[0034] Among them, R i Represents the i-th convolution kernel v i The feature vector obtained after the convolution operation, b i represents the bias, and U represents the output of the one-dimensional convolutional layer;
[0035] (2.3), Private LSTM layer:
[0036] The function of the private LSTM layer is to perform a separate prediction task based on the common features extracted by the shared layer. The calculation process is similar to that of the shared LSTM layer. Let c k represents the cell state at time k, x k represents the input data at time k, h k represents the hidden state output at time k; for the first private LSTM layer, its input data is For the second and third private LSTM layers, their input data is the output vector of the CNN layer:
[0037] f k =σ(W f ·[h t-1 ,C t ]+b f )
[0038] i k =σ(W i ·[h k-1 ,C k ]+b i )
[0039] g k =tanh(W g ·[h k-1 ,C k ]+b g )
[0040] c k =f k *c k-1+i k *g k
[0041] o k =σ(W o [h k-1 ,C k ]+b o )
[0042] h k =o k *tanh(c k )
[0043] Finally, each private LSTM layer output vector is obtained
[0044] (2.4) Attention layer:
[0045] The attention layer receives the output vector of the previous private LSTM layer As input;
[0046] The attention calculation process is as follows:
[0047] W a =W*h+b
[0048]
[0049] in, represents the weight matrix, w i,j Represents the matrix W a Elements in and is a trainable parameter, * represents the dot multiplication process of the matrix;
[0050] The weighted sum of the attention and input gives the resulting vector:
[0051] l k =∑α i h i
[0052] The result vector is calculated through the fully connected layer to get the predicted value:
[0053] y k =W k l k +b k
[0054] Step 3: Model training and prediction:
[0055] [C1,C2,...,C w ],[C2,C3,...,C w+1 ], ..., [C k,C k+1 ,...,C k+w-1 ], ... and their corresponding label values are used as training sets, and the loss function is calculated during the training process;
[0056]
[0057] Update the parameters of the model's internal parameters according to the loss function and iterate (back propagation).
[0058] Once the model training is complete, predictions can be made.
[0059] As a preferred method, the model uses multi-task LSTM (MT-LSTM) as the main framework of the model. The model uses a normalization method to limit the data to roughly the same scale, reducing the model's sensitivity to the data. The capacity value [C k ,C k+1 ,...,C k+w-1 ] Divide the capacity value C of the previous cycle k-1 , the prediction task now becomes:
[0060]
[0061] The model will perform three prediction tasks: k+w+p-2 , D k+w+p-1 , D k+w+p+1 , where D k+w+p-1 Is the main task of the model D k+w+p-2 and D k+w+p+1 For auxiliary tasks.
[0062] Preferably, the model includes LSTM, and the LSTM is divided into a shared layer LSTM and a unique layer LSTM, wherein the shared layer LSTM is used to extract features of the original time series, and the unique layer LSTM is used to process output data of the previous layer of neural network to extract features related to the prediction results.
[0063] Preferably, the model uses multiple one-dimensional convolutional layers to learn the output sequence of the shared layer LSTM and convert it into feature sequences of different abstract levels; a one-dimensional convolutional neural network (1D CNN) is a neural network that includes convolution calculations. It can capture the most relevant features of the input data to the target, thereby reducing the noise in the input data;
[0064] Suppose the hidden state input from the previous neural network to the convolutional layer at a certain moment is:
[0065]
[0066] Set a series of convolution kernels as:
[0067]
[0068] Then the input can be mapped to the output space Where s represents the size of the convolution kernel, n represents the dimension of the convolution kernel, which is equal to the dimension of the input, and m represents the number of convolution kernels;
[0069] When the convolution kernel successfully captures a certain feature, it will be activated by the activation function. In the convolution layer, multiple convolution kernels are used to learn in parallel to achieve the purpose of capturing features from multiple angles, and ReLU is used as the activation function of CNN;
[0070] The calculation process is expressed as:
[0071]
[0072] u i =ReLU(v i *H+b i )
[0073] Batch Normalization is added to the one-dimensional convolutional layer to improve the convergence speed and prevent overfitting. The Padding method is used to ensure that the output size is equal.
[0074] As a preferred method, the time-step self-attention mechanism is combined with LSTM;
[0075] Assume that at the current moment, the attention layer receives As input, the attention layer will now calculate a set of attention weights α based on the input k ,α k+1 ,…α k+w-1 , these attention weights represent the influence of the hidden state at each moment on the result; then the model performs a weighted summation on the input to obtain the result vector l k ;
[0076] The calculation process of the attention layer can be expressed as:
[0077] l k =∑α i h i
[0078] in, represents the weight matrix, w i,j Represents the matrix W a The elements in . and is a trainable parameter, * represents the dot multiplication process of the matrix, l k Represents the result vector.
[0079] The present invention has the following advantages:
[0080] The present invention provides a multi-task LSTM battery capacity prediction method based on attention mechanism, which uses historical capacity data to estimate the capacity at future moments to make it more in line with the actual environment, and applies the attention mechanism to the neural network algorithm, so that the model has the ability to screen inputs to improve the model prediction performance; based on the capacity prediction model of multi-task learning, multiple prediction tasks are performed, and auxiliary prediction tasks are used to improve the accuracy of the main prediction task, thereby improving the prediction accuracy and improving the performance of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0081] Figure 1 A schematic diagram of the convolution process in a multi-task LSTM battery capacity prediction method based on an attention mechanism provided by the present invention;
[0082] Figure 2 The multi-step capacity prediction result in the multi-task LSTM battery capacity prediction method based on the attention mechanism provided by the present invention;
[0083] Figure 3 The verification result of the multi-task mode on B0018 in the multi-task LSTM battery capacity prediction method based on the attention mechanism provided by the present invention;
[0084] Figure 4 A schematic diagram of the attention mechanism in the multi-task LSTM battery capacity prediction method based on the attention mechanism provided by the present invention. DETAILED DESCRIPTION
[0085] The technical solutions in the embodiments of the present invention are described clearly and completely below.
[0086] The present invention is further described in detail below with reference to examples and specific implementation modes.
[0087] A multi-task LSTM battery capacity prediction method based on attention mechanism includes the following steps:
[0088] Based on the collected historical capacity data, predict the capacity value for a certain period of time in the future and build a model:
[0089] C k+w+p-1 =f(C k ,C k+1 ,...,C k+w-1 );
[0090] Among them, w represents the sliding window width, p represents the prediction time interval, and f represents the prediction model proposed in this paper.
[0091] The model uses Multi-task LSTM (MT-LSTM) as the main framework of the model. The model uses a normalization method to limit the data to roughly the same scale, reducing the model's sensitivity to data. The capacity value [C k ,C k+1 ,…,C k+w-1 ] Divide the capacity value C of the previous cycle k-1 , the prediction task now becomes:
[0092]
[0093] The model will perform three prediction tasks: k+w+p-2 , D k+w+p-1 , D k+w+p+1 , where D k+w+p-1 Is the main task of the model D k+w+p-2 and D k+w+p+1 For auxiliary tasks.
[0094] The model contains LSTM, and LSTM is divided into LSTM in the shared layer and LSTM in the unique layer. The LSTM in the shared layer is used to extract the features of the original time series, and the LSTM in the unique layer is used to process the output data of the previous neural network layer and extract features related to the prediction results.
[0095] LSTM uses multiple gating functions to determine the information to be forgotten, remembered, and output, so that information can be selectively transmitted. LSTM mainly consists of three gate structures: forget gate, memory gate, and output gate. The gates interact with each other to improve the information analysis ability of the LSTM model.
[0096] The model uses multiple one-dimensional convolutional layers to learn the output sequence of the shared layer LSTM and convert it into feature sequences of different levels of abstraction;
[0097] One-dimensional convolutional neural network (1D CNN) is a neural network that contains convolution calculations. It can capture the most relevant features of the input data and reduce the noise in the input data;
[0098] Suppose the hidden state input from the previous neural network to the convolutional layer at a certain moment is:
[0099]
[0100] Set a series of convolution kernels as:
[0101]
[0102] Then the input can be mapped to the output space Where s represents the size of the convolution kernel, n represents the dimension of the convolution kernel, which is equal to the dimension of the input, and m represents the number of convolution kernels;
[0103] When the convolution kernel successfully captures a certain feature, it will be activated by the activation function. In the convolution layer, multiple convolution kernels are used to learn in parallel to achieve the purpose of capturing features from multiple angles, and ReLU is used as the activation function of CNN;
[0104] The calculation process is expressed as:
[0105]
[0106] u i =ReLU(v i *H+b i )
[0107] Batch Normalization is added to the one-dimensional convolutional layer to improve the convergence speed and prevent overfitting. The Padding method is used to ensure that the output size is equal.
[0108] A time-step self-attention mechanism is provided and combined with LSTM to process the output of the unique layer LSTM;
[0109] Assume that at the current moment, the attention layer receives As input, the attention layer will now calculate a set of attention weights α based on the input k ,α k+1 ,…α k+w-1 , these attention weights represent the influence of the hidden state at each moment on the result; then the model performs a weighted summation on the input to obtain the result vector l k ;
[0110] The calculation process of the attention layer can be expressed as:
[0111] l k =∑α i h i
[0112] in, represents the weight matrix, w i,j Represents the matrix W a The elements in . and is a trainable parameter, * represents the dot multiplication process of the matrix, l k Represents the result vector.
[0113] To verify our proposed method, we use three batteries (B0005, B0007, B0018) in the NASA dataset for simulation experiments. First, to verify the performance of the proposed model on the capacity prediction task, we select several traditional neural network models to compare with the model proposed in this paper, which are GRU
[17] , LSTM[6], and BP(ANN)
[18] models, which have been proven to have good performance in many studies. After that, to verify that the multi-task model has better accuracy than the single-task model, we use two deep learning models to compare with the model proposed in this paper, which are LSTM-CNN-LSTM model and Deep LSTM model. These two models can simulate the state of the model when it performs the main task and auxiliary task separately. Finally, to verify the role of the attention mechanism, we compare the performance of MT-LSTM with attention mechanism and MT-LSTM without attention mechanism on the test set.
[0114] For B0005 and B0007, the data of the first 70 cycles were used as the training set; for B0018, the data of the first 60 cycles were used as the training set. The capacity data of the 10 cycles after the training set was used as the validation set. We selected the best hyperparameters by evaluating the performance of the model on the validation set. Then, we performed capacity prediction for the three batteries respectively and evaluated the performance of these methods on the test set by different criteria.
[0115] Table 1: Multi-step capacity prediction results:
[0116]
[0117] In neural networks, hyperparameters are set in advance rather than obtained through training. Data-driven models usually require the selection of optimal hyperparameters to optimize model performance. A large hyperparameter search range is more likely to find hyperparameters that achieve the best performance for the model, but it may complicate the search process, take more time, and be inconvenient in actual use. To simplify the search process, we use the grid search method to search for some hyperparameters.
[0118] For MT-LSTM, LSTM, DeepLSTM, LSTM-CNN-LSTM, GRU, and ANN;
[0119] We set the number of hidden states to H = {16, 32, 64},
[0120] In particular, the number of convolution kernels of MTLSTM and LSTM-CNN-LSTM is set to m = {16, 32, 64}.
[0121] For models with multiple LSTM layers in the model, each LSTM layer has the same number of hidden states.
[0122] For B0005 and B0007, the sliding window width is set to w = 15; for B0006, the sliding window width is set to w = 10. The batch size is set to 32. The Adam optimizer is used to train the model, and we use the recommended learning rate Ir = 0.001.
[0123] To prevent overfitting, Early Stopping is used in the training process.
[0124] MAE was used to evaluate the performance of the model on the validation set.
[0125] The calculation process of MAE is as follows:
[0126]
[0127] Where N represents the total number of predicted cycles, represents the capacity prediction value at the i-th cycle, C i Represents the true value of capacity at the i-th cycle.
[0128] Compared with traditional methods:
[0129] A. Multi-step capacity prediction results
[0130] In this section, we analyze the results of multi-step prediction on the test set. In addition to the MAE mentioned above, we also use MSE to analyze the model performance on the test set. Compared with MAE, MSE pays more attention to the points in the prediction results that are significantly different from the actual results. Therefore, using MSE allows us to compare the proposed model with other traditional neural network models in many aspects.
[0131] The calculation process of MSE is as follows:
[0132]
[0133] Where N represents the total number of predicted cycles, represents the capacity prediction value at the i-th cycle, C i Represents the true value of capacity at the i-th cycle.
[0134] The MAE and MSE of each model on the test set are shown in Table 1. According to the results in Table 1, it can be seen that the model MT-LSTM proposed in this paper outperforms the traditional neural network in most cases. In the case where MT-LSTM does not perform as well as other models, the prediction error gap is also small.
[0135] Table 1 shows the prediction results of all models on three batteries.
[0136] For B0005, all models can accurately capture the trend of approximate capacity decrease, but GRU and LSTM models have difficulty in capturing the capacity regeneration phenomenon, so their predicted capacity curves are more linear. The prediction results of ANN contain large noise, so there is a very obvious difference from the actual capacity curve. MT-LSTM, as an improved method, can better capture the capacity regeneration phenomenon, and its prediction results are closer to reality. When the prediction interval is 10, compared with GRU, LSTM and ANN, the MAE of MT-LSTM decreases by 44.2%, 56.9% and 38.2% respectively.
[0137] When the prediction interval increases to 15, the prediction accuracy of most models decreases to a certain extent. For example, the MAE of MT-LSTM increases by 34.4%, and the MAE of LSTM increases by 43.4%. At the same time, the lag of prediction becomes more obvious. This shows that as the prediction interval increases, it becomes difficult to capture the capacity trend and the prediction pressure increases. However, MT-LSTM still outperforms other models most of the time, which also proves the good performance of MT-LSTM. We noticed that the traditional neural network model can capture the capacity regeneration well when predicting the capacity of battery B7. This may be because the capacity change of battery B7 is more regular than that of other batteries.
[0138] This may also be one of the reasons why the accuracy of some traditional neural network models is higher than that of MT-LSTM when the prediction interval is 15.
[0139] In the experiment, all models predicted that the results of battery B18 were worse than those of the other two batteries. This is because the degradation trend of battery B18 is accompanied by a large number of irregular regeneration phenomena, which are difficult for the model to learn in the training set.
[0140] Therefore, these models have difficulty in capturing the characteristics of B18 capacity changes. Figure 2 It can be seen that the accuracy of the traditional neural network model in predicting B18 is much lower, which is greatly mismatched with the actual capacity change. This can also be seen from the sharp increase in MSE.
[0141] Compared with them, the MT-LSTM proposed in this paper can capture the characteristics of capacity changes to a certain extent, so the prediction results are more realistic. In actual prediction, in order to overcome the phenomenon of poor prediction results, we recommend adding some margin to EOL when making RUL predictions to prevent the battery from being replaced in time due to prediction errors.
[0142] B. RUL prediction results
[0143] Based on the capacity prediction results, we can predict when the battery life will reach its end, so that users can replace the battery in time. According to the data description in the data set, when the battery capacity drops to 70% of the nominal capacity, it can be considered that the battery life has reached its end. The nominal capacity of the battery is 2Ah, so the end of life (End of Life, EOL) can be defined as:
[0144] EOL=C×0.7=1.4Ah
[0145] In this section, we analyze the prediction results of each model for RUL. In order to avoid untimely battery replacement due to prediction errors, we set an additional margin of 0.02Ah.
[0146] Therefore, we calculate the number of cycles for the capacity to decay to 1.42Ah based on the capacity prediction results. ER is used to calculate the error between the predicted value and the true value of RUL, which is defined as the difference between the predicted number of cycles to reach EOL and the actual number of cycles to reach EOL. Note that after the battery reaches EOL, due to the capacity regeneration phenomenon, the capacity may still return to above EOL. However, after that, the battery capacity is still lower than EOL for most of the time. Therefore, this article selects the number of cycles to reach EOL for the first time as the basis for RUL prediction. The prediction results of RUL are shown in the table.
[0147] It can be seen from Table 2 that when predicting RUL, the overall performance of MT-LSTM prediction is better than other models. It is worth noting that in most cases, the ER of the three models of GRU, LSTM, and ANN is negative, and the absolute value of their ER is greater than that of MT-LSTM, which shows that the traditional neural network has a very obvious lag in prediction.
[0148] In particular, when predicting B0018, the absolute values of ER of the three models almost all exceed 10. In contrast, this lag phenomenon is significantly improved in MT-LSTM.
[0149] Table 2: RUL prediction results:
[0150]
[0151] Multi-task mode verification:
[0152] In order to verify the role of the multi-task mode in the model proposed in this article, we give the comparison results of the model in multi-task mode and single-task mode in this section. When the model only performs the main task or the first auxiliary task, it can be regarded as an LSTM-CNN-LSTM model and a Deep LSTM model respectively. Therefore, we use the performance of these three models on the test set to verify the improvement of the multi-task mode on the prediction accuracy of the model.
[0153] From the results in Table 3, we can see that the multi-task mode has higher accuracy than the single-task mode in most cases. When the model performs the auxiliary task alone, the prediction accuracy is always poor. When the model performs the main task alone, the performance on B0005 and B0007 is generally not much different, but the multi-task mode still performs better in most cases. For B0018, where the capacity change trend is difficult to capture, the accuracy of the multi-task mode is significantly improved compared to the single-task mode.
[0154] from Figure 3 It can be seen intuitively that MT-LSTM can better predict the trend of capacity decline than the other two models. Therefore, judging from the prediction results of the three battery data sets, multi-task can make the model have stronger learning ability, and it is feasible to complement information in the future to improve model performance.
[0155] Table 3: Multi-task mode verification results:
[0156]
[0157] The improvement of accuracy by attention mechanism.
[0158] This section mainly verifies the role of the attention mechanism. We first select the best hyperparameters for the MT-LSTM model with attention mechanism and the MT-LSTM model without attention mechanism on the validation set, and then select two different sets of hyperparameters to compare the performance of these two models on battery B0005. From the results of the grid search, we can see that the best hyperparameters for MT-LSTM (with Attention) are H=64, m=64; the best hyperparameters for MT-LSTM (without Attention) are H=16, m=16. The results of hyperparameter selection and verification are shown in Table 4.
[0159] From Table 4, Figure 3 It can be seen that MT-LSTM with attention mechanism performs better on almost all hyperparameter combinations. In addition, we found that the accuracy of MT-LSTM with attention mechanism on the validation set is almost always higher than that of MT-LSTM without attention mechanism.
[0160] In summary, the model with attention mechanism has better learning ability.
[0161] Table 4: Attention mechanism verification results.
[0162]
[0163]
[0164] Through the above method, the present invention provides a multi-task LSTM battery capacity prediction method based on the attention mechanism, a multi-task LSTM battery capacity prediction method based on the attention mechanism, which uses historical capacity data to estimate the capacity at future moments to make it more in line with the actual environment, and applies the attention mechanism to the neural network algorithm, so that the model has the ability to filter inputs to improve the model prediction performance; the capacity prediction model based on multi-task learning performs multiple prediction tasks, and uses auxiliary prediction tasks to improve the accuracy of the main prediction task, thereby improving the prediction accuracy and improving the performance of the model.
[0165] The above is only a preferred implementation of a multi-task LSTM battery capacity prediction method based on an attention mechanism disclosed in the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the creative concept of the present invention, which all belong to the protection scope of the present invention.
Claims
1. A multi-task LSTM battery capacity prediction method based on attention mechanism, It is characterized in that It includes the following steps: Step 1: Data preprocessing and model building: Collect historical battery capacity data C 1 ,C 2 ,…,C total , and use a sliding window with a width of w to split the historical capacity data to obtain [C 1 ,C 2 ,...,C w ],[C 2 ,C 3 ,…,C w+1 ], ..., [C k ,C k+1 ,…,C k+w-1 ], ...; for the kth window data, its label value is k+w+p-2, k+w+p-1, and the actual capacity value C at the time k+w+p k+w+p-2 , C k+w+p-1 , C k+w+p ; Then the data is normalized. For the k-th window data and its true value, the normalization process is divided by the capacity value at the previous moment, that is, Step 2: Model calculation: (2.1) Shared LSTM layer Let c k represents the cell state at time k, C k represents the input data at time k, h k represents the hidden state of the output at time k; the LSTM cell at time k will receive three types of input information: c k-1 、h k-1 and C k ; These input information will first be sent to the forget gate and the memory gate for processing; the forget gate is used to forget information, which determines c k-1 Which information will be forgotten? The memory gate is used to filter h k-1 and C k The information that needs to be retained in the calculation process of the forget gate and the memory gate can be expressed as: f k =σ(W f ·[h t-1 ,C t ]+b f ) i k =σ(W i ·[h k-1 ,C k ]+b i ) g k =tanh(W g ·[h k-1 ,C k ]+b g ) After the information is processed by the forget gate and the memory gate, the cell state c at time k k Will be updated accordingly: c k =f k *c k-1 +i k *g k Finally, the output goalkeeper h k-1 , C k and c k To integrate the information: the k =σ(W o [h k-1 ,C k ]+b o ) h k =o k *tanh(c k ) Finally, we get the shared LSTM layer output vector (2.2) Abstract feature extraction based on one-dimensional convolutional neural network: This paper uses multiple one-dimensional convolutional layers to learn the output vector of the shared layer LSTM and convert it into feature sequences with different levels of abstraction; the input of the first one-dimensional convolutional layer is The input of the second and third convolutional layers is the hidden state of the output of the previous convolutional layer, that is, [U 1 ,U 2 ,...,U w ]; the calculation process of the convolutional layer is as follows: The core idea of the convolutional layer is to learn the features of the input sequence through the convolution operation of the convolution kernel; suppose the hidden state input from the previous neural network to the convolutional layer at a certain moment is: Set a series of convolution kernels as: The convolution operation can map the input sequence to the output space. Among them, s represents the size of the convolution kernel, n represents the dimension of the convolution kernel, which is equal to the dimension of the input sequence, and m represents the number of convolution kernels; When the convolution kernel successfully captures a certain feature, it will be activated by the activation function; in the convolution layer, multiple convolution kernels are used for parallel learning in order to capture features from multiple angles; the ReLU function is used as the activation function of the one-dimensional convolution layer; we add Batch Normalization to the one-dimensional convolution layer to improve the convergence speed and prevent overfitting; the convolution layer calculation process is expressed as: R i =v i *H+b i U = ReLU(BN(R)) Among them, R i Represents the i-th convolution kernel v i The feature vector obtained after the convolution operation, b i represents the bias, and U represents the output of the one-dimensional convolutional layer; (2.3), Private LSTM layer: The function of the private LSTM layer is to perform a separate prediction task based on the common features extracted by the shared layer. The calculation process is similar to that of the shared LSTM layer. Let c k represents the cell state at time k, x k represents the input data at time k, h k represents the hidden state output at time k; for the first private LSTM layer, its input data is For the second and third private LSTM layers, their input data is the output vector of the CNN layer: f k =σ(W f ·[h t-1 ,C t ]+b f ) i k =σ(W i ·[h k-1 ,C k ]+b i ) g k =tanh(W g ·[h k-1 ,C k ]+b g ) c k =f k *c k-1 +i k *g k the k =σ(W o [h k-1 ,C k ]+b o ) h k =o k *tanh(c k ) Finally, each private LSTM layer output vector is obtained (2.4) Attention layer: The attention layer receives the output vector of the previous private LSTM layer As input; The attention calculation process is as follows: W a =W*h+b in, represents the weight matrix, w i,j Represents the matrix W a Elements in and is a trainable parameter, * represents the dot multiplication process of the matrix; The weighted sum of the attention and input gives the resulting vector: l k =∑α i h i The result vector is calculated through the fully connected layer to get the predicted value: y k =W k l k +b k Step 3: Model training and prediction: [C 1 ,C 2 ,...,C w ],[C 2 ,C 3 ,...,C w+1 ], ..., [C k ,C k+1 ,…,C k+w-1 ], ... and their corresponding label values are used as training sets, and the loss function is calculated during the training process; Update the gradient of the model's internal parameters according to the loss function and iterate (back propagation); Once the model training is complete, predictions can be made.
2. According to claim 1, a multi-task LSTM battery capacity prediction method based on attention mechanism, It is characterized in that The model uses Multi-task LSTM (MT-LSTM) as the main framework of the model. The model uses a normalization method to limit the data to roughly the same scale, reducing the model's sensitivity to the data. The capacity value [C k ,C k+1 ,…,C k+w-1 ] Divide the capacity value C of the previous cycle k-1 , the prediction task now becomes: The model will perform three prediction tasks: k+w+p-2 , D k+w+p-1 , D k+w+p+1 , where D k+w+p-1 Is the main task of the model; D k+w+p-2 and D k+w+p+1 For auxiliary tasks.
3. According to claim 2, a multi-task LSTM battery capacity prediction method based on attention mechanism, It is characterized in that The model contains LSTM, and LSTM is divided into LSTM in the shared layer and LSTM in the unique layer. The LSTM in the shared layer is used to extract the features of the original time series, and the LSTM in the unique layer is used to process the output data of the previous neural network layer and extract features related to the prediction results.
4. According to claim 3, a multi-task LSTM battery capacity prediction method based on attention mechanism, It is characterized in that The model uses multiple one-dimensional convolutional layers to learn the output sequence of the shared layer LSTM and convert it into feature sequences with different levels of abstraction. A one-dimensional convolutional neural network is a neural network that includes convolution calculations. It can capture the most relevant features of the input data and thus reduce the noise in the input data. Suppose the hidden state input from the previous neural network to the convolutional layer at a certain moment is: Set a series of convolution kernels as: Then the input can be mapped to the output space Where s represents the size of the convolution kernel, n represents the dimension of the convolution kernel, which is equal to the dimension of the input, and m represents the number of convolution kernels; When the convolution kernel successfully captures a certain feature, it will be activated by the activation function; multiple convolution kernels are used in the convolution layer to learn in parallel to achieve the purpose of capturing features from multiple angles, and ReLU is used as the activation function of CNN; The calculation process is expressed as: her i =ReLU(v i *H+b i ) Batch Normalization is added to the one-dimensional convolutional layer to improve the convergence speed and prevent overfitting. The Padding method is used to ensure that the output size is equal.
5. According to claim 3, a multi-task LSTM battery capacity prediction method based on attention mechanism, It is characterized in that The self-attention mechanism of the time step, combining it with LSTM; Assume that at the current moment, the attention layer receives As input, the attention layer will now calculate a set of attention weights α based on the input k ,α k+1 ,…α k+w-1 , these attention weights represent the influence of the hidden state at each moment on the result; then the model performs a weighted summation on the input to obtain the result vector l k ; The calculation process of the attention layer can be expressed as: l k =∑α i h i in, represents the weight matrix, w i,j Represents the matrix W a Elements in and is a trainable parameter, * represents the dot multiplication process of the matrix, l k Represents the result vector.
