Pig house temperature prediction method based on resonance sparse Transformer network

By integrating the resonant sparse Transformer network and the convolutional neural network, the problem of inaccurate prediction of the traditional pig house temperature is solved, and accurate prediction of the pig house temperature is achieved, which provides a theoretical basis for fine regulation of the pig house environment and disease prevention and control. .

CN118277959BActive Publication Date: 2024-08-23ANHUI AGRICULTURAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410644882.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-23
Publication Date
2024-08-23
Estimated Expiration
2044-05-23

AI Technical Summary

Technical Problem

Traditional pig house temperature prediction methods are affected by the applied climate scenario, data sample size and model parameters, and the model stability and prediction accuracy do not meet the needs of practical engineering applications.

Method used

The fusion resonance sparse Transformer network is used to predict low-frequency temperature trends and high-frequency fluctuation sequences by setting up multiple temperature collection measurement points, using the resonance sparse decomposition and Transformer network models, and combines the two-way long short-term memory network of the convolutional neural network to perform data processing. Processing, adjusting hyperparameters in real time to improve prediction accuracy.

Benefits of technology

It achieves accurate extraction of temperature fluctuation trends in pig houses, prevents distortion of forecast trends, captures long-term dependencies in time series data, and improves forecast accuracy and algorithm running speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118277959B
    Figure CN118277959B
Patent Text Reader

Abstract

The present invention belongs to the field of agricultural information processing, specifically, a method for predicting temperature in a pig house by integrating a resonance sparse Transformer network. The temperature series data of each temperature collection point are decomposed by a resonance sparse decomposition method to obtain a low-frequency temperature trend series and a high-frequency fluctuation series of each temperature collection point; each low-frequency temperature trend series is predicted to obtain a low-frequency temperature prediction series of each temperature collection point; each high-frequency fluctuation series is predicted to obtain a high-frequency temperature prediction series of each temperature collection point; the low-frequency temperature prediction series and the high-frequency temperature prediction series are summed and calculated to obtain the final temperature prediction data of each temperature collection point, thereby regulating the pig house environment. The present invention takes into account the low-frequency trend and high-frequency oscillation characteristics of the intensive pig house temperature series data, can effectively capture the long-term dependency in the time series data, has low computational complexity, and high prediction accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of agricultural engineering and information processing, and in particular relates to a pig house temperature prediction method integrating a resonance sparse Transformer network. Background Art

[0002] In the intensive, large-scale and IoT-monitored pig farming process, the temperature of the pig house has an important impact on the survival rate of pig farming, pork growth and metabolism, disease transmission (such as diarrhea, respiratory diseases, pneumonia, fungal reproduction, etc.). Therefore, accurately predicting the temperature of the pig house, timely regulating the pig house environment according to the temperature fluctuation trend, and formulating early warning and epidemic prevention plans are of great significance for reducing energy consumption, reducing feed consumption, improving breeding survival rate and disease prevention in intensive pig farming.

[0003] At present, intensive pig houses are closed microclimate environments. Affected by the internal and external environments, the internal temperature of the pig houses fluctuates in a small range throughout the day, and the data distribution has characteristics such as sharp peaks, thick tails, and multiple coupling. Traditional model-driven prediction methods and data-driven prediction methods, such as time series prediction methods and neural network prediction methods, are affected by the application climate scenarios, data sample size, and model parameters. The model stability and prediction accuracy do not meet the actual engineering application requirements. Summary of the invention

[0004] The purpose of an embodiment of the present invention is to provide a pig house temperature prediction method integrating a resonant sparse Transformer network, aiming to solve the problem that traditional prediction methods are affected by application climate scenarios, data sample size and model parameters, and the model stability and prediction accuracy do not meet the requirements of practical engineering applications.

[0005] To achieve the above object, the present invention provides the following technical solutions.

[0006] Specifically, the present invention provides a method for predicting pig house temperature by integrating a resonance sparse Transformer network, the method comprising the following steps:

