A greenhouse soil temperature prediction method

By screening and weighting the key environmental characteristics in greenhouse environmental data, the problem of low prediction accuracy of a single parameter model in the prior art is solved, the calculation amount of the Transformer model is reduced, and the prediction accuracy of the greenhouse soil temperature is improved.

CN118656601BActive Publication Date: 2025-02-14ZHEJIANG UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411133471.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2025-02-14
Estimated Expiration
2044-08-19

AI Technical Summary

Technical Problem

The existing greenhouse soil temperature prediction methods mainly rely on a single parameter model, and fail to fully consider the influence of multiple environmental factors, resulting in low prediction accuracy. Traditional deep learning models have problems such as gradient disappearance and large amount of calculation when processing long-term dependency data, making it difficult to effectively predict greenhouse soil temperature.

Method used

By collecting greenhouse environmental data, the coupling relationship between each environmental feature and soil temperature is analyzed, environmental features with strong coupling relationships are screened out, and weighted processing is performed to reduce the calculation amount of the Transformer neural network model and improve prediction accuracy.

Benefits of technology

It effectively reduces the calculation amount of Transformer neural network model, improves the accuracy of greenhouse soil temperature prediction, and ensures the accuracy and reliability of prediction results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118656601B_ABST
    Figure CN118656601B_ABST
Patent Text Reader

Abstract

The present invention discloses a greenhouse soil temperature prediction method. It includes the following steps: sampling the environmental data of a greenhouse within a preset time period, wherein the environmental data includes the greenhouse soil temperature and multiple environmental features; preprocessing the sampled environmental data; analyzing the coupling relationship between each environmental feature and the greenhouse soil temperature, and screening out environmental features with a strong coupling relationship with the greenhouse soil temperature as coupling features; forming a first data set with the greenhouse soil temperature and the screened coupling features, and performing weighted processing on the data in the first data set using an attention mechanism variable weighted model to obtain a second data set; constructing a Transformer neural network model, inputting the second data set into the Transformer neural network model, and the Transformer neural network model outputs a predicted value of the greenhouse soil temperature within a future specified time period. The present invention can reduce the computational complexity of the Transformer neural network model and improve the prediction accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of greenhouse environment prediction, and in particular to a method for predicting greenhouse soil temperature. Background Art

[0002] Greenhouses are key infrastructure for modern agriculture, and the popularity of greenhouses has enabled a long-term supply of vegetables. The growth and development of crops in greenhouses are intricately linked to the climate environment, and the process of crop growth and development is significantly affected by factors such as temperature and light. The unique microclimate in these greenhouses can sometimes fluctuate greatly, leading to suboptimal growth conditions and reduced crop yields. Among them, greenhouse soil temperature, as a key factor in crop growth, has a direct impact on the germination of crop seeds and root growth. Precise control of greenhouse soil temperature can effectively ensure efficient crop growth, and effective prediction of greenhouse soil temperature is an important basis for achieving precise control.

[0003] At present, greenhouse soil temperature prediction methods are mainly divided into two categories: mechanism modeling methods based on domain knowledge and expert experience and data-driven system identification methods. The advancement of Internet of Things technology has promoted the extensive collection of environmental data, so data-driven models based on machine learning have received great attention in predicting meteorological and climate phenomena. However, the single prediction model established and optimized using traditional statistical methods and machine learning methods is relatively simple and has poor performance. At the same time, most models only use a single parameter as model input to predict future data changes without considering the influence of other environmental factors.

[0004] Currently, researchers are trying to combine multiple single models for modeling and have proposed a variety of improved models, such as the Attention-LSTM model and the Transformer model. The Attention-LSTM model combines the advantages of various algorithms in data feature processing and prediction performance, thereby improving the overall accuracy of prediction. However, the model is limited by the sequential processing of input data and the back propagation algorithm over time. It does not work well when processing data sets with long-term dependencies, and often suffers from problems such as gradient vanishing and gradient explosion. The Transformer model benefits from the self-attention mechanism and can associate the information of all variables in the time series in parallel, which can effectively avoid the above-mentioned problem of network gradient vanishing and greatly improve the accuracy of the network in long-term dependency data sets and time series prediction tasks. However, when the Transformer model inputs a large number of environmental variables, the model will have a large amount of calculation and high hardware requirements. Moreover, the greenhouse climate environment is a dynamic and complex system with complex coupling relationships between multiple environmental variables and characteristics such as nonlinearity and instability. The correct coupling relationship between the variables cannot be well calculated based on the Transformer model alone, resulting in large errors in the prediction results.

[0005] In summary, the problems existing in the prior art are:

