Agricultural machine track data classification method and device, electronic equipment and storage medium
By adopting the method of comparative learning and dynamic negative sample queues in agricultural machinery trajectory data classification, the problem of difficulty in effectively classifying agricultural machinery trajectory data in the existing technology is solved, and higher classification accuracy and generalization ability are achieved.
Patent Information
- Application Number
- CN202510592963.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-09
- Publication Date
- 2025-06-06
- Estimated Expiration
- 2045-05-09
AI Technical Summary
It is difficult for the prior art to effectively classify agricultural machinery trajectory data, especially when dealing with complex farmland operations and road driving modes, traditional methods are difficult to capture the spatiotemporal characteristics in the trajectory data, and are not robust to outliers and drifts.
The agricultural machinery trajectory data classification method based on contrast learning and dynamic negative sample queue is adopted, and the wav2vec comparison learning framework and dynamic negative sample queue idea is used to extract trajectory features through encoder network, context network and momentum encoder, and the model is optimized through InfoNCE, and the feature learning effect is evaluated by combining K-means clustering and contour coefficients.
It improves the accuracy and generalization ability of agricultural machinery trajectory data classification, can automatically learn complex features in trajectory data, enhances the model's ability to distinguish different trajectory modes, and effectively avoids model overfitting.
Smart Images