[0007] Step S1: setting a plurality of temperature collection points in the pig house, and picking up the temperature sequence data of each temperature collection point;

[0008] Step S2: Decomposing the temperature series data of each temperature collection point by using the resonance sparse decomposition method to obtain a low-frequency temperature trend series and a high-frequency fluctuation series of each temperature collection point;

[0009] Step S3: using the Transformer network model method to predict each low-frequency temperature trend sequence, and obtain a low-frequency temperature prediction sequence for each temperature collection point;

[0010] Step S4: using a convolutional neural network bidirectional long short-term memory network CNN-BiLSTM model to predict each high-frequency fluctuation sequence, and obtain a high-frequency temperature prediction sequence for each temperature collection point;

[0011] Step S5: The low-frequency temperature prediction sequence and the high-frequency temperature prediction sequence are summed and calculated to obtain the final temperature prediction data of each temperature collection point, and the error between the predicted time series and the actual time series is calculated at the same time, and the hyperparameters of the prediction model are adjusted in real time;

[0012] Step S6: According to the temperature prediction data, the pig house environment is regulated.

[0013] Furthermore, step S2 specifically includes:

[0014] Step S21: The temperature series data of each measuring point in the pig house collected by the temperature sensor is expressed as:

[0015] (1);

[0016] In formula (1), is the observed data, ; , are the trend sequence component of the low-frequency oscillation characteristic to be estimated and the harmonic component of the high-frequency oscillation characteristic;

[0017] Step S22: Signal Components , Using overcomplete wavelet basis Overcomplete wavelet basis The matching is characterized by: , (2);

[0018] In formula (2), and Respectively The wavelet transform coefficients of

[0019] Step S23: The constructed resonance sparse decomposition objective function is expressed as:

[0020] (3);

[0021] In formula (3), and is the regularization parameter;

[0022] Step S24: Apply the split augmented Lagrangian shrinkage algorithm to solve the minimum value of the constructed resonance sparse decomposition objective function, and iterate and update multiple times and , get the updated wavelet transform coefficients and , the trend sequence component of the low-frequency oscillation characteristics to be estimated and the harmonic component of the high-frequency oscillation characteristics are:

[0023] (4).

[0024] Furthermore, step S3 specifically includes:

[0025] Step S31: The Transformer model is composed of a model encoder and a model decoder; wherein the model encoder includes vector position encoding, multi-head self-attention mechanism, residual connection and network layer normalization processing and feedforward neural network; the model decoder includes mask multi-head self-attention mechanism, feedforward neural network, and fully connected layer;

[0026] Step S32: In the model encoder, vector position encoding is used to add label information to each position in the input sequence X to distinguish different positions and orders of the input sequence;

[0027] Step S33: In the model decoder, in order to predict that the data of a certain step will not be connected with the future data, a mask multi-head self-attention mechanism is constructed by creating a mask matrix to construct the future position, so that the attention score of the future position is set to infinitesimal, so that the current element is only connected with the historical elements, ensuring that the model can only rely on historical elements to predict the value of future elements.

[0028] Further, in step S32:

[0029] Step S321: Use the linear transformation of sin and cos functions to provide model position information. The specific operation is:

[0030] (5);

[0031] In formula (5), is the position of the input sequence, such as =0, 1, 2, ..., N; is the sequence dimension; and Indicates the parity of the sequence dimension; is the size of the embedding space dimension;

[0032] Step S322: In the model encoder, the multi-head self-attention mechanism uses multiple parallel self-attention mechanisms. A single self-attention mechanism captures the information of the subspace by learning different weights. The specific operations are:

[0033] According to the vector position encoding, add the position encoded vector through three weight matrices: query matrix , the bond matrix Sum Matrix , transformed into the vector Q, vector K and vector V required by the self-attention mechanism: , , ,in, is the input vector after adding the position encoding;

[0034] Step S323: Use the dot product method to calculate the correlation score between each element in the input sequence: Score=Q*KT;