[0006] (1) Most prediction methods use historical soil temperature data as a single parameter as model input to predict future soil temperature changes without considering the impact of other environmental factors;

[0007] (2) Traditional deep learning models, such as the Attention-LSTM model, do not work well when processing data with long-term dependencies, and often suffer from problems such as gradient vanishing and gradient explosion. The Transformer model greatly improves the accuracy of the network in processing long-term dependency data sets and time series prediction tasks. However, when there are many input environmental variables, the model has a large amount of computation and high hardware requirements, which hinders its accuracy in greenhouse soil temperature prediction.

[0008] (3) The coupling relationship between multiple environmental variables in the greenhouse is complex and has characteristics such as nonlinearity and instability. If the correct coupling relationship between the variables cannot be obtained, it will have a significant impact on the prediction results.

[0009] Therefore, it is urgent to explore a greenhouse soil temperature prediction method that fully considers the multi-dimensional environmental variables related to it, reduces the amount of model calculation, correctly calculates the coupling relationship between the variables, and realizes the accurate prediction of greenhouse soil temperature. Summary of the invention

[0010] In order to solve the above technical problems, the present invention provides a greenhouse soil temperature prediction method, which can find out environmental characteristics with a strong coupling relationship with the greenhouse soil temperature and perform reasonable weighted processing, thereby reducing the calculation amount of the Transformer neural network model and improving the prediction accuracy.

[0011] In order to solve the above problems, the present invention adopts the following technical solutions:

[0012] A greenhouse soil temperature prediction method of the present invention comprises the following steps:

[0013] S1: Sampling environmental data of the greenhouse within a preset time period, wherein the environmental data includes greenhouse soil temperature and multiple environmental characteristics;

[0014] S2: preprocessing the sampled environmental data;

[0015] S3: Analyze the coupling relationship between each environmental feature and the greenhouse soil temperature, and select environmental features with strong coupling relationship with the greenhouse soil temperature as coupling features;

[0016] S4: The greenhouse soil temperature and the selected coupling features are combined into a first data set, and the attention mechanism variable weighted model is used to weight the data in the first data set to obtain a second data set;

[0017] S5: construct a Transformer neural network model, input the second data set into the Transformer neural network model, and the Transformer neural network model outputs a predicted value of the greenhouse soil temperature within a specified time period in the future.

[0018] In this scheme, the environmental data of the greenhouse in historical time is first collected. After analyzing the coupling relationship between each environmental feature and the greenhouse soil temperature, the environmental features with weak coupling relationship with the greenhouse soil temperature are eliminated, thereby reducing the environmental features input into the Transformer neural network model, reducing the amount of calculation of the Transformer neural network model, and improving the calculation efficiency. Since the coupling relationship between the environmental features input into the Transformer neural network model and the soil temperature is strong, and after weighted processing by the attention mechanism variable weighted model, the prediction accuracy is improved.

[0019] Preferably, the multiple environmental characteristics include air temperature in the greenhouse, air humidity in the greenhouse, soil moisture in the greenhouse, light intensity in the greenhouse, carbon dioxide concentration in the greenhouse, effective photosynthetic radiation in the greenhouse, air temperature outside the greenhouse, ground air pressure outside the greenhouse, relative humidity outside the greenhouse, and wind speed outside the greenhouse.

[0020] Preferably, the method for preprocessing the environmental data in step S2 includes the following steps: performing data cleaning on the environmental data, and normalizing the cleaned environmental data.

[0021] Preferably, the method for cleaning environmental data comprises the following steps: when environmental data at a certain sampling moment is missing, linear interpolation of environmental data at two adjacent sampling moments is used to fill the missing data.

[0022] Preferably, the normalization processing method is a maximum-minimum normalization processing method.

[0023] Preferably, the method for analyzing the coupling relationship between environmental characteristics and greenhouse soil temperature in step S3 is as follows:

[0024] The coupling correlation coefficient D between the environmental characteristics and the greenhouse soil temperature is calculated. If the coupling correlation coefficient D≥the set value M, it means that the coupling relationship between the environmental characteristics and the greenhouse soil temperature is strong. If the coupling correlation coefficient D<the set value M, it means that the coupling relationship between the environmental characteristics and the greenhouse soil temperature is weak.

[0025] Preferably, the number of the environmental features is m, and the m environmental features are numbered 1, 2, ..., m, 1≤j≤m, and the coupling correlation coefficient D between the environmental feature numbered j and the greenhouse soil temperature is calculated. j The calculation formula is as follows:

[0026] ,

[0027] ,

