Classification method and device for agricultural machine track data and storage medium
The method enhances agricultural machinery trajectory classification by automating feature extraction and optimizing models with dynamic functions, improving efficiency and accuracy in complex scenarios.
Patent Information
- Application Number
- CN202411192880.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2024-12-13
AI Technical Summary
Traditional agricultural machinery trajectory classification methods face inefficiencies and low accuracy, especially in complex scenarios and large data volumes, due to reliance on simple statistical analysis and manual recognition.
A method involving preprocessing, short-range and long-range feature extraction, bidirectional long short-term memory networks, and a classifier, with dynamic loss functions and activation functions to optimize classification models for agricultural machinery trajectory data.
Improves feature extraction efficiency and accuracy by automating feature learning, enhancing position coding, and addressing category imbalance, leading to more precise agricultural machinery trajectory classification.
Smart Images

Figure CN119128719A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of agricultural machinery trajectory classification, and in particular to a classification method, device and storage medium for agricultural machinery trajectory data. Background Art
[0002] A core challenge in agricultural machinery operation management is how to accurately identify and analyze the working trajectory of agricultural machinery, which is directly related to the calculation of agricultural machinery operation area, operation quality assessment and the effectiveness of agricultural machinery scheduling system.
[0003] Traditional agricultural machinery trajectory classification methods mainly rely on simple statistical analysis and manual recognition. These methods have significant shortcomings when faced with complex agricultural machinery operation scenarios and large amounts of data, and have obvious deficiencies in efficiency and classification accuracy. Summary of the invention
[0004] The purpose of the present invention is to propose a classification method, device and storage medium for agricultural machinery trajectory data, so as to solve the technical problems of poor efficiency and low precision in the classification of agricultural machinery trajectory data in the prior art.
[0005] The present invention provides a method for classifying agricultural machinery trajectory data, comprising the following steps:
[0006] S1. Obtaining agricultural machinery trajectory data;
[0007] S2, preprocessing the agricultural machinery trajectory data to obtain preprocessed data; at the same time, constructing a classification model, the classification model includes: a short-range feature extraction module, a long-range feature extraction module, a bidirectional long short-term memory network and a classifier;
[0008] S3, extracting short-range features and long-range features from the preprocessed data, and fusing the short-range features and long-range features to obtain comprehensive features;
[0009] S4, input the comprehensive features into the bidirectional long short-term memory network to perform deep temporal pattern learning to obtain the learned features;
[0010] S5, input the learned features into the classifier to obtain the classification results of the agricultural machinery trajectory;
[0011] S6, comparing the classification result with the actual result, iteratively optimizing the classification model through the PDW loss function, and obtaining an optimized classification model;
[0012] S7. Use the optimized classification model to complete the classification of agricultural machinery trajectory data.
[0013] A storage medium stores instructions and data for implementing a classification method for agricultural machinery trajectory data.
[0014] A classification device for agricultural machinery trajectory data comprises: a processor and the storage medium; the processor loads and executes instructions and data in the storage medium to implement a classification method for agricultural machinery trajectory data.
[0015] The beneficial effects provided by the present invention are:
[0016] 1. Automatic feature learning: Traditional methods rely on manually designed features, which may result in redundant features or incomplete feature extraction due to subjective judgment. The present invention uses a one-dimensional convolutional layer and a long-range feature encoder to simultaneously focus on short-range and long-range information in the agricultural machinery trajectory data, automatically extract meaningful features without manual intervention, reduce dependence on professional domain knowledge, and improve the efficiency and accuracy of feature extraction.
[0017] 2. Enhanced position coding: The position coding module in the long-range feature encoder enhances the utilization of the position information of each trajectory point in the agricultural machinery trajectory data through the weighted position coding mechanism, and can better represent the spatial information of the trajectory.
[0018] 3. Parameter difference weighted loss function: By dynamically adjusting the loss generated by different input data through the difference between the input agricultural machinery trajectory data and the agricultural machinery trajectory dataset, and at the same time, in order to address the problem of category imbalance in the agricultural machinery trajectory data, the weights of different categories of data are adjusted, so that the model can pay more attention to categories with a smaller proportion during training, and more accurately reflect the loss under different agricultural machinery trajectory data inputs.
[0019] 4. Dynamically adjusted activation function: The activation function used in the present invention can dynamically adjust the slope and bias of the activation function in combination with the input features, making the activation function smoother and more stable, which helps to accelerate model convergence and improve training efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a schematic flow chart of the method of the present invention;
[0021] Figure 2 It is a schematic diagram of trajectory data before classification;
[0022] Figure 3 It is a schematic diagram of trajectory data after classification;
[0023] Figure 4 It is a working schematic diagram of the hardware device of the present invention. DETAILED DESCRIPTION
[0024] To make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention will be further described below with reference to the accompanying drawings.
[0025] Before formally describing the present invention, the scheme of the present invention is first generally described for easy understanding.
[0026] Please refer to Figure 1 , Figure 1 It is a schematic flow diagram of the method of the present invention;
[0027] The present invention provides a method for classifying agricultural machinery trajectory data, comprising the following steps:
[0028] S1. Obtaining agricultural machinery trajectory data;
[0029] It should be noted that in the present invention, the latitude and longitude, speed, equipment time and plot type data (confidence of cultivated land, roads and other plots) of the agricultural machinery are obtained through the data collection step.
[0030] S2, preprocessing the agricultural machinery trajectory data to obtain preprocessed data; at the same time, constructing a classification model, the classification model includes: a short-range feature extraction module, a long-range feature extraction module, a bidirectional long short-term memory network and a classifier;
[0031] It should be noted that the present invention pre-processes the agricultural machinery trajectory data, including calculating acceleration, azimuth, azimuth change, angular velocity and trajectory density. The calculation formulas for the above data are all conventional calculations, which will not be described in detail in the present invention.
[0032] S3, extracting short-range features and long-range features from the preprocessed data, and fusing the short-range features and long-range features to obtain comprehensive features;
[0033] It should be noted that the present invention uses a convolution operation with a kernel size of 7, a step size of 1, and a padding of 3 to extract short-range features. After the above convolution operation, sequence data with enhanced short-range features is output.
[0034] It should be noted that the extraction of long-range features in step S3 adopts a long-range feature extraction module, and the long-range feature extraction module includes: a position encoding module and an encoder module based on vector dot product.
[0035] The position encoding module uses cosine and sine encoding for odd-numbered bit features and even-numbered bit features of each trajectory point respectively.
[0036] As an embodiment, the construction of the position encoding module includes the following steps:
[0037] S311: Create a tensor pe with a shape of (1, length, size), where length is the number of trajectory points in the agricultural machinery trajectory data, and size is the features contained in each trajectory point. pe will store the position code of the agricultural machinery trajectory data;
[0038] S312: For each trajectory point, calculate the difference between the input parameter and the average parameter of the category in the data set, the formula is as follows:
[0039] Difference in cultivated land attributes: Δf=|ff i |
[0040] Road attribute difference: Δr=|rr i |
[0041] Where f and r are the confidences of the trajectory points on the farmland or road plots, f i and r i Represents the average confidence of category i on farmland or road plots.
[0042] S313: Calculate a weighting factor ω PE , the formula is as follows:
[0043] ω PE =exp(-(αΔf+βΔr))
[0044] Among them, α and β are weight parameters for adjusting the two differences, which are set to 0.5 and 0.5 respectively;
[0045] S4: Apply the weighting factor to the position and perform parameter weighted position encoding (PWPE) on each trajectory point. The formula is as follows:
[0046]
[0047] Among them, pos is the sequence number of the trajectory point in the agricultural machinery trajectory data, and size is the feature contained in each trajectory point. This encoding method uses cosine and sine encoding for the odd-numbered features and even-numbered features of each trajectory point respectively.
[0048] It should be noted that the encoder module based on vector dot product has 4 layers in total, each layer includes 8 correlation adaptive coding blocks, normalization is performed between each layer, and a feedforward neural network is inserted in the middle.
[0049] As an embodiment, the steps of constructing the correlation adaptive coding block are as follows:
[0050] S321: Perform linear transformation on the input tensor to generate three matrices K, Q, and V, which are learned for keys, queries, and values respectively to map to different representation spaces;
[0051] S322: split K, Q, and V into multiple parts, process each part through independent linear transformation, and then perform vector dot product to calculate the correlation to capture the feature association in different subspaces;
[0052] S323: In each part, the dot product of the query matrix Q and the key matrix K is calculated and divided by the square root of 8 / h as a scaling factor, where h refers to the number of points in the agricultural machinery trajectory data. The softmax function is applied to obtain the correlation weight matrix between each trajectory point, and then multiplied with the value matrix V to synthesize the information of different positions in a weighted summation manner.
[0053] S324: splicing the outputs obtained from different parts in the above steps, restoring them to the original dimension through the final linear transformation, and completing the correlation calculation.
[0054] It should be noted that the encoder module based on vector dot product adopts an adaptive feature activation function FAA, which is as follows:
[0055] FAA(x,v,ω)=max(0,α(v,ω)*x+β(v,ω)
[0056] in,
[0057] α(v,ω)=σ 1 (w 1 v+w 2 ω+b 1 )
[0058] β(v,ω)=σ 2 (w 3 v+w 4 ω+b 2 )
[0059] w 1 、w 2 、w 3 、w 4 and b 1 , b 2 is the parameter to be learned, σ 1 is the ReLU function, σ 2 is the sigmoid function; v and ω are the acceleration and angular velocity of the trajectory points.
[0060] It should be noted that the short-range features and long-range features are obtained through different parts in the above steps. In the present invention, the torch.cat() method is called to concatenate the two features to obtain comprehensive features.
[0061] S4, input the comprehensive features into the bidirectional long short-term memory network to perform deep temporal pattern learning to obtain the learned features;
[0062] As an embodiment, the bidirectional long short-term memory network described in the present invention is designed to have two layers, each layer has a bidirectional structure, so as to capture long-range dependencies and bidirectional context information in sequence data.
[0063] S5, input the learned features into the classifier to obtain the classification results of the agricultural machinery trajectory;
[0064] It should be noted that the fully connected layer of the classifier module configures the output dimension according to the requirements of the target classification task to achieve multi-category classification of the input sequence.
[0065] S6, comparing the classification result with the actual result, iteratively optimizing the classification model through the PDW loss function, and obtaining an optimized classification model;
[0066] As an embodiment, the calculation process of the PDW loss function in step S6 of the present invention is as follows:
[0067] S61. For each category i, calculate the difference between the parameter of each track point in the agricultural machinery track data and the average of the parameters of each category:
[0068] Speed difference: Δv i =|vb i |
[0069] Directional difference: Δθ i =|θ-θ i |
[0070] Track density difference: Δd i =|dd i |
[0071] S62: Combining these differences, calculate the weight of each category:
[0072] ω i =exp(-(αΔv i +βΔθ i +γΔd i ))
[0073] Among them, α, β, γ are weight parameters for adjusting speed, direction and trajectory density in the total difference, which are set to 0.3, 0.3 and 0.4 respectively in the present invention;
[0074] S3: Use the parameter difference weighted loss PDW Loss formula to calculate the gap between the output result and the true label. The formula is as follows:
[0075]
[0076] Where δ is a parameter for adjusting the weight of the category with a smaller proportion in the sample. In the present invention, its value is set to 5, and y i Refers to the value of the true label of the i-th class. If the sample belongs to the i-th class, then y i =1, if it does not belong to y i =0; Refers to the probability corresponding to this category of the model classification result; is the probability predicted by the model for category i. Through this formula, the loss function can dynamically adjust the category weights in combination with the input parameters, thereby more accurately reflecting the errors of different categories.
[0077] S7. Use the optimized classification model to complete the classification of agricultural machinery trajectory data.
[0078] Please refer to Figure 2 and Figure 3 , Figure 2 This is a schematic diagram of trajectory data before classification. Figure 3 This is a schematic diagram of the trajectory data after classification. It can be seen that after classification, the road trajectory (red), working trajectory (green) and parking trajectory (black) are effectively distinguished.
[0079] See also Figure 4 , Figure 4 4 is a schematic diagram of the working of the hardware device of an embodiment of the present invention, wherein the hardware device specifically comprises: a classification device 401 for agricultural machinery trajectory data, a processor 402 and a storage medium 403.
[0080] A classification device 401 for agricultural machinery trajectory data: The classification device 401 for agricultural machinery trajectory data implements the classification method for agricultural machinery trajectory data.
[0081] Processor 402: The processor 402 loads and executes the instructions and data in the storage medium 403 to implement the agricultural machinery trajectory data classification method.
[0082] Storage medium 403: The storage medium 403 stores instructions and data; the storage medium 403 is used to implement the agricultural machinery trajectory data classification method.
[0083] The beneficial effects of the present invention are:
[0084] 1. Automatic feature learning: Traditional methods rely on manually designed features, which may result in redundant features or incomplete feature extraction due to subjective judgment. The present invention uses a one-dimensional convolutional layer and a long-range feature encoder to simultaneously focus on short-range and long-range information in agricultural machinery trajectory data, automatically extract meaningful features without manual intervention, reduce dependence on professional domain knowledge, and improve the efficiency and accuracy of feature extraction.
[0085] 2. Enhanced position coding: The position coding module in the long-range feature encoder enhances the utilization of the position information of each trajectory point in the agricultural machinery trajectory data through the weighted position coding mechanism, and can better represent the spatial information of the trajectory.
[0086] 3. Parameter difference weighted loss function: By dynamically adjusting the loss generated by different input data through the difference between the input agricultural machinery trajectory data and the agricultural machinery trajectory dataset, and at the same time, in order to address the problem of category imbalance in the agricultural machinery trajectory data, the weights of different categories of data are adjusted, so that the model can pay more attention to categories with a smaller proportion during training, and more accurately reflect the loss under different agricultural machinery trajectory data inputs.
[0087] 4. Dynamically adjusted activation function: The activation function used in the present invention can dynamically adjust the slope and bias of the activation function in combination with the input features, making the activation function smoother and more stable, which helps to accelerate model convergence and improve training efficiency.
[0088] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A classification method for agricultural machinery trajectory data, characterized by: The method comprises the following steps: S1. Obtaining agricultural machinery trajectory data; S2, preprocessing the agricultural machinery trajectory data to obtain preprocessed data; At the same time, a classification model is constructed, wherein the classification model includes: a short-range feature extraction module, a long-range feature extraction module, a bidirectional long short-term memory network and a classifier; S3, extracting short-range features and long-range features from the preprocessed data, and fusing the short-range features and long-range features to obtain comprehensive features; S4, input the comprehensive features into the bidirectional long short-term memory network to perform deep temporal pattern learning to obtain the learned features; S5, input the learned features into the classifier to obtain the classification results of the agricultural machinery trajectory; S6, comparing the classification result with the actual result, iteratively optimizing the classification model through the PDW loss function, and obtaining an optimized classification model; S7. Use the optimized classification model to complete the classification of agricultural machinery trajectory data.
2. The method for classifying agricultural machinery trajectory data according to claim 1, characterized in that: In step S3, a convolution operation with a kernel size of 7, a stride of 1, and a padding of 3 is used to extract short-layer features.
3. The method for classifying agricultural machinery trajectory data according to claim 1, characterized in that: In step S3, the long-range feature extraction module is used for extracting the long-range feature, and the long-range feature extraction module includes: a position encoding module and an encoder module based on vector dot product.
4. A method for classifying agricultural machinery trajectory data according to claim 3, characterized in that: The position encoding module uses cosine and sine encoding for odd-numbered bit features and even-numbered bit features of each trajectory point respectively.
5. The method for classifying agricultural machinery trajectory data according to claim 3, characterized in that: The encoder module based on vector dot product has 4 layers in total, each layer includes 8 correlation adaptive coding blocks, normalization is performed between each layer, and a feedforward neural network is inserted in the middle.
6. A method for classifying agricultural machinery trajectory data according to claim 5, characterized in that: The vector dot product-based encoder module adopts an adaptive feature activation function FAA, as follows: FAA(x,v,ω)=max(0,α(v,ω)*x+β(v,ω) in, α(v,ω)=σ1(w1v+w2ω+b1) β(v,ω)=σ2(w3v+w4ω+b2) w1, w2, w3, w4 and b1, b2 are the parameters that need to be learned, σ1 is the ReLU function, σ2 is the sigmoid function; v and ω are the acceleration and angular velocity of the trajectory point.
7. The method for classifying agricultural machinery trajectory data according to claim 1, characterized in that: The calculation process of the PDW loss function in step S6 is as follows: S61. For each category i, calculate the difference between the parameter of each track point in the agricultural machinery track data and the average of the parameters of each category: Speed difference: Δv i =|vv i | Directional difference: Δθ i =|θ-θ i | Track density difference: Δd i =|dd i | S62: Combining these differences, calculate the weight of each category: oh i =exp(-(αΔv i +βΔθ i +γΔd i )) Among them, α, β, and γ are weight parameters for adjusting speed, direction, and trajectory density in the total difference; S3: Use the parameter difference weighted loss PDW Loss formula to calculate the gap between the output result and the true label. The formula is as follows: Among them, δ is the parameter that adjusts the weight of the category with smaller proportion in the sample, y i Refers to the value of the true label of the i-th class. If the sample belongs to the i-th class, then y i =1, if it does not belong to y i =0; Refers to the probability corresponding to this category of the model classification result; is the probability predicted by the model for category i.
8. A storage medium, characterized in that: The storage medium stores instructions and data for implementing a method for classifying agricultural machinery trajectory data as described in any one of claims 1 to 7.
9. A classification device for agricultural machinery trajectory data, characterized in that: include: Processor and storage medium; the processor loads and executes instructions and data in the storage medium to implement a method for classifying agricultural machinery trajectory data as described in any one of claims 1 to 7.
Citation Information
Cited By
Agricultural machine track data classification method and device, electronic equipment and storage medium
CN120105238A
Agricultural Machinery Trajectory Data Classification Method, Device, Electronic Equipment and Storage Medium
CN120105238B
