Spare part inventory data prediction method, system, equipment and medium
By combining the advantages of CNN, LSTM and Transformer, a comprehensive model that can effectively process spare parts inventory data is built, solving the shortcomings of the existing technology in capturing long-term and global dependencies, and significantly improving the prediction effect.
Patent Information
- Application Number
- CN202411935432.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-04-25
AI Technical Summary
When processing spare parts inventory data in the prior art, it is difficult to effectively capture the long-term dependencies and global dependencies of the data, resulting in poor prediction results.
The CNN-LSTM-Transformer combination model is adopted to extract local features through convolutional neural networks, and the long-term memory network captures long-term dependencies. The Transformer calculates global dependencies through self-attention mechanism to form a comprehensive model for prediction.
This model can more accurately capture local and global patterns in spare parts inventory data, improve the accuracy and reliability of prediction, and effectively solve the problem of sparse data prediction.
Smart Images

Figure CN119886428A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of inventory data prediction, and in particular, relates to a method, system, device and medium for predicting inventory data of spare parts. Background Art
[0002] In the manufacturing and service industries, inventory management of spare parts is a key link to ensure production continuity and service quality. Reasonable inventory management can not only reduce the operating costs of enterprises, but also improve production efficiency and customer satisfaction. However, since the demand for spare parts is usually irregular and low-frequency, inventory data often shows significant sparsity, which brings great challenges to prediction. The demand for spare parts has the following characteristics: First, the usage patterns of different accessories vary significantly. For example, some parts are prone to periodic failures, while other parts rarely fail. This difference makes it difficult to use a unified model to predict the demand for all parts. Secondly, the selection of prediction models traditionally often relies on manual experience rather than selecting the most suitable model by analyzing the rules of the accessory samples themselves. This method is highly subjective and easily leads to low accuracy of prediction results.
[0003] Traditional inventory forecasting methods mainly include time series-based analysis methods and machine learning-based methods. Time series analysis methods, such as RNN, ARIMA model, exponential smoothing, etc., perform well when processing data with strong regularity, but their forecasting results are often unsatisfactory when dealing with sparse data and sudden needs. Machine learning-based methods, such as support vector machines and random forests, have improved the flexibility and accuracy of forecasting to a certain extent, but they still face challenges when dealing with high-dimensional data and sparse data.
[0004] In recent years, deep learning models have made significant progress in the field of time series forecasting. Convolutional neural networks (CNNs) can effectively process spatial structured data and local patterns in time series data due to their powerful feature extraction capabilities. However, in the context of spare parts data, CNNs are insufficient in capturing long-term dependencies in time series. This is because spare parts data is often sparse, which makes it difficult for pure CNN models to capture the global features and long-term trends of the data when processing such data.
[0005] Long short-term memory (LSTM) networks are widely used in time series forecasting because they can capture long-term dependencies in time series through their gating mechanism. However, although LSTM performs well in processing general time series data, it does not work well when processing sparse data such as spare parts. This is mainly because LSTM requires a large amount of data to effectively train its model, and sparse data often does not provide enough information, resulting in a decrease in model performance. In addition, the irregularity and suddenness of demand for spare parts also increase the difficulty of forecasting, making LSTM perform poorly in this specific application scenario.
[0006] In summary, the existing technology has the problem of poor prediction effect on spare parts inventory data. Summary of the invention
[0007] To solve the above problems, the present invention provides a method, system, device and medium for predicting spare parts inventory data, which adopts the CNN-LSTM-TRANSFORMER combined model to predict sparse data, and can solve the problem that the existing model has difficulty in capturing long-term dependencies when processing sparse data, and accurately predict spare parts inventory data with sparsity characteristics.
[0008] The following are technical details of the present invention:
[0009] A method for predicting spare parts inventory data, characterized by comprising:
[0010] Construct a prediction model, wherein the prediction model outputs prediction data of spare parts inventory based on past spare parts inventory data; the prediction model includes:
[0011] A convolutional neural network is used to extract local features of past spare parts inventory data and output a local feature representation z(t) of the past spare parts inventory data;
[0012] LSTM neural network, used to represent z(t) based on local features and the hidden state h of the previous time step t-1 , output the hidden state h of the current time step containing long-term dependency information t ;
[0013] Transformer neural network is used to transform the hidden state h t After being converted into an input embedding vector, a self-attention mechanism is calculated based on the embedding vector to obtain a context vector containing global dependency information in the spare parts data; after adding position encoding to the context vector, the context vector with position encoding is subjected to feature enhancement through a multi-head attention mechanism layer and then input into a feedforward neural network to output future spare parts inventory forecast data;
[0014] After the prediction model is trained, the current spare parts inventory data is obtained, the current spare parts inventory data is input into the trained prediction model, and the prediction data of the future spare parts inventory is output.
[0015] Further,
[0016] The extracting local features of the past spare parts inventory data and outputting the local feature representation z(t) of the past spare parts inventory data comprises:
[0017] Use a one-dimensional convolutional layer to extract local features of past spare parts inventory data and output a feature matrix;
[0018] The feature matrix is processed by ReLU activation function and maximum pooling layer;
[0019] The feature map after the maximum pooling layer is passed to the second one-dimensional convolution layer to further extract local features to obtain the first feature matrix;
[0020] The first feature matrix is processed by the ReLU activation function and the maximum pooling layer to finally obtain the local feature representation z(t).
[0021] Further,
[0022] The local feature representation z(t) and the hidden state h of the previous time step are t-1 , output the hidden state h of the current time step containing long-term dependency information t ;include:
[0023] Use local features to represent z(t) and the hidden state h of the previous time step t-1 Calculate the output i of the input gate in the LSTM network t , the output f of the forget gate t , and generate new candidate cell states
[0024] Using the output i of the input gate t , the output f of the forget gate t , new candidate cell states and the cell state C at the previous time step t-1 Get the current cell state C t ;
[0025]
[0026] Using the current cell state C t , local feature representation z(t), hidden state h of the previous time step t-1 Calculate the hidden state h at the current time step t .
[0027] Further,
[0028] The training of the prediction model comprises:
[0029] Normalize historical spare parts inventory data;
[0030] Divide the normalized data into training set and test set;
[0031] Use the sliding window method to construct the training set into input sequence and output sequence; construct the test set into input sequence and output sequence;
[0032] The prediction model is trained using the input sequence and the output sequence, so that the prediction model outputs future spare parts inventory prediction data based on past spare parts inventory data.
[0033] Further,
[0034] The self-attention mechanism calculation is performed based on the embedding vector to obtain a context vector containing global dependency information in the spare parts data; including:
[0035] Based on the embedding vector, calculate the corresponding query matrix Q, key matrix K and value matrix V;
[0036] Calculate the dot product of the query matrix Q and the key matrix K to get the attention score of each position in the embedded vector, and pass the attention score through the softmax function to get the attention weight of each position in the embedded vector;
[0037] A context vector containing global dependency information in spare parts data is obtained by weighted summation based on the attention weights.
[0038] Further,
[0039] The query matrix Q, key matrix K and value matrix V are calculated as:
[0040]
[0041] Among them, W Q , W K and W V is a learnable weight matrix;
[0042] The attention weight of each vector position in the embedding vector is:
[0043]
[0044] Among them, d k is the dimension of the key vector.
[0045] Further,
[0046] The context vector after adding the position encoding is subjected to feature enhancement through a multi-head attention mechanism layer, including:
[0047] Calculate multiple self-attentions in parallel, concatenate their results and project them into the output space;
[0048] MultiHead(Q,K,V)=Concat(head1,head2,…,head h )W o
[0049] Among them, the calculation of each self-attention is as follows:
[0050]
[0051] in is the output weight matrix, Q is the query matrix, K is the key matrix and V is the value matrix.
[0052] A system for predicting spare parts inventory data, characterized by comprising:
[0053] A model building module is used to build a prediction model, wherein the prediction model outputs prediction data of spare parts inventory based on past spare parts inventory data; the prediction model includes:
[0054] A convolutional neural network is used to extract local features of past spare parts inventory data and output a local feature representation z(t) of the past spare parts inventory data;
[0055] LSTM neural network, used to represent z(t) based on local features and the hidden state h of the previous time step t-1 , output the hidden state h of the current time step containing long-term dependency information t ;
[0056] Transformer neural network is used to transform the hidden state h t After being converted into an input embedding vector, a self-attention mechanism is calculated based on the embedding vector to obtain a context vector containing global dependency information in the spare parts data; after adding position encoding to the context vector, the context vector with position encoding is subjected to feature enhancement through a multi-head attention mechanism layer and then input into a feedforward neural network to output future spare parts inventory forecast data;
[0057] The prediction module is used to obtain the current spare parts inventory data after training the prediction model, input the current spare parts inventory data into the trained prediction model, and output the prediction data of the future spare parts inventory.
[0058] A device for predicting spare parts inventory data, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method for predicting spare parts inventory data.
[0059] A computer storage medium stores executable instructions, which, when executed by a processor, enable the processor to implement the method.
[0060] Compared with the prior art, the present invention has the following advantages:
[0061] The convolutional neural network in the model of the present invention can effectively capture local patterns and sudden changes in spare parts inventory data by using structures such as one-dimensional convolutional layers. For example, when the demand for certain accessories increases significantly during equipment maintenance, it can convert them into local feature representations that can be used later, thus making up for the defects of traditional methods in local feature processing.
[0062] Long short-term memory networks, with their gating mechanism, can handle long-term dependencies in data based on local feature representations extracted by CNN, such as the impact of seasonality and long-term trends on parts demand;
[0063] The Transformer neural network converts the hidden state into an input embedding vector, and then calculates a context vector containing the global dependency information of spare parts data through the self-attention mechanism. After adding the position encoding, it strengthens the features through the multi-head attention mechanism layer and then inputs the feedforward neural network to output the prediction result, which can effectively capture the global dependency relationships such as the association between different accessories.
[0064] Through the collaborative cooperation of the three networks, combined with the process of obtaining current inventory data and inputting it into the trained model, this technology has achieved good results in predicting spare parts inventory data, effectively improving the accuracy and reliability of the prediction.
[0065] Other features and advantages of the present disclosure will be described in the following description, and partly become apparent from the description, or be understood by implementing the present disclosure. The purpose and other advantages of the present disclosure can be realized and obtained by the structures pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0067] Figure 1 A schematic diagram of the method of the present invention is shown. DETAILED DESCRIPTION
[0068] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0069] In order to solve the problem that the existing model has difficulty in capturing long-term dependencies and low prediction accuracy when processing sparse data, the present invention proposes a comprehensive model combining CNN, LSTM and Transformer, which is particularly suitable for spare parts inventory prediction. The technical solution adopted by the present invention to solve its technical problem is as follows:
[0070] Figure 1 A schematic diagram of the method according to the present invention is shown, and the specific implementation details of the present invention include:
[0071] Step 1:
[0072] Spare parts inventory data preprocessing:
[0073] 1) The role of preprocessing: Spare parts inventory data usually contains a lot of noise and outliers. If these data are not processed, it will have an adverse effect on the prediction performance of the model. For example, in spare parts inventory forecasting, spare parts demand data may come from multiple different regions and records of different staff. These data may have problems such as inconsistent formats, missing data, and erroneous records.
[0074] 2) Preprocessing process: In the data preprocessing stage, data cleaning, normalization and missing data filling are required to ensure the continuity and integrity of the data, eliminate the impact of these problems on the model, and improve the accuracy of the prediction.
[0075] Then, the normalized and missing data filled spare parts inventory data set is divided into a training set and a test set for model training and evaluation, respectively. The input in the training set and the test set can be set to the data volume of the past 7 days, and the output can be set to the data volume predicted for the next 1 day.
[0076] 3) Preprocessing process details:
[0077] 3.1 Normalization
[0078] In order to speed up the convergence and improve the accuracy of the model, the spare parts inventory data is normalized. The minimum-maximum normalization method is used to scale the data to the [-1,1] interval:
[0079]
[0080] Wherein, x is the spare parts inventory data, x′ is the normalized spare parts inventory data, min(x) and max(x) are the minimum and maximum values in the spare parts inventory data set, respectively.
[0081] 3.2 Data Partitioning
[0082] The data set of spare parts inventory data after normalization and missing data filling is divided into training set and test set. Assuming that the data length of spare parts inventory data is L, the first cut_point (cut_point can be understood as an identifier representing a number) data is selected as the training set, and the rest is used as the test set.
[0083] train data ={x1,x2,…,x cut _ point},
[0084]
[0085] Among them, train data The meaning is the training data set, test data The meaning is the test data set, x cut_point The spare parts inventory data for the cut_point (it can be counted by time, for example, the spare parts inventory on the first day is x1, on the second day is x2, and so on).
[0086] 3.3 Data Sequence Construction
[0087] Use the sliding window method to construct the input and output in the training set and test set into input sequences and output sequences respectively. Set the input sequence length to T (for example, data from the past 7 days) and the output sequence length to O (for example, data from the next day). For the training set, each input sequence Xi and the corresponding output sequence Y i Defined as:
[0088] X i ={x i ,x i+1 ,…,x i+T-1},
[0089] Y i ={x i+T ,x i+T+1 ,…,x i+T+O-1)}
[0090] Step 2:
[0091] Local feature processing:
[0092] 1) Function: In practical applications, by analyzing historical data, it can be found that the demand for certain accessories increases significantly at specific time points. For example, during equipment maintenance, the demand for certain accessories will suddenly increase. Through the local feature extraction capability of CNN, these local patterns can be effectively captured to improve the prediction ability of the model.
[0093] 2) Local feature processing technology used in the present invention: The demand data for spare parts usually has significant local patterns and sudden changes. For example, the demand for certain accessories may suddenly increase in a specific time period. In order to capture these local patterns, the present invention uses a convolutional neural network (CNN) to extract local features from the data to capture short-term dependencies and sudden changes. Two consecutive CNN modules are used to extract local patterns in time series data to capture short-term dependencies and sudden changes. Each CNN module consists of a 1D-CNN, a ReLU activation function, and a maximum pooling layer.
[0094] 3) Specific process of local feature processing:
[0095] Convolutional Neural Network (CNN) is a deep learning model specially designed to process data with grid topology. It uses convolution operation to capture the local features of input data and is particularly suitable for processing image and time series data.
[0096] 3.1 Use one-dimensional convolutional layer to extract local features of input data:
[0097] The data x in the above input sequence is passed through the first 1D-CNN layer to extract preliminary local features, and the convolution kernel w is set. The convolution kernel size is 3, the step size is 1, the number of output channels is 32, and the output is:
[0098]
[0099] Where y(t) is the output of the first 1D-CNN layer, and k is the size of the convolution kernel. The convolution layer extracts features at different locations by sliding the convolution kernel on the input data.
[0100] 3.2 The output of the first 1D-CNN layer is passed through the ReLU activation function to increase the nonlinearity of the model. This makes gradient descent and back propagation more efficient, accelerates the training of the neural network, and improves the convergence of the network.
[0101] 3.3 The output of the ReLU activation function is downsampled through a maximum pooling layer to reduce the size of the feature map and the number of parameters.
[0102] z(t)=max(x(t),x(t+1),…,x(t+k-1))
[0103] Where z(t) is the output after pooling by the maximum pooling layer. The maximum pooling layer reduces the data dimension by extracting the maximum value of the local area while retaining important features to improve the computational efficiency of the model.
[0104] 3.4 Pass the feature map after the maximum pooling layer to the second 1D-CNN layer to further extract higher-level local features. Set the convolution kernel size to 3, the step size to 1, and the number of channels to 32. After passing through the ReLU activation function and the second maximum pooling layer again, the local feature representation z(t) is finally obtained.
[0105] Through the above convolution and pooling operations, the local features of time series data can be effectively extracted.
[0106] Step 3:
[0107] Long term dependency capture:
[0108] 1) Function: Although local feature extraction can capture short-term dependencies, spare parts demand data usually also contains long-term dependencies. For example, the demand for certain accessories may be affected by seasonal changes and long-term trends.
[0109] 2) Long-term dependency capture method used in the present invention: In practical applications, by analyzing historical data, it can be found that the demand for certain accessories shows obvious seasonal changes and long-term trends. For example, in certain seasons, the frequency of use of equipment is high, and the demand for accessories also increases accordingly. LSTM is a special recursive neural network (RNN). By introducing memory units and gating mechanisms, it effectively solves the shortcomings of traditional RNN in dealing with long-term dependency problems, can effectively capture these long-term dependencies, and improve the prediction ability of the model. Therefore, in order to capture these long-term dependencies, the present invention adopts a long short-term memory network (LSTM).
[0110] 3) Data processing flow in the LSTM module:
[0111] 3.1LSTM receives the local feature representation z(t) of the current time step and the hidden state h of the previous time step recorded in LSTM t-1 The input gate inside the LSTM controls how much of the current input information z(t) needs to be updated into the cell state.
[0112] i t =σ(W i *[h t-1 ,z t ]+b i )
[0113] Among them, W i and b i is the weight matrix and bias vector, σ is the sigmoid activation function, i t is the output of the input gate.
[0114] 3.2 Determine the cell state C through the forget gate inside LSTM t-1 How much information is forgotten in the calculation is achieved by calculating the activation value of the forget gate through this process.
[0115] f t =σ(W i *[h t-1 ,z t ]+b f )
[0116] Among them, W i and b f is the weight matrix and bias vector, σ is the sigmoid activation function, f t is the output of the forget gate.
[0117] 3.3 Based on local feature representation z(t) and the hidden state h of the previous time step t-1 Generate new candidate cell states This candidate state will be used together with the output of the input gate to update the state C of the current cell t .
[0118]
[0119] Among them, W c and b c are the weight matrix and bias vector, and tanh is the activation function.
[0120] Current cell state C t By combining the cell state C of the previous time step t-1 and the current candidate status Update. The output f of the forget gate t Controls the degree to which the cell state at the previous time step is retained, and the output i of the input gate t Controls the extent to which candidate states are introduced.
[0121]
[0122] 3.4 The output gate of LSTM determines the hidden state h of the current time step t How much information to output. The activation value of the output gate together with the updated cell state determines the hidden state.
[0123] o t =σ(W o *[h t-1 ,z t ]+b o )
[0124] h t =σ*tanh(C t )
[0125] Among them, W o is the weight matrix, b o is the bias vector, h t is the hidden state at the current time step.
[0126] Through the above processing flow, LSTM can capture the long-term dependencies in time series data and pass this information to the next layer. Specifically, the local features z extracted by the convolutional layer t After LSTM processing, a hidden state h containing long-term dependency information is generated. t , which provides a basis for subsequent global dependency capture.
[0127] Step 4:
[0128] Global dependency capture integrated optimization
[0129] 1) Function: In spare parts inventory forecasting, the global dependencies of data are equally important. For example, there may be correlations between the demands for different accessories, and changes in the demand for certain accessories may affect the demand for other accessories. In order to capture these global dependencies, the present invention introduces the self-attention mechanism of Transformer to further capture the global dependencies in the data and enhance the prediction ability of the model. Combining the advantages of CNN, LSTM and Transformer, an optimized prediction model suitable for sparse data environments is formed. Use a fully connected layer to map the output of the Transformer to the final prediction result.
[0130] 2) The technology of the present invention: uses Transformer to capture the dependency between distant positions in the input sequence by calculating the attention weight of each position in the input sequence.
[0131] 3) Spare parts data processing flow in Transformer:
[0132] 3.1 The hidden state h of the time step output by the LSTM layer t Convert to input embedding vector X emb .
[0133] X emb =h t *W e
[0134] Among them, W e is the embedding matrix. For each input embedding vector, the corresponding query matrix Q, key matrix K, and value matrix V are calculated.
[0135]
[0136] Among them, W Q , W K and W V is a learnable weight matrix. By calculating the dot product of the query matrix Q and the key matrix K, the attention score of each position is obtained, and then these scores are passed through the softmax function to obtain the attention weight.
[0137]
[0138] Among them, d k is the dimension of the key vector, and the softmax function is used to normalize the attention weights.
[0139] 3.2 Use the attention weight value matrix V to perform weighted summation to obtain the context vector of each position. These context vectors contain the global dependency information in the spare parts data.
[0140] Z = Attention(Q,K,V)
[0141] Since the Transformer model does not have time sequence information, the present invention adds position encoding to the context vector to retain the position relationship of each element in the sequence.
[0142] X pos =X+PositionalEncoding
[0143] 3.3 In order to further enhance the expressiveness of the model, a multi-head attention mechanism is used to calculate multiple self-attentions in parallel, and concatenate the results and project them into the output space.
[0144] MultiHead(Q,K,V)=Concat(head1,head2,…,head h )W o
[0145] The calculation of each head is as follows:
[0146]
[0147] in is the output weight matrix.
[0148] Finally, the output of the multi-head attention mechanism passes through a feed-forward neural network to further extract features.
[0149] 3.4 The output of the multi-head attention mechanism is passed through a feedforward neural network to further extract features.
[0150] FFN(Z)=ReLU(ZW1+b1)W2+b2
[0151] Among them, ReLU is the activation function, FFN(Z) is the output of the feedforward neural network, W1 and W2 are learnable weights, Z is the data input to the feedforward neural network, and b1 and b2 are bias vectors.
[0152] Through the above processing flow, the Transformer model can capture the global dependencies in spare parts data. Combining the advantages of LSTM and Transformer, the model can simultaneously capture long-term and global dependencies in time series, improving the accuracy and robustness of predictions. In summary, through the comprehensive optimization of LSTM's long-term dependency capture and Transformer's global dependency capture, the model of the present invention can more comprehensively understand and predict complex patterns in spare parts data, and achieve high-precision predictions.
[0153] Experimental comparison:
[0154] On a sparse dataset of spare parts, the present invention was trained for 150 epochs and the model of the present invention was compared with four baseline models. Spare parts inventory management is critical to equipment maintenance and operational continuity, and the forecasting model needs to be able to accurately capture demand fluctuations to ensure timely replenishment when demand increases and no inventory backlog when demand decreases. However, the demand data for spare parts is usually very sparse, with long intervals between data points, which makes traditional time series forecasting models perform poorly on such datasets.
[0155] Because CNN can only capture local information, its performance is very poor when directly processing time series data. CNN is effective in spatial data processing, but its application in time series data is limited because it lacks the ability to handle time dependencies. Although RNN and LSTM can be directly used for time series prediction, their performance is poor on sparse data sets such as spare parts due to the poor coherence of sparse data sets. RNN is prone to the problem of gradient disappearance, and although LSTM partially solves this problem by introducing a gating mechanism, the effect on sparse data sets is still not ideal. Although CNN+LSTM makes up for the disadvantages of CNN, RNN and LSTM to a certain extent, the effect on sparse data sets is still not ideal. The predicted data is a smooth curve, and the demand change law of spare parts has not been truly learned.
[0156] The performance of the prediction model based on CNN-LSTM-Transformer proposed in the present invention on sparse data sets is significantly better than the above-mentioned baseline model. Specifically, the CNN part is used to preliminarily extract local features, the LSTM part captures time dependencies, and the Transformer better captures the long-distance dependencies between data through the self-attention mechanism, and models the contextual information of the data to capture the global dependencies between accessories. The model of the present invention can accurately predict the changes in demand for spare parts, and the prediction results change with the ups and downs of the true value. This shows that the model of the present invention can not only capture local features and time dependencies, but also recognize and learn the global characteristics of the data through the self-attention mechanism of the Transformer, thereby improving the accuracy of the prediction.
[0157] Through the above comparative experiments, the present invention verifies the superiority of the CNN-LSTM-Transformer-based model in a sparse data environment. This model can better adapt to the actual needs of spare parts inventory management, provide more accurate and reliable inventory demand forecasts, and thus help enterprises optimize inventory management, reduce costs, and improve operational efficiency.
[0158] Based on the method of the present invention, the embodiment of the present disclosure also provides a system corresponding to the above method, which includes:
[0159] A model building module is used to build a prediction model for outputting future spare parts inventory prediction data based on past spare parts inventory data; the prediction model includes:
[0160] A convolutional neural network is used to extract local features of past spare parts inventory data and output a local feature representation z(t) of the past spare parts inventory data;
[0161] LSTM neural network, used to represent z(t) based on local features and the hidden state h of the previous time step t-1 , output the hidden state h of the current time step containing long-term dependency information t ;
[0162] Transformer neural network is used to transform the hidden state h t After being converted into an input embedding vector, a self-attention mechanism is calculated based on the embedding vector to obtain a context vector containing global dependency information in the spare parts data; after adding position encoding to the context vector, the context vector with position encoding is subjected to feature enhancement through a multi-head attention mechanism layer and then input into a feedforward neural network to output future spare parts inventory forecast data;
[0163] The prediction module is used to obtain the current spare parts inventory data after training the prediction model, input the current spare parts inventory data into the trained prediction model, and output the prediction data of the future spare parts inventory.
[0164] Based on the same inventive concept as the above disclosed content, an embodiment of the present disclosure also provides a device corresponding to the above method, which includes at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the above method.
[0165] It should be noted that the electrical connection between the above-mentioned units does not necessarily mean the connection between lines. An indirect connection method can be applied to the embodiments of the present disclosure as long as the purpose of the present disclosure is achieved.
[0166] Based on the same inventive concept, the present disclosure also provides a computer storage medium on which executable instructions are stored. When the instructions are executed by a processor, the processor performs the above method.
[0167] Although the present disclosure has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure.
Claims
1. A method for predicting spare parts inventory data, characterized in that: include: Constructing a prediction model, wherein the prediction model outputs prediction data of spare parts inventory based on past spare parts inventory data; The prediction model includes: A convolutional neural network is used to extract local features of past spare parts inventory data and output a local feature representation z(t) of the past spare parts inventory data; LSTM neural network, used to represent z(t) based on local features and the hidden state h of the previous time step t-1 , output the hidden state h of the current time step containing long-term dependency information t ; Transformer neural network is used to transform the hidden state h t After being converted into an input embedding vector, a self-attention mechanism is calculated based on the embedding vector to obtain a context vector containing global dependency information in the spare parts data; after adding position encoding to the context vector, the context vector with position encoding is subjected to feature enhancement through a multi-head attention mechanism layer and then input into a feedforward neural network to output the prediction data of spare parts inventory; After the prediction model is trained, the current spare parts inventory data is obtained, the current spare parts inventory data is input into the trained prediction model, and the prediction data of the future spare parts inventory is output.
2. A method for predicting spare parts inventory data according to claim 1, characterized in that: The extracting local features of the past spare parts inventory data and outputting the local feature representation z(t) of the past spare parts inventory data comprises: Use a one-dimensional convolutional layer to extract local features of past spare parts inventory data and output a feature matrix; The feature matrix is processed by ReLU activation function and maximum pooling layer; The feature map after the maximum pooling layer is passed to the second one-dimensional convolution layer to further extract local features to obtain the first feature matrix; The first feature matrix is processed by the ReLU activation function and the maximum pooling layer to finally obtain the local feature representation z(t).
3. The method for predicting spare parts inventory data according to claim 1, characterized in that: The local feature representation z(t) and the hidden state h of the previous time step are t-1 , output the hidden state h of the current time step containing long-term dependency information t ; include: Use local features to represent z(t) and the hidden state h of the previous time step t-1 Calculate the output i of the input gate in the LSTM network t , the output f of the forget gate t , and generate new candidate cell states Using the output i of the input gate t , the output f of the forget gate t , new candidate cell states and the cell state C at the previous time step t-1 Get the current cell state C t ; Using the current cell state C t , local feature representation z(t), hidden state h of the previous time step t-1 Calculate the hidden state h at the current time step t .
4. The method for predicting spare parts inventory data according to claim 1, characterized in that: The training of the prediction model comprises: Normalize historical spare parts inventory data; Divide the normalized data into training set and test set; Use the sliding window method to construct the training set into input sequence and output sequence; construct the test set into input sequence and output sequence; The prediction model is trained using the input sequence and the output sequence, so that the prediction model outputs future spare parts inventory prediction data based on past spare parts inventory data.
5. The method for predicting spare parts inventory data according to claim 1, characterized in that: The self-attention mechanism calculation is performed based on the embedding vector to obtain a context vector containing global dependency information in the spare parts data; including: Based on the embedding vector, calculate the corresponding query matrix Q, key matrix K and value matrix V; Calculate the dot product of the query matrix Q and the key matrix K to get the attention score of each position in the embedded vector, and pass the attention score through the softmax function to get the attention weight of each position in the embedded vector; A context vector containing global dependency information in spare parts data is obtained by weighted summation based on the attention weights.
6. A method for predicting spare parts inventory data according to claim 5, characterized in that: The query matrix Q, key matrix K and value matrix V are calculated as: Among them, W Q , W K and W V is a learnable weight matrix; The attention weight of each vector position in the embedding vector is: Among them, d k is the dimension of the key vector.
7. The method for predicting spare parts inventory data according to claim 1, characterized in that: The context vector after adding the position encoding is subjected to feature enhancement through a multi-head attention mechanism layer, including: Calculate multiple self-attentions in parallel, concatenate their results and project them into the output space; MultiHead(Q,K,V)=Concat(head1,head2,...,head h )W o Among them, the calculation of each self-attention is as follows: in is the output weight matrix, Q is the query matrix, K is the key matrix and V is the value matrix.
8. A prediction system for spare parts inventory data, characterized in that: include: A model building module, used to build a prediction model, wherein the prediction model outputs prediction data of spare parts inventory based on past spare parts inventory data; The prediction model includes: A convolutional neural network is used to extract local features of past spare parts inventory data and output a local feature representation z(t) of the past spare parts inventory data; LSTM neural network, used to represent z(t) based on local features and the hidden state h of the previous time step t-1 , output the hidden state h of the current time step containing long-term dependency information t ; Transformer neural network is used to transform the hidden state h t After being converted into an input embedding vector, a self-attention mechanism is calculated based on the embedding vector to obtain a context vector containing global dependency information in the spare parts data; after adding position encoding to the context vector, the context vector with position encoding is subjected to feature enhancement through a multi-head attention mechanism layer and then input into a feedforward neural network to output the prediction data of spare parts inventory; The prediction module is used to obtain the current spare parts inventory data after training the prediction model, input the current spare parts inventory data into the trained prediction model, and output the prediction data of the future spare parts inventory.
9. A device for predicting spare parts inventory data, comprising: at least one processor; And a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method for predicting spare parts inventory data as described in any one of claims 1 to 7.
10. A computer storage medium having executable instructions stored thereon, wherein when the instructions are executed by a processor, the processor is enabled to implement the method according to any one of claims 1 to 7.
Citation Information
Cited By
Water level prediction method and device, electronic equipment and storage medium
CN120315071A
Nuclear power plant spare part demand prediction method and device based on LSTM neural network
CN120430826A