[0028] Where n is the number of sampling times, 1≤i≤n, X ji is the value of the environmental feature numbered j collected at the i-th sampling moment, Y i is the value of greenhouse soil temperature collected at the i-th sampling moment, is the mean value of the environmental feature numbered j collected from n samplings, is the mean value of greenhouse soil temperature collected by n samplings, is the sample standard deviation of the environmental characteristic numbered j, is the sample standard deviation of greenhouse soil temperature.

[0029] The coupling relationship between the various environmental characteristics of the greenhouse and the greenhouse soil temperature is complex. This method uses the coupling correlation coefficient D to represent the degree of coupling between the environmental characteristics and the greenhouse soil temperature. The coupling correlation coefficient D can characterize any regression relationship between a single environmental characteristic and the greenhouse soil temperature, rather than just the linear or nonlinear relationship between the two.

[0030] Preferably, in step S4, the method of using the attention mechanism variable weighted model to perform weighted processing on the data in the first data set to obtain the second data set includes the following steps:

[0031] The first data set is input into the attention mechanism variable weighted model. The formula of the attention mechanism variable weighted model is as follows:

[0032] ,

[0033] ,

[0034] Wherein, F is the first data set, W(F) is the weight matrix, Conv(.) indicates convolution processing, MaxPool(.) indicates maximum pooling processing, AvgPool(.) indicates average pooling processing, StochasticPool(.) indicates random pooling processing, and MLP(.) indicates multi-layer perception processing. is the sigmoid activation function;

[0035] The attention mechanism variable weights the model output as the second data set.

[0036] Preferably, the formula for the multi-layer perception processing is as follows:

[0037] ,

[0038] ,

[0039] Among them, x0 is the input of multi-layer perception processing, y1 is the output of multi-layer perception processing, w0 and w1 are weights, and b0 and b1 are bias values.

[0040] Preferably, step S3 comprises the following steps:

[0041] S31: Calculate the coupling correlation coefficient D between each environmental feature and the greenhouse soil temperature, and form a first environmental feature set with all environmental features having the coupling correlation coefficient D ≥ a set value M;

[0042] m environmental features are numbered 1, 2, ..., m, 1≤j≤m, and the coupling correlation coefficient D between the environmental feature numbered j and the greenhouse soil temperature is calculated. j The calculation formula is as follows:

[0043] ,

[0044] ,

[0045] Where n is the number of sampling times, 1≤i≤n, Xji is the value of the environmental feature numbered j collected at the i-th sampling moment, Y i is the value of greenhouse soil temperature collected at the i-th sampling moment, is the mean value of the environmental feature numbered j collected from n samplings, is the mean value of greenhouse soil temperature collected by n samplings, is the sample standard deviation of the environmental characteristic numbered j, is the sample standard deviation of greenhouse soil temperature;

[0046] S32: Filter the environmental features in the first environmental feature set to obtain a second environmental feature set, where the coupling correlation coefficient E between any two environmental features in the second environmental feature set is less than a set value G, and the environmental features in the second environmental feature set are used as coupling features;

[0047] The method of screening the environmental features in the first environmental feature set to obtain the second environmental feature set is as follows:

[0048] N1: Sort the environmental features in the first environmental feature set from large to small according to the coupling correlation coefficient D, and number them 1, 2, ..., k, 1≤k≤m, k is the number of environmental features in the first environmental feature set, and set p=1;

[0049] N2: calculate q=p+1;

[0050] N3: Calculate the coupling correlation coefficient E between the environmental feature numbered p and the environmental feature numbered q pq , if E pq < set value G, then the environmental feature numbered q is retained in the first environmental feature set; if E pq ≥ the set value G, then the environmental feature numbered q is deleted from the first environmental feature set;

[0051] N4: Determine whether q is less than k. If so, calculate q=q+1 and then execute step N5; otherwise, execute step N6;

[0052] N5: Determine whether the environmental feature numbered q is in the first environmental feature set. If yes, jump to step N3; otherwise, jump to step N4;

[0053] N6: Determine whether p is less than k-1. If so, calculate p=p+1 and then execute step N7; otherwise, take out the remaining environmental features in the first environmental feature set to form a second environmental feature set;

[0054] N7: Determine whether the environmental feature numbered p is in the first environmental feature set. If yes, jump to step N2; otherwise, jump to step N6;

[0055] The coupling correlation coefficient E between the environmental feature numbered p and the environmental feature numbered q pq The calculation formula is as follows:

[0056] ,

[0057] ,