[0035] In order to stabilize the gradient during model training, the correlation scores between each element are normalized: ,in, is the dimension of vector K; through the Softmax function, the score vector between each element in the position-encoded vector is converted into a probability distribution between [0,1], and the calculation formula is:

[0036] (6);

[0037] Step S324: The multi-head attention mechanism uses multiple sets of weight matrices ( , , ), get multiple sets of required vectors Q, vectors K and vectors V, and get the outputs of multiple heads connected together to perform linear transformation matrix Z:

[0038] (7);

[0039] In formula (7), , , is the i-th vector Q, K and V; is the attention head weight matrix;

[0040] Step S325: residual connection and network layer normalization processing are as follows:

[0041] After the multi-head attention mechanism output in the previous step, the residual connection operation is performed Normalization operation with network layer ;

[0042] Step S326: The feedforward neural network is a two-layer neural network, which first performs a linear transformation, then a ReLU nonlinear transformation, and then a linear transformation, specifically:

[0043] (8);

[0044] In formula (8), The output of the previous layer , and is the weight coefficient of the feedforward neural network, and It is the bias of the feedforward neural network, and finally the residual connection method is used to connect each layer .

[0045] Further, in step S33:

[0046] The specific masked multi-head self-attention mechanism is: (9);

[0047] In formula (9), Mmask is the mask matrix, Attention weight matrix with mask;

[0048] The feedforward neural network and fully connected layer in the model decoder Decoder. The feedforward neural network performs nonlinear transformation on the upper layer results, allowing the network to capture and represent complex nonlinear relationships. The fully connected layer uses the ReLU function as the activation function.

[0049] Compared with the prior art, the pig house temperature prediction method integrating the resonance sparse Transformer network of the present invention has the following beneficial effects:

[0050] First, the pig house temperature prediction method proposed in the present invention takes into account the low-frequency trend and high-frequency oscillation characteristics of the intensive pig house temperature series data, and can accurately extract the pig house temperature fluctuation trend to prevent the prediction trend from being distorted;

[0051] Second, compared with the time series prediction method and the data-driven prediction method, the method proposed in the present invention can effectively capture the long-term dependencies in the time series data, with low computational complexity, high prediction accuracy, and fast algorithm operation speed.

[0052] In summary, the present invention overcomes the problem of inaccuracy of traditional prediction methods, especially for prediction problems under characteristics such as small-range data fluctuations, data distribution peaks and thick tails, and multiple coupling. The pig house temperature prediction method of the present invention can realize accurate prediction of intensive pig house temperature and provide a theoretical basis for fine control of pig house environment and disease prevention and control. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the embodiments of the present invention 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 in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can be obtained based on these drawings without paying creative work.

[0054] Figure 1 This is a principle framework diagram of the pig house temperature prediction method integrating a resonance sparse Transformer network of the present invention;

[0055] Figure 2 This is a schematic diagram of the temperature change waveform of a certain measuring point in a pig house collected in an embodiment of the present invention;

[0056] Figure 3 A low-frequency component graph obtained by resonant sparse decomposition according to an embodiment of the present invention;

[0057] Figure 4 A high frequency component graph obtained by resonant sparse decomposition according to an embodiment of the present invention;

[0058] Figure 5 It is a schematic diagram of the low-frequency temperature and humidity prediction results of a certain measuring point in an intensive pig house predicted based on the Transformer network model according to an embodiment of the present invention;

[0059] Figure 6 This is a schematic diagram of the high-frequency temperature prediction result of a certain measuring point in an intensive piggery predicted by a bidirectional long short-term memory network CNN-BiLSTM model based on a convolutional neural network in an embodiment of the present invention;

[0060] Figure 7 The temperature prediction result of a certain measuring point in a pig house predicted by the pig house temperature prediction method of the present invention;

[0061] Figure 8 is the temperature prediction error based on the pig house temperature prediction method of the present invention;