Figure CN120105238A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of agricultural machinery trajectory classification, and specifically relates to an agricultural machinery trajectory data classification method, device, electronic equipment and storage medium. Background Art
[0002] Driven by the agricultural Internet of Things, intelligent agricultural machinery and equipment, and precision agriculture technology, intelligent agricultural machinery equipment such as combine harvesters, seeders, and drones have been widely used, generating a massive amount of agricultural machinery trajectory data. Agricultural machinery trajectory data is an important part of agricultural digitalization, providing strong support for the intelligent and precise development of agriculture. When agricultural machinery is operating in the field, its trajectory data can reflect the operation mode, farmland utilization, operation efficiency, and operation status of agricultural machinery. Especially in the process of deep loosening, deep plowing, land consolidation, etc., land subsidies are closely related to the operation area. Accurate trajectory classification can not only improve the accuracy of operation statistics, but also provide a scientific basis for subsidy issuance, and ensure the fairness and effectiveness of subsidies.
[0003] In addition, with the development of large-scale agricultural operations, cross-regional operation scheduling of agricultural machinery has become an important means to improve agricultural production efficiency. Intelligent classification based on trajectory data can optimize the allocation of agricultural machinery resources, improve the utilization rate of agricultural machinery, reduce operating costs, and help the intelligent upgrade of modern agriculture.
[0004] However, the original agricultural machinery trajectory data has the characteristics of large temporal and spatial span, complex operation scenes, multi-source heterogeneity, and is easily disturbed by factors such as topography and crop growth. The classification of agricultural machinery trajectory data faces many challenges. Compared with traditional vehicle trajectories or logistics trajectories, agricultural machinery trajectories have the following characteristics: First, agricultural machinery trajectories have the particularity of operation scenes. Agricultural machinery trajectories involve two main modes: farmland operations and road driving. Farmland trajectories usually show low-speed, tortuous, and repeated coverage patterns, while road trajectories are more regular and have relatively stable speeds. This mode difference makes it difficult to apply traditional trajectory classification methods. Secondly, agricultural machinery trajectory data is more complex. It is affected by factors such as terrain, farmland shape, and crop types. Its path is highly random and difficult to classify by fixed rules. In addition, agricultural machinery trajectory data not only includes location (latitude and longitude), but also involves parameters such as operation speed, driving direction, and operation status. How to effectively integrate these multidimensional information and improve classification accuracy is a major challenge. Finally, due to the complex operating environment of agricultural machinery, GNSS trajectory data may be interfered by satellite signals, resulting in trajectory point drift, missing or a large number of outliers, which puts higher requirements on the robustness of the classification model.
[0005] Although trajectory data classification has important application value, due to the complexity and diversity of trajectory data, existing classification methods still face many challenges. At present, trajectory data classification methods can be divided into two categories: traditional methods and deep learning methods.
[0006] Traditional trajectory classification methods mainly rely on manually designed rules or statistical features. Early studies distinguished different objects by setting rules such as speed thresholds and direction angle changes. For example, "average speed exceeding 60 km / h" was used to identify the type of highway vehicle. Although such methods are intuitive, they have limited feature expression capabilities and are difficult to capture complex patterns such as periodic commuting or sudden path deviations. In addition, the rules need to be readjusted for different scenarios, and the generalization is poor.
[0007] Subsequently, traditional machine learning-based methods (such as decision trees, support vector machines (SVMs), naive Bayes, etc.) were widely used. These methods manually extract a large number of features (such as speed changes, direction changes, etc.) for classification. Although these methods have achieved certain results in some simple scenarios, the manual feature extraction process is cumbersome, time-consuming, and highly dependent on the experience of experts in the field. Different experts may extract different sets of features, resulting in poor stability and consistency of classification results. In addition, manually extracted features are often difficult to fully and accurately reflect the intrinsic characteristics and complex patterns of trajectory data, limiting the accuracy and generalization ability of classification. Moreover, agricultural machinery trajectory data may have problems such as outliers and drift, and traditional machine learning methods have poor robustness to such data.
[0008] In recent years, deep learning methods have shown significant advantages in feature extraction and pattern recognition for trajectory classification. For example, the RNN / LSTM model can capture the time series information of the trajectory, but its computational complexity is high and it may face the gradient vanishing problem when processing long trajectory data. In addition, the Transformer model solves the problem of long sequence modeling through the self-attention mechanism, but the computational overhead is high and it is difficult to meet real-time requirements. At the same time, although the autoencoder can extract features through data reconstruction, the generated representation focuses on the overall distribution and lacks discriminative semantics.
[0009] For another example, Chinese patent document CN119046759A discloses a method for classifying agricultural machinery trajectories based on trajectory similarity measurement, a computer-readable storage medium, and a computer program product. The method uses the agricultural machinery GNSS trajectory data and cleans it, then uses the contrastive learning model TrajCL to extract the structural features and spatial features of the trajectory and trajectory points from the original trajectory data, calculates the trajectory embedding vector, and then combines the sliding window technology to achieve accurate field-road classification. The TrajCL model used in this method is specially designed for trajectories, which solves the problem of insufficient feature extraction.
[0010] Chinese patent document CN119128719A discloses a classification method, device and storage medium for agricultural machinery trajectory data, which preprocesses agricultural machinery trajectory data and constructs a classification model; extracts short-range features and long-range features from the preprocessed data, and fuses the short-range features and long-range features to obtain comprehensive features; inputs the comprehensive features into a bidirectional long short-term memory network to perform deep temporal pattern learning; inputs the learned features into a classifier to obtain the agricultural machinery trajectory classification results; compares the classification results with the actual results, and optimizes the classification model through the PDW loss function; and uses the optimized classification model to complete the classification of agricultural machinery trajectory data. This method introduces a parameter difference weighted loss function, dynamically adjusts the category weights, optimizes the model performance, and improves the accuracy and generalization ability of agricultural machinery trajectory data classification.
[0011] The above respectively reflect the application of different deep learning methods in trajectory classification.
[0012] In terms of negative sample construction strategies, traditional negative sample strategies usually rely on random sampling or fixed rules. Although simple and direct, they have many limitations, such as difficulty adapting to complex scenarios and changes in sample distribution. In order to break through these bottlenecks, various strategies have emerged. For example, the negative sample enhancement strategy generates negative samples through data enhancement (such as random cropping and noise addition) to improve the model's robustness to outliers and drift. The multi-view positive sample strategy extracts positive samples from different perspectives (such as time, space, and semantics) to enhance the diversity and discriminability of features. The Moco model in contrastive learning takes a different approach. By maintaining a dynamically updated negative sample queue, it increases the number of negative samples and improves the quality of model training signals, effectively solving the problem of insufficient negative samples in small batch training.
[0013] In view of this, the present invention proposes an agricultural machinery trajectory data classification method based on contrastive learning and dynamic negative sample queue. The method uses the wav2vec contrastive learning framework and integrates the idea of dynamic negative sample queue to solve the above technical problems. Summary of the invention
[0014] The present invention aims to overcome at least one defect of the above-mentioned prior art and provide a method for classifying agricultural machinery trajectory data.
[0015] The invention also discloses a device loaded with the agricultural machinery trajectory data classification method.
[0016] The detailed technical scheme of the present invention is as follows: A method for classifying agricultural machinery trajectory data, the method comprising: S1. Preprocessing and feature conversion operations are performed on the original agricultural machinery GNSS trajectory data to obtain continuous and uniform time series trajectory data; wherein the original agricultural machinery GNSS trajectory data includes multiple discrete trajectory points, and the features of each discrete trajectory point include longitude, latitude, timestamp, speed, direction and category label, and the categories of trajectory points include field trajectory and road trajectory; S2. Construct a trajectory classification model including a feature extraction module and a classification head. The feature extraction module includes an encoder network, a context network and a momentum encoder. The time series trajectory data is used as a training sample to train the trajectory classification model. The training of the trajectory classification model includes a feature pre-training stage and a classification fine-tuning stage, specifically: S21, using the encoder network to extract features from the time series trajectory data, and using the context network to capture the long-distance dependencies of the extracted features in the context information to construct positive sample pairs; S22, performing a data enhancement operation on the time series trajectory data, inputting the enhanced time series trajectory data into the momentum encoder to obtain its feature representation, and constructing a negative sample pair in combination with a dynamic queue mechanism; S23. In the feature pre-training stage, based on the positive sample pairs and the negative sample pairs, the feature extraction module of the trajectory classification model is iteratively trained using the InfoNCE contrast loss function, and an early stopping mechanism is introduced. When the loss value of multiple consecutive training cycles tends to be stable, the early stopping mechanism is triggered, and the representation vector of all time series trajectory data is extracted using the current feature extraction module. K-means clustering is performed based on the representation vector, and the clustering quality is evaluated by calculating the silhouette coefficient to judge the feature learning effect of the current trajectory classification model; In the classification fine-tuning stage, the feature extraction module is frozen, the classification head is trained using supervised cross entropy loss, and the category labels are enabled for supervised learning, so that the classification head outputs the category probability distribution of the trajectory; S3. Deploy the trained trajectory classification model and use it to classify the agricultural machinery trajectory data.
[0017] According to a preferred embodiment of the present invention, in S1, the original agricultural machinery GNSS trajectory data is preprocessed, including: According to the category labels of the track points in the original agricultural machinery GNSS track data, the track points are divided into a number of different track segments, wherein the category labels of the track points are 1 or 0, 1 represents a field track, and 0 represents a road track; And, resampling and interpolation operations are performed on the segmented trajectory segments, specifically: Set the sampling interval , and according to the set sampling interval , construct a new time grid: ,in, is the start time of the trajectory segment, is the end time of the trajectory segment; Arrange the trajectory points in ascending order according to the timestamps, set the timestamps of the trajectory points as indices, and use linear interpolation to interpolate the features of the trajectory points on the newly created time grid. That is, for the time to be interpolated , assuming that the nearest original trajectory points on both sides are ( , )、( , ), then the characteristic estimate for: (1); In formula (1): Indicates the time to be interpolated The estimated value of the feature inserted at the location; Furthermore, a fixed window segmentation operation is performed on the interpolated agricultural machinery GNSS trajectory data to obtain trajectory segments of equal length, wherein the window length is set to 200 points and the sliding step size is 100 points to generate overlapping trajectory segments.
[0018] Preferably, in S1, the pre-processed original agricultural machinery GNSS trajectory data is subjected to feature conversion, including: Extract key features from each trajectory point, including longitude, latitude, speed and direction, and perform standardization on the features; wherein the longitude and latitude are standardized as follows: Convert the longitude and latitude of each track point to obtain its x- and y-coordinate values in the UTM coordinate system, and calculate its relative displacement relative to the starting point and , and then the relative displacement and Perform Z-score standardization: (2); (3); In formula (2)-(3): , Respectively The mean and standard deviation of the feature; , Respectively The mean and standard deviation of the feature; , Respectively represent the normalized relative displacement coordinates; The directions are standardized, specifically: Convert the direction angle to sine and cosine values: (4); (5); Perform Z-score normalization on sine and cosine values: (6); (7); In formulas (4)-(7): represents the heading of the i-th trajectory point; , They represent the sine projection and cosine projection of the direction angle respectively; , Respectively represent the mean of the sine component of all trajectory points and the mean of the cosine component of all trajectory points; , Respectively represent the standard deviation of the sine component of all trajectory points and the standard deviation of the cosine component of all trajectory points; , They represent the normalized sine component of heading angle and the normalized cosine component of heading angle respectively; And, the standardized features are concatenated to obtain the feature vector representation of each trajectory point, that is, for the trajectory point , whose eigenvector is expressed as ; Then arrange the feature vectors of all trajectory points in chronological order to form a time series matrix. That is, assuming that there are N trajectory points, the formed time series matrix is .
[0019] Preferably, in S21, the encoder network includes three layers of one-dimensional convolution, which is used to extract local features of the time series trajectory data to obtain the real feature representation of the current time t. And the real feature representation at the kth moment in the future The context network uses a time convolution network (TCN), which uses three layers of time convolution to extract the context representation of the current time t. ; The context is represented as After linear transformation W, the predicted feature representation is obtained , and based on the real feature representation Feature representation with prediction Construct positive sample pairs as .
[0020] Preferably, according to the present invention, in S22, the parameters of the momentum encoder are updated using a momentum update formula, namely: (8); In formula (8): represents the parameters of the momentum encoder; Represents the parameters of the main model; is the momentum coefficient, ranging from 0 to 1; The negative sample pairs are constructed by combining the dynamic queue mechanism, specifically: A dual-queue management mechanism is built based on field trajectories and road trajectories to maintain and Two independent negative sample storage channels, where It is a field trajectory queue, which is used to store the field category representations generated by the momentum encoder in the latest batches; It is a road trajectory queue, which is used to store the road category representations generated by the momentum encoder in the most recent batches; In each round of training, according to the category of the current input trajectory, negative samples are selected from the feature queue corresponding to another category to build a cross-category comparison relationship. That is, when the current trajectory sample belongs to the field category, negative samples are selected from the road trajectory queue. Randomly select As negative samples, the predicted feature representation Constitute a negative sample pair ; When the current trajectory sample belongs to the road category, it is selected from the field trajectory queue Randomly select As negative samples, the predicted feature representation Constitute a negative sample pair .
[0021] According to a preferred embodiment of the present invention, in S23, in the feature pre-training stage, if the current trajectory sample is a field trajectory category, the negative sample is selected from the road trajectory queue, and the InfoNCE loss function is: (9); In formula (9): represents a road trajectory queue; represents the i-th negative sample in the road trajectory queue; sim is the cosine similarity; Represents the feature representation of the future moment predicted by the model, i.e., the benchmark sample; Represents the true future moment feature representation, i.e., positive sample; is the temperature parameter, used to control the distribution of similarity; If the current trajectory sample is a road trajectory, the negative sample is selected from the field trajectory queue. At this time, the InfoNCE loss function is: (10); In formula (10): represents a road trajectory queue; represents the i-th negative sample from the field trajectory queue.
[0022] Preferably, according to the present invention, S23 also includes, at the initial stage of feature pre-training, randomly selecting a number of field trajectories and road trajectories from the time series trajectory data as pre-initialized data sets, performing data enhancement on the pre-initialized data sets and then inputting them into the momentum encoder to construct an initial negative sample queue.
[0023] In another aspect of the present invention, a device for implementing a method for classifying agricultural machinery trajectory data is provided, the device comprising: A data acquisition module is used to perform preprocessing and feature conversion operations on the original agricultural machinery GNSS trajectory data to obtain continuous and uniform time series trajectory data; wherein the original agricultural machinery GNSS trajectory data includes a plurality of discrete trajectory points, and the features of each discrete trajectory point include longitude, latitude, timestamp, speed, direction and category label, and the categories of trajectory points include field trajectory and road trajectory; The model building and training module is used to build a trajectory classification model including a feature extraction module and a classification head. The feature extraction module includes an encoder network, a context network and a momentum encoder, and uses the time series trajectory data as a training sample to train the trajectory classification model. The training of the trajectory classification model includes a feature pre-training stage and a classification fine-tuning stage, specifically: Using the encoder network to extract features from the time series trajectory data, and using the context network to capture long-distance dependencies of the extracted features in context information to construct positive sample pairs; Performing data enhancement operation on the time series trajectory data, inputting the enhanced time series trajectory data into the momentum encoder to obtain its feature representation, and constructing negative sample pairs in combination with a dynamic queue mechanism; In the feature pre-training stage, based on the positive sample pairs and the negative sample pairs, the feature extraction module of the trajectory classification model is iteratively trained using the InfoNCE contrast loss function, and an early stopping mechanism is introduced. When the loss value of multiple consecutive training cycles tends to be stable, the early stopping mechanism is triggered, and the current feature extraction module is used to extract the representation vector of all time series trajectory data. K-means clustering is performed based on the representation vector, and the clustering quality is evaluated by calculating the silhouette coefficient to judge the feature learning effect of the current trajectory classification model; In the classification fine-tuning stage, the feature extraction module is frozen, the classification head is trained using supervised cross entropy loss, and the category labels are enabled for supervised learning, so that the classification head outputs the category probability distribution of the trajectory; The model application module is used to deploy the trained trajectory classification model and use it to classify agricultural machinery trajectory data.
[0024] In another aspect of the present invention, there is also provided an electronic device, comprising: at least one processor; and A memory storing instructions, which, when executed by the at least one processor, enables the at least one processor to execute the agricultural machinery trajectory data classification method as described above.
[0025] In another aspect of the present invention, a machine-readable storage medium is provided, which stores executable instructions, and when the instructions are executed, the machine executes the agricultural machinery trajectory data classification method as described above.
[0026] Compared with the prior art, the present invention has the following beneficial effects: (1) The present invention provides a method for classifying agricultural machinery trajectory data. The constructed trajectory classification model automatically learns the complex and key features in the trajectory data by maximizing the similarity between positive sample pairs and minimizing the similarity between negative sample pairs during the comparative learning process, without the need for a large amount of manually labeled data. Compared with the traditional method that relies on manually designed features, this method breaks the limitation of traditional trajectory data classification relying on manual labeling and manual feature extraction, and can capture the subtle spatiotemporal features in the trajectory data, greatly improving the accuracy and generalization ability of classification, and is suitable for trajectory classification tasks in various complex scenarios.
[0027] (2) The present invention uses the idea of dynamic negative sample queue in the contrastive learning framework, updates the negative sample queue in real time, and promptly incorporates the newly emerged trajectory data into it, effectively avoiding the model from overfitting the known data; at the same time, through dual queue management with category distinction, the negative sample queues of field trajectories and road trajectories are maintained separately to ensure the category consistency of negative samples.
[0028] (3) In each round of model training, the trajectory classification model selects negative samples from the feature queue corresponding to another category according to the category of the current input trajectory, builds a cross-category comparison relationship, and enhances the model's ability to distinguish different trajectory patterns. This design provides a more reliable solution for trajectory data classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is a flow chart of the agricultural machinery trajectory data classification method described in the present invention.
[0030] Figure 2 This is a category classification diagram of the original agricultural machinery GNSS trajectory data in Example 1 of the present invention.
[0031] Figure 3 It is a schematic diagram of the trajectory classification model constructed in Example 1 of the present invention.
[0032] Figure 4 It is a flowchart of training the trajectory classification model in Example 1 of the present invention. DETAILED DESCRIPTION
[0033] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0034] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.
[0035] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0036] In the absence of conflict, the embodiments of the present invention and the features of the embodiments may be combined with each other.
[0037] In view of the shortcomings of the prior art, the present invention provides a method for classifying agricultural machinery trajectory data. The method proposes a contrastive learning framework that integrates a dynamic negative sample queue. The framework draws on the core idea of the wav2vec model and makes adaptive improvements: wav2vec is a speech feature extraction method based on self-supervised learning. Its core lies in capturing the temporal dependency of speech signals through an encoder network and a context network, and constructing features for contrastive tasks to predict future time steps, thereby learning robust representations from raw data.
[0038] Considering that speech signals are composed of sound wave sequences with continuous timestamps, and trajectory data is essentially a serialized expression of the evolution of spatiotemporal positions over time, both rely on the ability to model long-range temporal relationships. Based on this commonality, this framework migrates the temporal modeling idea of wav2vec to the trajectory learning scenario, and optimizes it by combining the construction of a multi-scale spatiotemporal comparison task with a dynamic negative sample queue. The dynamic negative sample queue maintains a continuously updated repository to expand the scale of negative samples and ensure diversity, solving the problem of limited number and insufficient diversity of negative samples in trajectory data, and can more effectively utilize negative sample information and improve the model's ability to distinguish.
[0039] The agricultural machinery trajectory data classification method and device of the present invention are further described below in conjunction with specific embodiments.
[0040] Embodiment 1, Ginseng Figure 1 This embodiment provides a method for classifying agricultural machinery trajectory data. The method extracts trajectory features through a dual-branch structure of an encoder-context network: the encoder captures local spatiotemporal patterns, and the context network uses a spatiotemporal attention mechanism to model long-range dependencies; a dynamic negative sample queue is introduced to continuously store trajectory fragments of different categories and spatiotemporal scenes in historical training, and dynamically updates them through a first-in-first-out strategy to expand the scale of negative samples and improve diversity.
[0041] The method specifically comprises: S1. Preprocessing and feature conversion operations are performed on the original agricultural machinery GNSS trajectory data to obtain continuous and uniform time series trajectory data; wherein the original agricultural machinery GNSS trajectory data includes multiple discrete trajectory points, and the features of each discrete trajectory point include longitude, latitude, timestamp, speed, direction and category label, and the categories of trajectory points include field trajectory and road trajectory.
[0042] In this embodiment, the GNSS trajectory data set collected by the Beidou team of China Agricultural University is used for research and verification. This data set records the latitude and longitude coordinates, timestamps, speed, and driving direction of agricultural machinery operations through GNSS positioning technology. It has the characteristics of strong spatiotemporal continuity and high data density, and can fully present the regularity of agricultural machinery operation trajectories.
[0043] Based on the input data requirements of the model used in the method of this embodiment, the original agricultural machinery GNSS trajectory data must first be preprocessed and feature converted to obtain a data format that can meet the model input requirements.
[0044] Specifically, the wav2vec model was originally designed to process audio data, and its input is usually a continuous one-dimensional floating-point waveform signal with high data continuity and high sampling density. However, agricultural machinery GNSS trajectory data is essentially different from audio data. GNSS trajectory data is generally composed of multiple discrete spatiotemporal data (trajectory) points, and each data point contains information such as longitude, latitude, timestamp, speed, direction, and category label. Although these data points can record the motion state and spatial position of the trajectory, due to the actual conditions of agricultural machinery operations (such as equipment sampling frequency, satellite signal interference, and operation breaks), the data often presents the characteristics of uneven sampling frequency, sparse and discontinuous distribution of data points. This sparsity and discreteness make it impossible for GNSS trajectory data to be directly adapted to the wav2vec model framework originally designed for dense continuous signals.
[0045] Therefore, in order to effectively utilize the time series modeling capability of wav2vec, it is first necessary to preprocess and transform the original GNSS trajectory data, that is, to convert it into a continuous and uniform feature vector time series to meet the model's requirements for the continuity and regularity of the input data.
[0046] In this embodiment, the original agricultural machinery GNSS trajectory data is preprocessed and feature converted as follows: 1) According to the category labels of the trajectory points in the original agricultural machinery GNSS trajectory data, namely field trajectory and road trajectory, it is divided into several different trajectory segments.
[0047] In the original agricultural machinery GNSS trajectory data, each trajectory point carries a category label, usually "1" for field trajectory and "0" for road trajectory. Based on these labels, different types of trajectory segments can be identified. The specific operation is to traverse the entire set of original agricultural machinery GNSS trajectory data, and when encountering a change in category label, such as from "1" to "0" or from "0" to "1", a new trajectory segment can be divided. For example, between consecutive data points of field trajectory (labeled "1"), all data points belong to the same category; when encountering a road trajectory (labeled "0"), a new trajectory segment begins.
[0048] Each trajectory segment will contain a class label "1" or "0" and form a continuous trajectory segment according to the time order. The classification process is as follows Figure 2 shown.
[0049] After this processing, the trajectories are divided into two categories: field trajectories and road trajectories. Each trajectory segment can clearly indicate its corresponding trajectory type (field or road), providing clear labels for subsequent feature extraction and model training.
[0050] 2) Resample and interpolate the segmented trajectory segments to obtain continuous and uniform agricultural machinery GNSS trajectory data.
[0051] In view of the problems of uneven sampling frequency and sparse data in the original agricultural machinery GNSS trajectory data, in order to ensure that the model can obtain continuous and unified time series input, this embodiment adopts a resampling method.
[0052] According to the sampling frequency and classification task of the original agricultural machinery GNSS trajectory data, select a suitable sampling interval. For example, set the sampling interval = 30 seconds, that is, one data point is collected every thirty seconds. Then get the start time of each trajectory segment and end time . According to the set sampling interval , construct a new time grid: .
[0053] Specifically, firstly, the trajectory points are arranged in ascending order according to the timestamps, and the timestamps of the original trajectory points are set as the index. Then, linear interpolation is used to interpolate the features of the trajectory points. Interpolation is only performed on the newly created fixed grid points. If the original trajectory points do not fall on the grid points, they will not be directly retained. The linear interpolation formula used is as follows: For the interpolation time , assuming that the nearest original trajectory points on both sides are ( , )、( , ), then the characteristic estimate for: (1); In formula (1): Indicates the time to be interpolated The estimated value of the feature to be inserted at .
[0054] Finally, each trajectory forms a trajectory sequence that is uniformly sampled at fixed timestamps such as 0 seconds, 30 seconds, 60 seconds, and 90 seconds. After resampling, the trajectory data becomes consistent in the time dimension, providing a stable foundation for subsequent feature extraction and formatting.
[0055] 3) Perform a fixed window segmentation operation on the interpolated agricultural machinery GNSS trajectory data to obtain trajectory segments of equal length.
[0056] After the original agricultural machinery GNSS trajectory data is segmented by category, the lengths of the trajectory segments of different categories may be different. For example, the trajectory segments of field operations are longer, while the trajectory segments of road driving may be shorter. This length imbalance will affect the input format and training stability of the model. Therefore, it is necessary to use a fixed window segmentation method to uniformly process the trajectory segments with uneven lengths into subsequences of equal length to meet the input requirements of the model.
[0057] In this embodiment, the basic idea of data segmentation is to apply a sliding window technique to each trajectory segment, with the window length set to 200 points and the sliding step size set to 100 points, to generate overlapping trajectory segments.
[0058] For the remaining part with a length of less than 200 points, if its length is greater than or equal to 50 points, it is retained by padding to 200 points; if its length is less than 50 points, it is directly discarded.
[0059] Each segmented trajectory inherits the category label of the original segment to ensure label consistency. In this way, multiple fixed-length trajectory segments can be generated, which not only preserves the temporal context of the trajectory, but also enhances the diversity of trajectory data, providing high-quality input for model training.
[0060] 4) Perform feature extraction and formatting operations on the segmented trajectory segments.
[0061] Feature extraction and formatting are key steps to convert raw agricultural machinery GNSS trajectory data into a form that can be processed by the model. In this embodiment, key features such as longitude, latitude, speed and direction are extracted from each trajectory point, and these features are organized into a continuous time series in chronological order.
[0062] First, each trajectory point contains information in multiple dimensions, among which longitude and latitude are geographic coordinates that accurately describe the two-dimensional position of the point on the earth's surface. Speed reflects the speed of the vehicle or device at that point and is an important motion attribute. Direction indicates the direction of the vehicle, usually expressed as an angle relative to the north, ranging from [0, 360] degrees. The longitude, latitude, speed and direction of each trajectory point are extracted.
[0063] Then, the extracted features are normalized.
[0064] The numerical ranges of different extracted features may vary greatly. If they are not standardized, the model may give higher weights to features with larger numerical ranges and ignore features with smaller numerical ranges. This will cause the model's training results to be biased towards features with larger numerical ranges, thus affecting the model's performance and generalization ability. Therefore, it is necessary to perform Z-score standardization on each feature to convert the feature into a standard normal distribution with a mean of 0 and a standard deviation of 1.
[0065] At the same time, due to the particularity of spatial coordinates (latitude and longitude) and directional characteristics, they need to be standardized after certain operations, specifically: 4-1) Standardization of longitude and latitude: In order to avoid the destruction of geographic spatial relationships caused by directly standardizing longitude and latitude, such as the different actual distances of 1° longitude at different latitudes, this embodiment uses UTM projection to convert the longitude and latitude coordinates of the trajectory points into a plane coordinate system.
[0066] Specifically, the latitude and longitude of each track point are converted to obtain its x (easting coordinate) and y (northing coordinate) values in the UTM coordinate system, and then its relative displacement relative to the starting point is calculated. For example, for track point i, the relative displacement and Indicates the plane displacement of the trajectory point relative to the starting point.
[0067] Then the relative displacement coordinates (i.e. and ) to perform Z-score normalization to ensure that all features are on the same scale. The normalization formula is as follows: (2); (3); In formula (2)-(3): , Respectively The mean and standard deviation of the feature; , Respectively The mean and standard deviation of the feature; , Respectively represent the standardized relative displacement coordinates.
[0068] By normalizing, the relative displacement of all trajectory points and will all have zero mean and unit variance.
[0069] 4-2) Standardization of direction: Direction has periodic characteristics, and directly normalizing the direction may lead to data discontinuity. It is necessary to convert the angle into sine and cosine values, and then perform Z-score normalization on these values. The specific formula is as follows: Convert to sine and cosine first: (4); (5); Normalize the sine and cosine values: (6); (7); In formulas (4)-(7): Represents the heading angle of the i-th trajectory point; , They represent the sine projection and cosine projection of the direction angle respectively; , Respectively represent the mean of the sine component of all trajectory points and the mean of the cosine component of all trajectory points; , Respectively represent the standard deviation of the sine component of all trajectory points and the standard deviation of the cosine component of all trajectory points; , They represent the normalized sine component of the heading angle and the normalized cosine component of the heading angle respectively.
[0070] It should be understood that the speed feature does not need special processing and can be directly subjected to Z-score normalization processing, which will not be described in detail here.
[0071] Based on the above, the standardization of all trajectory point features is completed.
[0072] 5) Perform concatenation operations on the standardized features to obtain continuous and uniform time series trajectory data.
[0073] The standardized longitude, latitude, speed, and direction of each trajectory point are concatenated to form a feature vector. , its eigenvector can be expressed as: , the feature vector Contains the track point All key information can be recognized and learned by the model.
[0074] Then, the feature vectors of all trajectory points are arranged in chronological order to form a time series. Assuming that there are N trajectory points and these points have been sorted by timestamps, the time series of the entire trajectory segment can be represented as a matrix:
[0075] Here, each row of the matrix X corresponds to the eigenvector of a trajectory point. The entire matrix X is arranged in chronological order, thus preserving the temporal characteristics of the trajectory.
[0076] Finally, the continuity of the time series is ensured, that is, the order of trajectory points in the matrix must be consistent with the actual time order, so that the subsequent model can correctly capture the trend and pattern of trajectory changes over time. In this way, the original agricultural machinery GNSS trajectory data is converted into a structured time series form to adapt it to the input requirements of the model.
[0077] S2. Construct a trajectory classification model including a feature extraction module and a classification head, wherein the feature extraction module includes an encoder network, a context network and a momentum encoder, and use the time series trajectory data as training samples to train the trajectory classification model, wherein the training of the trajectory classification model includes a feature pre-training stage and a classification fine-tuning stage.
[0078] Ginseng Figure 3 , in the feature pre-training stage, specifically including: S21. Using the encoder network to perform feature extraction on the time series trajectory data, and using the context network to capture the long-distance dependencies of the extracted features in the context information to construct positive sample pairs.
[0079] Specifically, the encoder network contains three one-dimensional convolutions to extract local trajectory features. For the convolution layer of the encoder network, using convolution kernels of different sizes and strides can help the model extract features of different time scales. The specific configuration is as follows: The first convolution layer: the convolution kernel size is 10, the stride is 2, the padding is 3, and the number of output channels is 128; The second convolution layer: the convolution kernel size is 8, the stride is 2, the padding is 2, and the number of output channels is 256; The third convolution layer: the convolution kernel size is 6, the stride is 2, the padding is 1, and the number of output channels is 512.
[0080] Each convolutional layer is configured with ReLU activation function and batch normalization.
[0081] Through multiple layers of convolution, local features are extracted from the preprocessed time series trajectory data. After each layer of convolution operation, the ReLU activation function is used to introduce nonlinearity, and the pooling operation further reduces the size of the feature map while retaining the most important feature information. Finally, the real feature representation of the current time t can be obtained. And the real feature representation at the kth moment in the future .
[0082] In trajectory data processing, it is extremely important to accurately capture the long-distance dependencies in context information. In the context network, this embodiment uses a time convolutional network (TCN) to capture the long-distance dependencies in trajectory data. Traditional networks such as feedforward neural networks are difficult to perceive time sequence, and RNN networks are prone to gradient disappearance or explosion when processing long sequences. The time convolutional network (TCN) can process sequence data in parallel and extract features through convolution operations.
[0083] Specifically, the temporal convolution network TCN of this embodiment uses 3 layers of temporal convolution, each layer has a convolution kernel size of 3, a stride of 1, and an output channel number of 512. A ReLU activation function is used after each convolution operation to introduce nonlinearity. This setting can expand the receptive field, effectively capture the long-distance dependency of trajectory data in the time series, and provide strong support for trajectory analysis.
[0084] Based on the above, the constructed trajectory classification model extracts the context representation of the current time t through the encoder network and the context network , this representation captures the temporal information of the current moment and the moments before and after it.
[0085] In getting the context After that, the model predicts the feature representation of the kth moment in the future, that is, the model transforms the context representation into After a series of linear transformations W, the predicted feature representation is obtained .
[0086] The goal of this embodiment is to make the predicted feature representation With the real feature representation As similar as possible, so the real feature representation obtained Feature representation with prediction The positive samples are used as positive samples and reference samples for calculating the loss function. The positive samples are based on the real feature representation. Feature representation with prediction Build, that is .
[0087] S22, performing a data enhancement operation on the time series trajectory data, inputting the enhanced time series trajectory data into the momentum encoder to obtain its feature representation, and constructing a negative sample pair in combination with a dynamic queue mechanism.
[0088] In this embodiment, the data enhancement operation is to mirror-flip the trajectory along the vertical axis (equivalent to the y-axis), specifically, the longitude of each point in the trajectory is inverted and the latitude remains unchanged, so as to generate a new trajectory.
[0089] In order to achieve good results in contrastive learning, it is necessary to have a negative sample set that is large enough and has consistent sample distribution. In order to improve the scale and diversity of negative sample construction in contrastive learning, this embodiment introduces a dynamic negative sample queue mechanism to store and update the trajectory feature representation generated during the training process. This mechanism dynamically maintains historical sample information during the training process by constructing a continuously updated feature queue, thereby overcoming the problems of limited number of negative samples and single sample distribution in traditional methods, and significantly improving the model's ability to recognize different trajectory categories.
[0090] Specifically, a momentum encoder network is constructed in parallel during model training, which has the same network structure as the main model but with different parameter update methods. The momentum encoder receives the enhanced trajectory fragments, generates feature representations for contrastive learning, and participates in the loss calculation of contrastive learning together with the output of the main model.
[0091] To ensure the stability and diversity of features, the momentum encoder parameters are adjusted using a momentum update strategy based on historical gradient information, so that the direction of parameter update depends not only on the current gradient, but also on the previous gradient direction, avoiding frequent parameter changes from causing disturbances to the feature distribution, thereby improving the consistency and quality of negative samples.
[0092] During each training, the parameters of the momentum encoder are updated using the momentum update formula, which is: (8); In formula (8): represents the parameters of the momentum encoder; Represents the parameters of the main model; is the momentum coefficient, and its value range is usually between 0 and 1. Here, the value of m is set to 0.999, so that the negative sample features can remain stable and not be affected by the fluctuations of the main model parameters.
[0093] In view of the two typical modes of "field trajectory" and "road trajectory" in trajectory data, this embodiment further designs a dual queue management mechanism for category distinction, maintaining and Two independent channels for storing negative samples.
[0094] in, It is a field trajectory queue, storing the field category representations generated by the momentum encoder in the most recent batches; It is a road trajectory queue that stores the road category representations generated by the momentum encoder in the most recent batches.
[0095] In each round of training, the model selects negative samples from the feature queue corresponding to another category according to the category of the current input trajectory, builds cross-category comparison relationships, and strengthens the model's ability to distinguish different trajectory patterns. For example, if the current trajectory sample belongs to the field category, then the negative sample is selected from the road trajectory queue. Randomly select As negative samples, the predicted feature representation Constitute a negative sample pair If the current trajectory sample belongs to the road category, then from the field trajectory queue Randomly select As negative samples, the predicted feature representation Constitute a negative sample pair .
[0096] For each sample, classification by category has been completed during data preprocessing, and it has a clear category. After the data enhancement operation, the sample is input into the momentum encoder to generate feature representation.
[0097] After each training, the feature representations are stored in the queues of the corresponding categories according to the sample categories. For example, if the sample belongs to a field trajectory, the corresponding feature representation is placed in the field queue. Each queue is updated using a first-in-first-out strategy of a fixed size n=2048. When new features are generated, they are added to the corresponding queue in order. If the queue is full, the oldest sample feature is removed to keep the queue capacity fixed, the sample diversity rich, and the timeliness strong.
[0098] At the beginning of training, since there is no historical data, both the field trajectory queue and the road trajectory queue are empty. When the first trajectory data is input, the model obtains the feature representation of the positive sample pair, but since the dynamic negative sample queue is empty, no negative sample can be obtained from it. Therefore, the two dynamic negative sample queues need to be initialized before training begins.
[0099] Specifically, in the data preprocessing stage, the data has been divided into two categories: "field tracks" and "road tracks" based on the prior information of agricultural machinery trajectory data. Subsequently, a pre-initialized data set is prepared for each category, that is, about 100 pre-processed field track segments and road track segments are randomly selected to ensure that there are enough samples of both types of data to fill the queue.
[0100] After data enhancement, each sample in the pre-initialized dataset is input into the momentum encoder to obtain the corresponding feature representation. For each category, according to the set queue capacity, the calculated feature representation is inserted into the corresponding negative sample queue in turn to complete the queue initialization.
[0101] This mechanism not only effectively increases the number and coverage of negative samples, but also enhances their spatiotemporal diversity and category distinction, which helps the model obtain more stable and discriminative representation capabilities in the comparative learning process, thereby significantly improving the accuracy and robustness of trajectory classification.
[0102] S23. In the feature pre-training stage, based on the positive sample pairs and the negative sample pairs, the feature extraction module of the trajectory classification model is iteratively trained using the InfoNCE contrast loss function, and an early stopping mechanism is introduced. When the loss value of multiple consecutive training cycles tends to be stable, the early stopping mechanism is triggered, and the representation vector of all time series trajectory data is extracted using the current feature extraction module. K-means clustering is performed based on the representation vector, and the clustering quality is evaluated by calculating the silhouette coefficient to judge the feature learning effect of the current trajectory classification model; In the classification fine-tuning stage, the feature extraction module is frozen, the classification head is trained using supervised cross entropy loss, and the category labels are enabled for supervised learning so that the classification head outputs the category probability distribution of the trajectory.
[0103] In this embodiment, the InfoNCE contrast loss is used to perform self-supervisory optimization on the features, so that the similarity between positive samples is maximized and the similarity between negative samples is minimized.
[0104] The InfoNCE loss function is as follows: Assuming that the current sample belongs to the field trajectory category, the negative sample is selected from the road trajectory queue: (9); In formula (9): represents a road trajectory queue; represents the i-th negative sample in the road trajectory queue; sim is the cosine similarity, Represents the feature representation of the future moment predicted by the model, i.e., the benchmark sample; Represents the real future moment feature representation, that is, the positive sample; is the temperature parameter, which is used to control the distribution of similarity.
[0105] Similarly, if the current sample belongs to the road trajectory category, the negative sample is selected from the field trajectory queue: (10); In formula (10): represents a road trajectory queue; represents the i-th negative sample from the field trajectory queue.
[0106] The training adopts a phased training strategy, the core concept of which is "optimize features first and then classify", which aims to improve the generalization ability and classification accuracy of the model by optimizing features first and then classifying. Specifically, this method is divided into two main stages: feature pre-training stage and classification fine-tuning stage.
[0107] Ginseng Figure 4 First, the original agricultural machinery GNSS trajectory data is preprocessed. The original trajectory data contains information such as longitude, latitude, timestamp, speed, direction and category. After data preprocessing, the original features are spliced into an input form that is more suitable for the model. In this stage, the data is segmented by category, the length of the input trajectory segment is fixed, the quality of the input data is improved, and each feature is normalized. 100 trajectory segments are selected from each category to be integrated into a pre-initialized data set, which is used to fill the negative sample queue before training begins.
[0108] Each segmented data is taken as an independent sample and is sequentially fed into the encoder network and the context network to obtain the positive sample pairs required for contrastive learning. At the same time, the segmented data is fed into the momentum encoder after a data augmentation operation, and combined with the dynamic negative sample queue to obtain the negative samples required for contrastive learning.
[0109] At this point, the contrastive learning task is completed.
[0110] Then, through contrast loss functions such as InfoNCE, the model learns a representation that brings similar trajectory features closer and dissimilar trajectory features farther apart.
[0111] The obtained positive and negative samples are constructed into a data set, and the data set is divided into 70% training, 15% validation, and 15% testing ratios.
[0112] In the feature pre-training stage, the encoder network learns a robust trajectory representation through contrastive learning and dynamic negative sample queue mechanism. The training batch size is set to 32, the total number of training rounds is 50, and early stopping or learning rate adjustment is used when necessary. Through the forward propagation of the encoder network, context network and momentum encoder, dynamic queue update and negative sample sampling are performed, and the contrast loss InfoNCE is calculated. The AdamW optimizer (learning rate is set to 3e-4, weight decay is 0.01) is used for back propagation and parameter update, and the momentum encoder is updated at the same time.
[0113] In the feature pre-training stage, InfoNCE loss is first used as the main optimization target. By maximizing the feature similarity of positive sample pairs and minimizing the similarity of negative sample pairs, the encoder network and context network are driven to continuously improve their ability to recognize trajectory patterns. After each training cycle, the loss value is recorded in real time. If there is no significant decrease for multiple consecutive cycles, such as 5 training cycles, the early stopping mechanism is triggered to avoid invalid training.
[0114] At the same time, in order to introduce an auxiliary evaluation mechanism for the quality of feature distribution in addition to the contrast loss, after the early stopping mechanism is triggered or the training is completed, the representation vector of all trajectory segments of the current trajectory classification model is extracted, and the K-means algorithm is used to divide them into two categories: field trajectories and road trajectories. The compactness and separation of the cluster structure are measured by calculating the silhouette coefficient. When the silhouette coefficient reaches or exceeds 0.6, it means that the features learned by the model have performed well in class distinction, and the subsequent classification task can be considered; if the silhouette coefficient continues to be lower than this threshold, it indicates that the feature clustering effect is not good, and it is necessary to return to the contrast learning stage to continue to optimize the model parameters or adjust the hyperparameters.
[0115] The entire process is dominated by the loss reduction trend and supplemented by clustering quality evaluation. It organically combines early stopping, K-means clustering and silhouette coefficient, so that the model can not only achieve the optimal contrast loss, but also show clear category boundaries in practical applications, thus laying a solid feature foundation for downstream transportation mode classification tasks.
[0116] In the classification fine-tuning stage, a classification head is designed for the model. The classification head is the last part of the model and is responsible for converting the feature representation into a category probability distribution. This part consists of two fully connected layers, and finally uses the softmax layer to output the probability distribution of the category. The first fully connected layer maps the output features to a lower dimensional space, and then the second fully connected layer further maps the intermediate representation output by the first fully connected layer to the number of target categories. The ReLU activation function is used to introduce nonlinear characteristics, which helps the model learn more complex feature representations. Finally, the output layer uses the softmax activation function to generate the probability distribution of each category.
[0117] At this stage, the pre-trained feature extractor (including the encoder network, context network, and momentum encoder) is frozen, and only the classification head is trained. The input data is a trajectory segment of length 200, and the classification label is enabled for supervised learning. During the training process, supervised cross entropy loss is used to guide model learning. By comparing the difference between the predicted results and the true labels, the parameters of the classification head are dynamically optimized, so that the model gradually reduces the prediction error. After such training, the classification head can focus on distinguishing high-level semantic features, thereby effectively improving the classification accuracy.
[0118] During the training process, each batch of data first passes through the encoder and context network to obtain high-dimensional features, and then passes through the classification head to predict the category. At the same time, the dynamic negative sample queue is used to update the negative samples and calculate the contrast loss.
[0119] Based on the above, the training process of the trajectory classification model is completed.
[0120] S3. Deploy the trained trajectory classification model and use it to classify the agricultural machinery trajectory data.
[0121] Finally, the trained trajectory classification model is applied to the actual agricultural machinery trajectory classification task to complete the classification of agricultural machinery trajectory data.
[0122] Embodiment 2, This embodiment provides a device for implementing a method for classifying agricultural machinery trajectory data, the device comprising: A data acquisition module is used to perform preprocessing and feature conversion operations on the original agricultural machinery GNSS trajectory data to obtain continuous and uniform time series trajectory data; wherein the original agricultural machinery GNSS trajectory data includes a plurality of discrete trajectory points, and the features of each discrete trajectory point include longitude, latitude, timestamp, speed, direction and category label, and the categories of trajectory points include field trajectory and road trajectory; The model building and training module is used to build a trajectory classification model including a feature extraction module and a classification head. The feature extraction module includes an encoder network, a context network and a momentum encoder, and uses the time series trajectory data as a training sample to train the trajectory classification model. The training of the trajectory classification model includes a feature pre-training stage and a classification fine-tuning stage, specifically: Using the encoder network to extract features from the time series trajectory data, and using the context network to capture long-distance dependencies of the extracted features in context information to construct positive sample pairs; Performing data enhancement operation on the time series trajectory data, inputting the enhanced time series trajectory data into the momentum encoder to obtain its feature representation, and constructing negative sample pairs in combination with a dynamic queue mechanism; In the feature pre-training stage, based on the positive sample pairs and the negative sample pairs, the feature extraction module of the trajectory classification model is iteratively trained using the InfoNCE contrast loss function, and an early stopping mechanism is introduced. When the loss value of multiple consecutive training cycles tends to be stable, the early stopping mechanism is triggered, and the current feature extraction module is used to extract the representation vector of all time series trajectory data. K-means clustering is performed based on the representation vector, and the clustering quality is evaluated by calculating the silhouette coefficient to judge the feature learning effect of the current trajectory classification model; In the classification fine-tuning stage, the feature extraction module is frozen, the classification head is trained using supervised cross entropy loss, and the category labels are enabled for supervised learning, so that the classification head outputs the category probability distribution of the trajectory; The model application module is used to deploy the trained trajectory classification model and use it to classify agricultural machinery trajectory data.
[0123] Embodiment 3, This embodiment also provides an electronic device, including: at least one processor; and A memory storing instructions, which, when executed by the at least one processor, enables the at least one processor to execute the agricultural machinery trajectory data classification method as described above.
[0124] In this embodiment, the electronic device may include, but is not limited to: personal computers, server computers, workstations, desktop computers, laptop computers, notebook computers, mobile computing devices, smart phones, tablet computers, cellular phones, personal digital assistants (PDAs), handheld devices, messaging devices, wearable computing devices, consumer electronic devices, and the like.
[0125] Embodiment 4, This embodiment also provides a machine-readable storage medium storing executable instructions, which, when executed, enable the machine to execute the agricultural machinery trajectory data classification method as described above.
[0126] Specifically, a system or device equipped with a readable storage medium can be provided, on which software program codes that implement the functions of any of the above-mentioned embodiments are stored, and a computer or processor of the system or device can read and execute instructions stored in the readable storage medium.
[0127] In this case, the program code itself read from the machine-readable medium can realize the function of any one of the above embodiments, and thus the machine-readable code and the machine-readable storage medium storing the machine-readable code constitute part of this specification.
[0128] Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tapes, non-volatile memory cards, and ROMs. Optionally, the program code may be downloaded from a server computer or a cloud via a communication network.
[0129] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0130] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0131] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0132] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0133] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the technical solution of the present invention, and are not intended to limit the specific implementation methods of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the claims of the present invention shall be included in the protection scope of the claims of the present invention.
Claims
1. A method for classifying agricultural machinery trajectory data, characterized in that: The method comprises: S1. Preprocessing and feature conversion operations are performed on the original agricultural machinery GNSS trajectory data to obtain continuous and uniform time series trajectory data; wherein the original agricultural machinery GNSS trajectory data includes multiple discrete trajectory points, and the features of each discrete trajectory point include longitude, latitude, timestamp, speed, direction and category label, and the categories of trajectory points include field trajectory and road trajectory; S2. Construct a trajectory classification model including a feature extraction module and a classification head. The feature extraction module includes an encoder network, a context network and a momentum encoder. The time series trajectory data is used as a training sample to train the trajectory classification model. The training of the trajectory classification model includes a feature pre-training stage and a classification fine-tuning stage, specifically: S21, using the encoder network to extract features from the time series trajectory data, and using the context network to capture the long-distance dependencies of the extracted features in the context information to construct positive sample pairs; S22, performing a data enhancement operation on the time series trajectory data, inputting the enhanced time series trajectory data into the momentum encoder to obtain its feature representation, and constructing a negative sample pair in combination with a dynamic queue mechanism; S23. In the feature pre-training stage, based on the positive sample pairs and the negative sample pairs, the feature extraction module of the trajectory classification model is iteratively trained using the InfoNCE contrast loss function, and an early stopping mechanism is introduced. When the loss value of multiple consecutive training cycles tends to be stable, the early stopping mechanism is triggered, and the representation vector of all time series trajectory data is extracted using the current feature extraction module. K-means clustering is performed based on the representation vector, and the clustering quality is evaluated by calculating the silhouette coefficient to judge the feature learning effect of the current trajectory classification model; In the classification fine-tuning stage, the feature extraction module is frozen, the classification head is trained using supervised cross entropy loss, and the category labels are enabled for supervised learning, so that the classification head outputs the category probability distribution of the trajectory; S3. Deploy the trained trajectory classification model and use it to classify the agricultural machinery trajectory data.
2. The agricultural machinery trajectory data classification method according to claim 1, characterized in that: In S1, the original agricultural machinery GNSS trajectory data is preprocessed, including: According to the category labels of the track points in the original agricultural machinery GNSS track data, the track points are divided into a number of different track segments, wherein the category labels of the track points are 1 or 0, 1 represents a field track, and 0 represents a road track; And, resampling and interpolation operations are performed on the segmented trajectory segments, specifically: Set the sampling interval , and according to the set sampling interval , construct a new time grid: ,in, is the start time of the trajectory segment, is the end time of the trajectory segment; Arrange the trajectory points in ascending order according to the timestamps, set the timestamps of the trajectory points as indices, and use linear interpolation to interpolate the features of the trajectory points on the newly created time grid. That is, for the time to be interpolated , assuming that the nearest original trajectory points on both sides are ( , )、( , ), then the characteristic estimate for: (1); In formula (1): Indicates the time to be interpolated The estimated value of the feature inserted at the location; Furthermore, a fixed window segmentation operation is performed on the interpolated agricultural machinery GNSS trajectory data to obtain trajectory segments of equal length, wherein the window length is set to 200 points and the sliding step size is 100 points to generate overlapping trajectory segments.
3. The agricultural machinery trajectory data classification method according to claim 1, characterized in that: In S1, feature conversion is performed on the pre-processed original agricultural machinery GNSS trajectory data, including: Extract key features from each trajectory point, including longitude, latitude, speed and direction, and perform standardization on the features; wherein the longitude and latitude are standardized as follows: Convert the longitude and latitude of each track point to obtain its x- and y-coordinate values in the UTM coordinate system, and calculate its relative displacement relative to the starting point and , and then the relative displacement and Perform Z-score standardization: (2); (3); In formula (2)-(3): , Respectively The mean and standard deviation of the feature; , Respectively The mean and standard deviation of the feature; , Respectively represent the normalized relative displacement coordinates; The directions are standardized, specifically: Convert the direction angle to sine and cosine values: (4); (5); Perform Z-score normalization on sine and cosine values: (6); (7); In formulas (4)-(7): Represents the heading angle of the i-th trajectory point; , They represent the sine projection and cosine projection of the direction angle respectively; , Respectively represent the mean of the sine component of all trajectory points and the mean of the cosine component of all trajectory points; , Respectively represent the standard deviation of the sine component of all trajectory points and the standard deviation of the cosine component of all trajectory points; , They represent the normalized sine component of heading angle and the normalized cosine component of heading angle respectively; And, the standardized features are concatenated to obtain the feature vector representation of each trajectory point, that is, for the trajectory point , whose eigenvector is expressed as ; Then arrange the feature vectors of all trajectory points in chronological order to form a time series matrix. That is, assuming that it contains N trajectory points, the formed time series matrix is .
4. The agricultural machinery trajectory data classification method according to claim 1, characterized in that: In S21, the encoder network includes three layers of one-dimensional convolution, which is used to extract local features of the time series trajectory data to obtain the real feature representation of the current time t. And the real feature representation at the kth moment in the future The context network uses a time convolution network (TCN), which uses three layers of time convolution to extract the context representation of the current time t. ; The context is represented as After linear transformation W, the predicted feature representation is obtained , and based on the real feature representation Feature representation with prediction Construct positive sample pairs as .
5. The agricultural machinery trajectory data classification method according to claim 4, characterized in that: In S22, the parameters of the momentum encoder are updated using the momentum update formula, namely: (8); In formula (8): represents the parameters of the momentum encoder; Represents the parameters of the main model; is the momentum coefficient, ranging from 0 to 1; The negative sample pairs are constructed by combining the dynamic queue mechanism, specifically: A dual-queue management mechanism is built based on field trajectories and road trajectories to maintain and Two independent negative sample storage channels, where It is a field trajectory queue, which is used to store the field category representations generated by the momentum encoder in the latest batches; It is a road trajectory queue, which is used to store the road category representations generated by the momentum encoder in the most recent batches; In each round of training, according to the category of the current input trajectory, negative samples are selected from the feature queue corresponding to another category to build a cross-category comparison relationship. That is, when the current trajectory sample belongs to the field category, negative samples are selected from the road trajectory queue. Randomly select As negative samples, the predicted feature representation Constitute a negative sample pair ; When the current trajectory sample belongs to the road category, it is selected from the field trajectory queue Randomly select As negative samples, the predicted feature representation Constitute a negative sample pair .
6. The agricultural machinery trajectory data classification method according to claim 5, characterized in that: In S23, in the feature pre-training stage, if the current trajectory sample is a field trajectory category, the negative sample is selected from the road trajectory queue. At this time, the InfoNCE loss function is: (9); In formula (9): represents a road trajectory queue; represents the i-th negative sample in the road trajectory queue; sim is the cosine similarity; Represents the feature representation of the future moment predicted by the model, i.e., the benchmark sample; Represents the true future moment feature representation, i.e., positive sample; is the temperature parameter, used to control the distribution of similarity; If the current trajectory sample is a road trajectory, the negative sample is selected from the field trajectory queue. At this time, the InfoNCE loss function is: (10); In formula (10): represents a road trajectory queue; represents the i-th negative sample from the field trajectory queue.
7. The agricultural machinery trajectory data classification method according to claim 6, characterized in that: The S23 also includes, at the beginning of the feature pre-training stage, randomly selecting a number of field tracks and road tracks from the time series trajectory data as pre-initialized data sets, performing data enhancement on the pre-initialized data sets and then inputting them into the momentum encoder to construct an initial negative sample queue.
8. A device for implementing a method for classifying agricultural machinery trajectory data, characterized in that: The device comprises: A data acquisition module is used to perform preprocessing and feature conversion operations on the original agricultural machinery GNSS trajectory data to obtain continuous and uniform time series trajectory data; wherein the original agricultural machinery GNSS trajectory data includes a plurality of discrete trajectory points, and the features of each discrete trajectory point include longitude, latitude, timestamp, speed, direction and category label, and the categories of trajectory points include field trajectory and road trajectory; The model building and training module is used to build a trajectory classification model including a feature extraction module and a classification head. The feature extraction module includes an encoder network, a context network and a momentum encoder, and uses the time series trajectory data as a training sample to train the trajectory classification model. The training of the trajectory classification model includes a feature pre-training stage and a classification fine-tuning stage, specifically: Using the encoder network to extract features from the time series trajectory data, and using the context network to capture long-distance dependencies of the extracted features in context information to construct positive sample pairs; Performing data enhancement operation on the time series trajectory data, inputting the enhanced time series trajectory data into the momentum encoder to obtain its feature representation, and constructing negative sample pairs in combination with a dynamic queue mechanism; In the feature pre-training stage, based on the positive sample pairs and the negative sample pairs, the feature extraction module of the trajectory classification model is iteratively trained using the InfoNCE contrast loss function, and an early stopping mechanism is introduced. When the loss value of multiple consecutive training cycles tends to be stable, the early stopping mechanism is triggered, and the current feature extraction module is used to extract the representation vector of all time series trajectory data. K-means clustering is performed based on the representation vector, and the clustering quality is evaluated by calculating the silhouette coefficient to judge the feature learning effect of the current trajectory classification model; In the classification fine-tuning stage, the feature extraction module is frozen, the classification head is trained using supervised cross entropy loss, and the category labels are enabled for supervised learning, so that the classification head outputs the category probability distribution of the trajectory; The model application module is used to deploy the trained trajectory classification model and use it to classify agricultural machinery trajectory data.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and A memory storing instructions, which, when executed by the at least one processor, enables the at least one processor to execute the agricultural machinery trajectory data classification method according to any one of claims 1 to 7.
10. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores executable instructions, and when the instructions are executed, the machine executes the agricultural machinery trajectory data classification method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Classification method and device for agricultural machine track data and storage medium
CN119128719A
Encryption event classification method and system based on prompt learning
CN116467442A
Signature handwriting identification method and system based on prompt learning, and storage medium
CN116645683A
Text classification method and related device for fusion fine tuning of large model and expansion convolution
CN118861307A
Agricultural machine trajectory classification method based on trajectory similarity measurement, computer readable storage medium and computer program product
CN119046759A
Cited By
Method and system for identifying track of agricultural machine
CN121637074A
Unsupervised agricultural machine trajectory classification method and device based on comparative learning
CN121723271A
An Unsupervised Agricultural Machinery Trajectory Classification Method and Device Based on Comparative Learning
CN121723271B
Agricultural machine track segmentation and classification method based on boundary perception residual time sequence convolutional network
CN122388713A
Agricultural machine trajectory segmentation and classification method based on boundary-aware residual temporal convolution network
CN122388713B