[0058] Where n is the number of sampling times, 1≤i≤n, X pi is the value of the environmental feature numbered p collected at the i-th sampling moment, X qi is the value of the environmental feature numbered q collected at the i-th sampling moment, is the mean value of the environmental feature numbered p collected from n samplings, is the mean value of the environmental feature numbered q collected from n samplings, is the sample standard deviation of the environmental characteristic numbered p, is the sample standard deviation of the environmental characteristic numbered q.

[0059] The environmental features were further screened to ensure the independence of each environmental feature in the second environmental feature set and to avoid complex coupling between environmental features. On the basis of ensuring prediction accuracy, the environmental features input into the Transformer neural network model were further reduced, which further reduced the amount of calculation and improved the calculation efficiency.

[0060] The beneficial effects of the present invention are that environmental features with a strong coupling relationship with greenhouse soil temperature can be found and reasonable weighted processing can be performed, thereby reducing the calculation amount of the Transformer neural network model and improving the prediction accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] Figure 1 is a flow chart of Example 1;

[0062] Figure 2 is a schematic diagram of a process for screening coupling features in Example 1;

[0063] Figure 3 is a schematic diagram of the structure of the attention mechanism variable weighted model of Example 1;

[0064] Figure 4 is a performance comparison chart of the method in Example 1 and the traditional prediction method based on the Transformer model;

[0065] Figure 5 This is a schematic diagram of the greenhouse soil temperature prediction results illustrated in Example 1. DETAILED DESCRIPTION

[0066] The technical solution of the present invention is further specifically described below through embodiments and in conjunction with the accompanying drawings.

[0067] Embodiment 1: A greenhouse soil temperature prediction method of this embodiment, such as Figure 1 As shown, the following steps are included:

[0068] S1: Sampling environmental data of a greenhouse within a preset time period, wherein the environmental data includes greenhouse soil temperature and m environmental characteristics.

[0069] S2: Preprocess the sampled environmental data.

[0070] The method for preprocessing environmental data includes the following steps: performing data cleaning on the environmental data, and normalizing the cleaned environmental data.

[0071] The method for cleaning environmental data comprises the following steps: when environmental data at a certain sampling moment is missing, linear interpolation of environmental data at two adjacent sampling moments is used to fill in the missing data.

[0072] The normalization method is the maximum and minimum normalization method. The normalization interval is [-1, 1]. The formula is as follows:

[0073] ,

[0074] Among them, f is the environmental data to be normalized, is the data after maximum and minimum normalization, f max is the maximum value of the same environmental data, f min It is the minimum value of the same environmental data.

[0075] In the process of greenhouse environmental data collection, data missing and abnormal conditions caused by sensor collection failure or data transmission problems will affect the prediction accuracy. In order to improve the accuracy of the environmental data itself, this method first observes the overall distribution of the data and eliminates abnormal data. For missing data, linear interpolation of data from two adjacent time points is used to fill it. Then, in order to eliminate the dimensional influence between environmental data and speed up the convergence of the model, the maximum and minimum normalization method is used to normalize the data.

[0076] S3: Analyze the coupling relationship between each environmental feature and the greenhouse soil temperature, and select environmental features with strong coupling relationship with the greenhouse soil temperature as coupling features.

[0077] The method for analyzing the coupling relationship between a certain environmental feature and the greenhouse soil temperature is as follows:

[0078] The coupling correlation coefficient D between the environmental characteristics and the greenhouse soil temperature is calculated. If the coupling correlation coefficient D≥the set value M, it means that the coupling relationship between the environmental characteristics and the greenhouse soil temperature is strong. If the coupling correlation coefficient D<the set value M, it means that the coupling relationship between the environmental characteristics and the greenhouse soil temperature is weak.

[0079] m environmental features are numbered 1, 2, ..., m, 1≤j≤m, and the coupling correlation coefficient D between the environmental feature numbered j and the greenhouse soil temperature is calculated. j The calculation formula is as follows:

[0080] ,

[0081] ,

[0082] Where n is the number of sampling times, 1≤i≤n, X ji is the value of the environmental feature numbered j collected at the i-th sampling moment, Y i is the value of greenhouse soil temperature collected at the i-th sampling moment, is the mean value of the environmental feature numbered j collected from n samplings, is the mean value of greenhouse soil temperature collected by n samplings, is the sample standard deviation of the environmental characteristic numbered j, is the sample standard deviation of greenhouse soil temperature.

[0083] The coupling relationship between various environmental characteristics of the greenhouse and the greenhouse soil temperature is complex. This method uses the coupling correlation coefficient D to represent the coupling degree between the environmental characteristics and the greenhouse soil temperature. The coupling correlation coefficient D can characterize any regression relationship between a single environmental characteristic and the greenhouse soil temperature, rather than just the linear or nonlinear relationship between the two. The environmental characteristics with a coupling correlation coefficient D ≥ the set value M between the greenhouse soil temperature and the greenhouse soil temperature are taken as coupling characteristics.

