Cotton nitrogen content prediction method and system based on small sample hyperspectral data
By using the 1D-CNN and DF monitoring model and BiLSTM&Transformer and TCN-Transformer timing prediction models in cotton nitrogen content prediction, the accuracy and timeliness prediction of cotton nitrogen content under small sample hyperspectral data are solved, and efficient and accurate nitrogen content prediction and crop production management support are achieved.
Patent Information
- Application Number
- CN202411725993.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-21
AI Technical Summary
The prior art is difficult to effectively use small sample hyperspectral data to accurately predict cotton nitrogen content, and the traditional machine learning method lacks in inversion accuracy, which cannot meet the timeliness requirements for dynamic changes in crop nitrogen content.
The monitoring model based on 1D-CNN and DF is used to train small sample hyperspectral data to generate time-series data of the nitrogen content of cotton leaves, and timing prediction is performed through BiLSTM&Transformer and TCN-Transformer models to achieve accurate prediction of cotton nitrogen content.
It improves the accuracy and agingness of cotton nitrogen content prediction, and can effectively adapt the dynamic trend of nitrogen content in cooperative substances under small sample conditions, supporting the timing prediction of crop phenotypic parameters and production precision management.
Smart Images

Figure CN119666762A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of agricultural information technology, and more particularly to a method and system for predicting cotton nitrogen content based on small sample hyperspectral data. Background Art
[0002] Nitrogen is one of the most important elements for crop growth and development, and is the main component of proteins, nucleic acids and a large number of other biological molecules. Appropriate nitrogen content is crucial to cotton growth, development, yield and quality. Excessive nitrogen application will lead to ecological and environmental pollution. Therefore, during the cotton growing period, it is of great significance to determine and apply nitrogen fertilizer in a timely, fast and accurate manner.
[0003] With the development of science and technology, hyperspectral has gradually replaced manual experience and chemical titration with its advantages of non-destructive, high sensitivity and rapidity, becoming the mainstream; relevant researchers have used spectral data sources combined with traditional machine learning methods to effectively monitor the nitrogen content of crops such as cotton, potatoes, rice, wheat and corn and put them into use. However, the inversion accuracy of traditional machine learning needs to be improved. An advanced machine learning is called deep learning. Due to multi-layer learning, it can accurately invert the complex nonlinear relationship between parameters. The fitting and generalization performance are significantly improved compared with traditional machine learning. However, conventional deep learning technology cannot meet its training conditions due to the difficulty in obtaining agricultural samples and the small scale, and it is difficult to apply it in crop phenotypic monitoring.
[0004] In addition, nitrogen content changes dynamically during crop growth, and monitoring results at a single time point cannot reflect the changing trend. In production applications, the nitrogen content monitored requires a period of time to determine the appropriate nitrogen application amount, which is time-limited and cannot meet the needs of crops in a timely manner.
[0005] Therefore, how to propose an efficient and accurate cotton nitrogen content prediction method and system is a problem that technical personnel in this field need to solve urgently. Summary of the invention
[0006] In view of this, the present invention provides a method and system for predicting cotton nitrogen content based on small sample hyperspectral data.
[0007] In order to achieve the above object, the present invention adopts the following technical solution:
[0008] In one aspect, the present invention discloses a method for predicting cotton nitrogen content based on small sample hyperspectral data, comprising the following steps:
[0009] Collecting cotton leaf data and preprocessing them to obtain a monitoring data set; the cotton leaf data includes cotton leaf hyperspectral data and cotton leaf nitrogen content data;
[0010] Constructing a monitoring model, and training the monitoring model based on the monitoring data set to obtain an optimal monitoring model;
[0011] Outputting non-destructive cotton leaf nitrogen content data through the optimal monitoring model to construct a cotton leaf nitrogen content time series data set;
[0012] A time series prediction model is constructed, and the cotton leaf nitrogen content time series data set is combined with the time series prediction model to obtain a cotton nitrogen content prediction result.
[0013] Preferably, collecting cotton leaf data includes:
[0014] The cotton plants to be tested were divided into a destructive sampling group and a non-destructive sampling group, and the hyperspectral data of cotton leaves of all cotton plants in the destructive sampling group and the non-destructive sampling group were collected; the cotton leaf nitrogen content data of the cotton plants in the destructive sampling group were collected.
[0015] Preferably, the cotton leaf hyperspectral data is preprocessed, including:
[0016] The hyperspectral data of multiple positions of each cotton leaf are collected and averaged to obtain the mean of the spectral data;
[0017] The mean value of the spectral data of each cotton leaf is used as the original spectral data, and the original spectral data is substituted into the SG filter and then subjected to a first-order differential operation to obtain D1 spectral data;
[0018] The D1 spectral data were processed using the SFLA algorithm, and finally the nitrogen content sensitive band was selected using the Pearson correlation coefficient.
[0019] Preferably, the monitoring model includes a 1D-CNN model or a DF model;
[0020] The 1D-CNN model includes an input layer, a first convolutional layer, a BN layer, a first activation function layer, a first pooling layer, a second convolutional layer, a second activation function layer, a second pooling layer, a third convolutional layer, a third pooling layer, a flattening layer, a first fully connected layer, a third activation function layer, a first Dropout layer, a second fully connected layer, a fourth activation function layer, a second Dropout layer and an output layer connected in sequence;
[0021] The DF model is implemented based on the CascadeForestRegressor architecture. The DF model has a built-in early stopping mechanism based on default tolerance and performance improvement threshold to control the level growth, and uses Grid Search to optimize parameters.
[0022] Preferably, the first activation function layer adopts the Swish activation function, and the second activation function layer, the third activation function layer, and the fourth activation function layer all apply the SELU activation function.
[0023] Preferably, a cotton leaf nitrogen content time series data set is used as an input of the time series prediction model, and the time series prediction model includes a first cycle prediction model and a second cycle prediction model;
[0024] The first cycle prediction model is a BiLSTM&Transformer model; the second cycle prediction model is a TCN-Transformer model;
[0025] The BiLSTM&Transformer model includes a BiLSTM part and a Transformer part that operate in parallel, and performs gated fusion on the output features of the BiLSTM part and the Transformer part to output a cotton nitrogen content prediction result;
[0026] The TCN-Transformer model includes a Transformer part and a TCN part connected in sequence, wherein the Transformer part first extracts global features of the input data, and then focuses on extracting local features through the TCN part, and finally outputs the prediction result of cotton nitrogen content.
[0027] Preferably, the TCN captures short-term fluctuations and long-term dependencies through multi-layer dilated convolutions; the BiLSTM part captures forward and backward dependency information through bidirectional processing; and the Transformer part uses a self-attention mechanism to capture sequence information.
[0028] On the other hand, the present invention also proposes a cotton nitrogen content prediction system based on small sample hyperspectral data, which is used to implement the cotton nitrogen content prediction method based on small sample hyperspectral data, comprising:
[0029] A data processing module is used to collect cotton leaf data and perform preprocessing to obtain a monitoring data set; the cotton leaf data includes cotton leaf hyperspectral data and cotton leaf nitrogen content data;
[0030] A monitoring model design module, used to construct a monitoring model and train the monitoring model based on the monitoring data set to obtain an optimal monitoring model;
[0031] A time series data set construction module, used to output non-destructive cotton leaf nitrogen content data through the optimal monitoring model to construct a cotton leaf nitrogen content time series data set;
[0032] The nitrogen content prediction module is used to construct a time series prediction model. The cotton leaf nitrogen content time series data set is combined with the time series prediction model to obtain the cotton nitrogen content prediction result.
[0033] It can be known from the above technical solutions that compared with the prior art, the present invention discloses a method and system for predicting the nitrogen content of cotton based on small sample hyperspectral data. Destructive and non-destructive hyperspectral data sampling is performed at fixed intervals about 30 days after the cotton seedlings emerge. After destructive sampling, nitrogen determination is carried out in the laboratory to obtain nitrogen content data to train the monitoring model. The present invention adopts 1D-CNN and DF monitoring models suitable for small samples to meet the characteristics of difficult acquisition and small volume of agricultural samples; then the time series of cotton leaf nitrogen content is generated through the optimal monitoring model, and the sliding window method is used to substitute it into the time series prediction structure integrated by TCN, LSTM, BiLSTM and Transformer, combining the advantages of different algorithms to accurately predict the nitrogen content in the future. The present invention provides method support for the time series prediction of crop phenotypic parameters and the precise management of crop production, and contributes to agricultural modernization and sustainable development. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0035] Figure 1 A flow chart of a cotton nitrogen content prediction method based on small sample hyperspectral data provided by the present invention;
[0036] Figure 2 A schematic diagram of the sensitive band screening results provided by the present invention;
[0037] Figure 3 A schematic diagram of the time series of nitrogen content of cotton leaves provided by the present invention;
[0038] Figure 4 The structure diagram of the TCN-Transformer model provided by the present invention;
[0039] Figure 5 A partial structural diagram of the TCN provided by the present invention;
[0040] Figure 6 The LSTM part structure diagram provided by the present invention;
[0041] Figure 7 Partial structure diagram of BiLSTM provided by the present invention;
[0042] Figure 8 A partial structural diagram of the Transformer provided by the present invention;
[0043] Fig. 9 This is the BiLSTM&Transformer structure diagram provided by the present invention. DETAILED DESCRIPTION
[0044] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0045] On the one hand, the present invention discloses a cotton nitrogen content prediction method based on small sample hyperspectral data, referring to Figure 1 , the method comprises the following steps:
[0046] S1. Collect cotton leaf data and preprocess them to obtain a monitoring data set; the cotton leaf data includes cotton leaf hyperspectral data and cotton leaf nitrogen content data.
[0047] The data collected for cotton leaves include:
[0048] The cotton plants to be tested were divided into a destructive sampling group and a non-destructive sampling group, and the hyperspectral data of cotton leaves of all cotton plants in the destructive sampling group and the non-destructive sampling group were collected; the cotton leaf nitrogen content data of the cotton plants in the destructive sampling group were collected.
[0049] Further, the hyperspectral data collection and preprocessing process is as follows:
[0050] In this embodiment, the cotton leaf hyperspectral data is measured by coupling the SR-3500 portable spectrometer (Spectral Evolution Inc., Lawrence, USA) with its special accessory test clip. The spectrum test clip itself has a simulated light source, which can be measured in a closed environment, has stable operation, and is less affected by environmental interference factors. The band range it provides is 350-2500nm, and the data resampling interval is 1nm.
[0051] Destructive and non-destructive data collection of cotton main stems and leaves was carried out simultaneously around 30 days after seedling emergence. Non-destructive sampling was carried out every three days, while destructive sampling was carried out every other time, that is, every seven days. The starting point was chosen to be 30 days after seedling emergence, mainly because in the early stage of cotton growth, the leaf morphology and quantity changed greatly and were relatively fragile, which was not suitable for continuous monitoring; after 30 days, the structure and function of the cotton plant tended to be stable, and the data was highly representative. Each time, one cotton plant under all nitrogen treatments was destructively sampled, and after obtaining the spectral data, the main stem leaves were cut for nitrogen determination to provide a data set for the subsequent construction of the monitoring model; each time, nine cotton plants under all nitrogen treatments were non-destructively sampled, and only spectral data were obtained without cutting. As the cotton plant growth entered the late stage, due to the natural growth cycle, reduced light in the lower part, nutrient redistribution or human intervention (such as moving), some leaves fell off, resulting in interruptions in the time series spectral data; in addition, the period before boll opening is a critical stage for cotton nitrogen accumulation and utilization. During these periods, the nitrogen demand of the plant is high, which significantly affects the growth and development of cotton. When cotton enters the boll opening stage, the vegetative growth of the plant is basically completed. Therefore, the number of non-destructive time series sampling in this embodiment is 21 times, covering the cotton boll development stage.
[0052] Each cotton main stem leaf is measured from bottom to top, and leaves that fall off due to natural or human factors are marked to ensure that the main stem leaf spectral data of each non-destructive sampling can correspond one to one. White board calibration is required before collecting each main stem leaf. When collecting, pay attention to avoid leaf veins and collect 3 positions.
[0053] The spectral data collected by destructive sampling and non-destructive sampling were uniformly preprocessed. First, the mean of the spectral data collected at three positions of each leaf was used as the original spectral data of the leaf, and then substituted into the Savitzky-Golay (SG) filter to smooth the spectral curve and reduce noise while maintaining the spectral information; then the first-order differential (D1) operation was performed to enhance the spectral information by calculating the difference between adjacent bands and reduce the influence of background noise and baseline drift; then the D1 spectral data was substituted into the random frog jumping (SFLA) algorithm, which is similar to the genetic algorithm or particle swarm optimization algorithm, simulating the random jumping behavior of frog groups in the search space to extract useful information from the spectral data, reduce the data dimension, and improve the efficiency and accuracy of the subsequent monitoring and prediction model; finally, the band significantly correlated with the nitrogen content, that is, the nitrogen sensitive band, was selected by the Pearson correlation coefficient to further reduce redundant information.
[0054] The results show that the screened sensitive bands are basically concentrated in the near-infrared region ( Figure 2), this phenomenon is caused by the spatial heterogeneity of spectral characteristics in the field of view. The reflectivity difference in the near-infrared band is greater than that in the visible light band. In the visible light region, crop pigments strongly absorb light, resulting in generally low reflectivity.
[0055] The data collection and preprocessing process of cotton leaf nitrogen content is as follows:
[0056] After obtaining the spectral information, the main stems and leaves of the cotton plants used for destructive sampling were cut and placed in envelopes, and then refrigerated in a small insulated box equipped with an ice crystal box and brought back to the laboratory. In the laboratory, the leaves were dried at 105°C for 30 minutes, then dried at 80°C to constant weight, and the dry weight was weighed to 0.1000g using a 1 / 10,000 balance. 2 SO 4 -H 2 O 2 The cotton leaves were digested by the automatic Kjeldahl nitrogen analyzer and the total nitrogen content was measured.
[0057] The nitrogen contents of all cotton leaves sampled destructively were aggregated and processed together, and the data marked with NULL nitrogen values due to experimental errors were removed as outliers to provide data support for the construction and selection of subsequent monitoring models.
[0058] The monitoring dataset includes cotton leaf hyperspectral data and cotton leaf nitrogen content data of cotton plants used for destructive sampling, which are used for training subsequent detection models.
[0059] S2. Build a monitoring model and train the monitoring model based on the monitoring data set to obtain the optimal monitoring model.
[0060] The input of the monitoring model is the nitrogen content sensitive band obtained after preprocessing, and the output is the estimated value of nitrogen content in the corresponding leaves.
[0061] The output data (model estimated value) obtained by inputting the hyperspectral data of cotton leaves of the destructive sampling group into the monitoring model was compared with the nitrogen content data of cotton leaves of the destructive sampling group (the actual value measured by Kjeldahl nitrogen determination) to train the monitoring model.
[0062] The monitoring model includes a 1D-CNN model or a DF model.
[0063] The structure of the 1D-CNN model in this embodiment is shown in Table 1, including an input layer (with preprocessed cotton leaf hyperspectral data as input data), a first convolutional layer, a BN layer, a first activation function layer, a first pooling layer, a second convolutional layer, a second activation function layer, a second pooling layer, a third convolutional layer, a third pooling layer, a flattening layer, a first fully connected layer, a third activation function layer, a first Dropout layer, a second fully connected layer, a fourth activation function layer, a second Dropout layer and an output layer connected in sequence; wherein the first activation function layer adopts the Swish activation function, and the second activation function layer, the third activation function layer, and the fourth activation function layer all use the SELU activation function.
[0064] The 1D-CNN model structure applies batch normalization to make the feature distribution more stable and help the model converge faster in the case of small samples. The Swish nonlinear activation function is used to effectively improve the expressiveness of the model; the SELU (Scaled Exponential Linear Unit) activation function is also used, which is a self-normalized activation function that helps alleviate the gradient vanishing and gradient exploding problems. It is worth noting that the Swish and SELU activation functions have a good smoothing effect on the expression of nonlinear features and can handle complex feature combinations, which is particularly important under small sample conditions. In addition, considering the problem that small sample data is prone to overfitting, AvgPooling and Dropout layers are introduced into the model to improve the generalization ability of the model and enhance the robustness of the model. 1D-CNN Learning Rate Scheduling settings: step size is 200, gamma value is 0.9; Adam optimizer is used, and the learning rate is 0.001.
[0065] Table 11D-CNN model structure
[0066]
[0067]
[0068] The DF model is implemented based on the CascadeForestRegressor architecture. By stacking multiple levels, the model can gradually learn the deep features of the data and improve its prediction performance. However, not all levels will have a positive impact on model performance. The architecture has a built-in early stopping mechanism based on the default tolerance (n_tolerant_rounds) and performance improvement threshold (delta). Once multiple consecutive levels fail to significantly improve model performance, new levels will be stopped. Grid Search is used to optimize parameters such as the number of ensemble trees (n_estimator), the maximum tree depth (max_depth), and the minimum number of samples required to split internal nodes (min_samples_split). When evaluating the split quality of tree nodes, the mean absolute error (criterion="mae") is selected as the criterion to meet the needs of regression tasks. At the same time, the number of parallel execution tasks is set to the number of all available CPU cores (n_jobs="-1") to accelerate the model training process. To further improve the prediction accuracy of the model, the custom predictor is Extreme gradient boosting (XGBoost)(predictor="xgboost"), which aims to combine the hierarchical feature extraction capability of DF and the learning ability of XGBoost to explore better regression performance.
[0069] This embodiment also includes verification of the performance of the monitoring model.
[0070] The sample size of destructive sampling was 341. A 5-fold cross validation was used to conduct a comprehensive and reliable evaluation of the 1D-CNN and DF models, and compared them with four traditional machine learning and ensemble learning models: RF, Extreme gradient boosting (XGBoost), and Adaptive boosting (AdaBoost). These models were used to fit and generalize the 69 spectral sensitive bands selected with the nitrogen content of cotton leaves. The model test results are shown in Table 2. The training set R 2 Higher, while the validation set R 2It shows insufficient generalization ability, which may be due to the excessive feature dimensions, the model overfits the details instead of learning the essential laws of the data, resulting in overfitting, which affects the performance on the validation set; DF automatically adapts to the feature distribution through a multi-level integrated learning structure, which makes DF superior to traditional machine learning and integrated learning algorithms in the generalization ability of small sample data. However, due to data heterogeneity and the strategy of building multiple models layer by layer in the DF model, a certain degree of overfitting occurs; 1D-CNN has multi-level feature representation capabilities, and the combination of multi-layer convolution and activation functions can capture richer feature information. In addition, by reducing the complexity of the model, the risk of network overfitting is reduced, making it suitable for small sample data. Comprehensive comparison shows that the optimal monitoring model is 1D-CNN, with a validation set R2 of 0.876 and RMSE of 2.410.
[0071] Table 2 Monitoring model performance test results
[0072]
[0073] S3. Output non-destructive cotton leaf nitrogen content data through the optimal monitoring model and construct a cotton leaf nitrogen content time series data set.
[0074] The hyperspectral preprocessing method and the optimized 1D-CNN monitoring model are applied to the spectral time series data of non-destructive sampling. Although the present embodiment carried out 21 non-destructive time series samplings, due to the natural growth cycle of the leaves or the influence of human operation, some leaves grew or fell off during the sampling period, resulting in less than 21 actual data. In order to reduce the error of the monitoring model, 10 non-destructive sampling data (with a time interval of seven days) were finally selected for time series prediction modeling to reduce the high-frequency fluctuations or noise of short-term data. This choice helps to more accurately capture the trend of nitrogen content and avoid the subsequent prediction model from overfitting random fluctuations. In addition, based on the dynamic range, overall trend and previous literature research of all sampling frequency data, the present embodiment uses a graphical inspection method to eliminate more obvious discrete values and smoothes the time series using linear interpolation. At the same time, data with less than eight times of time series and significant non-stationarity are deleted. Figure 3 The data presents the estimated time series data of nitrogen content in some cotton leaves. The nitrogen content in cotton leaves basically shows a trend of "gradually increasing first and then decreasing": in the early stage, the nitrogen content in the leaves increases to support the growth of cotton plants; then the nitrogen content in the leaves decreases to meet the needs of reproductive organ development; however, due to external factors and uneven nitrogen absorption and distribution, some leaves in the data set also show a trend of continuous increase, premature decrease or fluctuation.
[0075] By reasonably balancing the sampling frequency and data quality, increasing the time interval of the prediction model, and smoothing the sequence, the trend of nitrogen content can be effectively captured; in addition, continuous optimization of the monitoring model is crucial, and its higher precision can effectively improve the accuracy and robustness of the prediction. It is worth noting that although the above treatment may introduce systematic biases and retain random errors, it plays an important role in capturing the trend of nitrogen content in cotton leaves and improving the prediction performance of the time series model.
[0076] S4. Construct a time series prediction model. The cotton leaf nitrogen content time series data set is combined with the time series prediction model to obtain the cotton nitrogen content prediction result.
[0077] The cotton leaf nitrogen content time series data set is input into the time series prediction model by using a sliding window method. The time series prediction model includes the first cycle prediction model and the second cycle prediction model.
[0078] The prediction model for the first cycle is the BiLSTM&Transformer model; the prediction model for the second cycle is the TCN-Transformer model;
[0079] The BiLSTM & Transformer model structure is as follows Fig. 9 As shown in the figure, it includes the BiLSTM part and the Transformer part of parallel operation, and the output features of the BiLSTM part and the Transformer part are gated and fused to output the cotton nitrogen content prediction result. The BiLSTM&Transformer model is a parallel structure. By combining the advantages of BiLSTM and Transformer, it is similar to an integrated learning algorithm or a dual-branch convolutional neural network, thereby achieving model complementarity. The BiLSTM&Transformer model involves the outputs of the BiLSTM and Transformer parts, and a feature fusion step is required.
[0080] TCN-Transformer model Figure 4 As shown in the figure, it includes the Transformer part and the TCN part connected in sequence, in which the Transformer part first extracts global features of the input data, so that the subsequent TCN layer can focus more on the extraction of local features, thereby enhancing the model's ability to capture fine-grained patterns based on the preliminary global context, and finally outputs the prediction results of cotton nitrogen content.
[0081] The cotton leaf nitrogen content time series data was substituted into TCN-Transformer. TCN can effectively capture short-term fluctuations and long-term dependencies by expanding the receptive field with fewer network layers through multi-layer extended convolution; while Transformer captures global dependencies through the self-attention mechanism, connects them in series to achieve multi-level feature extraction, and enhances the modeling ability of different types of dependencies. Moreover, both TCN and Transformer can be calculated in parallel, which can improve the overall computing efficiency.
[0082] Specifically, the structure of the TCN part is as follows Figure 5 , a deep neural network composed of multiple dilated causal convolution blocks (DCC Block), each DCC Block extracts features from time series data through causal convolution and dilated convolution operations to capture sequence dependencies. The use of causal convolution is to prevent the leakage of future information by convolution operations and ensure the rationality of the prediction model; the use of dilated convolution allows the convolution kernel to jump sampling in the time dimension, and obtain a larger receptive field range with fewer network layers, thereby capturing dependencies in a longer time range without significantly increasing the computational complexity; in addition, in order to eliminate the gradient vanishing and explosion problems of deep neural networks, TCN usually uses residual connections to promote model training.
[0083] The structure of the LSTM part is as follows Figure 6 Compared with RNN, LSTM adds a memory unit to judge whether the information is useful or not, which solves the gradient vanishing and gradient exploding problems of RNN when dealing with time-dependent problems. The memory unit is used to store long-term information and control the flow of information through a gating mechanism to maintain the time dependency in the entire sequence; the forget gate determines which information in the current memory unit state needs to be discarded through a sigmoid layer; the input gate controls how new information flows into the memory unit; the output gate controls the information in the memory unit to be output to the next time step. The specific formula of the LSTM structure is shown in Table 3:
[0084] Table 3 LSTM gating mechanism formula
[0085]
[0086]
[0087] The BiLSTM part can capture the bidirectional information in the time series data by combining an LSTM that processes the forward sequence (time order) with an LSTM that processes the reverse sequence (time reverse order). That is, the BiLSTM part captures the forward and backward dependency information through bidirectional processing. Specifically, the forward LSTM processes the sequence from left to right according to the time step, and the hidden state h of each time step ist As shown in the previous section, the reverse LSTM processes the sequence from right to left in time steps, and similarly, its hidden state h at each time step can be obtained t '; The final output is obtained by concatenating the hidden states of the two LSTMs, i.e. h bilstm-t =[h t ,h t ']. The BiLSTM structure is as follows Figure 7 As shown:
[0088] The Transformer part is composed of multiple Encoders and Decoders stacked together. Encoders are widely used by researchers for time series data prediction problems due to their excellent global modeling capabilities. This example uses the Encoder in the Transformer to predict the time series nitrogen value of cotton leaves. Its structure is as follows: Figure 8 As shown in the figure, it consists of N identical stacked layers, each of which consists of two modules: Multi-Head Attention and feedforward network. The two modules process data through residual connection and layer normalization. Since the Transformer model does not have built-in sequence position information, it is necessary to introduce sequence position information through position encoding. Position encoding is generated by sine and cosine functions and embedded in the input. Multi-Head Attention, as the core part of Transformer, allows the model to independently calculate attention in multiple different subspaces and splice these results together to capture richer features. For the specific formula of the Transformer part, please refer to Table 4.
[0089] Table 4 Transformer position encoding and multi-head attention mechanism formula
[0090]
[0091] Furthermore, the embodiment of the present invention also verifies the time series prediction model.
[0092] In this embodiment, the sliding window size is set to 7, the step size is set to 1, and each cotton leaf uses the past 7 measurement data to predict the nitrogen content of the leaf in the next 1 or 2 times ([x 1 ,x 2 ,x 3 ,…,x 6 ,x 7 ]Prediction[x 8 ] or [x 9 ];[x 2 ,x 3 ,x 4 ,…,x 7 ,x 8 ]Prediction[x9 ] or [x 10 ]; and so on, until the time series data of the leaf ends. n Represents the nth estimated value of nitrogen content in cotton leaves). This setting covers the distance from the low peak to the peak of nitrogen content in most cotton leaves, which can effectively improve the prediction performance of the model. At the same time, the nitrogen content of some cotton leaves shows a continuous upward trend. The setting of a window size of 7 can capture the key inflection point and distinguish the nitrogen content time series data with different trends to further optimize the model's adaptability and prediction effect for different types of data; in addition, the setting of the sliding window allows overlap between adjacent samples. This overlap helps the model to better understand the data characteristics and enhances the robustness of the model. To avoid data leakage, this embodiment divides the cotton leaf nitrogen content time series data into a training set and a validation set based on the number of leaves at a ratio of 7:3 before the sliding window generates a data set. The study also reduced the impact of differences between different leaves on the model through Z-score standardization, helping the model to focus more on changes in the time series itself.
[0093] A large number of studies have confirmed that for time-dependent data, the effect of using a time series prediction model is usually better than the machine learning method for processing independently distributed data, so this embodiment uses TCN, LSTM, BiLSTM and Transformer models. In order to solve the problem of limited time series, this embodiment integrates the above-mentioned multiple time series models to take advantage of their respective advantages. This combination can improve the prediction ability and adaptability of the model while maintaining the sequence characteristics.
[0094] The models obtained by integrating the above-mentioned multiple timing models include: a serial timing prediction model and a parallel timing prediction model. The structures of the serial timing prediction model and the parallel timing prediction model are shown in Table 5 and Table 6 respectively.
[0095] Table 5 Structure of tandem time series prediction model
[0096]
[0097] Table 6 Parallel timing prediction model structure
[0098]
[0099] The serial time series prediction model includes three structures: TCN, LSTM and BiLSTM serial Transformer, which are represented by TCN-Transformer, LSTM-Transformer and BiLSTM-Transformer respectively. The model structure of LSTM-Transformer and BiLSTM-Transformer is similar to that of TCN-Transformer. Figure 4 .
[0100] The parallel time series prediction model involves three structures: TCN, LSTM, and BiLSTM parallel Transformer, which are represented by TCN&Transformer, LSTM&Transformer, and BiLSTM&Transformer respectively. The model structures of TCN&Transformer and LSTM&Transformer are similar to those of BiLSTM&Transformer. Fig. 9 .
[0101] As can be seen from Table 7, the prediction accuracy of a small part of the integrated time series structure is not as good as that of a single model. This may be because noise or errors are also accumulated during the integration process, resulting in the model performance not being as expected; in addition, the task of predicting one step into the future (Forecast Horizon) has higher accuracy than the task of predicting two steps into the future. This is because the model can better capture the relationship between the prediction target and the nearby historical data, and as the prediction step increases, it faces problems such as weakening of time correlation, resulting in a decrease in prediction accuracy. In comprehensive comparison, BiLSTM&Transformer performs best when predicting the nitrogen content of cotton leaves in the next 1 time step (next 7 days) based on the nitrogen content of cotton leaves in the past 7 time steps, with a validation set R 2 and RMSE are 0.900 and 2.135; when predicting the nitrogen content of cotton leaves in the next 2 time steps (next 14 days) based on the nitrogen content of cotton leaves in the past 7 time steps, TCN-Transformer is the best, and its validation set R 2 and RMSE are 0.821 and 2.843.
[0102] Table 7. Test results of time series prediction model
[0103]
[0104] In summary, the BiLSTM & Transformer and TCN-Transformer models constructed in the present invention can effectively predict the nitrogen content change trend of cotton leaves in the next 7 days and 14 days respectively. The prediction period is an important stage for the coordinated development of cotton vegetative growth and reproductive growth, and has a significant impact on cotton fiber formation and final yield. It helps agricultural personnel to formulate fertilization strategies more scientifically and timely, optimize resource utilization, and improve yield and quality. In addition, the present invention provides a basis for researchers to explore nitrogen dynamics and optimize nitrogen fertilizer application technology in depth.
[0105] On the other hand, the present invention also proposes a cotton nitrogen content prediction system based on small sample hyperspectral data, comprising:
[0106] The data processing module is used to collect cotton leaf data and perform preprocessing to obtain a monitoring data set; the cotton leaf data includes cotton leaf hyperspectral data and cotton leaf nitrogen content data;
[0107] The monitoring model design module is used to build a monitoring model and train the monitoring model based on the monitoring data set to obtain the optimal monitoring model;
[0108] A time series data set construction module is used to output non-destructive cotton leaf nitrogen content data through an optimal monitoring model and construct a cotton leaf nitrogen content time series data set;
[0109] The nitrogen content prediction module is used to build a time series prediction model. The cotton leaf nitrogen content time series data set is combined with the time series prediction model to obtain the cotton nitrogen content prediction result.
[0110] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0111] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A cotton nitrogen content prediction method based on small sample hyperspectral data, characterized in that: The following steps are involved: Collecting cotton leaf data and preprocessing them to obtain a monitoring data set; the cotton leaf data includes cotton leaf hyperspectral data and cotton leaf nitrogen content data; Constructing a monitoring model, and training the monitoring model based on the monitoring data set to obtain an optimal monitoring model; Outputting non-destructive cotton leaf nitrogen content data through the optimal monitoring model to construct a cotton leaf nitrogen content time series data set; A time series prediction model is constructed, and the cotton leaf nitrogen content time series data set is combined with the time series prediction model to obtain a cotton nitrogen content prediction result.
2. The cotton nitrogen content prediction method based on small sample hyperspectral data according to claim 1, characterized in that: The data collected for cotton leaves include: The cotton plants to be tested were divided into a destructive sampling group and a non-destructive sampling group, and the hyperspectral data of cotton leaves of all cotton plants in the destructive sampling group and the non-destructive sampling group were collected; the cotton leaf nitrogen content data of the cotton plants in the destructive sampling group were collected.
3. The cotton nitrogen content prediction method based on small sample hyperspectral data according to claim 2 is characterized in that: The cotton leaf hyperspectral data is preprocessed, including: The hyperspectral data of multiple positions of each cotton leaf are collected and averaged to obtain the mean of the spectral data; The mean value of the spectral data of each cotton leaf is used as the original spectral data, and the original spectral data is substituted into the SG filter and then subjected to a first-order differential operation to obtain D1 spectral data; The D1 spectral data were processed using the SFLA algorithm, and finally the nitrogen content sensitive band was selected using the Pearson correlation coefficient.
4. The cotton nitrogen content prediction method based on small sample hyperspectral data according to claim 1, characterized in that: The monitoring model includes a 1D-CNN model or a DF model; The 1D-CNN model includes an input layer, a first convolutional layer, a BN layer, a first activation function layer, a first pooling layer, a second convolutional layer, a second activation function layer, a second pooling layer, a third convolutional layer, a third pooling layer, a flattening layer, a first fully connected layer, a third activation function layer, a first Dropout layer, a second fully connected layer, a fourth activation function layer, a second Dropout layer and an output layer connected in sequence; The DF model is implemented based on the CascadeForestRegressor architecture. The DF model has a built-in early stopping mechanism based on default tolerance and performance improvement threshold to control the level growth, and uses Grid Search to optimize parameters.
5. The cotton nitrogen content prediction method based on small sample hyperspectral data according to claim 4 is characterized in that: The first activation function layer adopts the Swish activation function, and the second activation function layer, the third activation function layer, and the fourth activation function layer all apply the SELU activation function.
6. The cotton nitrogen content prediction method based on small sample hyperspectral data according to claim 1 is characterized in that: Taking a cotton leaf nitrogen content time series data set as input of the time series prediction model, the time series prediction model includes a first cycle prediction model and a second cycle prediction model; The first cycle prediction model is a BiLSTM&Transformer model; the second cycle prediction model is a TCN-Transformer model; The BiLSTM&Transformer model includes a BiLSTM part and a Transformer part that operate in parallel, and gates and fuses the features of the outputs of the BiLSTM part and the Transformer part, and finally outputs the prediction result of the cotton nitrogen content; The TCN-Transformer model includes a Transformer part and a TCN part connected in sequence, wherein the Transformer part first extracts global features of the input data, and then focuses on extracting local features through the TCN part, and finally outputs the prediction result of cotton nitrogen content.
7. The cotton nitrogen content prediction method based on small sample hyperspectral data according to claim 6, characterized in that: The TCN captures short-term fluctuations and long-term dependencies through multi-layer dilated convolutions; the BiLSTM part captures forward and backward dependency information through bidirectional processing; and the Transformer part uses a self-attention mechanism to capture sequence information.
8. A cotton nitrogen content prediction system based on small sample hyperspectral data, characterized in that: include: A data processing module is used to collect cotton leaf data and perform preprocessing to obtain a monitoring data set; the cotton leaf data includes cotton leaf hyperspectral data and cotton leaf nitrogen content data; A monitoring model design module, used to construct a monitoring model and train the monitoring model based on the monitoring data set to obtain an optimal monitoring model; A time series data set construction module, used to output non-destructive cotton leaf nitrogen content data through the optimal monitoring model to construct a cotton leaf nitrogen content time series data set; The nitrogen content prediction module is used to construct a time series prediction model. The cotton leaf nitrogen content time series data set is combined with the time series prediction model to obtain the cotton nitrogen content prediction result.
Citation Information
Cited By
Agricultural planting liquid fertilizer drip irrigation amount control and targeted use method based on artificial intelligence
CN121095718A
Agricultural machinery automatic fertilization control method and system based on image recognition
CN121415088A