[0062] Fig. 9 The present invention is a flow chart of a method for predicting pig house temperature by integrating a resonance sparse Transformer network. DETAILED DESCRIPTION

[0063] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0064] At present, intensive pig houses are closed microclimate environments. Affected by the internal and external environments, the internal temperature of the pig houses fluctuates in a small range throughout the day, and the data distribution has characteristics such as sharp peaks, thick tails, and multiple coupling. Traditional model-driven prediction methods and data-driven prediction methods, such as time series prediction methods and neural network prediction methods, are affected by the application climate scenarios, data sample size, and model parameters. The model stability and prediction accuracy do not meet the actual engineering application requirements.

[0065] To solve the above problems, the present invention proposes a pig house temperature prediction method that integrates a resonant sparse Transformer network. The method takes into account the low-frequency trend and high-frequency oscillation characteristics of intensive pig house temperature series data, and can accurately extract the temperature fluctuation trend of the pig house to prevent the prediction trend from being distorted. Compared with the time series prediction method and the data-driven prediction method, the method proposed in the present invention can effectively capture the long-term dependency in the time series data, with low computational complexity, high prediction accuracy, and fast algorithm running speed.

[0066] The specific implementation of the present invention is described in detail below in conjunction with specific embodiments.

[0067] like Figure 1 and Fig. 9 As shown, the pig house temperature prediction method provided by the present invention by integrating the resonance sparse Transformer network includes the following steps:

[0068] Step S1: setting a plurality of temperature collection points in the pig house, and picking up the temperature sequence data of each temperature collection point;

[0069] Step S2: Decomposing the temperature series data of each temperature collection point by using the resonance sparse decomposition method to obtain a low-frequency temperature trend series and a high-frequency fluctuation series of each temperature collection point;

[0070] Step S3: using the Transformer network model method to predict each low-frequency temperature trend sequence, and obtain a low-frequency temperature prediction sequence for each temperature collection point;

[0071] Step S4: using a convolutional neural network bidirectional long short-term memory network CNN-BiLSTM model to predict each high-frequency fluctuation sequence, and obtain a high-frequency temperature prediction sequence for each temperature collection point;

[0072] Step S5: The low-frequency temperature prediction sequence and the high-frequency temperature prediction sequence are summed and calculated to obtain the final temperature prediction data of each temperature collection point, and the error between the predicted time series and the actual time series is calculated at the same time, and the hyperparameters of the prediction model are adjusted in real time;

[0073] Step S6: According to the temperature prediction data, the pig house environment is regulated.

[0074] Furthermore, step S2 specifically includes:

[0075] Step S21: The temperature series data of each measuring point in the pig house collected by the temperature sensor is expressed as:

[0076] (1);

[0077] In formula (1), is the observed data, ; , are the trend sequence component of the low-frequency oscillation characteristic to be estimated and the harmonic component of the high-frequency oscillation characteristic;

[0078] Step S22: Signal Components , Using overcomplete wavelet basis Overcomplete wavelet basis The matching is characterized by:

[0079] , (2);

[0080] In formula (2), and Respectively Wavelet transform coefficients of

[0081] Step S23: The constructed resonance sparse decomposition objective function is expressed as:

[0082] (3);

[0083] In formula (3), and is the regularization parameter;

[0084] Step S24: Apply the split augmented Lagrangian shrinkage algorithm to solve the minimum value of the constructed resonance sparse decomposition objective function, and iterate and update multiple times and , get the updated wavelet transform coefficients and , the trend sequence component of the low-frequency oscillation characteristics to be estimated and the harmonic component of the high-frequency oscillation characteristics are:

[0085] (4);

[0086] Furthermore, step S3 specifically includes:

[0087] Step S31: The Transformer model is composed of a model encoder Encoder and a model decoder Decoder; wherein the model encoder Encoder includes vector position encoding, multi-head self-attention mechanism, residual connection and network layer normalization processing and feedforward neural network; the model decoder Decoder includes a masked multi-head self-attention mechanism, a feedforward neural network, and a fully connected layer;