[0084] For example: Figure 2 As shown, for t0, t1, ..., t n The environmental data of the greenhouse is sampled at each moment, and the m environmental features are recorded as V1, V2, ... V m , the greenhouse soil temperature is recorded as V m+1 , calculate the coupling correlation coefficient D between each environmental feature and the greenhouse soil temperature, and obtain m coupling correlation coefficients, which are recorded as D1, D2, ..., D m , where the coupling correlation coefficient D between the environmental characteristics V1, V2, V3, V4 and the greenhouse soil temperature is ≥ the set value M, then the environmental characteristics V1, V2, V3, V4 are selected as coupling characteristics.

[0085] S4: The greenhouse soil temperature and the screened coupling features are combined into a first data set, and the attention mechanism variable weighted model is used to weight the data in the first data set to obtain a second data set.

[0086] The method of using the attention mechanism variable weighted model to weight the data in the first data set to obtain the second data set includes the following steps:

[0087] The first data set is input into the attention mechanism variable weighted model. The formula of the attention mechanism variable weighted model is as follows:

[0088] ,

[0089] ,

[0090] Wherein, F is the first data set, W(F) is the weight matrix, Conv(.) indicates convolution processing, MaxPool(.) indicates maximum pooling processing, AvgPool(.) indicates average pooling processing, StochasticPool(.) indicates random pooling processing, and MLP(.) indicates multi-layer perception processing. is the sigmoid activation function;

[0091] The formula for multi-layer perception processing is as follows:

[0092] ,

[0093] ,

[0094] Among them, x0 is the input of multi-layer perception processing, y1 is the output of multi-layer perception processing, w0 and w1 are weights, and b0 and b1 are bias values;

[0095] The attention mechanism variable weights the model output as the second data set.

[0096] First, the input data is convolved. The local perception and parameter sharing characteristics of the convolution kernel can effectively capture the local pattern and structural information in the time series array, thereby improving the model's ability to understand and represent complex data. This enables the model to more accurately adjust and learn the weights between variables and more effectively process two-dimensional data such as time series. In contrast, not adding convolution may cause the model to perform poorly when processing large-scale data because it lacks sensitivity to local patterns and structures, and may require more parameters and computing resources to capture the complex relationships of the data, while it is difficult to maintain the generalization ability and efficiency of the model. In the subsequent pooling process, maximum pooling, average pooling, and random pooling are performed. Maximum pooling retains the maximum value in the time series data, average pooling considers each feature in the time series data, and random pooling randomly selects a subset within the pooling window for pooling operations, so that the data processed by the model during each training is random, thereby reducing the risk of overfitting. This method can not only better handle complex two-dimensional data features, but also effectively adapt to different samples and scenarios, making the model more robust and practical.

[0097] The structure of the attention mechanism variable weighted model, such as Figure 3 As shown in the figure, the first data set F is first flattened into a one-dimensional vector by column and then input into the convolution layer Conv. The convolution kernel size is set to 3, the step size is set to 1, and the data is convolved along the time dimension and then passes through the maximum pooling layer MaxPool, the average pooling layer AvgPool and the random pooling layer StochasticPool in parallel to obtain 3 parallel pooling layer data. The data passes through the same multi-layer perceptron MLP to obtain 3 features of the same size. The multi-layer perceptron MLP includes a fully connected layer MLP1 and a fully connected layer MLP2. After the original features are convolutionally pooled, they pass through two fully connected layers to realize feature conversion and extraction. The maximum pooling layer MaxPool can retain the maximum value in the time series data, the average pooling layer AvgPool considers each feature in the time series data, and the random pooling layer StochasticPool considers the influence of random noise data in the time series features. These features are added together to obtain the weight matrix W(F). Finally, the weight matrix W(F) is multiplied by the input first data set F to obtain the output second data set. .

[0098] S5: construct a Transformer neural network model, input the second data set into the Transformer neural network model, and the Transformer neural network model outputs a predicted value of the greenhouse soil temperature within a specified time period in the future.

[0099] The second dataset is divided into a training set and a test set in a ratio of 8:2. The training set is used for model training, and the test set is used to evaluate the generalization ability of the model.

