Metal ion battery voltage prediction method based on SDAE-Transform-ECA model
Through the SDAE-Transform-ECA model, the shortcomings of traditional battery voltage prediction methods in processing complex nonlinear relationships are solved, more accurate battery voltage prediction is achieved, the performance of battery management systems and smart grids is enhanced, and renewable energy storage is optimized.
Patent Information
- Application Number
- CN202510575171.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-06
- Publication Date
- 2025-09-19
AI Technical Summary
Traditional battery capacity prediction methods perform poorly when dealing with complex nonlinear relationships and multidimensional features, making it difficult to accurately predict the voltage of lithium-ion batteries, affecting battery performance evaluation and the safety and reliability of equipment.
A battery voltage prediction method based on the SDAE-Transform-ECA model is adopted. The autoencoder module extracts high-level features, the transformer module captures long-distance dependencies, and the efficient channel attention ECA layer is introduced to enhance the focus on key features, forming a synergistic effect and adapting to complex nonlinear relationships.
The accuracy and robustness of battery voltage prediction are improved, and it can be integrated with the battery management system to achieve real-time voltage prediction, optimize battery usage strategies, and improve the efficiency and reliability of battery management systems, smart grids, and renewable energy storage.
Smart Images

Figure CN120671493A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of metal ion battery voltage prediction and deep learning technology, and in particular to a metal ion battery voltage prediction method based on the SDAE-Transform-ECA model. Background Art
[0002] In modern battery technology, lithium-ion batteries are widely used in portable electronic devices, electric vehicles, and renewable energy storage systems due to their high energy density, long cycle life, and low self-discharge rate. However, with the widespread application of lithium-ion batteries in various fields, accurately predicting their capacity and voltage has become particularly important. Battery capacity prediction not only affects battery performance evaluation but is also directly related to the safety and reliability of the equipment. Traditional battery capacity prediction methods often rely on empirical formulas and simple linear regression models, which often perform poorly when dealing with complex nonlinear relationships and multidimensional features. With the development of data science and machine learning technologies, prediction models based on deep learning have gradually become a research hotspot. Deep learning models can automatically extract high-level features from data and adapt to complex nonlinear relationships, thereby improving prediction accuracy. Summary of the Invention
[0003] The object of the present invention is to provide a prediction method that can improve the accuracy of battery voltage prediction through deep learning technology.
[0004] To achieve the above object, the present invention proposes a metal ion battery voltage prediction method based on the SDAE-Transform-ECA model, comprising the following steps:
[0005] S1: Collect the original battery feature data set and perform preprocessing;
[0006] S2: Build an autoencoder module that uses preprocessed battery data as initial input, extracts high-level features of the battery data, and maps the input data to high-level features.
[0007] S3: Build a transformer module that uses the output of the autoencoder module as the initial input to capture long-range dependencies in battery data, enhance the model's ability to process time series data, and achieve the mapping of high-level features to time-dependent features.
[0008] S4: An efficient channel attention (ECA) layer is introduced after the transformer module to enhance the model’s focus on key features, improve feature extraction capabilities, and complete the mapping of temporal features to key channel weights.
[0009] S5: The ECA-weighted features are directly mapped to scalar voltage values. The prediction model formed by the autoencoder (SDAE) module, the transformer module (Transformer) and the ECA layer is trained and tested to obtain the battery voltage prediction result.
[0010] Furthermore, in step S1, raw battery data is read from a data source (such as a CSV file), wherein the raw battery data includes temperature characteristics, charge state characteristics, discharge state characteristics, and a target variable, wherein the target variable is the average voltage of the battery.
[0011] The preprocessing includes data cleaning, feature selection, data partitioning, standardization, one-hot encoding, and principal component analysis (PCA) dimensionality reduction. The processing methods are as follows:
[0012] A. Data cleaning: remove missing values and outliers to ensure data integrity and accuracy.
[0013] 1) The missing value processing method is: after reading the data, check whether there are missing values in the data frame. Missing values can be handled by interpolation, mean filling or deleting missing rows;
[0014] 2) Outlier detection and processing methods: In a dataset, outliers may have a negative impact on model training, so they need to be detected and processed. Among them, outliers can be identified by the following methods:
[0015] Z-score method: Calculate the Z-score of each data point. The calculation formula of Z-score is:
[0016] Z=(X-μ) / σ
[0017] Where X is the data point, μ is the mean of the feature, and σ is the standard deviation of the feature. Typically, points with an absolute value of Z-score greater than 3 are considered outliers.
[0018] Box plot method: By drawing a box plot, identify the upper and lower quartiles (Q1 and Q3) and the interquartile range (IQR). The calculation formula is: IQR = Q3 - Q1.
[0019] The methods for handling outliers are:
[0020] Remove outliers: Directly remove outliers from the dataset.
[0021] Replace outliers: Replace outliers with the mean or median of the feature.
[0022] B. Feature selection: Extract features useful for the prediction task from the raw data, calculate the correlation between the features and the target variable, and use the Pearson correlation coefficient to measure the linear relationship. Select features with correlations above a certain threshold (such as 0.5) to ensure that the model can capture important information.
[0023] C. Data Partitioning: Divide the dataset into training, validation, and test sets. Stratified sampling is typically used to maintain a consistent distribution of the target variable. The dataset is divided into training and test sets, with the test set typically accounting for 20% of the total data. A validation set is further partitioned from the training set, typically accounting for 20% of the training set.
[0024] D. Standardization: Use the mean and standard deviation to standardize the training set, validation set, and test set to eliminate the dimensional differences between features and ensure the qualitative nature of model training.
[0025] E. One-hot encoding: One-hot encodes categorical features and converts categorical data into numerical data to improve the input validity of the model and prevent the model from misunderstanding the sequential relationship between categories.
[0026] F. Principal Component Analysis (PCA) Dimensionality Reduction: Perform dimensionality reduction on the standardized data, selecting an appropriate number of principal components to retain at least 95% of the variance, extract key features, and reduce computational complexity. The goal of PCA is to find a new feature space that maximizes the variance of the data within that space.
[0027] Furthermore, in step S2, the autoencoder module (SDAE) includes two parts, an encoder and a decoder. The encoder part includes n linear layers, a ReLU activation function, a batch normalization layer and a Dropout layer. Each linear layer is followed by a ReLU activation function to introduce nonlinear features; and a batch normalization layer and a Dropout layer are added after each layer to accelerate the training process and improve the stability of the model, prevent overfitting, and enhance the generalization ability of the model; wherein, the first linear layer maps the input features to 128 dimensions, the second linear layer maps the 128-dimensional output to 64 dimensions, and the third linear layer maps the 64-dimensional output to 32 dimensions; the structure of the decoder part is opposite to that of the encoder structure, and is used to reconstruct the input data. The specific structure is: the first linear layer of the encoder maps the 32-dimensional output back to 64 dimensions, the second linear layer maps the 64-dimensional output back to 128 dimensions, and the third linear layer maps the 128-dimensional output back to the original input dimension.
[0028] Furthermore, in step S3, the transformer module includes an embedding layer and a multi-layer self-attention mechanism: the embedding layer maps the input features to a high-dimensional space to facilitate subsequent self-attention calculations; the multi-layer self-attention mechanism uses multiple attention heads for parallel calculations to capture different subspace feature representations, specifically: the calculation of each attention head includes: linear transformation of query (Q), key (K) and value (V); calculation of attention weights and application to value (V); adding residual connections and layer normalization layers after each self-attention layer to improve the training efficiency and stability of the model. The formula for calculating attention weights is:
[0029] The output of the self-attention layer is further processed by a feedforward neural network layer and combined with a nonlinear activation function to improve the expressiveness of the model. Specifically, the first linear layer maps the input features to 512 dimensions, uses the ReLU activation function, and the second linear layer maps the 512-dimensional output back to 256 dimensions.
[0030] Furthermore, in step S4, the efficient channel attention ECA layer generates channel attention weights by calculating the inter-channel relationship of the input features, thereby dynamically adjusting the importance of the features. The efficient channel attention ECA layer includes an adaptive average pooling layer and a convolution layer. The adaptive average pooling layer is used to perform global average pooling on the feature maps of each channel of the input features and calculate the inter-channel relationship of the input features; the convolution layer uses a 1D convolution operation to generate channel attention weights, and applies the weights to the input features through a Sigmoid activation function, thereby enhancing the model's attention to key features, adjusting the importance of features, and improving prediction accuracy. Specifically, the channel attention weights are generated using a 1D convolution operation.
[0031] Furthermore, in step S5, the model training and testing method is:
[0032] 1) Define the loss function and use the mean square error (MSE) as the loss metric for the regression task to calculate the squared difference between the predicted value and the true value;
[0033] 2) Use the Adam optimizer to test and optimize the model parameters, adopt a learning rate decay strategy, and dynamically adjust the learning rate to accelerate convergence;
[0034] 3) During training, an early stopping mechanism is used to monitor validation loss. If validation loss does not improve within the set patience rounds, training is stopped early to prevent model overfitting and ensure the generalization ability of the model. The specific method is as follows: the patience rounds are set to 20 rounds. If validation loss does not improve within 20 patience rounds, training is stopped early; the best model parameters are saved to ensure that the model with the best performance on the validation set is selected.
[0035] 4) Calculate the mean square error (MSE), root mean square error (RMSE), mean absolute error (MAE) and R 2 Scoring indicators are used to comprehensively evaluate the prediction performance of the model. The calculation methods are as follows:
[0036] Mean Square Error:
[0037] Root mean square error: RMSE = √MSE
[0038] Mean absolute error:
[0039] Scoring indicators:
[0040] 5) Draw the loss curve and a scatter plot of the predicted results and the true values to show the model training process and prediction effect.
[0041] Furthermore, in step S1, the method of data division in the preprocessing is: using a stratified sampling method to divide the data set into a training set, a validation set and a test set, specifically: stratifying the data set according to the quantile of the target variable to ensure that the distribution of the target variable in each subset is consistent with the original data set; setting the training set proportion to 70%, the validation set proportion to 15%, and the test set proportion to 15%.
[0042] Furthermore, the early stopping mechanism is used to monitor the validation loss as follows: 1) setting the patience round to 20 rounds, and stopping training when the validation loss does not decrease within 20 rounds; 2) saving the best model parameters to ensure that the model with the best performance on the validation set is selected.
[0043] Furthermore, the prediction model formed by the autoencoder module, converter module and ECA layer is integrated with the battery management system BMS, providing an API interface, allowing the BMS system to obtain battery voltage prediction results in real time; supporting data interaction with other monitoring systems to achieve a comprehensive evaluation of the battery status.
[0044] Furthermore, the SDAE-Transform-ECA model is a battery voltage prediction model, which includes:
[0045] Data preprocessing module: used to perform standardization, one-hot encoding and principal component analysis on battery voltage data;
[0046] Autoencoder module: used to extract high-level features of battery voltage data, including encoder and decoder parts;
[0047] Transformer module: used to capture long-range dependencies in battery voltage data, including embedding layers and multi-layer self-attention mechanisms;
[0048] Efficient channel attention layer: used to enhance the model's attention to key features, including adaptive average pooling and convolution layers;
[0049] Training and evaluation module: used to train the model, monitor validation loss, and evaluate model performance.
[0050] The SDAE-Transform-ECA model achieves end-to-end mapping through the following chain transformation: raw battery data → preprocessing (normalization, PCA) → SDAE extracts abstract features (32 dimensions) → Transformer captures temporal dependencies (256 dimensions) → ECA strengthens key channels (dynamic weights) → fully connected layer outputs voltage prediction values.
[0051] Furthermore, the data preprocessing module can automatically process battery voltage data in different formats to ensure the consistency and validity of data input. Specifically, it supports reading multiple data formats such as CSV and Excel; automatically identifies numerical and categorical features in the data, and performs corresponding preprocessing.
[0052] Furthermore, the decoder part of the autoencoder module can reconstruct the input data to verify the effectiveness of the feature representation learned by the model. Specifically, during the training process, the reconstruction error is calculated to evaluate the performance of the autoencoder; by minimizing the reconstruction error, it is ensured that the model can effectively learn the feature representation of the input data.
[0053] Furthermore, the multi-layer self-attention mechanism of the converter module can improve the training efficiency and prediction performance of the model through parallel computing. Specifically, through the multi-head attention mechanism, the model can simultaneously focus on different parts of the input data and capture multiple feature relationships; through residual connections and layer normalization, the stability and convergence speed of the model during training are ensured.
[0054] Furthermore, the efficient channel attention layer can adjust the channel attention weight according to the dynamic changes of the input features to adapt to different prediction tasks. Specifically, it dynamically calculates the feature importance of each channel through adaptive average pooling; and uses convolution operations to generate channel attention weights to enhance the model's attention to key features.
[0055] Furthermore, the training and evaluation module facilitates users to analyze model performance by generating loss curves during training and visual charts of prediction results. Specifically, the module uses the Matplotlib library to draw curves of training loss and validation loss; and draws scatter plots of prediction results and true values to intuitively display the prediction effect of the model.
[0056] Furthermore, the battery voltage prediction model is integrated with the battery management system (BMS), specifically by providing an API interface to allow the BMS system to obtain battery voltage prediction results in real time; supporting data interaction with other monitoring systems to achieve a comprehensive evaluation of the battery status.
[0057] The battery voltage prediction model can be widely used in battery management systems, smart grids, renewable energy storage and other fields. The following is a further detailed description of the application scenario:
[0058] Battery Management System (BMS): In electric vehicles and energy storage systems, the BMS monitors and manages the battery's status. Using the model presented in this paper, the BMS can predict battery voltage in real time, optimizing charging and discharging strategies to ensure the battery operates within a safe range. In practice, the BMS can adjust charging and discharging strategies based on the predicted voltage to improve battery efficiency and lifespan.
[0059] Smart Grid: In smart grids, batteries serve as energy storage devices, balancing electricity supply and demand. By accurately predicting battery voltage, smart grids can better manage battery charging and discharging, improving grid stability and reliability. In practice, smart grids can adjust power distribution and scheduling strategies based on battery voltage predictions to address fluctuations in power demand.
[0060] Renewable energy storage: In renewable energy systems like wind and solar, batteries are used to store excess energy. The model presented in this paper predicts battery voltage fluctuations, optimizing energy storage and release strategies and improving overall system efficiency. In practice, the system can use battery voltage predictions to determine when to store and release excess energy, maximizing renewable energy utilization.
[0061] Compared with the prior art, the advantages of the present invention are:
[0062] 1. The present invention uses deep learning technology to construct a battery voltage prediction model, combining autoencoders, converters, and ECA mechanisms for integrated battery voltage prediction. The autoencoder SADE dynamically strengthens key channels and extracts high-level features to address the problem of insufficient expressiveness of traditional linear models. The converter module is used to capture long-term dependencies (capturing the cross-time-step correlation of voltage changes). At the same time, the ECA layer adaptively focuses on features that significantly affect voltage, enhancing the model's focus on important features and forming a synergistic effect. This allows for feature fusion and reshaping, adapting to complex nonlinear relationships, and resolving the technical issues of traditional methods in feature extraction and model fusion, improving the accuracy and robustness of the overall prediction model.
[0063] 2. The SDAE-Transform-ECA battery voltage prediction model constructed by combining the autoencoder, the transformer and the ECA mechanism in the method of the present invention can be integrated with the battery management system (BMS) to achieve real-time voltage prediction through the API interface. It can be widely used in battery management systems, smart grids, renewable energy storage and other fields. Through modular integration and structural optimization, it solves the problems of complex nonlinearity, long time series dependence and dynamic changes in feature importance in battery data, provides more reliable support for battery management systems, provides new ideas for the intelligent management and optimized use of lithium-ion batteries, and promotes the further development of battery technology.
[0064] 3. The present invention adopts targeted structural design in constructing the SDAE-Transform-ECA battery voltage prediction model. Among them, the autoencoder SDAE adopts a specific layer structure, namely 128→64→32-dimensional encoding, ReLU+batch normalization+Dropout to prevent overfitting; the feedforward network of the transformer layer is designed to be 512→256-dimensional to adapt to the battery data dimension; ECA uses 1D convolution (kernel size 3) to generate attention weights to improve computational efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 Schematic diagram of the process of a metal ion battery voltage prediction method based on the SDAE-Transform-ECA model according to an embodiment of the present invention;
[0066] Figure 2 This is a scatter plot of average voltage prediction results obtained by cross-validating the trained model based on the dataset of the optimal feature combination in an embodiment of the present invention;
[0067] Figure 3 4 is a schematic flow chart of the algorithm structure of two encoders in the simplified Transform module in the SDAE-Transform-ECA model in an embodiment of the present invention. DETAILED DESCRIPTION
[0068] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be further described below.
[0069] This embodiment proposes a metal ion battery voltage prediction method based on the SDAE-Transform-ECA model, such as Figure 1 As shown, the following steps are included:
[0070] S1, numerical reading and preprocessing: collect the original characteristic data set of the battery and perform preprocessing;
[0071] Use appropriate tools (such as the Pandas library in Python) to read a battery dataset from a data source (such as a CSV file). The dataset should contain multiple features (such as temperature, state of charge, state of discharge, etc.) and a target variable (such as the average battery voltage). When reading data, check the path and format of the data file to ensure that the file exists and is in the correct format.
[0072] The collected feature data is preprocessed, including data cleaning, feature selection, data partitioning, standardization, one-hot encoding, and principal component analysis (PCA) dimensionality reduction. The processing methods are as follows:
[0073] A. Data cleaning: Use the dropna and loc methods of Pandas to clean the data, remove missing values and outliers, and ensure the integrity and accuracy of the data.
[0074] 1) The missing value processing method is as follows: After reading the data, check whether there are missing values in the data frame. Missing values can be handled by interpolation, mean filling, or deleting missing rows. In this example, the isnull() and fillna() methods of Pandas are used to identify and fill missing values.
[0075] 2) Outlier detection and processing methods: In a dataset, outliers may have a negative impact on model training, so they need to be detected and processed. Among them, outliers can be identified by the following methods:
[0076] Z-score method: Calculate the Z-score of each data point. The calculation formula of Z-score is:
[0077] Z=(X-μ) / σ
[0078] Where X is the data point, μ is the mean of the feature, and σ is the standard deviation of the feature. Typically, points with an absolute value of Z-score greater than 3 are considered outliers.
[0079] Box plot method: By drawing a box plot, identify the upper and lower quartiles (Q1 and Q3) and the interquartile range (IQR). The calculation formula is: IQR = Q3 - Q1.
[0080] The methods for handling outliers are:
[0081] Remove outliers: Directly remove outliers from the dataset.
[0082] Replace outliers: Replace outliers with the mean or median of the feature.
[0083] B. Feature selection: Extract features useful for the prediction task from the raw data, calculate the correlation between the features and the target variable, and use the Pearson correlation coefficient to measure the linear relationship. Select features with correlations above a certain threshold (such as 0.5) to ensure that the model can capture important information.
[0084] C. Data Partitioning: Stratified sampling is used, using the train_test_split function to partition the dataset into training, validation, and test sets to maintain a consistent distribution of the target variable. The dataset is divided into training and test sets, with the test set typically comprising 20% of the total data. A validation set is further partitioned from the training set, typically comprising 20% of the training set. In this embodiment, the dataset is stratified by quantile of the target variable to ensure that the distribution of the target variable in each subset is consistent with the original dataset; the training set is set to 70%, the validation set to 15%, and the test set to 15%.
[0085] D. Standardization: StandardScaler is used to standardize the features. The calculation method is to subtract the mean of each feature from the feature value and then divide it by the standard deviation of the feature. The mean and standard deviation of each feature are calculated and used to standardize the features so that the mean of each feature is 0 and the standard deviation is 1.
[0086] E. One-hot encoding: Use the get_dummies() method of pandas to one-hot encode categorical features and convert categorical data into numerical data to improve the input validity of the model and avoid the model from misunderstanding the sequential relationship between categories.
[0087] F. Principal Component Analysis (PCA) Dimensionality Reduction: Perform PCA dimensionality reduction on the standardized data, calculate the standardized feature covariance matrix, calculate the eigenvalues and eigenvectors of the covariance matrix, select the first k eigenvectors with the largest eigenvalues to form a projection matrix, and project the standardized feature matrix into the new feature space.
[0088] G. Data balance: In some cases, the dataset may have class imbalance, especially in regression tasks. In order to improve the generalization ability of the model, the following methods can be used to balance the data:
[0089] Oversampling: Duplicate minority class samples to increase their proportion in the dataset;
[0090] Undersampling: Randomly delete majority class samples to reduce their proportion in the dataset;
[0091] Synthetic minority samples: Use algorithms such as SMOTE (Synthetic Minority Over-sampling Technique) to generate new minority samples.
[0092] S2. Feature Engineering: By transforming, combining, or creating new features from the original features, you can enhance the model's learning ability and improve model performance. Specific implementation steps include:
[0093] Feature transformation: Perform logarithmic transformation, square root transformation, or standardization on features to reduce the skewed distribution of features.
[0094] Feature combination: Combine multiple features into new features, such as generating interactive features through multiplication and addition.
[0095] Time series features: If the data contains timestamps, you can extract time features (such as year, month, day, hour) or calculate time differences (such as the difference between the last charging time and the current time)
[0096] S3. Model construction: A battery voltage prediction model, namely the SDAE-Transform-ECA model, is constructed by designing a self-encoder (SDAE), a transformer (Transformer), and an ECA (Efficient Channel Attention) mechanism.
[0097] (1) Constructing a self-encoder module (SDAE) with pre-processed battery data as initial input to extract high-level features of battery data and realize the mapping from raw input data to high-level features;
[0098] The autoencoder module (SDAE) includes two parts: an encoder and a decoder. In this embodiment, the encoder part includes three linear layers, a ReLU activation function, a batch normalization layer, and a Dropout layer. Each linear layer is followed by a ReLU activation function to introduce nonlinear features. A batch normalization layer and a Dropout layer are added after each layer to accelerate the training process and improve the stability of the model, suppress noise interference, prevent overfitting, extract robust high-level abstract features (such as the nonlinear combination of temperature and charge and discharge state), and enhance the generalization ability of the model. The first linear layer maps the original input features to 128 dimensions, the second linear layer maps the 128-dimensional output to 64 dimensions, and the third linear layer maps the 64-dimensional output to 32 dimensions. The structure of the decoder part is opposite to that of the encoder and is used to reconstruct the input data. The specific structure is: the first linear layer of the encoder maps the 32-dimensional output back to 64 dimensions, the second linear layer maps the 64-dimensional output back to 128 dimensions, and the third linear layer maps the 128-dimensional output back to the original input dimension. The feature validity is verified by minimizing the reconstruction error (MSE) to ensure that the encoder captures key information.
[0099] In this embodiment, a simplified autoencoder model is constructed, and the output of the encoder can be expressed as:
[0100] h=f(We*x+be)
[0101] Where x is the input feature, We is the encoder weight, be is the bias, and f is the activation function (such as ReLU). When designing the encoder, consider the number of layers and the number of neurons in each layer to ensure that the model can effectively learn the representation of the input features.
[0102] The output of the decoder can be expressed as:
[0103] ^=g(Wd*h+bd)
[0104] Where Wd is the decoder weight, bd is the bias, and g is the activation function. The decoder structure should be symmetrical with the encoder to facilitate reconstruction of the input data.
[0105] The loss function of the autoencoder usually uses the mean squared error (MSE) to measure the reconstruction error.
[0106] (2) Construct a transformer module (Transformer), using the output of the autoencoder module as the initial input. The transformer module is constructed on the output of the autoencoder to capture the long-range dependencies in the battery data, enhance the model's ability to process time series data, and realize the mapping of high-level features to time-dependent features.
[0107] The Transformer module includes an embedding layer and a multi-layer self-attention mechanism: the 32-dimensional features output by the encoder are mapped to a high-dimensional space (such as 256 dimensions) through the embedding layer to facilitate subsequent self-attention calculations; the multi-layer self-attention mechanism uses multiple attention heads for parallel calculations to capture the representation of different subspace features. Specifically, the calculation of each attention head includes: linear transformation of query (Q), key (K) and value (V); calculation of attention weights and application to value (V); adding residual connections and layer normalization layers after each self-attention layer to improve the training efficiency and stability of the model. The formula for calculating attention weights is: Through multi-head attention calculation, the output of each attention head is spliced and then stabilized by residual connection + layer normalization (LayerNorm).
[0108] The self-attention output is nonlinearly transformed through a feedforward neural network layer. The output of the self-attention layer is further processed and combined with a nonlinear activation function to improve the model's expressiveness. The design should consider the number of layers in the feedforward network and the number of neurons in each layer. Specifically, the first linear layer maps the input features (256 dimensions) to 512 dimensions using the ReLU activation function. The second linear layer maps the 512-dimensional output back to 256 dimensions, enhancing the expressiveness of temporal features.
[0109] Figure 3 This is a schematic flowchart of the algorithm structure of the two encoders in the simplified Transform module in the SDAE-Transform-ECA model.
[0110] (3) An efficient channel attention (ECA) mechanism layer is introduced after the transformer module to enhance the model’s focus on key features, improve feature extraction capabilities, and achieve the mapping of temporal features to key channel weights;
[0111] The Efficient Channel Attention (ECA) layer calculates the inter-channel relationship of the input features and generates channel attention weights, thereby dynamically adjusting the importance of the features. The ECA layer includes an adaptive average pooling layer and a convolutional layer:
[0112] Adaptive average pooling layer: used to perform global average pooling on the feature maps of each channel of the input features and calculate the channel-to-channel relationship of the input features. In this embodiment, the adaptive average pooling layer will globally average the 256-dimensional temporal features output by the Transformer to generate channel-level statistics.
[0113] Convolutional layer: Uses a 1D convolution operation with a kernel size of 3 to generate channel attention weights (for example, certain temperature channels or time step features are more important). The weights are applied to the input features through the Sigmoid activation function, dynamically adjusting the contribution of each channel (for example, highlighting the impact of abnormal temperature on voltage). This enhances the model's focus on key features, adjusts feature importance, and improves prediction accuracy.
[0114] (4) A fully connected layer (FC) is added to the output of the ECA layer to map the features to the final output dimension, which is the average voltage of the battery.
[0115] In this embodiment, the 256-dimensional features after ECA weighting are directly mapped to scalar voltage values through a fully connected layer, and its numerical expression is:
[0116] V pred =W FC *EAC(Transform(SDAE(X input )))+bFC
[0117] Among them, X input is the preprocessed input data, W FC and b FC are the parameters of the fully connected layer.
[0118] (5) The prediction model formed by the autoencoder (SDAE) module, transformer module (Transformer) and ECA layer is trained and tested to obtain the battery voltage prediction results.
[0119] The model training process includes forward propagation, loss calculation, and backpropagation. The specific model training and testing methods are as follows:
[0120] a) Define the loss function and use the mean square error (MSE) as the loss metric for the regression task to calculate the square difference between the predicted value and the true value.
[0121] b) Hyperparameter Tuning: During model training, the selection of hyperparameters has a significant impact on model performance. Common hyperparameters include learning rate, batch size, number of training rounds, and hidden layer dimensions. Hyperparameter tuning can be performed using methods such as grid search or random search to find the optimal hyperparameter combination. The Adam optimizer is used to test and optimize model parameters, employing a learning rate decay strategy to dynamically adjust the learning rate to accelerate convergence.
[0122] c) Monitoring the training process: During training, an early stopping mechanism is used to monitor validation loss to determine the training effect of the model. If the validation loss does not improve within the set patience rounds, training is stopped early to prevent model overfitting and ensure the generalization ability of the model. The specific method is as follows: the patience rounds are set to 20 rounds. If the validation loss does not improve within 20 patience rounds, training is stopped early. The optimal model parameters are saved to ensure that the model with the best performance on the validation set is selected.
[0123] d) Saving and loading the model: After training is complete, the trained model must be saved to disk for later use. You can use serialization methods (such as Pickle or Joblib) to save the model to a file. When loading the model, ensure that the model structure is consistent with the saved structure.
[0124] e) After the model training is completed, the test set is used to evaluate the model. The evaluation indicators include mean square error (MSE), root mean square error (RMSE), mean absolute error (MAE) and R 2 Scoring, calculating mean square error MSE, root mean square error RMSE, mean absolute error MAE and R 2 Scoring indicators are used to comprehensively evaluate the prediction performance of the model. The calculation methods are as follows:
[0125] Mean Square Error:
[0126] Root mean square error: RMSE = √MSE
[0127] Mean absolute error:
[0128] Scoring indicators:
[0129] In this embodiment, the specific steps of model evaluation are:
[0130] 1) Evaluation: Input the test set into the trained model and calculate the model's predictions. Calculate the model's performance using the defined evaluation metrics to determine the model's generalization ability.
[0131] 2) Result visualization: By drawing the loss curve and the scatter plot of the predicted value and the true value, the model training process and prediction effect are intuitively displayed. The loss curve shows the trend of the training and validation loss, and the scatter plot shows the accuracy of the model prediction. The visualization results can help researchers and engineers better understand the performance of the model and the direction of improvement. Figure 2 As shown in the figure, a scatter plot of the average voltage prediction results is obtained after cross-validation of the trained model based on the dataset with the optimal feature combination.
[0132] 3) Model Comparative Analysis: Compare the proposed model with other benchmark models (e.g., linear regression, decision tree, random forest, etc.) to assess the strengths and potential for improvement. This comparative analysis can identify the strengths and weaknesses of the model and provide a reference for subsequent research.
[0133] In this embodiment, the SDAE-Transform-ECA battery voltage prediction model includes:
[0134] Data preprocessing module: used to perform standardization, one-hot encoding, and principal component analysis on battery voltage data; the data preprocessing module can automatically process battery voltage data in different formats to ensure the consistency and validity of data input. Specifically, it supports reading multiple data formats such as CSV and Excel; automatically identifies numerical and categorical features in the data, and performs corresponding preprocessing.
[0135] Autoencoder module: This module is used to extract high-level features from battery voltage data and consists of an encoder and a decoder. The decoder portion of the autoencoder module reconstructs the input data to verify the effectiveness of the feature representation learned by the model. Specifically, during training, the reconstruction error is calculated to evaluate the performance of the autoencoder. By minimizing the reconstruction error, the model is ensured to effectively learn the feature representation of the input data.
[0136] Converter module: This module is used to capture long-range dependencies in battery voltage data and includes an embedding layer and a multi-layer self-attention mechanism. The multi-layer self-attention mechanism of the converter module can improve the model's training efficiency and prediction performance through parallel computing. Specifically, through the multi-head attention mechanism, the model can simultaneously focus on different parts of the input data and capture multiple feature relationships. Residual connections and layer normalization ensure the stability and convergence speed of the model during training.
[0137] Efficient channel attention layer: used to enhance the model's attention to key features, including adaptive average pooling and convolution layers; the efficient channel attention layer can adjust the channel attention weight according to the dynamic changes of input features to adapt to different prediction tasks. Specifically: through adaptive average pooling, the feature importance of each channel is dynamically calculated; convolution operations are used to generate channel attention weights to enhance the model's attention to key features.
[0138] The Training and Evaluation module is used to train the model, monitor validation loss, and evaluate model performance. This module generates visualizations of the training loss curve and prediction results, making it easier for users to analyze model performance. Specifically, it uses the Matplotlib library to plot the training and validation loss curves and creates scatter plots of the prediction results against the true values to visually demonstrate the model's prediction performance.
[0139] The above prediction model can be integrated with the battery management system (BMS), providing an API interface that allows the BMS system to obtain battery voltage prediction results in real time; it supports data interaction with other monitoring systems to achieve a comprehensive assessment of battery status.
[0140] The above description is merely a preferred embodiment of the present invention and does not limit the present invention in any way. Any person skilled in the art who, without departing from the scope of the present invention, makes any equivalent substitution, modification, or other changes to the technical solution and technical content disclosed in the present invention shall be deemed to be within the scope of the present invention and still fall within the scope of protection of the present invention.
Claims
1. A metal ion battery voltage prediction method based on the SDAE-Transform-ECA model, characterized in that: The steps include: S1: Collect the original battery feature data set and perform preprocessing; S2: Build an autoencoder module that takes the preprocessed battery data as initial input and extracts high-level features of the battery data; S3: Construct a transformer module that takes the output of the autoencoder module as initial input to capture long-range dependencies in the battery data; S4: An efficient channel attention (ECA) layer is introduced after the transformer module to enhance feature extraction capabilities. S5: Train and test the prediction model formed by the autoencoder module, the converter module, and the ECA layer to obtain the battery voltage prediction result.
2. The metal ion battery voltage prediction method based on the SDAE-Transform-ECA model according to claim 1, characterized in that: In step S1, the battery raw data includes temperature characteristics, charge state characteristics, discharge state characteristics and target variables, and the target variable is the average voltage of the battery; the preprocessing includes data reading, data cleaning, data partitioning, standardization processing, one-hot encoding processing, and principal component analysis (PCA) dimensionality reduction processing.
3. The metal ion battery voltage prediction method based on the SDAE-Transform-ECA model according to claim 1, characterized in that: In step S2, the autoencoder module includes an encoder and a decoder. The encoder part includes n linear layers, a ReLU activation function, a batch normalization layer, and a Dropout layer. Each linear layer is followed by a ReLU activation function to introduce nonlinear features. A batch normalization layer and a Dropout layer are added after each layer to prevent overfitting; the first linear layer maps the input features to 128 dimensions, the second linear layer maps the 128-dimensional output to 64 dimensions, and the third linear layer maps the 64-dimensional output to 32 dimensions; the structure of the decoder part is opposite to that of the encoder, and is used to reconstruct the input data. The specific structure is: the first linear layer of the encoder maps the 32-dimensional output back to 64 dimensions, the second linear layer maps the 64-dimensional output back to 128 dimensions, and the third linear layer maps the 128-dimensional output back to the original input dimension. Each layer is followed by a ReLU activation function and a batch normalization layer.
4. The metal ion battery voltage prediction method based on the SDAE-Transform-ECA model according to claim 1, characterized in that: In step S3, the transformer module includes an embedding layer and a multi-layer self-attention mechanism: the embedding layer maps the input features to a high-dimensional space; the multi-layer self-attention mechanism captures the feature representations of different subspaces through parallel calculations of multiple attention heads, specifically: the calculation of each attention head includes: linear transformation of query, key and value; calculation of attention weights and application to values; adding residual connections and layer normalization layers after each self-attention layer; Among them, the formula for calculating the attention weight is: The output of the self-attention layer is further processed by a feedforward neural network layer and combined with a nonlinear activation function to improve the expressiveness of the model. Specifically, the first linear layer maps the input features to 512 dimensions, uses the ReLU activation function, and the second linear layer maps the 512-dimensional output back to 256 dimensions.
5. The metal ion battery voltage prediction method based on the SDAE-Transform-ECA model according to claim 1, characterized in that: In step S4, the efficient channel attention ECA layer includes an adaptive average pooling layer and a convolution layer. The adaptive average pooling layer is used to perform global average pooling on the feature map of each channel of the input feature and calculate the channel relationship of the input feature; the convolution layer uses a 1D convolution operation to generate channel attention weights and applies the weights to the input features through a Sigmoid activation function.
6. The metal ion battery voltage prediction method based on the SDAE-Transform-ECA model according to claim 1, characterized in that: In step S5, the model training and testing method is: 1) Define the loss function and use the mean square error (MSE) as the loss metric for the regression task to calculate the squared difference between the predicted value and the true value; 2) Use the Adam optimizer to test and optimize the model parameters, adopt a learning rate decay strategy, and dynamically adjust the learning rate to accelerate convergence; 3) Use early stopping mechanism to monitor validation loss and prevent model overfitting; 4) Calculate the mean square error (MSE), root mean square error (RMSE), mean absolute error (MAE) and R 2 Scoring metrics to comprehensively evaluate the model’s predictive performance; 5) Draw the loss curve and a scatter plot of the predicted results and the true values to show the model training process and prediction effect.
7. The metal ion battery voltage prediction method based on the SDAE-Transform-ECA model according to claim 1, characterized in that: In step S1, the method of data division in the preprocessing is: using a stratified sampling method to divide the data set into a training set, a validation set and a test set, specifically: stratifying the data set according to the quantile of the target variable to ensure that the distribution of the target variable in each subset is consistent with the original data set; setting the training set to account for 70%, the validation set to account for 15%, and the test set to account for 15%.
8. The metal ion battery voltage prediction method based on the SDAE-Transform-ECA model according to claim 6, characterized in that: The specific method of using the early stopping mechanism to monitor the validation loss is as follows: 1) set the patience round to 20 rounds, and stop training when the validation loss does not decrease within 20 rounds; 2) save the best model parameters to ensure that the model with the best performance on the validation set is selected.
9. The metal ion battery voltage prediction method based on the SDAE-Transform-ECA model according to claim 1, characterized in that: The prediction model formed by the autoencoder module, converter module and ECA layer is integrated with the battery management system BMS, providing an API interface, allowing the BMS system to obtain battery voltage prediction results in real time; supporting data interaction with other monitoring systems to achieve a comprehensive evaluation of the battery status.
10. The metal ion battery voltage prediction method based on the SDAE-Transform-ECA model according to claim 1, characterized in that: The SDAE-Transform-ECA model is a battery voltage prediction model, which includes: Data preprocessing module: used to perform standardization, one-hot encoding and principal component analysis on battery voltage data; Autoencoder module: used to extract high-level features of battery voltage data, including encoder and decoder parts; Transformer module: used to capture long-range dependencies in battery voltage data, including embedding layers and multi-layer self-attention mechanisms; Efficient channel attention layer: used to enhance the model's attention to key features, including adaptive average pooling and convolution layers; Training and evaluation module: used to train the model, monitor validation loss, and evaluate model performance.