Agricultural machinery operation data anomaly detection method based on adversarial neural network

By building an LK-GAN network model, using LSTM and multi-head attention mechanism to capture the timing characteristics of agricultural machinery operation data, the problem of insufficient detection accuracy and timeliness of traditional methods is solved, and more efficient abnormal detection effects are achieved, providing reliable technical support for smart agriculture.

CN120180328APending Publication Date: 2025-06-20HENAN UNIV OF SCI & TECH
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202510255909.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-05
Publication Date
2025-06-20

AI Technical Summary

Technical Problem

Traditional agricultural machinery operation data abnormality detection methods are difficult to effectively capture the timing characteristics of the data and abnormal data in complex environments, resulting in insufficient detection accuracy and timeliness.

Method used

The LK-GAN network model is constructed using an adversarial neural network method. The generator is based on the LSTM model and introduces a dual-channel multi-head attention mechanism and KAN output layer. The discriminator is also based on the LSTM model and introduces a dual-channel multi-head attention mechanism, and performs abnormal detection through adversarial training and model optimization.

Benefits of technology

It improves the accuracy and timeliness of abnormal detection of agricultural machinery operation data, can more effectively capture the timing characteristics of the data and abnormal data in complex environments, and enhances the technical support of smart agriculture.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120180328A_ABST
    Figure CN120180328A_ABST
Patent Text Reader

Abstract

The invention discloses an agricultural machinery operation data anomaly detection method based on an adversarial neural network. The method comprises the steps of data acquisition, preprocessing, LK-GAN network model construction, adversarial training and model optimization, anomaly detection and data transmission and visualization. According to the method, the GAN generator is used for simulating distribution of normal data, and abnormal data are identified through the discriminator; the long LSTM is introduced into the generator and the discriminator to enhance the capturing capability of time sequence features, and the feature extraction capability of the generator is improved in combination with a KAN network and an attention mechanism, so that the anomaly detection precision is improved. Meanwhile, the original data and the detection result are transmitted to the cloud platform in real time and are visually displayed on a client interface, so that the timeliness of anomaly detection is enhanced, and reliable technical support is provided for intelligent agriculture.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of agricultural machinery, and in particular to a method for detecting abnormal agricultural machinery operation data based on a confrontation neural network. Background Art

[0002] Precision agriculture integrates high-precision sensor devices into agricultural machinery such as combine harvesters, grain trucks, and tractors to continuously monitor the operating conditions of agricultural machinery, thereby improving agricultural production efficiency and resource utilization. However, the field operation environment is complex and changeable, and sensor data is easily interfered by factors such as tree occlusion and mechanical failures, resulting in abnormal data. For example, abnormal GPS data may cause inaccurate automatic driving control and even driving accidents; abnormal mechanical operation parameter sensor data may affect the operation effect of agricultural machinery and the precise control of agricultural inputs. Therefore, in the face of data abnormality problems occurring in complex environments, researching efficient abnormality detection methods is an important direction for the development of smart agriculture.

[0003] Traditional methods for detecting abnormal agricultural machinery operation data mainly include rule-based, statistical, and traditional machine learning methods. These methods have certain detection capabilities in small-scale and single-dimensional data scenarios, but it is difficult to fully mine the potential features of data, especially the ability to capture temporal features is insufficient. In the face of the characteristics of large-scale, high-dimensional, and strong spatio-temporal correlation of agricultural machinery operation data, the limitations of traditional methods are becoming increasingly prominent.

[0004] In recent years, with the rapid development of deep learning technology, remarkable achievements have been made in fields such as speech recognition and image processing. Deep learning models have also gradually been introduced into time series data analysis, providing new ideas for solving the problem of detecting abnormal agricultural machinery operation data. Among them, the Generative Adversarial Network (GAN), as a powerful deep learning framework, can effectively capture the deep distribution features of data through the adversarial training of a generator and a discriminator, and is particularly suitable for abnormal detection tasks of complex data.

[0005] However, applying GAN to the detection of abnormal agricultural machinery operation data still faces some challenges. For example, agricultural machinery operation data has obvious spatio-temporal correlation, and how to effectively use this information to improve the accuracy of abnormal detection still needs further research. In addition, the field operation environment is complex and changeable, and how to build a robust abnormal detection model to adapt to different operation scenarios is also an urgent problem to be solved.

[0006] Therefore, developing a method for detecting abnormal agricultural machinery operation data based on an improved generative adversarial network is of great significance for improving the efficiency of agricultural machinery operation, ensuring agricultural production safety, and promoting the development of smart agriculture. Summary of the Invention

[0007] The present invention aims to solve at least one of the technical problems existing in the prior art. For this purpose, the present invention provides a method for detecting abnormal agricultural machinery operation data based on an adversarial neural network, which can perform real-time abnormal detection on operation data at the agricultural machinery end, synchronously transmit the original data and detection results to the cloud, and perform visual display on the client side, so as to improve the analysis and decision-making ability of the agricultural machinery big data platform, enhance the accuracy and timeliness of abnormal detection, and provide reliable technical support for smart agriculture.

[0008] A method for detecting abnormal agricultural machinery operation data based on an adversarial neural network according to an embodiment of the present invention includes the following steps:

[0009] S1. Data acquisition and preprocessing: Obtain the time series data of agricultural machinery operations, divide the original data into a training data set and a test data set, and perform missing value processing, cleaning, standardization, and sliding window processing on the data;

[0010] S2. Construct an LK-GAN network model: The generator is based on an LSTM model, and a dual-channel multi-head attention mechanism and a KAN output layer are introduced; the discriminator is based on an LSTM model, and a dual-channel multi-head attention mechanism is introduced;

[0011] S3. Perform adversarial training and model optimization based on the LK-GAN network model;

[0012] S4. Abnormal detection: After the test set data is processed by a sliding window, it is input into the discriminator to calculate its discrimination loss; at the same time, the generator generates forged data based on random noise and calculates the reconstruction loss; the residual loss of the generator and the discrimination loss of the discriminator are weighted to obtain an abnormal score, which is used to evaluate the degree of abnormality of the data;

[0013] S5. Data transmission and visualization: Transmit the original data and detection results to the cloud platform in real time, and perform visual display on the client interface. The original data is used to reflect the key status information during the agricultural machinery operation; the abnormal data is separately displayed in the abnormal monitoring box so that users can analyze the equipment operation status according to the time point of the abnormal data.

[0014] The method for detecting abnormal agricultural machinery operation data based on an adversarial neural network according to an embodiment of the present invention uses the generator of the GAN to simulate the distribution of normal data and identifies abnormal data through the discriminator. Both the generator and the discriminator introduce long short-term memory networks (LSTM) to enhance the ability to capture time series features, and combine the KAN network and the attention mechanism to improve the feature extraction ability of the generator, further improving the accuracy of abnormal detection. At the same time, the original data and detection results are transmitted to the cloud platform in real time and visually displayed on the client interface to enhance the timeliness of abnormal detection and provide reliable technical support for smart agriculture.

[0015] In some embodiments of the present invention, step S2 specifically includes the following steps:

[0016] S21. Both the generator and the discriminator are based on the LSTM model, and the LSTM includes a forget gate, an input gate, and an output gate;

[0017] S22. Add a dual-channel multi-head attention mechanism after the LSTM layer, calculate the time-step attention and the feature attention respectively, and fuse the information of the two;

[0018] S23. Introduce the KAN network into the generator, perform time-dependent feature encoding on the latent vector through the LSTM layer, and perform non-linear mapping through the KAN network;

[0019] S24. Construct the LK-GAN network model with a generator model of three-layer LSTM and a discriminator model of two-layer LSTM.

[0020] In some embodiments of the present invention, the calculation formula of the dual-channel multi-head attention mechanism in step S22 is as follows:

[0021] First, the time-step attention channel:

[0022]

[0023]

[0024]

[0025] where X ∈ R n*d is the output matrix of the LSTM, n represents the number of time steps, and d represents the feature dimension; is the time-step attention matrix of the i-th attention head, and are the query, key, and value matrices of the i-th time-step attention, is the parameter matrix of the i-th head, 1 ≤ i ≤ h, and h is the number of attention heads included in each channel; d k is a scaling factor for stabilizing the gradient; Concat is to splice the outputs of all heads into a large matrix, is the linear transformation matrix after splicing the time-step attention;

[0026] Second, the feature attention:

[0027]

[0028]

[0029]

[0030] Among them, is the feature attention matrix of the i-th attention head, and are the query, key, and value matrices of the feature attention; is the parameter matrix of the i-th head, d k is a scaling factor used to stabilize the gradient; Concat concatenates the outputs of all heads into a large matrix, is the linear transformation matrix after the feature attention is concatenated;

[0031] Third, fuse the outputs of the time-step attention channel and the feature attention channel:

[0032] A = λA t + (1 - λ)A f ;

[0033] Among them, λ is a learnable parameter used to balance the contributions of the time-step attention and the feature attention.

[0034] In some embodiments of the present invention, step S3 specifically includes the following steps:

[0035] S31. The generator receives a noise vector randomly sampled from the latent space and generates time series data through LSTM combined with the KAN network;

[0036] S32. The loss function of the generator combines the adversarial loss, the feature matching loss, and the residual loss;

[0037] S33. The discriminator uses the cross-entropy loss function to distinguish between real data and generated data;

[0038] S34. Use the RMSProp optimizer to update the parameters of the generator and the discriminator;

[0039] S35. The generator and the discriminator are alternately optimized through the min-max game until convergence.

[0040] In some embodiments of the present invention, the total loss of the generator in step S32 is the weighted sum of the adversarial loss, the feature matching loss, and the residual loss, and the corresponding formula is:

[0041] L G = ω1L GAN + ω2L fea + ω3L rec ;

[0042] Among them, ω1, ω2, ω3 are weight coefficients, L GAN is the adversarial loss, L fea is the feature matching loss, L recis the residual loss.

[0043] In some embodiments of the present invention, in step S33, the real time series sample and the forged data generated by the generator are input into the discriminator for binary classification supervised learning. The cross-entropy loss function of the discriminator is:

[0044]

[0045] where E x and E z respectively represent the expected values of data x and noise z; P data (x) is the distribution of normal data, and P z (z) is the data distribution in the latent space; D(x) is the discrimination probability of the discriminator for real data, and D(G(z)) is the discrimination probability of the discriminator for generated data.

[0046] In some embodiments of the present invention, the optimization in step S35 is specifically as follows:

[0047] During the adversarial training process, the generator is continuously optimized to make D(G(z)) as close to 1 as possible; the discriminator continuously improves its ability to distinguish real data and forged data to make D(G(z)) as close to 0 as possible; G and D form a minimax game, and its objective function V(G,D) is:

[0048]

[0049] During the training process, G and D are alternately optimized until they converge to an equilibrium point, making the generated data as close to the real data as possible.

[0050] In some embodiments of the present invention, step S4 specifically includes the following steps:

[0051] S41. The anomaly score is calculated by weighting the reconstruction error and the discrimination error;

[0052] S42. Set a threshold through statistical analysis of the anomaly scores of normal data in the training set;

[0053] S43. Determine whether the anomaly score of the data point is greater than the threshold. If it is greater, it is marked as abnormal data.

[0054] In some embodiments of the present invention, the protocol for data transmission in step S5 is the MQTT protocol.

[0055] In some embodiments of the present invention, after step S5, it further includes the validity verification of the algorithm, that is, verifying the validity of abnormal data identification and the validity of data transmission. Description of the Drawings

[0056] Figure 1It is a flowchart of a method for detecting abnormal agricultural machinery operation data based on an adversarial neural network according to an embodiment of the present invention;

[0057] Figure 2 It is an architecture diagram of a GAN anomaly detection model combined with a KAN network constructed by the present invention;

[0058] Figure 3 It is a process diagram of the sliding window operation in the present invention;

[0059] Figure 4 It is an LSTM structure diagram in the present invention;

[0060] Figure 5 It is a KAN network structure diagram in the present invention;

[0061] Figure 6 It is the structural design of the generator and discriminator in an embodiment of the present invention;

[0062] Figure 7 It is a result diagram of box plot analysis in an embodiment of the present invention;

[0063] Figure 8 It is a schematic diagram of the anomaly detection result of the LK-GAN model on GPS data in an embodiment of the present invention;

[0064] Figure 9 It is a schematic diagram of the anomaly detection result of the LK-GAN model on SMD data in an embodiment of the present invention.

[0065] Figure 10 It is a schematic diagram of the client visualization interface in an embodiment of the present invention. Detailed implementation manners

[0066] The embodiments of the present invention will be described in detail below. Examples of the embodiments are shown in the accompanying drawings, where the same or similar reference numerals are the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to explain the present invention and should not be construed as limiting the present invention.

[0067] The following refers to Figures 1 - 10 Describe a method for detecting abnormal agricultural machinery operation data based on an adversarial neural network according to an embodiment of the present invention, including the following steps:

[0068] A method for detecting abnormal agricultural machinery operation data based on an adversarial neural network according to an embodiment of the present invention, including the following steps:

[0069] S1. Data acquisition and preprocessing: Obtain time series data of agricultural machinery operations, divide the original data into a training data set and a test data set, and perform missing value processing, cleaning, standardization, and sliding window processing on the data;

[0070] S2. Construct the LK-GAN network model: The generator is based on the LSTM model, and a dual-channel multi-head attention mechanism and a KAN output layer are introduced; the discriminator is based on the LSTM model, and a dual-channel multi-head attention mechanism is introduced;

[0071] S3. Conduct adversarial training and model optimization based on the LK-GAN network model;

[0072] S4. Anomaly detection: After the test set data is processed by a sliding window, it is input into the discriminator, and its discrimination loss is calculated; at the same time, the generator generates forged data based on random noise and calculates the reconstruction loss; the weighted residual loss of the generator and the discrimination loss of the discriminator are used to obtain an anomaly score for evaluating the anomaly degree of the data;

[0073] S5. Data transmission and visualization: The original data and the detection results are transmitted to the cloud platform in real time and visualized on the client interface. The original data is used to reflect the key state information during the agricultural machinery operation; the abnormal data is separately displayed in the anomaly monitoring box for the user to analyze the equipment operation status according to the time point of the abnormal data

[0074] Of course, after step S5, algorithm effectiveness verification can be added, that is, verify the effectiveness of abnormal data recognition and the effectiveness of data transmission. Existing effectiveness verification can be used, so it will not be elaborated here.

[0075] It can be understood that among them, the data acquisition can be collected from agricultural machinery sensors or recording devices, including GPS data such as longitude, latitude, speed, heading angle, pitch angle, etc., and parameters such as flow meters and fertilization amounts during mechanical operations. The generator is based on the LSTM model to capture the temporal characteristics of time series data. Introducing a dual-channel multi-head attention mechanism can enhance the model's ability to focus on key features; combining the KAN output layer can further improve the non-linear expression ability of LSTM in time series modeling. The discriminator uses the LSTM structure and the dual-channel attention mechanism to improve the discriminator's ability to identify abnormal data.

[0076] According to the agricultural machinery operation data anomaly detection method based on the adversarial neural network in the embodiments of the present invention, the generator of GAN is used to simulate the distribution of normal data, and the discriminator is used to identify abnormal data. Both the generator and the discriminator introduce long short-term memory networks (LSTM) to enhance the ability to capture temporal characteristics, and combine the KAN network and the attention mechanism to improve the feature extraction ability of the generator, further improving the accuracy of anomaly detection. At the same time, the original data and real-time detection results generated during the agricultural machinery operation process are synchronously transmitted to the cloud and displayed in real time on the client interface to realize the visualization display of abnormal data.