[0100] In this scheme, the m environmental characteristics include air temperature in the greenhouse, air humidity in the greenhouse, soil moisture in the greenhouse, light intensity in the greenhouse, carbon dioxide concentration in the greenhouse, effective photosynthetic radiation in the greenhouse, air temperature outside the greenhouse, ground pressure outside the greenhouse, relative humidity outside the greenhouse, and wind speed outside the greenhouse.

[0101] First, the environmental data of the greenhouse in historical time is collected. After analyzing the coupling relationship between each environmental feature and the greenhouse soil temperature, the environmental features with weak coupling relationship with the greenhouse soil temperature are eliminated, thereby reducing the environmental features input into the Transformer neural network model, reducing the amount of calculation of the Transformer neural network model, and improving the calculation efficiency, thereby reducing the calculation time of the entire method. Due to the strong coupling relationship between the environmental features input into the Transformer neural network model and the soil temperature, and the weighted processing after the attention mechanism variable weighted model, the prediction accuracy is improved.

[0102] Based on the environmental data of the greenhouse in the same preset time period, the method of this embodiment and the traditional prediction method based on the Transformer model are used to predict the greenhouse soil temperature in the future specified time period. The performance of the two methods is compared, as shown in FIG. Figure 4 shown. Figure 4 In the example, the MAE, RMSE, and R 2 All three indicators are better than the traditional prediction method based on the Transformer model, indicating that the method of this embodiment has stronger generalization ability.

[0103] The Transformer neural network model includes a position encoding layer, an encoder layer, and a decoder layer. The Transformer neural network model uses a multi-step time series prediction method, which is to predict data at multiple time points in the future at one time. The position encoding layer adds position encoding information to the input data. The encoder layer takes the output of the position encoding layer as input. This layer includes a multi-head attention mechanism, normalization, a dropout layer, and a linear layer. The calculation of the multi-head attention mechanism is as follows:

[0104] ,

[0105] ,

[0106] ,

[0107] ,

[0108] First, input After layer normalization, a multi-head self-attention mechanism with deep weights is applied, and the result is similar to the input Additive , this residual connection helps alleviate the gradient vanishing problem and facilitates the training of deep networks. Perform layer normalization and apply the result of MLP to the input to form This structure helps improve the nonlinear expression ability of the model. SA is the calculation process of the scaled dot product attention mechanism. MSA is the calculation process of the multi-head self-attention mechanism.

[0109] The decoder layer includes a linear layer. After the input model data passes through the attention mechanism variable weighting module, the output data size is adjusted to , input_window is the input time window size, batchsize is the number of samples used in each iteration. After the output data passes through the position encoder layer, the sequence position information is added and the size is adjusted to The output data after position encoding is input to the encoder layer, passes through the Linear layer, and then the multi-head self-attention mechanism weights are used to perform weighted summation on the input to obtain the long-term dependency characteristics of the sequence data. At this time, the input and output features remain unchanged. After that, the multi-head self-attention output is normalized, and some neurons are randomly discarded after passing through the Dropout layer to prevent overfitting. The parameter is set to 0.5. At this time, the output feature size is , and then after the Linear layer, the feature output size is adjusted to

[0110] , the feature dimension is expanded from 256 to 2048. After the Dropout layer and the linear layer, the feature dimension is reduced from 2048 to 256. Finally, after normalization, the output of the encoder layer is The decoder layer consists of only one linear layer, which reduces the dimension from 256 to 1, and the output size is The Transformer neural network model processes input features through the position encoder layer and the encoder layer, uses the attention mechanism to perform weighted summation on the features, and finally outputs the results through the decoder layer.

[0111] The MSE loss function is used in the training process of the Transformer neural network model to represent the deviation between the actual soil temperature and the predicted soil temperature.

[0112] For example:

[0113] The greenhouse faces south, is 80m long from east to west, 56m wide from north to south, and 8m high. It is equipped with controlled roller blinds, ventilation, and water mist equipment. Tomatoes are grown in the greenhouse. RS-FSXCS-N01-1 sensors and SlabSense-AAAB002 sensors are used to collect environmental data. Environmental data include greenhouse soil temperature, greenhouse air temperature, greenhouse air humidity, greenhouse soil moisture, greenhouse light intensity, greenhouse carbon dioxide concentration, greenhouse effective photosynthetic radiation, greenhouse air temperature, greenhouse ground pressure, greenhouse relative humidity, and greenhouse wind speed. The set value M is 0.5.

[0114] The environmental data of the greenhouse from 0:00 to 13:00 on July 1, 2022 is sampled at 10-minute intervals, and the method of this embodiment is used to predict the greenhouse soil temperature from 13:00 to 20:00 on July 1, 2022, as shown in FIG. Figure 5 As shown, from Figure 5 It can be seen that the actual soil temperature in the greenhouse is very consistent with the predicted soil temperature change trend, which can well reflect the soil temperature change in the greenhouse. It can be used as a reference for the optimization and control strategy of the soil temperature in the greenhouse, and at the same time can make up for the lag problem of environmental control effect to a certain extent.