[0088] Step S32: In the model encoder, vector position encoding is used to add label information to each position in the input sequence X to distinguish different positions and orders of the input sequence;

[0089] Step S33: In the model decoder, in order to predict that the data of a certain step will not be connected with the future data, a mask multi-head self-attention mechanism is constructed by creating a mask matrix to construct the future position, so that the attention score of the future position is set to infinitesimal, so that the current element is only connected with the historical elements, ensuring that the model can only rely on historical elements to predict the value of future elements.

[0090] Further, step S32 includes:

[0091] Step S321: Use the linear transformation of sin and cos functions to provide model position information. The specific operation is:

[0092] (5);

[0093] In formula (5), is the position of the input sequence, such as =0, 1, 2, ..., N; is the sequence dimension; and Indicates the parity of the sequence dimension; is the size of the embedding space dimension;

[0094] Step S322: In the model encoder, the multi-head self-attention mechanism uses multiple parallel self-attention mechanisms. A single self-attention mechanism captures the information of the subspace by learning different weights. The specific operations are:

[0095] According to the vector position encoding, the position-encoded vector is added through three weight matrices ( , , ), that is, the query matrix , the bond matrix , value matrix Transformed into the vector Q, vector K and vector V required by the self-attention mechanism, that is , , , is the input vector after adding the position encoding;

[0096] Step S323: Use the dot product method to calculate the correlation score between each element in the input sequence: Score=Q*KT;

[0097] In order to stabilize the gradient during model training, the correlation scores between each element are normalized: ,in, is the dimension of vector K; through the Softmax function, the score vector between each element in the position-encoded vector is converted into a probability distribution between [0,1], and the calculation formula is:

[0098] (6);

[0099] Step S324: The multi-head attention mechanism uses multiple sets of weight matrices ( , , ), get multiple sets of required vectors Q, vectors K and vectors V, and get the outputs of multiple heads connected together to perform linear transformation matrix Z:

[0100] (7);

[0101] In formula (7), , , is the i-th vector Q, K and V; is the attention head weight matrix;

[0102] Step S325: residual connection and network layer normalization processing are as follows:

[0103] After the multi-head attention mechanism output in the previous step, the residual connection operation is performed Normalization operation with network layer ;

[0104] Step S326: The feedforward neural network is a two-layer neural network, which first performs a linear transformation, then a ReLU nonlinear transformation, and then a linear transformation, specifically:

[0105] (8);

[0106] In formula (8), The output of the previous layer , and is the weight coefficient of the feedforward neural network, and It is the bias of the feedforward neural network, and finally the residual connection method is used to connect each layer .

[0107] Further, in step S33:

[0108] The specific masked multi-head self-attention mechanism is: (9);

[0109] In formula (9), Mmask is the mask matrix, Attention weight matrix with mask;

[0110] The feedforward neural network and fully connected layer in the model decoder Decoder. The feedforward neural network performs nonlinear transformation on the upper layer results, allowing the network to capture complex nonlinear relationships. The fully connected layer uses the ReLU function as the activation function, and the calculation process is similar to that of the model encoder Encoder.

[0111] The pig house temperature prediction method proposed in the present invention takes into account the low-frequency trend and high-frequency oscillation characteristics of the intensive pig house temperature series data, and can accurately extract the pig house temperature fluctuation trend to prevent the prediction trend from being distorted;

[0112] Compared with the time series prediction method and the data-driven prediction method, the method proposed in the present invention can effectively capture the long-term dependencies in the time series data, has low computational complexity, high prediction accuracy, and fast algorithm operation speed.

[0113] In summary, the present invention overcomes the problem of inaccuracy of traditional prediction methods, especially for prediction problems under characteristics such as small-range data fluctuations, data distribution peaks and thick tails, and multiple coupling. The pig house temperature prediction method of the present invention can realize accurate prediction of intensive pig house temperature and provide a theoretical basis for fine control of pig house environment and disease prevention and control.