[0077] In some embodiments of the present invention, the step S2 specifically includes the following steps:

[0078] In S21, both the generator and the discriminator are based on the LSTM model, and the LSTM includes a forget gate, an input gate, and an output gate;

[0079] In S22, a dual-channel multi-head attention mechanism is added after the LSTM layer to calculate the time-step attention and the feature attention respectively, and fuse the information of both;

[0080] In S23, the KAN network is introduced into the generator, the latent vector is encoded with time-dependent features through the LSTM layer, and a non-linear mapping is performed through the KAN network;

[0081] In S24, the LK-GAN network model is constructed with a generator model of three-layer LSTM and a discriminator model of two-layer LSTM.

[0082] It should be noted that both the generator and the discriminator are based on the LSTM model, and the LSTM introduces a storage unit (cell state), an input gate i, a forget gate f, and an output gate o to control the information flow. The storage unit can accumulate and retain important information for a long time, while the three gates are used to regulate the information flow in and out of the unit.

[0083] The structure of a standard LSTM cell is as Figure 4 shown, and the specific description is as follows:

[0084] (1) Forget gate: The main function of the forget gate is to determine which information needs to be retained or forgotten according to the previous hidden state h t-1 and the current input X t , and output a vector f between [0,1] through the sigmoid function t to be multiplied element-wise with the cell state C t-1 of the previous moment to control the update of the state:

[0085] f t = σ(W f ·[h t-1 , X t +b f );

[0086] where σ is the sigmoid activation function, and W f and b f are the weight and bias parameters of the forget gate.

[0087] (2) Input gate: The input gate is responsible for updating new information into the cell state, and this process is divided into two parts.

[0088] The first part, generation of the candidate state: Through the previous hidden state h t-1 and the current input X t, a candidate memory vector is generated using the tanh activation function

[0089]

[0090] where W c and b c are the weight and bias parameters of the candidate cell state, and tanh is the hyperbolic tangent function.

[0091] The second part is the weight control of the input gate: the current input and the hidden state at the previous moment are processed through the sigmoid activation function to output a vector i with values between [0, 1] t .:

[0092] i t = σ(W i · [h t-1 , X t + b i );

[0093] Finally, the input gate i t and the candidate cell state are multiplied element-wise and combined with the old cell state after being processed by the forget gate to determine the addition of new information. The combination process can be represented by the following formula:

[0094]

[0095] where f t is the output of the forget gate, C t-1 is the previous cell state, is the new information part.

[0096] (3) Output gate: The output gate determines which information in the current cell state C t is output as the hidden state ht. The previous hidden state h t-1 and the current input X t are processed through the sigmoid function to calculate the output vector o t . The formula is as follows:

[0097] o t = σ(W o · [h t-1 , X t + b o );

[0098] The output gate processes the current cell state C t through the tanh function and multiplies it element-wise with the value o of the output gate t to obtain the final hidden state h t , which is passed to the LSTM cell at the next moment:

[0099] h t = o t *tanh(C t )。

[0100] In the present invention, both the generator and the discriminator are set based on LSTM, and the structure of the LSTM unit is a prior art, so it will not be described in detail herein.

[0101] In view of this, when constructing the LK-GAN network model of the present invention, a dual-channel multi-head attention mechanism is added after the LSTM layer, so that the constructed model can further focus on the relationship between time steps and features. In this mechanism, in the same attention layer, the time-step attention and the feature attention are calculated separately, and finally the information of the two is fused, so that the generator and the discriminator simultaneously focus on the time dynamics and the feature interaction, thereby more effectively capturing the key information in anomaly detection.

[0102] The dual-channel multi-head attention layer is composed of two independent attention channels: the time-step attention channel and the feature attention channel, and its calculation formula is as follows:

[0103] First, the time-step attention channel:

[0104]

[0105]

[0106]

[0107] where X ∈ R n*d is the output matrix of LSTM, n represents the number of time steps, and d represents the feature dimension; is the time-step attention matrix of the i-th attention head, and are the query, key, and value matrices of the i-th time-step attention, is the parameter matrix of the i-th head, 1 ≤ i ≤ h, where h is the number of attention heads included in each channel; d k is a scaling factor used to stabilize the gradient; Concat is to concatenate the outputs of all heads into a large matrix, is the linear transformation matrix after concatenation of the time-step attention;

[0108] Second, the feature attention:

[0109]

[0110]

[0111]

[0112] Among them, is the feature attention matrix of the i-th attention head, and are the query, key, and value matrices of the feature attention; is the parameter matrix of the i-th head, d k is a scaling factor used to stabilize the gradient; Concat concatenates the outputs of all heads into a large matrix, is the linear transformation matrix after concatenating the feature attention;

[0113] Third, fuse the outputs of the time-step attention channel and the feature attention channel:

[0114] A = λA t + (1 - λ)A f ;

[0115] where λ is a learnable parameter used to balance the contributions of the time-step attention and the feature attention.

[0116] Furthermore, the KAN network is introduced into the LSTM generator. The generator encodes the time-dependent features of the latent vector z through the LSTM layer to extract the latent features; subsequently, the encoded high-dimensional features are non-linearly mapped through the KAN network to generate the reconstructed time-series data. This method can capture the complex relationships in the data and enhance the robustness of the model. The KAN-based architecture used in the present invention is as Figure 8 shown.

[0117] The KAN network focuses on feature interaction and modeling complex relationships, and is particularly suitable for processing high-dimensional data and complex time-series data.

[0118] It should be noted that KAN (Kolmogorov - Arnold Networks) is a neural network model based on the Kolmogorov - Arnold representation theorem. This theorem was proposed by mathematicians Andrey Kolmogorov and Vladimir Arnold and is an important result in the theory of function representation. The theorem states that any multivariate continuous function can be composed of a series of simple univariate functions nested. KAN utilizes this theory to capture the non-linear correlations between input features through kernel function mapping and hierarchical weighted aggregation, thereby achieving a more powerful feature expression ability.

[0119] In KAN, each neural connection not only has weight parameters but also contains an optimizable kernel function, enabling the network to automatically discover the most suitable non - linear transformation. This flexibility allows KAN to automatically discover the optimal non - linear transformation of input features, making it particularly suitable for handling complex patterns and dependencies in time series.

[0120] Specifically, its specific form is:

[0121]

[0122] Where, And Φ q : R→R, representing the kernel function mapping and non - linear aggregation respectively.

[0123] In a single - layer network, the activation value of the neurons in the (l + 1)-th layer is obtained by the weighted sum of the activation values of the previous layer through non - linear kernel function mapping, and its formula is:

[0124]

[0125] Representing the mapping of the entire layer in matrix form is:

[0126]

[0127] At this time, Φ l is called the parameter function matrix of the l - th layer.

[0128] Therefore, for a KAN network with L layers, the output of the input vector x can be expressed as:

[0129] KAN(x)=(Φ L-1 . Φ L-2 ... Φ0)(x).

[0130] Considering that the deep discriminator model is prone to over - fitting problems on small datasets, affecting the generalization ability of the model; while the shallow generator model is difficult to generate high - quality forged data and cannot effectively deceive the discriminator. Therefore, the present invention adopts a medium - depth generator model and a shallower discriminator model to achieve a better balance in the training process, that is, the generator adopts a three - layer LSTM structure and the discriminator adopts two layers. The specific generator and discriminator architectures are as Figure 6 shown.

[0131] In some embodiments of the present invention, the adversarial training and model optimization based on LK - GAN specifically include the following steps:

[0132] S31. The generator receives a noise vector randomly sampled from the latent space and generates time - series data through LSTM combined with the KAN network; that is, through LSTM combined with the KAN network, it learns the distribution characteristics of time - series data and generates a time - series similar to the real data distribution.

[0133] S32. The loss function of the generator combines adversarial loss, feature matching loss, and residual loss.

[0134] In the classical GAN framework, the objective of the generator is to "fool" the discriminator by maximizing the output probability of the discriminator, making the discriminator think that the generated data is "real". Specifically, the standard loss function of the generator is defined as:

[0135]

[0136] However, when both the generator and the discriminator try to optimize the loss, it may lead to unstable training. To solve this problem, feature matching loss is introduced. By measuring the similarity of the intermediate layer features of the generated samples and the real samples in the discriminator, the training of the generator is constrained to avoid relying solely on the final output of the discriminator. Feature matching loss helps the generator better capture the high-order features and potential correlations of the data, improving its ability to model time series data. It is defined by the following formula:

[0137]

[0138] In addition, to further reduce the error in details between the generated samples and the real samples, residual loss is introduced in the generator loss to quantify the pointwise dissimilarity between the generated sample G(Z) and the real sample x. Specifically, given an input time series Xtest, the generator generates a reconstructed sample G(Ztest) according to the optimal latent variable. It is defined by the following formula:

[0139]

[0140] Therefore, in some embodiments of the present invention, the total loss of the generator is the weighted sum of adversarial loss, feature matching loss, and residual loss, and the corresponding formula is:

[0141] L G = ω1L GAN + ω2L fea + ω3L rec ;

[0142] where ω1, ω2, ω3 are weight coefficients, L GAN is the adversarial loss, L fea is the feature matching loss, and L rec is the residual loss.

[0143] S33. The discriminator uses the cross-entropy loss function to distinguish real data and generated data.

[0144] Specifically, the training data is processed through a sliding window to obtain time series samples. The real time series samples and the forged data generated by the generator are input into the discriminator for binary classification supervised learning. The cross-entropy loss function of the discriminator is as follows:

[0145]

[0146] where, E x and E z represent the expected values of data x and noise z respectively; P data (x) is the distribution of normal data, and P z (z) is the data distribution in the latent space; D(x) is the discrimination probability of the discriminator for real data, and D(G(z)) is the discrimination probability of the discriminator for the generated data.

[0147] S34. Use the RMSProp optimizer to update the parameters of the generator and the discriminator. RMSProp can effectively alleviate the problem of gradient oscillation during training by adaptively adjusting the learning rate, thereby improving the stability of model training.

[0148] S35. The generator and the discriminator are alternately optimized through a minimax game until convergence.

[0149] Specifically, during the adversarial training process, the generator is continuously optimized so that the generated data can better "deceive" the discriminator, that is, making D(G(z)) as close to 1 as possible; the discriminator, on the other hand, continuously improves its ability to distinguish between real data and forged data, and assigns correct labels to real and forged sequences as accurately as possible, making D(G(z)) as close to 0 as possible. As the training progresses, G and D form a minimax game, and its objective function V(G,D) is as follows:

[0150]

[0151] During the training process, G and D are alternately optimized until they converge to an equilibrium point, making the generated data as close to the real data as possible.

[0152] In some embodiments of the present invention, step S4 specifically includes the following steps:

[0153] S41. The anomaly score is calculated by weighting the reconstruction error and the discrimination error, that is, the anomaly score consists of two parts: the reconstruction error and the discrimination error, which are used to measure whether a sample is abnormal. The anomaly score is defined as follows:

[0154] S(x) = α·L rec (x,D(x)) + β·L D (D(x));

[0155] where, L rec(x, D(x)) is the reconstruction error, L D (D(x)) is the discrimination error, and α, β are hyperparameters used to balance the weights of the reconstruction error and the discrimination error.

[0156] It should be noted that the reconstruction error here is the residual error, which can be obtained from the residual loss. Correspondingly, the discrimination error is the discrimination loss.

[0157] S42. Set the threshold through the statistical analysis of the anomaly scores of the normal data in the training set, that is, through the statistical analysis of the anomaly scores of the normal data in the training set, set the threshold threshold, and use the quantile setting:

[0158] threshold = P 95 (S(x));

[0159] S43. Determine whether the anomaly score of the data point is greater than the threshold threshold. If it is greater, mark it as abnormal data. The judgment formula is as follows:

[0160]

[0161] It can be understood that in the anomaly detection stage, the test set data is input into the discriminator after being processed by a sliding window, and its anomaly score is calculated. At the same time, the generator generates fake time series data based on random noise. By calculating the reconstruction loss and the discrimination loss between the test data and the generated data, the anomaly score of the data is calculated weighted for anomaly detection. Finally, by setting the threshold of the anomaly score, the input data is classified to determine whether it is abnormal data.

[0162] In some embodiments of the present invention, the data transmission protocol in step S5 is the MQTT protocol.

[0163] It should be noted that in the missing value processing during the data preprocessing in the above step S1, the K-nearest neighbor method can be used to fill the missing values in the data, that is, fill based on the data points of the K nearest neighbors near the missing value. For the missing value x i , the filling method is expressed by the formula:

[0164]

[0165] Among them, X j is the data points of the K nearest neighbors of the missing value, and W j is the weight (the reciprocal of the distance).

[0166] For data cleaning in data preprocessing, the box plot method can be used to simply clean the training set to remove obvious outliers.

[0167] In the analysis of multivariate time series, due to the large differences in the value ranges of different variables, in order to ensure the reliability of the analysis results and improve the convergence speed and accuracy of the model, the training set and the test set are standardized to mitigate the adverse effects caused by the large numerical differences between variables in the time series data. The formula for the standardization process is as follows:

[0168]

[0169] where max(x train,i ) and min(x train,i ) are the maximum and minimum values of the i-th dimension in the training set, respectively, and ∈' is a small constant vector used to prevent division by zero.

[0170] When using a sliding window to segment the time series, it can be divided into sequences of a fixed length for subsequent analysis and training of the model. The sliding window model is as shown in Figure 2 . For the sake of illustration, assume that the current time is A and the sliding window size is B. In window 1, the data set is represented as DA = {XA, …, XA + B}; in window 2, the data set is represented as DA+1 = {XA+1, …, XA + B + 1}. In the illustration, the white dots represent the data being detected, and the black dots represent the data to be detected next. As the window slides to the right, new data points enter the window, and at the same time, some old data points are removed.

[0171] Embodiment

[0172] Step 1. Collect the agricultural machinery operation data set

[0173] We collected the GPS data of a tractor during the wheat harvesting and grain unloading operation in June 2024. This data set was collected from a farm covering 800 mu in Yiyang County, Luoyang City, Henan Province. The grain unloading operation mainly includes the tractor driving to the target location, docking for grain unloading, and repositioning and operation after the grain unloading is completed. The data was exported through an industrial tablet device installed on the tractor, which is equipped with a high-precision GPS module for accurately recording the operation trajectory and operation status log. In addition, the tractor is also equipped with other sensors (such as wheel angle sensors, hydraulic valve sensors, etc.) to synchronously collect the mechanical operation status and environmental information.

[0174] We selected two sets of GPS data: one set records the trajectory and status of the tractor under the standard operation process, and the other set has problems such as excessive speed and path deviation due to equipment failures, resulting in some obvious abnormal points in the data. To perform multivariate anomaly detection, we parsed the obtained GPS logs, and the main data attributes considered include: latitude, longitude, speed, ground heading, heading angle, and pitch angle. These attributes are the core data for the intelligent agricultural machinery's automatic driving and path planning, directly related to the adjustment of the agricultural machinery's travel route, the optimization of the operation trajectory, and the operation safety.

[0175] Step 2: Process the original dataset

[0176] To ensure that the training set only contains normal data, box plots were used to perform outlier analysis on the training data to identify possible abnormal points. The analysis results are as Figure 8 shown. There are significant outliers in the speed attribute. This is because the speed data distribution is skewed towards the low-value region, resulting in points with higher speeds being identified as outliers statistically. However, considering the operation background, during the grain unloading process, the tractor may pause temporarily or travel at a very low speed due to docking with the grain unloading point, adjusting the position, waiting for loading and unloading, etc. These low-speed or near-zero speed values reflect the intermittent behavior of the tractor during normal operation and should not be regarded as abnormal states but as part of normal operation. Therefore, we re-evaluated these "outliers" and regarded them as normal data points. For the test set, we labeled the abnormal data through known equipment failures (such as excessive speed, path deviation, etc.) to evaluate the model's detection ability in actually dealing with abnormal states. Finally, the dataset was standardized and processed with a sliding window.

[0177] Step 3: Train the model

[0178] Randomly sample noise in the latent space as the input of the generator to generate fake data samples. The original time series data is segmented by a sliding window of size 20, and the input data shape is adjusted to three-dimensional data. Subsequently, the real data sequence and the generated fake sequence are input into the discriminator for adversarial training. The hyperparameter settings of the network model are shown in Table 1:

[0179] Table 1

[0180] Parameter meaning Parameter value Optimizer RMSProp Learning rate 0.0001 Number of batch training samples 32 Number of training epochs 100 Hidden layer dimension 96 Dropout rate 0.2 Generator / discriminator training ratio 1 / 3 Number of grid divisions for input dimension 4 Sliding window size 20 Latent space dimension size 30

[0181] Step 4: Anomaly detection

[0182] In the anomaly detection stage, the test data is processed through a sliding window and then input into the model to calculate the anomaly score for each sample. The anomaly score is calculated by weighting the reconstruction error and the discrimination error. Then, the threshold is calculated through statistical analysis of the anomaly scores of the normal data in the training set, and the threshold is set using the sum of the mean and three times the standard deviation. When the anomaly score exceeds the threshold, the sample is determined to be abnormal. Finally, the performance of the algorithm is evaluated by calculating the precision, recall, and F1-score.

[0183] The method provided by this solution can effectively detect the anomaly points and anomaly regions in the agricultural machinery working data, and has obvious superiority compared with other methods. To verify the generalization of the model, it is also tested on a public dataset. The comparison table of anomaly detection results is as follows:

[0184] Table 2

[0185]

[0186] The results show that the traditional anomaly detection methods (PCA, KNN, IsoForest) all fail in the anomaly detection of multivariate time series and are difficult to capture complex time dependencies and high-level features. In contrast, the method based on the present invention can automatically extract complex features from high-dimensional data. As shown in the above table, the LK-GAN model has achieved the highest F1-score on both datasets. The recall rate of the LK-GAN model on the GPS data has increased by 4.83% compared with the second-best method, and the F1-score has reached a high value of 92.71%. The LK-GAN model not only performs well on the GPS data, but also achieves good indicators on other datasets, indicating that the model has strong generalization ability and can effectively handle the anomaly detection tasks of other time series data.

[0187] Step Five: Data Transmission

[0188] The original data and the anomaly detection results are transmitted to the cloud platform through the local area network and are displayed in real time on the client interface, as Figure 10 shown. The original data reflects the key status information during the agricultural machinery operation; the abnormal data is separately displayed in the anomaly monitoring box, which is convenient for users to analyze the equipment operation status according to the time points of the abnormal data.

[0189] In summary, the present invention proposes a new anomaly detection method. By adopting the LSTM-KAN architecture in the generator, it combines the advantages of LSTM in capturing long-term dependencies in time series with the strong non-linear expression ability of the KAN model, enabling the generator to more accurately model the distribution of complex data. In terms of model error calculation, feature matching loss and residual loss are introduced into the generation loss to better train the model, and the losses of both the generator and the discriminator are incorporated into the calculation of the anomaly score. At the same time, the present invention uses an unsupervised algorithm to model normal data, enabling the neural network to learn its features, thereby identifying anomaly patterns and solving the problem of scarce and unlabeled anomaly data in agricultural machinery operation data. Meanwhile, the original data and the detection results are synchronously transmitted to the cloud and visually displayed on the client side to improve the analysis and decision-making ability of the agricultural machinery big data platform, enhance the timeliness of anomaly detection, and provide reliable technical support for smart agriculture.

[0190] Although the embodiments of the present invention have been shown and described, those of ordinary skill in the art can understand that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the claims and their equivalents.

Claims

1. A method for detecting anomaly in agricultural machinery operation data based on adversarial neural network, characterized in that: The steps include: S1. Data acquisition and preprocessing: Obtain the time series data of agricultural machinery operations, divide the original data into training data set and test data set, and perform missing value processing, cleaning, standardization and sliding window processing on the data; S2. Construct LK-GAN network model: the generator is based on the LSTM model, and introduces a dual-channel multi-head attention mechanism and a KAN output layer; the discriminator is based on the LSTM model, and introduces a dual-channel multi-head attention mechanism; S3. Conduct adversarial training and model optimization based on the LK-GAN network model; S4, anomaly detection: the test set data is processed by the sliding window and then input into the discriminator to calculate its discrimination loss. At the same time, the generator generates fake data based on random noise and calculates the reconstruction loss. The residual loss of the generator and the discrimination loss of the discriminator are weighted to obtain an anomaly score, which is used to evaluate the degree of abnormality of the data. S5. Data transmission and visualization: The original data and test results are transmitted to the cloud platform in real time and visualized on the client interface. The original data is used to reflect the key status information during the operation of agricultural machinery; the abnormal data is displayed separately in the abnormal monitoring box, so that users can analyze the equipment operation status according to the time point of the abnormal data.

2. The method for detecting anomaly in agricultural machinery operation data based on adversarial neural network according to claim 1, characterized in that: The step S2 specifically includes the following steps: S21, the generator and the discriminator are all based on the LSTM model. The LSTM includes a forget gate, an input gate, and an output gate; S22, add a dual-channel multi-head attention mechanism after the LSTM layer to calculate the time step attention and feature attention respectively, and fuse the information of the two; S23, introduce the KAN network into the generator, encode the time-dependent features of the latent vector through the LSTM layer, and perform nonlinear mapping through the KAN network; S24. Construct the LK-GAN network model with a three-layer LSTM generator model and a two-layer LSTM discriminator model.

3. The method for detecting anomaly in agricultural machinery operation data based on adversarial neural network according to claim 2 is characterized in that: The calculation formula of the dual-channel multi-head attention mechanism in step S22 is as follows: First, the time-step attention channel: Where X∈R n*d is the output matrix of LSTM, n represents the number of time steps, and d represents the feature dimension; is the time-step attention matrix of the ith attention head, and is the query, key, and value matrix of attention at the i-th time step, is the parameter matrix of the i-th head, 1≤i≤h, h is the number of attention heads contained in each channel; d k is a scaling factor used to stabilize the gradient; Concat concatenates the outputs of all heads into a large matrix. is the linear transformation matrix after time step attention concatenation; Second, feature attention: in, is the feature attention matrix of the ith attention head, and is the query, key, and value matrix of feature attention; is the parameter matrix of the ith head, d k is a scaling factor used to stabilize the gradient; Concat concatenates the outputs of all heads into a large matrix. is the linear transformation matrix after feature attention concatenation; Third, fuse the outputs of the time-step attention channel and the feature attention channel: A=λA t +(1-λ)A f ; Among them, λ is a learnable parameter used to balance the contribution of time step attention and feature attention.

4. The method for detecting anomaly in agricultural machinery operation data based on adversarial neural network according to claim 1, characterized in that: The step S3 specifically includes the following steps: S31, the generator receives the noise vector randomly sampled from the latent space and generates time series data through LSTM combined with KAN network; S32, the loss function of the generator combines adversarial loss, feature matching loss and residual loss; S33, the discriminator uses the cross entropy loss function to distinguish between real data and generated data; S34, use RMSProp optimizer to update the parameters of the generator and discriminator; S35, the generator and the discriminator are optimized alternately through the minimax game until convergence.

5. The method for detecting anomaly in agricultural machinery operation data based on adversarial neural network according to claim 4 is characterized in that: The total loss of the generator in step S32 is the weighted sum of the adversarial loss, feature matching loss and residual loss, and the corresponding formula is: L G =ω1L GAN +ω2L fea +ω3L rec ; Among them, ω1, ω2, ω3 are weight coefficients, L GAN To combat the loss, L fea is the feature matching loss, L rec is the residual loss.

6. The method for detecting anomaly in agricultural machinery operation data based on adversarial neural network according to claim 4 is characterized in that: In step S33, the real time series samples and the forged data generated by the generator are input into the discriminator together for binary classification supervised learning. The cross entropy loss function of the discriminator is: Among them, E x and E z Represent the expected values ​​of data x and noise z respectively; P data (x) is the distribution of normal data, P z (z) is the data distribution in the latent space; D(x) is the probability of the discriminator distinguishing the real data, and D(G(z)) is the probability of the discriminator distinguishing the generated data.

7. The method for detecting anomaly in agricultural machinery operation data based on adversarial neural network according to claim 4 is characterized in that: The optimization in step S35 is specifically as follows: During adversarial training, the generator is continuously optimized to make D(G(z)) as close to 1 as possible; the discriminator continuously improves its ability to distinguish between real data and forged data, making D(G(z)) as close to 0 as possible; G and D form a minimax game, and its objective function V(G,D) is: During the training process, G and D are optimized alternately until they converge to the equilibrium point, making the generated data as close to the real data as possible.

8. The method for detecting anomaly in agricultural machinery operation data based on adversarial neural network according to claim 1, characterized in that: The step S4 specifically includes the following steps: S41, the anomaly score is calculated by weighting the reconstruction error and the discrimination error; S42, setting a threshold by statistically analyzing the abnormal scores of normal data in the training set; S43. Determine whether the abnormal score of the data point is greater than a threshold, and if so, mark it as abnormal data.

9. The method for detecting anomaly in agricultural machinery operation data based on adversarial neural network according to claim 1, characterized in that: The data transmission protocol in step S5 is the MQTT protocol.

10. The method for detecting anomaly in agricultural machinery operation data based on adversarial neural network according to claim 1, characterized in that: The step S5 also includes the validation of the algorithm, that is, the validation of the validity of abnormal data identification and the validity of data transmission.

Citation Information

Cited By

  • Hive on Tez operation anomaly detection method and system based on deep learning

    CN120763024A

  • A deep learning-based hive on tez job anomaly detection method and system

    CN120763024B

  • Adversarial generative network driven abnormal access detection method and system

    CN121193534A