[0115] Embodiment 2: This embodiment is a method for predicting greenhouse soil temperature. The method of this embodiment is different from the method of Embodiment 1 only in step S3, and the remaining steps are the same.

[0116] Step S3 includes the following steps:

[0117] S31: Calculate the coupling correlation coefficient D between each environmental feature and the greenhouse soil temperature, and group all environmental features with the coupling correlation coefficient D ≥ the set value M into a first environmental feature set.

[0118] m environmental features are numbered 1, 2, ..., m, 1≤j≤m, and the coupling correlation coefficient D between the environmental feature numbered j and the greenhouse soil temperature is calculated. j The calculation formula is as follows:

[0119] ,

[0120] ,

[0121] Where n is the number of sampling times, 1≤i≤n, X ji is the value of the environmental feature numbered j collected at the i-th sampling moment, Y i is the value of greenhouse soil temperature collected at the i-th sampling moment, is the mean value of the environmental feature numbered j collected from n samplings, is the mean value of greenhouse soil temperature collected by n samplings, is the sample standard deviation of the environmental characteristic numbered j, is the sample standard deviation of greenhouse soil temperature.

[0122] S32: Filter the environmental features in the first environmental feature set to obtain a second environmental feature set, where the coupling correlation coefficient E between any two environmental features in the second environmental feature set is less than the set value G, and the environmental features in the second environmental feature set are used as coupling features.

[0123] The method of screening the environmental features in the first environmental feature set to obtain the second environmental feature set is as follows:

[0124] N1: Sort the environmental features in the first environmental feature set according to the coupling correlation coefficient D from large to small, and number them 1, 2...k in sequence, 1≤k≤m, k is the number of environmental features in the first environmental feature set, and set p=1;

[0125] N2: calculate q=p+1;

[0126] N3: Calculate the coupling correlation coefficient E between the environmental feature numbered p and the environmental feature numbered q pq , if E pq < set value G, then the environmental feature numbered q is retained in the first environmental feature set; if E pq ≥ the set value G, then the environmental feature numbered q is deleted from the first environmental feature set;

[0127] N4: Determine whether q is less than k. If so, calculate q=q+1 and then execute step N5; otherwise, execute step N6;

[0128] N5: Determine whether the environmental feature numbered q is in the first environmental feature set. If yes, jump to step N3; otherwise, jump to step N4;

[0129] N6: Determine whether p is less than k-1. If so, calculate p=p+1 and then execute step N7; otherwise, take out the remaining environmental features in the first environmental feature set to form a second environmental feature set;

[0130] N7: Determine whether the environmental feature numbered p is in the first environmental feature set. If so, jump to step N2; otherwise, jump to step N6.

[0131] The coupling correlation coefficient E between the environmental feature numbered p and the environmental feature numbered q pq The calculation formula is as follows:

[0132] ,

[0133] ,

[0134] Where n is the number of sampling times, 1≤i≤n, X pi is the value of the environmental feature numbered p collected at the i-th sampling moment, X qi is the value of the environmental feature numbered q collected at the i-th sampling moment, is the mean value of the environmental feature numbered p collected from n samplings, is the mean value of the environmental feature numbered q collected from n samplings, is the sample standard deviation of the environmental characteristic numbered p, is the sample standard deviation of the environmental characteristic numbered q.

[0135] The m environmental features in this embodiment include air temperature in the greenhouse, air humidity in the greenhouse, soil moisture in the greenhouse, light intensity in the greenhouse, carbon dioxide concentration in the greenhouse, effective photosynthetic radiation in the greenhouse, air temperature outside the greenhouse, ground pressure outside the greenhouse, relative humidity outside the greenhouse, and wind speed outside the greenhouse. The method of this embodiment optimizes step S3 on the basis of the method of embodiment 1. Compared with embodiment 1, this embodiment further screens the environmental features to ensure the independence of each environmental feature in the second environmental feature set, avoids complex coupling between environmental features, and further reduces the environmental features input to the Transformer neural network model on the basis of ensuring prediction accuracy, further reduces the amount of calculation, and improves calculation efficiency.

Claims