[0114] The present invention adopts a certain intensive pig breeding enterprise in Wuhu to pick up the temperature sequence data of a certain measuring point based on Ethernet and sensor fusion network technology. The temperature change sequence of a certain measuring point for about 11 months is as follows Figure 2 As shown, one temperature point is collected every day, with a total of 333 data points.

[0115] The resonance sparse decomposition method {refer to IW Selesnick, Resonance-based signal decomposition: a new sparsity-enabled signal analysis method, Signal Processing, 2011, 91(12): 2793-2809.} is used to decompose the temperature time series of a certain measuring point to obtain the low-frequency temperature trend series and high-frequency fluctuation series of the measuring point. Figure 3 is a low-frequency component graph obtained by resonant sparse decomposition according to an embodiment of the present invention, Figure 4 From the high-frequency component diagram obtained by the resonance sparse decomposition of the embodiment of the present invention, it can be seen that the low-frequency component signal reflects the temperature fluctuation trend of the pig house, and the high-frequency component signal reflects the impact of external interference factors on the fluctuation of the ambient temperature.

[0116] The Transformer network model is used to predict the low-frequency temperature trend sequence of a certain measuring point. The low-frequency temperature prediction sequence of a certain measuring point is obtained. The results are as follows: Figure 5 As shown, it can be seen that the Transformer network model method can accurately track the temperature fluctuation trend of the pig house.

[0117] The convolutional neural network bidirectional long short-term memory network (CNN-BiLSTM) model is used to predict the high-frequency fluctuation sequence of a certain measuring point, and the high-frequency temperature prediction sequence of a certain measuring point is obtained. The results are as follows: Figure 6 As shown in the figure, it can be seen that the CNN-BiLSTM model can accurately track the oscillation process of the high-frequency temperature component; finally, the low-frequency temperature prediction sequence and the high-frequency temperature prediction sequence are summed to obtain the temperature prediction data of a certain measuring point, such as Figure 7 shown; Figure 8 This is the temperature prediction error based on the method of the present invention in the embodiment of the present invention. It can be seen that the prediction error range of the method proposed by the present invention has small fluctuation, high prediction accuracy, and good industrial application value.

[0118] Although the embodiments of the present invention have been disclosed above, they are not limited to the applications listed in the specification and the embodiments. It can be fully applied to various fields suitable for the present invention. For those familiar with the art, additional modifications can be easily realized. Therefore, without departing from the general concept defined by the claims and equivalent scope, the present invention is not limited to the specific details and the illustrations shown and described here.

Claims

