A method for predicting greenhouse temperature based on small samples
Through 1D CNN-GRU deep neural network and transfer learning technology, the problem of universality and insufficient data of facility greenhouse temperature modeling under various different conditions is solved, and efficient and accurate greenhouse temperature prediction is achieved.
Patent Information
- Application Number
- CN202211552061.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-05
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2042-12-05
AI Technical Summary
The prior art under the various greenhouse conditions, the temperature modeling of facilities greenhouses lacks universality, and due to insufficient data, it is difficult to establish high-precision prediction models.
Using a deep learning-based facility greenhouse temperature prediction method, a general greenhouse temperature prediction model is constructed through 1D CNN-GRU deep neural network, and using transfer learning to adjust network parameters in a small sample data set to quickly build multiple prediction models.
It realizes rapid and efficient temperature prediction under a variety of different greenhouse conditions, reduces calculation costs, avoids model overfitting, and improves prediction accuracy and model generalization capabilities.
Smart Images

Figure CN115796040B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of agricultural Internet of Things and agricultural service technology, relates to greenhouse technology, and particularly to a facility greenhouse temperature prediction method based on a small sample. Background Art
[0002] Temperature is one of the important parameters that affect the yield and quality of crops in greenhouses. Too high or too low a temperature will harm the growth and development of crops. Studies have shown that effective temperature control is of great significance to the increase in production of facility agriculture. At present, the production regulation of facility agriculture mostly relies on the relevant experience of producers, and only makes regulatory decisions through data collection and analysis. This method will cause lag in feedback control and affect crop growth. Therefore, integrating multiple environmental factors to construct a facility temperature time series prediction model is an important prerequisite for accurate and efficient control of facility greenhouse temperature.
[0003] The study found that the greenhouse temperature is not only a continuous time series with time-varying, nonlinear, and periodic characteristics, but also has a complex coupling relationship with various environmental factors inside and outside the greenhouse. Factors affecting the temperature in the greenhouse include indoor and outdoor air temperature, indoor and outdoor air relative humidity, outdoor wind speed, outdoor wind direction, indoor and outdoor soil temperature, indoor and outdoor light intensity, indoor and outdoor CO 2 Independent time series characteristics such as concentration and indoor and outdoor soil moisture, as well as non-time series characteristics such as environmental distribution characteristics, ventilation characteristics, and humidification characteristics. Therefore, in order to couple these characteristic information that affect greenhouse temperature and fully explore the internal potential connections of these characteristics, the greenhouse temperature prediction model must comprehensively consider the impact of multiple environmental factors on greenhouse temperature, which is the key to accurately predict the temperature of the greenhouse.
[0004] In recent years, domestic and foreign scholars have conducted extensive research on greenhouse temperature prediction using a variety of methods. Among them, Zuo Zhiyu et al. (2010) proposed a method of establishing a temperature prediction model using a time series analysis method to address the problem that the existing greenhouse environmental control system cannot accurately predict the greenhouse temperature in the next period; Liu Zhipeng et al. (2017) selected relevant meteorological factors that affect the temperature change in the greenhouse and established a greenhouse temperature prediction model through a stepwise regression analysis method; Li X et al. (2020) proposed a three-dimensional solar greenhouse temperature prediction model based on the BP neural network algorithm; Tian Dong et al. (2020) used the combination of ARIMAI and SVR to improve the approximate simulation ability of edible fungi greenhouse temperature under different environmental conditions. With the development of artificial intelligence technology, more and more scholars have incorporated deep learning algorithms into the prediction of greenhouse temperature. Among them, the special network structure of the convolutional neural network can extract high-dimensional features that reflect the complex and dynamic changes of temperature, and construct the proposed feature vector in the form of a time series as the input of the recurrent neural network to learn the dynamic changes of the features. The recurrent neural network (RNN), gated recurrent unit neural network (GRU) and long short-term neural network (LSTM) have also been applied to the field of temperature prediction by combining convolutional neural networks. For example, Zhao Quanming et al. (2020) proposed a method for predicting temperature and humidity at multiple points in mushroom houses based on CNN-GRU, which mined deep effective information and enabled the GRU model to better learn the high-dimensional time series features extracted by CNN; Elmaz F et al. (2021) proposed a CNN-LSTM architecture for predicting indoor temperature modeling, which solved the problems of temperature nonlinearity and hysteresis and achieved good results. The above methods not only improve the prediction accuracy but also take into account the operating efficiency, improve the performance of the entire model, and provide a theoretical basis for accurate temperature prediction.
[0005] However, current related research focuses on greenhouse temperature modeling at the same location or in the same climate, and rarely considers temperature modeling under a variety of different greenhouse conditions. There have always been the following two defects: First, the model is not universal under a variety of different greenhouse conditions. Since most studies only model greenhouse temperatures at the same location or in the same climate, one type of greenhouse model cannot be migrated to another type of greenhouse model. Different models must be trained according to greenhouse conditions, which increases the computational cost. Second, in computer science, in order to avoid overfitting in deep learning, sufficient training data is usually required. However, every year, a large number of newly built, expanded, and renovated greenhouses have a short operating time and have not accumulated enough historical data, making it difficult to establish a high-precision prediction model. Therefore, there is an urgent need to explore a fast and effective modeling method suitable for this greenhouse. Summary of the invention
[0006] In order to overcome the shortcomings of the above-mentioned prior art, the purpose of the present invention is to provide a facility greenhouse temperature prediction method based on a small sample, so as to quickly and effectively construct a variety of prediction models for a class of greenhouse temperature prediction models with a large amount of data under a variety of different facility greenhouse conditions through transfer learning, so as to make continuous, efficient and accurate predictions on the temperature.
[0007] In order to achieve the above object, the technical solution adopted by the present invention is:
[0008] A method for predicting greenhouse temperature of a facility based on a small sample, comprising:
[0009] Step 1, collecting environmental factors as features and constructing a data set, the environmental factors including: indoor temperature, indoor air relative humidity, indoor soil temperature, indoor light intensity, outdoor air temperature, outdoor air relative humidity and outdoor soil temperature;
[0010] Step 2: Based on the 1D CNN-GRU deep neural network, a general greenhouse temperature prediction model is constructed;
[0011] The 1D CNN-GRU deep neural network is composed of an input layer, a convolutional layer, a recurrent layer and an output layer in sequence; wherein the input layer X t+j,i is a two-dimensional matrix; X t,i~ X t+j,i represents the i-th feature data of the input sample from time t to time t+j; X t,1 ~X t,i Indicates that the sample data at time t has 1 to i features in total; the convolution layer uses a one-dimensional convolution filter to extract the two-dimensional features contained in the data; the recurrent layer selects a two-layer GRU network, constructs the extracted two-dimensional features into a time series and inputs them into the first layer of the GRU network. The first layer of the GRU network returns the complete sequence output at each time step, and the second layer of the GRU network returns the final output of each input sequence; the output layer is a fully connected layer, which outputs the predicted value at the target time;
[0012] Step 3, training the universal greenhouse temperature prediction model, obtaining network parameters corresponding to the optimal prediction result, and obtaining a universal optimal model;
[0013] Step 4: According to the optimal model, adjust its network parameters in a small sample data set in a pre-training and fine-tuning manner based on transfer learning to construct a greenhouse temperature prediction model for greenhouse conditions of facilities in different locations and / or different climates, wherein the types of environmental factors in the small sample data set are consistent with the environmental factors in step 1, but the amount of data is much smaller than the amount of data in the data set constructed in step 1.
[0014] In one embodiment, in step 1, the data in the data set are continuously collected every day according to a set interval T, and the continuous time is not less than one month.
[0015] In one embodiment, in step 2, the model takes indoor temperature, indoor air relative humidity, indoor soil temperature, indoor light intensity, outdoor air temperature, outdoor air relative humidity and outdoor soil temperature as input, and the time step is 6, that is, the input matrix size is 6×7, and the temperature after T time is taken as output, and the output step d is set to predict the temperature change within T×d time.
[0016] In one embodiment, in step 3, all data are first normalized and scaled to [0, 1]; then the normalized data are divided into a training set and a test set, the model is trained with the training set data, and the generalization ability and accuracy of the model are verified with the test set data.
[0017] In one embodiment, in step 3, the size of the convolution layer filter is set to 3, the step size is 1, the number of convolution kernels is 64, the number of output nodes of the recurrent layer is 128, and the number of output nodes of the output layer is 1; the convolution layer converts the input sample data s at time t into t After performing the convolution operation with the one-dimensional convolution kernel, it is biased by b cnn Entering the loop layer through the activation function, in the loop layer, its sample data x t By resetting gate r, updating gate z and providing temporary unit state c at time t, a dot product operation is performed and output to the fully connected layer.
[0018] In one embodiment, in step 2, the input layer, convolution layer, recurrent layer and output layer all use a rectified linear unit (Relu) as an activation function, a mean square error (MSE) as a loss function, and an Adam optimization algorithm is used to update the neural network weights to optimize the model performance; when the model completes the specified number of training rounds, it is determined whether its output result meets the model accuracy. If not, the parameter value is readjusted and training is continued until the model accuracy is reached; if it is satisfied, the result is output.
[0019] In one embodiment, in step 3, the test set temperature is taken as the actual value and the model output value is taken as the predicted value. The two are first denormalized to restore the original dimension level, and then the coefficient of determination R is used to determine the predicted value. 2 The mean square error (MSE) is used as the evaluation index to evaluate the model accuracy and generalization ability.
[0020] In one embodiment, in step 4, the network of the general optimal model is used as a pre-trained network, and the convolutional layer, the convolutional layer and the top recurrent layer, and the convolutional layer and the two recurrent layers of the source domain network are frozen in sequence. When the remaining network parameters are retrained, the target domain data is selected for verification to construct a greenhouse temperature prediction model for facility greenhouse conditions in different locations and / or different climates, so as to achieve accurate prediction of facility greenhouse temperature.
[0021] Compared with the prior art, the present invention comprehensively considers the impact of various environmental factors inside and outside the greenhouse on the temperature inside the greenhouse, and takes accurate and efficient temperature prediction as the goal under various types of greenhouse conditions. It proposes a facility greenhouse temperature prediction model based on deep learning, and verifies the prediction effect of the model at different times (i.e., different weather conditions) and different locations. The beneficial effects of the present invention are mainly reflected in:
[0022] (1) A general greenhouse temperature model is constructed based on a recurrent neural network. The temporal, nonlinear, high volatility and strong coupling characteristics of temperature are fully considered, and effective information contained in environmental data is mined through a convolutional neural network. The extracted high-dimensional features are reduced in dimension, and the extracted deep-level abstract features are converted into global feature vectors as the input of the recurrent layer for effective dynamic time series data modeling. The model's operating efficiency and prediction performance are taken into account, providing a theoretical basis for accurate and efficient temperature prediction under various types of greenhouse conditions.
[0023] (2) Construct a temperature prediction model with small sample data based on transfer learning. Under the same type of conditions and different types of conditions, a type of greenhouse temperature prediction model with a large amount of data is pre-trained, and the network parameters are adjusted in a small data set in a fine-tuning manner to quickly and effectively construct multiple prediction models. This technology prevents model overfitting while reducing the computational cost as much as possible, laying the foundation for precise control of the greenhouse environment of the facility. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 This is a schematic diagram of the structure of the greenhouse internal and external monitoring platform.
[0025] Figure 2 Schematic diagram of the working principle of 1D CNN.
[0026] Figure 3 Schematic diagram of the gated recurrent unit structure.
[0027] Figure 4 Schematic diagram of the 1D CNN-GRU network structure.
[0028] Figure 5 Build a flow chart for the temperature prediction model.
[0029] Figure 6 It is a schematic diagram of the fitting effect of the winter prediction model according to an embodiment of the present invention.
[0030] Figure 7 Schematic diagram of the model migration process. DETAILED DESCRIPTION
[0031] The embodiments of the present invention are described in detail below with reference to the accompanying drawings and examples.
[0032] The present invention provides a facility greenhouse temperature prediction method based on small samples. Firstly, a large number of data sets are obtained as source domains according to the current internal and external environmental information of the greenhouse, and the two-dimensional features contained in the source domain data are mined and extracted through a convolutional neural network; secondly, the extracted feature vectors are constructed as time series input into a recurrent neural network to extract their time features, predict the future greenhouse temperature, and establish a universal optimal model for greenhouse temperature prediction; finally, based on transfer learning, the network parameters are adjusted in a small data set in a pre-training and fine-tuning manner, and a greenhouse temperature prediction model under facility greenhouse conditions in different locations and / or different climates is constructed, laying a foundation for achieving efficient and accurate prediction of greenhouse temperatures of various facilities and precise environmental regulation.
[0033] The prediction method of the present invention can be specifically described as follows:
[0034] Step 1: Collect environmental factors as features and construct a data set, where the environmental factors include: indoor temperature, indoor air relative humidity, indoor soil temperature, indoor light intensity, outdoor air temperature, outdoor air relative humidity and outdoor soil temperature.
[0035] In one embodiment of the present invention, the experiment was conducted from August 13, 2019 to September 11, 2019 (summer), December 2, 2019 to December 31, 2019 (winter), and December 11, 2020 to December 30, 2020 in East 5 and East 3 of Jingyang Vegetable Experimental Demonstration Station of Northwest A&F University, located at 34°53′N, 108°84′E, 404m above sea level, belonging to the warm temperate continental monsoon climate, with an average annual temperature of 13°C. The source domain greenhouse is a single-building single-slope type, with a light steel structure as the frame, a PC board and a silk cotton quilt covering the back slope, and the east, west and north sides are wall parts, all of which are built with clay. It faces south and is 50m long, 10m wide, 3m high at the back wall, 1.6m high at the ridge, equipped with skylights, fans, roller blinds, sunshade nets, wet curtains, sprinklers, etc. The fans speed up the air flow in the greenhouse to adjust the air temperature in the greenhouse, making the temperature values in different places in the greenhouse change evenly.
[0036] During the test period, from December 2, 2019 to December 31, 2019, there were six types of weather: sunny, sunny to cloudy, cloudy, overcast, haze, and haze to cloudy. In order to further analyze the prediction effect of temperature under different weather conditions, the clarity index K T Classify the above weather. T It characterizes the degree of attenuation of solar radiation when it passes through the atmosphere and is closely related to the weather conditions at the time. As shown in Table 1, winter weather is divided into three categories according to the weather phenomena corresponding to the clarity index. T ≥0.5 for 15 days, 0.5>K T ≥0.2 for 5 days, 0.2>K T ≥0.1 for 10 days, K T <0.1 for 0 days.
[0037] Table 1 Weather phenomena corresponding to the clarity index
[0038]
[0039]
[0040] In the summer, no crops were grown in the greenhouse, and sterilization and airtight treatment were carried out during the experiment. In the winter, tomatoes were grown in the greenhouse, and drip irrigation was used. During the experiment, the insulation blanket was uncovered from 8:00 to 8:30 every day. T ≥0.5 and 0.5>K T ≥0.2, the greenhouse should open windows for ventilation from 10:00 to 10:30; when 0.2>K T When the temperature is ≥0.1, the greenhouse window opening time should be appropriately delayed according to the actual situation.
[0041] refer to Figure 1 ,In order to realize the collection of environmental factors, a ,monitoring platform inside and outside the greenhouse was constructed, which is mainly ,composed of information monitoring module, information transmission module and agricultural production ,IoT monitoring platform.,The data in the dataset are collected continuously ,daily according to the set interval time T, and the continuous time is no ,less than one month.
[0042] In this embodiment, continuous data collection is set from 0:00 to 24:00 every day, and the sampling interval T is 20 minutes. The collected environmental factors include indoor light intensity (QY-150A light intensity sensor, range: 0-200KLux, accuracy: ±1Lux), indoor temperature and outdoor air temperature (PT1000 temperature sensor, range: -200℃~+200℃, accuracy: ±0.1℃), indoor and outdoor air relative humidity (DHT11 humidity sensor, range: 20%~90%, accuracy: ±5%), indoor and outdoor soil temperature (PT1000 temperature sensor, range: -200℃~+200℃, accuracy: ±0.1℃). The sensor is placed in the middle of the greenhouse, 1.2m above the ground. Data is collected for 30 days each season, and a total of 2160 sets of sample data are obtained each season. The information transmission module sends the perceived information to the gateway node through the ZigBee network for data processing, and then transmits it to the mobile base station through the GPRS network and uses the Web server to achieve remote connection and data interaction, and uploads the acquired data to the agricultural production Internet of Things monitoring platform.
[0043] Step 2: Build a universal greenhouse temperature prediction model.
[0044] On the basis of the experimental data obtained above, in order to quickly and effectively build a variety of prediction models for greenhouses in different locations and / or different climate facilities, it is necessary to establish a universal optimal model for greenhouse temperature prediction, laying the foundation for achieving efficient and accurate prediction of greenhouse temperatures of various facilities and precise environmental control.
[0045] The present invention uses an improved one-dimensional convolutional network (1D CNN) and a gated recurrent unit (GRU) algorithm to construct a temperature prediction model. Among them, 1D CNN is an effective learning framework in deep learning. It simulates the human brain to extract features from local graphs through convolution operations, and has achieved good results in computer vision. At the same time, in sequence problems, 1D CNN can capture the relationship between input data through the filter of the convolution layer, and combine it into a shorter feature sequence and input it into the next layer of the network for prediction. For example, when the convolution sliding window is 5, 1D CNN extracts local one-dimensional sequence segments from the sequence in turn through window sliding and performs dot products with weights, such as Figure 2 shown.
[0046] The gated recurrent unit (GRU) is an optimization network based on recurrent neural networks. By introducing the concept of "gates", it optimizes the internal structure of neurons, selectively transmits information, and solves the problem that recurrent neural networks are difficult to learn long-distance dependencies in sequences. In the hidden layer, each neuron is connected to each other, and the input is not only related to the input layer input, but also to the hidden layer output at the previous moment. Figure 3 As shown in a, x is the total input, h is the hidden layer output, and o is the total output. Figure 3As shown in b, the GRU "gate" includes a reset gate r and an update gate z. The reset gate r fuses the input x t Compared with the historical data h at the previous moment t-1 , and discards the historical data that is irrelevant to time, retaining the dependencies between short sequence data; the update gate z stores the memory h of the previous moment t-1 , selectively memorize information and continuously update its value to capture the dependencies between long sequence data.
[0047] Based on the above network structure, the present invention builds a 1D CNN-GRU deep neural network, whose specific structure is as follows Figure 4 As shown in Figure 1, the overall structure is connected in a stacked manner and consists of an input layer, a convolutional layer, a recurrent layer, and an output layer. t+j,i is a two-dimensional matrix, i is the number of features, j is the time step; X t,i~ X t+j,i represents the i-th feature data of the input sample from time t to time t+j; X t,1 ~X t,i Indicates that the sample data at time t has 1 to i features. The convolution layer uses a one-dimensional convolution filter to extract the two-dimensional features contained in the data. Because the sample data has a small dimension, no pooling layer is added. The circulation layer selects a two-layer GRU network, and constructs the extracted two-dimensional features into a time series input to the first layer of the GRU network. The first layer of the GRU network returns the complete sequence of outputs at each time step, and the second layer of the GRU network returns the final output of each input sequence. The output layer is a fully connected layer that outputs the predicted value at the target time.
[0048] In the embodiment of the present invention, the winter model takes indoor temperature, indoor air relative humidity, indoor soil temperature, indoor light intensity, outdoor air temperature, outdoor air relative humidity and outdoor soil temperature as input, and the time step is 6, that is, the input matrix size is 6×7. The temperature after T time is output, the output step is d, and the temperature change within T×d time is predicted. The specific flow chart is as follows Figure 5 In this embodiment, T is set to 20 minutes, and the output step length is set to 9, so the model is used to predict the temperature change within three hours.
[0049] Step 3: train the universal greenhouse temperature prediction model, obtain network parameters corresponding to the optimal prediction result, and obtain a universal optimal model.
[0050] The training process of the present invention is specifically as follows:
[0051] (1) Since the numerical ranges of different sample data vary greatly and the dimensions are also different, in order to speed up the neural network fitting speed and improve the model prediction accuracy, all sample data are normalized and scaled to [0,1]. The calculation formula used is:
[0052]
[0053] Where x min is the minimum value in each dimension, x max is the maximum value in each dimension, x nor is the normalized data.
[0054] (2) The normalized data is divided into a training set and a test set. The model is trained with the training set data, and the generalization ability and accuracy of the model are verified with the test set data.
[0055] In this embodiment, among the 2160 groups of data after normalization, 1512 groups of data (accounting for 70% of the total sample data) are selected as training sets, and the remaining 648 groups of data (accounting for 30% of the total sample data) are selected as test sets.
[0056] (3) In order to maintain the stability of the network and fully explore the local effective information between data, the present invention sets the convolution layer filter size to 3, the step size to 1, the number of convolution kernels to 64, the number of output nodes of the recurrent layer to 128, and the number of output nodes of the output layer to 1.
[0057] (4) The convolutional layer converts the input sample data s at time t t After performing the convolution operation with the one-dimensional convolution kernel, it is biased by b cnn Enter the loop layer through the activation function, as shown in the following formula.
[0058] y t =f(W cnn *s t +b cnn )
[0059] In the circulation layer, its sample data x t The point multiplication operation is performed by resetting gate r, updating gate z and providing temporary unit state c at time t, and then output to the fully connected layer. The specific calculation process is shown in the following formula.
[0060] z=sigmoid(W z h t-1 +U z x t )
[0061] r = sigmoid(W r h t-1 +U r x t )
[0062]
[0063]
[0064] Where f is the activation function, W cnn is the weight matrix corresponding to the input layer to the convolutional layer, s t is the input sample data at time t, b cnn is the bias matrix corresponding to the input layer to the convolution layer, y t Output data for the convolution layer, in y t Based on this, we can extract a two-dimensional matrix and get x t .W z , W r , W c , U z , U r , U c Weight matrices for update gates, reset gates, and temporary outputs.
[0065] (5) Each network layer (i.e., input layer, convolutional layer, recurrent layer, and output layer) uses the Rectified Linear Unit (Relu) as the activation function and the Mean Square Error (MSE) as the loss function. At the same time, in order to update the neural network weights W, U, and V, the Adam optimization algorithm is used to update the neural network weights to achieve the best model performance. When the model completes the specified number of training rounds, it is determined whether its output results meet the model accuracy. If not, the parameter values are readjusted and training is continued until the model accuracy is reached; if it is satisfied, the results are output.
[0066] (6) Taking the test set temperature as the actual value and the model output value as the predicted value, first denormalize the two to restore the original dimension level, and then use the determination coefficient R 2 The mean square error (MSE) is used as the evaluation index to evaluate the model accuracy and generalization ability.
[0067] In order to verify the generalization ability and prediction performance of the winter solar greenhouse temperature prediction model constructed in this step, 648 sets of sample data of the temperature test set after 20 minutes are used to verify it. The verification results show that the determination coefficient of the model training set is 0.998, the mean square error is 0.101℃, and the average error is 0.199℃; the determination coefficient of the test set is 0.998, the mean square error is 0.085℃, and the average error is 0.185℃. Figure 6 As shown, the fitting coefficient of the fitting line is 1.001, which is almost close to 1, and the intercept is -0.009, which is almost close to 0, indicating that the predicted value and the actual value of the model are almost on both sides of the straight line y=x, and there is a strong correlation between the two. The model achieves ideal prediction accuracy.
[0068] On this basis, in order to further verify the changes in the prediction accuracy of the winter model after 20 minutes, 40 minutes, 1 hour, 1 hour and 20 minutes, 1 hour and 40 minutes, 2 hours, 2 hours and 20 minutes, 2 hours and 40 minutes, and 3 hours, the coefficient R 2 , mean square error MSE and mean absolute error MAE are the evaluation indicators. The specific results are shown in Table 4.
[0069] Table 4 Multi-step prediction duration results of winter model
[0070]
[0071] As shown in Table 4, the accuracy of the winter model gradually decreases with the increase of step length. The model can accurately predict the temperature in the first 9 steps, that is, the temperature after 20 minutes to 3 hours. The range of the model determination coefficient in the first 9 steps is 0.964-0.998, the range of the mean square error is 0.085℃-2.276℃, and the range of the mean absolute error is 0.185℃-0.927℃, which meets the precision requirements of agricultural production regulation. Farmers can choose an appropriate step length to predict the future trend of greenhouse temperature according to their own needs.
[0072] In order to verify the prediction performance of the algorithm of the present invention, the model accuracy after 20 minutes is taken as an example, and the determination coefficient R 2 , mean square error (MSE) and mean absolute error (MAE) were used as evaluation indicators. Multiple linear regression (MLR), time series analysis (AR), BP neural network algorithm, support vector machine regression (SVR) and one-dimensional convolutional gated recurrent unit network (1D CNN-GRU) were selected for modeling comparison after parameter optimization. The prediction results of the five models are shown in Table 5.
[0073] Table 5 Comparison results of different algorithms
[0074]
[0075]
[0076] As shown in Table 5, the one-dimensional convolution gated recurrent unit algorithm is significantly better than the statistical methods represented by multivariate linear regression and time series analysis, and the shallow neural network methods represented by BP neural network algorithm and support vector machine regression. This is because the statistical method is based on linear mathematical equations and it is difficult to establish an accurate mathematical model; the shallow neural network method has limited processing capabilities for multidimensional time series data and it is difficult to accurately predict large-scale sample data. In the one-dimensional convolution gated recurrent unit, since the one-dimensional convolution can obtain the effective features that are interconnected in the multidimensional data, and the gated recurrent unit network can better learn the time series features, the algorithm can greatly improve the temperature prediction accuracy.
[0077] In summary, the models established with one-dimensional convolutional gated recurrent unit networks are significantly better than the above four groups of control models in predicting temperature time series data, thus verifying the superiority of the algorithm.
[0078] At the same time, to verify the winter model at different K T The applicability of the model is tested on three types of weather from December 23, 2019 to December 31, 2019. Among them, December 26 (sunny), December 27 (sunny to cloudy), December 28 (sunny), December 30 (sunny) and December 31 (sunny) are K T ≥0.5; December 25 (cloudy) 0.5>K T ≥0.2; December 23 (haze), December 24 (haze) and December 29 (haze turning to cloudy) 0.2>K T ≥0.1. Based on the above constructed models, the MLR model and BP model are compared with the 1D CNN-GRU model. The three models have different K T The prediction results are shown in Table 6.
[0079] Table 6 Different K in winter T The following multiple models verify the results
[0080]
[0081]
[0082] As shown in Table 6, in the three types of K T The 1D CNN-GRU model has the best prediction effect, while the MLR model has the worst prediction effect. T When K ≥ 0.5, the indoor lighting is almost unaffected by clouds due to the sunny weather and few clouds in Shaanxi Province in winter, and the illuminance value fluctuates slightly. Therefore, the prediction effect of the 1D CNN-GRU model is better than that of 0.5>K T ≥0.2 and 0.2>K T ≥0.1 is the best. When 0.5>K T When K ≥0.2, although the prediction errors of the three models fluctuate slightly, the fit between the predicted values and the actual values is low. This is because the cloudy greenhouse is affected by the movement of the cloud layer, which moves quickly and its thickness changes constantly, resulting in large fluctuations in indoor light intensity and a certain degree of prediction error in the model. T When ≥0.1, the particles in haze weather will affect the light intensity indoors, so the prediction effect of the 1D CNN-GRU model is not as good as that of sunny days. Taking all factors into consideration, the winter solar greenhouse temperature prediction model is T The prediction effect is best when the weather is ≥0.5 (sunny), and in the three categories of KT Although the prediction effects of the following models are different, their coefficients of determination are all above 0.984, their mean square errors are all below 0.115℃, and their mean absolute errors are all below 0.218℃. T The following models all showed high accuracy, indicating that this method is applicable and can be applied to actual production. In winter, when indoor solar radiation is weak, the model can be used to predict the temperature in advance, and heating equipment can be used to supplement the heating of the greenhouse, providing a reliable basis for high-quality crop production.
[0083] Step 4: Based on the optimal model obtained, the network parameters are adjusted in the small sample data set by pre-training and fine-tuning based on transfer learning to build a greenhouse temperature prediction model for greenhouse conditions in facilities at different locations and / or different climates. The types of environmental factors in the small sample data set are consistent with those in step 1, but the amount of data is often much smaller than the amount of data in the data set constructed in step 1.
[0084] Transfer learning is a machine learning method that reuses a pre-trained model in another task. Compared with traditional methods, it can effectively avoid the problem of insufficient training samples and improve the generalization ability of the model, thereby improving the prediction accuracy of models with insufficient training sets. Hu Q et al. (2016) and Huang X et al. (2020) applied transfer learning methods to wind speed prediction and weather forecast processing, respectively. By pre-learning a large number of samples and transferring knowledge in a small number of samples, they solved the problem of overfitting of a small number of samples and improved the prediction accuracy. Transfer learning is different from the basic assumptions of traditional machine learning methods, that is, training and test data are extracted from the same feature space and satisfy similar data distributions. Its goal is to apply the knowledge or patterns learned in a certain field or task to different but related fields or problems. It is an effective strategy for small sample prediction, including instance-based transfer, feature-based transfer, and model-shared parameter-based transfer. Among them, the transfer learning method based on model-shared parameters can embed the network model pre-trained in a large-scale dataset into other task models as a feature extractor, thereby effectively extracting the deep feature information of small sample data for prediction.
[0085] Transfer learning mainly includes two concepts: domain and task. The domain is the type and composition of the data, representing the basic attributes; the task is the attribute completed using the data, which is the prediction task in this invention. Usually the domain consists of two parts, which can be expressed as D = {Z, P(Z)}, namely the feature space Z and the marginal distribution P(Z) of the feature space. The feature space Z can be expressed as Z = {z|z i ∈Z,i=1,2....n}. Given a domain D={Z,P(Z)}, a task can be represented as T={Y,f(·)}, i.e., a label control Y and a target prediction function f(·).
[0086] Most existing transfer learning only considers the existence of a source domain D s and a target domain D t The case of single-source domain transfer learning is called single-source domain transfer learning. Let the source domain D s ={(z s,1 ,y s,1 ),(z s,2 ,y s,2 ),...,(z s,n ,y s,n )},z (s,j) ∈Z s represents the observed samples in the source domain, y (s,j) ∈Y s Represents the source domain observation sample z (s,j) Corresponding label. Target domain D t ={(z t,1 ,y t,1 ),(z t,2 ,y t,2 ),...,(z t,n ,y t,n )},z (t,j) ∈Z t represents the target domain observation sample, y (t,j) ∈Y t represents the target domain sample z (t,j) Based on the above symbolic definition, the purpose of transfer learning is: s and source domain learning task T s , target domain D t and the target domain task T t , and satisfies D t ≠D s and T t ≠T s In this case, by using the source domain D s and T s knowledge in the target domain D t The learning effect of the target prediction function f(·) in .
[0087] On this basis, in order to solve the problems of low greenhouse temperature prediction accuracy and overfitting in the case of insufficient data, the present invention constructs a variety of different types of greenhouse temperature prediction models based on transfer learning, and obtains the universal optimal model for greenhouse temperature prediction established by the present invention, and uses fine-tuning to adjust the network parameters in a small data set. Specifically, the network of the optimal model is used as the pre-trained network, and the source domain network freezes the convolution layer, freezes the convolution layer and the top circulation layer, and freezes the convolution layer and the two circulation layers in turn. When the remaining network parameters are retrained, they are verified with the target domain data to construct a greenhouse temperature prediction model for facility greenhouses in different locations and / or different climates, and realize accurate prediction of facility greenhouse temperatures. Transfer learning and feature extraction complement each other. For the frozen model base used for feature extraction, the top few layers are "thawed", and these thawed layers and the newly added parts are jointly trained. The specific migration process is as follows: Figure 7 shown.
[0088] Since the temperature change trends of the same type of greenhouses vary due to factors such as geographical location and crop growth, for the same type of greenhouse, if the trained greenhouse temperature prediction model of a certain location can be applied to greenhouses in other locations, time costs can be saved to a great extent. Therefore, the data of East No. 5 Solar Greenhouse from December 2, 2019 to December 31, 2019 are selected as the initial source domain of the example; the data of East No. 3 Solar Greenhouse from December 11, 2020 to December 30, 2020 are selected as the target domain.
[0089] The network of the East No. 5 winter temperature prediction model established by the present invention is used as the pre-trained network. When the source domain network freezes the convolution layer and the other network parameters are retrained, the target domain selects the data from December 11, 2020 to December 24, 2020 (a total of 14 days) and the data from December 11, 2020 to December 19, 2020 (a total of 9 days) of the East No. 3 solar greenhouse as the training set training model; when the source domain network freezes the convolution layer and the top circulation layer, and the other network parameters are retrained, the target domain still selects the data from December 11, 2020 to December 24, 2020 (a total of 14 days) of the East No. 3 solar greenhouse. The data from December 11, 2020 to December 24, 2020 (a total of 14 days) and the data from December 11, 2020 to December 19, 2020 (a total of 9 days) were used as training sets to train the model; when the convolutional layer and two recurrent layers of the source domain network were frozen and the remaining network parameters were retrained, the target domain selected the data from December 11, 2020 to December 16, 2020 (a total of 6 days) and the data from December 11, 2020 to December 13, 2020 (a total of 3 days) of the East No. 3 Solar Greenhouse as the training set to train the model. The above models all used the data from December 25, 2020 to December 30, 2020 (a total of 6 days) as the test set to verify the generalization ability and accuracy of the model. The specific results of the model are shown in Table 7.
[0090] Table 7 Prediction duration is 20 minutes
[0091]
[0092] As shown in Table 7, the models built with 1 to 3 freezing layers perform better in all evaluation indicators, and the fewer freezing layers, the higher the accuracy of the model. At the same time, when the number of freezing layers is 1, the model with 14 days in the training set has better prediction effect on the test set than the model with 9 days, and the MSE of the training set is 0.265℃, and the MSE of the test set is 0.172℃. The difference between the results of the two sets is small, indicating that the generalization ability is better than the 9-day model. In addition, when the number of freezing layers is 2 to 3, the difference between the training set days of 14 days and 9 days and 6 days and 3 days in the test set is not obvious, which shows that when the number of freezing layers is large, the prediction model based on small sample data can achieve twice the prediction effect of small sample data.
[0093] Similarly, to verify the applicability of this method under multiple step lengths, a comparative verification is performed with a prediction time of 40 minutes and 1 hour as shown in Tables 8 and 9.
[0094] Table 8 Prediction duration is 40 minutes
[0095]
[0096] Table 9 Prediction duration is 1 hour
[0097]
[0098] The results in Tables 8 and 9 show that the three freezing effects also show similar characteristics in the modeling of different prediction durations. When the network freezes one layer, the model has the highest accuracy and the best fitting effect, and the model established for 14 days has higher accuracy than that for 9 days, indicating that the more sample data, the better the model performance in the test set; when the number of network freezing layers increases, the accuracy of the model decreases layer by layer, and there is no obvious advantage in the amount of sample data. At the same time, it can be seen from the above three tables that the accuracy of the model established decreases with the increase of the time step, but it still meets the actual production requirements of agriculture.
[0099] Similarly, since the greenhouse temperature changes differently in different seasons, two temperature models are constructed for winter and summer respectively. However, for the same type of greenhouse, if the trained greenhouse temperature prediction model for one season can be applied to the models of other seasons, the time cost can be saved to a great extent. Therefore, when the winter model is selected as the source domain model, part of the data of East No. 5 Solar Greenhouse from August 13, 2019 to September 11, 2019 (summer) is used as the target domain.
[0100] The network of the winter temperature prediction model established by the present invention is used as the pre-trained network. When the convolution layer of the source domain network is frozen and the other network parameters are retrained, the target domain selects the data from August 13, 2019 to August 26, 2019 in summer (a total of 14 days) and the data from August 18, 2019 to August 26, 2019 (a total of 9 days) as the training set training model; when the convolution layer and the top circulation layer of the source domain network are frozen and the other network parameters are retrained, the target domain still selects the data from August 18, 2019 in summer, 2019. The data from August 13, 2019 to August 26, 2019 (a total of 14 days) and the data from August 18, 2019 to August 26, 2019 (a total of 9 days) were used as training sets to train the model; when the source domain network freezes the convolutional layer and two recurrent layers and the remaining network parameters are retrained, the target domain selects the data from August 21, 2019 to August 26, 2019 (a total of 6 days) and the data from August 24, 2019 to August 26, 2019 (a total of 3 days) in summer as the training set to train the model. The above models all use the data from August 27, 2019 to September 1, 2019 (a total of 6 days) as the test set to verify the generalization ability and accuracy of the model, and use three prediction durations as comparative verification, as shown in Tables 10, 11 and 12.
[0101] Table 10 Prediction duration is 20 minutes
[0102]
[0103] Table 11 Prediction duration is 40 minutes
[0104]
[0105] Table 12 Prediction duration is 1 hour
[0106]
[0107] From the above table, it can be seen that the model built with 1 to 3 frozen layers performs better in all evaluation indicators, and the fewer frozen layers, the higher the accuracy of the model. When the prediction time is 20 minutes, the test set fit is 0.964-0.997, MSE is 0.499℃-6.117℃, and MAE is 0.351℃-1.761℃; when the prediction time is 40 minutes, the test set fit is 0.945-0.997, MSE is 0.460℃-10.021℃, and MAE is 0.423℃-2.224℃; when the prediction time is 1 hour, the test set fit is 0.931-0.997, MSE is 0.464℃-11.688℃, and MAE is 0.485℃-2.539℃. The accuracy of the above models is not much different from the prediction model accuracy when the training data is sufficient in Section 2, and in some cases the prediction accuracy can even exceed the traditional method when the training data is sufficient. It can be seen that the summer temperature prediction model constructed by the pre-training and fine-tuning method has high accuracy, and can achieve continuous and accurate prediction of temperature under different step lengths under the condition of small samples.
[0108] In summary, the current methods mostly use statistical methods and shallow neural network methods, which can only achieve accurate prediction of short-term greenhouse temperature. However, as the prediction time increases, it is difficult to mine the temporal characteristics contained in the data, resulting in a rapid decrease in the prediction accuracy of the model, which is difficult to meet the actual production needs. The present invention provides a facility greenhouse temperature model construction method based on a convolutional neural network and a gated recurrent network, which can be used for long-term prediction. It fully considers the temporal, nonlinear, high volatility and strong coupling characteristics of temperature, and mines the effective information contained in the environmental data through a convolutional neural network; the extracted high-dimensional features are reduced in dimension, and the extracted deep-level abstract features are converted into global feature vectors as the input of the recurrent layer to perform effective dynamic time series data modeling. This method takes into account the operating efficiency and prediction performance of the model, and provides a theoretical basis for accurately and efficiently predicting temperature under various types of greenhouse conditions. At the same time, the transfer learning method used in the present invention adjusts the network parameters in a small data set in a fine-tuning manner, and quickly and effectively constructs a variety of prediction models. While preventing the model from overfitting, this technology reduces the computational cost as much as possible, laying the foundation for accurate control of the facility greenhouse environment.
Claims
1. A method for predicting greenhouse temperature of a facility based on a small sample, characterized in that: include: Step 1, collecting environmental factors as features and constructing a data set, the environmental factors including: indoor temperature, indoor air relative humidity, indoor soil temperature, indoor light intensity, outdoor air temperature, outdoor air relative humidity and outdoor soil temperature; Step 2: Based on the 1D CNN-GRU deep neural network, a general greenhouse temperature prediction model is constructed; The 1D CNN-GRU deep neural network is composed of an input layer, a convolutional layer, a recurrent layer and an output layer in sequence; wherein the input layer X t+j,i is a two-dimensional matrix; X t,i~ X t+j,i represents the i-th feature data of the input sample from time t to time t+j; X t,1 ~X t,i Indicates that the sample data at time t has 1 to i features in total; the convolution layer uses a one-dimensional convolution filter to extract the two-dimensional features contained in the data; the recurrent layer selects a two-layer GRU network, constructs the extracted two-dimensional features into a time series and inputs them into the first layer of the GRU network. The first layer of the GRU network returns the complete sequence output at each time step, and the second layer of the GRU network returns the final output of each input sequence; the output layer is a fully connected layer, which outputs the predicted value at the target time; Step 3, training the universal greenhouse temperature prediction model, obtaining network parameters corresponding to the optimal prediction result, and obtaining a universal optimal model; Step 4: According to the optimal model, adjust its network parameters in a small sample data set in a pre-training and fine-tuning manner based on transfer learning to construct a greenhouse temperature prediction model for greenhouse conditions of facilities in different locations and / or different climates, wherein the types of environmental factors in the small sample data set are consistent with the environmental factors in step 1, but the amount of data is much smaller than the amount of data in the data set constructed in step 1.
2. The facility greenhouse temperature prediction method based on a small sample according to claim 1 is characterized in that: In the step 1, the data in the data set are collected continuously every day according to the set interval time T, and the continuous time is not less than one month.
3. The facility greenhouse temperature prediction method based on a small sample according to claim 2 is characterized in that: In step 2, the model takes indoor temperature, indoor air relative humidity, indoor soil temperature, indoor light intensity, outdoor air temperature, outdoor air relative humidity and outdoor soil temperature as input, with a time step of 6, that is, the input matrix size is 6×7, and takes the temperature after T time as output, and sets the output step d to predict the temperature change within T×d time.
4. The facility greenhouse temperature prediction method based on a small sample according to claim 1 is characterized in that: In step 3, all data are first normalized and scaled to [0, 1]; then the normalized data are divided into a training set and a test set, the model is trained with the training set data, and the generalization ability and accuracy of the model are verified with the test set data.
5. The facility greenhouse temperature prediction method based on a small sample according to claim 1 is characterized in that: In step 3, the size of the convolution layer filter is set to 3, the step size is 1, the number of convolution kernels is 64, the number of output nodes of the recurrent layer is 128, and the number of output nodes of the output layer is 1; the convolution layer converts the input sample data s at time t into t After performing the convolution operation with the one-dimensional convolution kernel, it is biased by b cnn Entering the loop layer through the activation function, in the loop layer, its sample data x t By resetting gate r, updating gate z and providing temporary unit state c at time t, a dot product operation is performed and output to the fully connected layer.
6. The facility greenhouse temperature prediction method based on a small sample according to claim 5 is characterized in that: In the step 2, the input layer, convolution layer, recurrent layer and output layer all use the rectified linear unit (Relu) as the activation function, the mean square error (MSE) as the loss function, and the Adam optimization algorithm is used to update the neural network weights to optimize the model performance; when the model completes the specified number of training rounds, it is determined whether its output result meets the model accuracy. If not, the parameter value is readjusted and training is continued until the model accuracy is reached; if it is satisfied, the result is output.
7. The facility greenhouse temperature prediction method based on a small sample according to claim 6 is characterized in that: In step 3, the test set temperature is taken as the actual value and the model output value is taken as the predicted value. The two are first denormalized to restore the original dimension level, and then the coefficient of determination R is used to determine the 2 The mean square error (MSE) is used as the evaluation index to evaluate the model accuracy and generalization ability.
8. The facility greenhouse temperature prediction method based on a small sample according to claim 1, characterized in that: In step 4, the network of the general optimal model is used as a pre-trained network, and the convolutional layer, the convolutional layer and the top recurrent layer, and the convolutional layer and the two recurrent layers of the source domain network are frozen in sequence. When the remaining network parameters are retrained, the target domain data is selected for verification to construct a greenhouse temperature prediction model for facility greenhouse conditions in different locations and / or different climates, so as to achieve accurate prediction of facility greenhouse temperature.