1. A greenhouse soil temperature prediction method, characterized in that: The following steps are involved: S1: Sampling environmental data of the greenhouse within a preset time period, wherein the environmental data includes greenhouse soil temperature and multiple environmental characteristics; S2: preprocessing the sampled environmental data; S3: Analyze the coupling relationship between each environmental feature and the greenhouse soil temperature, and select environmental features with strong coupling relationship with the greenhouse soil temperature as coupling features; S4: The greenhouse soil temperature and the selected coupling features are combined into a first data set, and the attention mechanism variable weighted model is used to weight the data in the first data set to obtain a second data set; S5: constructing a Transformer neural network model, inputting the second data set into the Transformer neural network model, and the Transformer neural network model outputs a predicted value of the greenhouse soil temperature within a specified time period in the future; The method for analyzing the coupling relationship between environmental characteristics and greenhouse soil temperature in step S3 is as follows: Calculate the coupling correlation coefficient D between the environmental characteristics and the greenhouse soil temperature. If the coupling correlation coefficient D ≥ the set value M, it means that the coupling relationship between the environmental characteristics and the greenhouse soil temperature is strong. If the coupling correlation coefficient D < the set value M, it means that the coupling relationship between the environmental characteristics and the greenhouse soil temperature is weak. The environmental features are m in number, and the m environmental features are numbered 1, 2, ..., m in sequence, 1≤j≤m, and the coupling correlation coefficient D between the environmental feature numbered j and the greenhouse soil temperature is calculated. j The calculation formula is as follows: , , Where n is the number of sampling times, 1≤i≤n, X ji is the value of the environmental feature numbered j collected at the i-th sampling moment, Y i is the value of greenhouse soil temperature collected at the i-th sampling moment, is the mean value of the environmental feature numbered j collected from n samplings, is the mean value of greenhouse soil temperature collected by n samplings, is the sample standard deviation of the environmental characteristic numbered j, is the sample standard deviation of greenhouse soil temperature.

2. A greenhouse soil temperature prediction method according to claim 1, characterized in that: The multiple environmental characteristics include air temperature in the greenhouse, air humidity in the greenhouse, soil moisture in the greenhouse, light intensity in the greenhouse, carbon dioxide concentration in the greenhouse, effective photosynthetic radiation in the greenhouse, air temperature outside the greenhouse, ground air pressure outside the greenhouse, relative humidity outside the greenhouse, and wind speed outside the greenhouse.

3. A greenhouse soil temperature prediction method according to claim 1, characterized in that: The method for preprocessing the environmental data in step S2 includes the following steps: performing data cleaning on the environmental data, and normalizing the cleaned environmental data.

4. A greenhouse soil temperature prediction method according to claim 3, characterized in that: The method for cleaning environmental data comprises the following steps: when environmental data at a certain sampling moment is missing, linear interpolation of environmental data at two adjacent sampling moments is used to fill in the missing data.

5. A greenhouse soil temperature prediction method according to claim 3, characterized in that: The normalization processing method is a maximum-minimum normalization processing method.

6. A greenhouse soil temperature prediction method according to claim 1, characterized in that: In step S4, the method of using the attention mechanism variable weighted model to perform weighted processing on the data in the first data set to obtain the second data set includes the following steps: The first data set is input into the attention mechanism variable weighted model. The formula of the attention mechanism variable weighted model is as follows: , , Wherein, F is the first data set, W(F) is the weight matrix, Conv(.) indicates convolution processing, MaxPool(.) indicates maximum pooling processing, AvgPool(.) indicates average pooling processing, StochasticPool(.) indicates random pooling processing, and MLP(.) indicates multi-layer perception processing. is the sigmoid activation function; The attention mechanism variable weights the model output as the second data set.

7. A greenhouse soil temperature prediction method according to claim 6, characterized in that: The formula for the multi-layer perception processing is as follows: , , Among them, x0 is the input of multi-layer perception processing, y1 is the output of multi-layer perception processing, w0 and w1 are weights, and b0 and b1 are bias values.

8. A greenhouse soil temperature prediction method according to claim 1, characterized in that: The step S3 comprises the following steps: S31: Calculate the coupling correlation coefficient D between each environmental feature and the greenhouse soil temperature, and form a first environmental feature set with all environmental features having the coupling correlation coefficient D ≥ a set value M; S32: Filter the environmental features in the first environmental feature set to obtain a second environmental feature set, wherein the coupling correlation coefficient E between any two environmental features in the second environmental feature set is less than the set value G, and the environmental features in the second environmental feature set are used as coupling features.

Citation Information

Patent Citations

  • Real estate surveying and mapping data processing method and system based on artificial intelligence

    CN118230175A

  • Greenhouse soil temperature and humidity prediction model construction method, prediction method and device, electronic equipment, storage medium and program product

    CN118261198A