1. A pig house temperature prediction method integrating a resonance sparse Transformer network is characterized in that: The method comprises the following steps: Step S1: setting a plurality of temperature collection points in the pig house, and picking up the temperature sequence data of each temperature collection point; Step S2: Decomposing the temperature series data of each temperature collection point by using the resonance sparse decomposition method to obtain a low-frequency temperature trend series and a high-frequency fluctuation series of each temperature collection point; Step S3: using the Transformer network model method to predict each low-frequency temperature trend sequence, and obtain a low-frequency temperature prediction sequence for each temperature collection point; Step S4: using a convolutional neural network bidirectional long short-term memory network CNN-BiLSTM model to predict each high-frequency fluctuation sequence, and obtain a high-frequency temperature prediction sequence for each temperature collection point; Step S5: The low-frequency temperature prediction sequence and the high-frequency temperature prediction sequence are summed and calculated to obtain the final temperature prediction data of each temperature collection point, and the error between the predicted time series and the actual time series is calculated at the same time, and the hyperparameters of the prediction model are adjusted in real time; Step S6: regulating the pig house environment according to each temperature prediction data; Step S3 specifically includes: Step S31: The Transformer model is composed of a model encoder Encoder and a model decoder Decoder; wherein the model encoder Encoder includes vector position encoding, multi-head self-attention mechanism, residual connection and network layer normalization processing and feedforward neural network; the model decoder Decoder includes a masked multi-head self-attention mechanism, a feedforward neural network, and a fully connected layer; Step S32: In the model encoder, vector position encoding is used to add label information to each position in the input sequence X to distinguish different positions and orders of the input sequence; Step S33: In the model decoder Decoder, a mask multi-head self-attention mechanism is constructed by creating a mask matrix for the future position, so that the attention score of the future position is set to infinitesimal, so that the current element is only connected with the historical element; In step S32: Step S321: Use the linear transformation of sin and cos functions to provide model position information. The specific operation is: (5); In formula (5), is the position of the input sequence, such as =0, 1, 2, ..., N; is the sequence dimension; and Indicates the parity of the sequence dimension; is the size of the embedding space dimension; Step S322: In the model encoder, the multi-head self-attention mechanism uses multiple parallel self-attention mechanisms. A single self-attention mechanism captures the information of the subspace by learning different weights. The specific operations are: According to the vector position encoding, add the position encoded vector through three weight matrices: query matrix , the bond matrix Sum Matrix , respectively transformed into the vector Q, vector K and vector V required by the self-attention mechanism: , , ,in, is the input vector after adding the position encoding; Step S323: Use the dot product method to calculate the correlation score between each element in the input sequence: Score=Q*KT; Normalize the correlation scores between each element: ,in, is the dimension of vector K; Through the Softmax function, the score vector between each element in the position-encoded vector is converted into a probability distribution between [0,1], and the calculation formula is: (6); Step S324: The multi-head attention mechanism uses multiple sets of weight matrices , , , we get multiple sets of required vectors Q, vectors K and vectors V, and connect the outputs of multiple heads together to perform a linear transformation matrix Z: (7); In formula (7), , , is the i-th vector Q, K and V; is the attention head weight matrix; Step S325: residual connection and network layer normalization processing are as follows: After the multi-head attention mechanism output in the previous step, the residual connection operation is performed Normalization operation with network layer ; Step S326: The feedforward neural network is a two-layer neural network, which first performs a linear transformation, then a ReLU nonlinear transformation, and then a linear transformation, specifically: (8); In formula (8), The output of the previous layer , and is the weight coefficient of the feedforward neural network, and It is the bias of the feedforward neural network, and finally the residual connection method is used to connect each layer .

2. The method for predicting pig house temperature by integrating resonance sparse Transformer network according to claim 1 is characterized in that: Step S2 specifically includes: Step S21: The temperature series data of each measuring point in the pig house collected by the temperature sensor is expressed as: (1); In formula (1), is the observed data, ; , are the trend sequence component of the low-frequency oscillation characteristic to be estimated and the harmonic component of the high-frequency oscillation characteristic; Step S22: Signal Components , Using overcomplete wavelet basis Overcomplete wavelet basis The matching is characterized by: ; (2); In formula (2), and Respectively The wavelet transform coefficients of Step S23: The constructed resonance sparse decomposition objective function is expressed as: (3); In formula (3), and is the regularization parameter; Step S24: Apply the split augmented Lagrangian shrinkage algorithm to solve the minimum value of the constructed resonance sparse decomposition objective function, and iterate and update multiple times and , get the updated wavelet transform coefficients and , the trend sequence component of the low-frequency oscillation characteristics to be estimated and the harmonic component of the high-frequency oscillation characteristics are: (4)。 3. The method for predicting pig house temperature by integrating resonance sparse Transformer network according to claim 2 is characterized in that: In step S33: The specific masked multi-head self-attention mechanism is: (9); In formula (9), Mmask is the mask matrix, Attention weight matrix with mask; The feedforward neural network and fully connected layer in the model decoder Decoder. The feedforward neural network performs nonlinear transformation on the upper layer results, allowing the network to capture and represent complex nonlinear relationships. The fully connected layer uses the ReLU function as the activation function.