Unsupervised agricultural machine trajectory classification method and device based on comparative learning

An unsupervised agricultural machinery trajectory classification method based on deep contrastive learning utilizes asymmetric feature dimension data augmentation and a hybrid encoder to adaptively sample hard-to-separate negative samples, achieving unsupervised agricultural machinery trajectory classification. This solves the problems of dependence on manual annotation and insufficient feature extraction, and improves the robustness and stability of the classification.

CN121723271AActive Publication Date: 2026-03-24QILU UNIVERSITY OF TECHNOLOGY (SHANDONG ACADEMY OF SCIENCES) +1
View PDF 7 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-02-24
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

Existing agricultural machinery trajectory classification methods rely on manual annotation, which is costly, inefficient, and highly subjective. Furthermore, existing contrastive learning-based methods cannot simultaneously extract local and global features of the trajectory, leading to a decrease in classification robustness.

Method used

An unsupervised agricultural machinery trajectory classification method based on deep contrastive learning is adopted. Through asymmetric data augmentation of feature dimensions, hierarchical temporal decoupling hybrid encoder and adaptive hard-to-separate negative sample sampling, trajectory feature representation is automatically learned from unlabeled data, realizing unsupervised trajectory clustering and classification.

Benefits of technology

It requires no human intervention, has strong feature representation capabilities, and provides stable training results. It is suitable for large-scale intelligent trajectory analysis of agricultural machinery, possesses good generalization ability and engineering robustness, and is suitable for continuous analysis of long-term operating data across multiple regions and machine models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121723271A_ABST
    Figure CN121723271A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of electric digital data processing, and particularly relates to an unsupervised agricultural machine track classification method and device based on comparative learning. According to the method, through mechanisms such as multi-view enhancement, global and local time sequence modeling, dynamic negative sample optimization and the like, the model can automatically learn track feature representation with discrimination from unlabeled data, so that unsupervised track clustering and classification are realized, and the stability, interpretability and generalization ability of model learning are remarkably improved. According to the method, an end-to-end unsupervised learning framework is constructed, potential operation modes and structural differences can be directly and automatically found from continuously collected mass agricultural machine trajectory data, no prior category information or artificial experience rules are needed, the problems that manual labeling is high in subjectivity, high in cost and difficult to scale are solved, and the method is suitable for popularization and application. The method is especially suitable for continuous analysis scenes of multi-region and multi-model long-term operation data.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of digital data processing, and particularly relates to an unsupervised agricultural machine trajectory classification method and device based on contrast learning. BACKGROUND

[0002] Agricultural machine trajectory data has extremely high value in the agricultural production system, and can truly reflect the operation mode, running behavior, power response and field environment structure of agricultural machines, and is an important basis for constructing intelligent agricultural machine scheduling, operation quality evaluation and agricultural machine efficiency modeling. However, at present, trajectory classification still mainly relies on manual annotation, which has the following key problems: (1) High labor cost: the amount of agricultural machine trajectory data is huge, and the data is collected at a high frequency and over a long time span, so the cost of relying on manual annotation of each piece of data is extremely high; (2) Low efficiency and poor scalability: agricultural operation scenarios are rich, including road driving, field plowing, transplanting and pesticide spraying, and manual annotation is difficult to adapt to the rapid growth of trajectory data volume; (3) Strong subjectivity and heavy data noise: different annotators may have different understandings of the same trajectory, which can cause inconsistent labels and fuzzy decision boundaries, and thus produce "garbage labels", which seriously affect the stability of model training.

[0003] For example, Chinese patent document CN120105238A discloses an agricultural machine trajectory data classification method, device, electronic equipment and storage medium. The method comprises: performing preprocessing and feature conversion operations on original agricultural machine GNSS trajectory data to obtain continuous and uniform time sequence trajectory data; the original agricultural machine GNSS trajectory data contains a plurality of discrete trajectory points, and the categories of the trajectory points include field trajectories and road trajectories; a trajectory classification model containing a feature extraction module and a classification head is constructed, and the time sequence trajectory data is used as a training sample to train the trajectory classification model, wherein the feature extraction module is trained in a contrast learning manner, and the classification head is trained by cross-entropy loss; and the trained trajectory classification model is deployed to classify agricultural machine trajectory data. However, it needs to manually annotate the trajectory, which is time-consuming and laborious, increases the cost, and has a high error rate.

[0004] To solve the above problems, researchers have carried out research on agricultural machinery trajectory classification technology based on contrast learning. For 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 contrast 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 classification of field-road. However, the spatial features extracted by the method are limited to the length of a sliding window, the receptive field is limited, and both local and global features of the trajectory cannot be extracted at the same time, which reduces the classification robustness of complex operation scenarios and is not conducive to classification.

[0005] Based on this, the present application proposes an unsupervised agricultural machinery trajectory classification method and device based on deep contrast learning, which eliminates the dependence on manual annotation, uses massive unlabeled trajectory data to automatically mine operation behavior patterns, and realizes robust and high-precision agricultural machinery trajectory classification and feature representation learning. The method significantly improves the stability, interpretability and generalization ability of model learning through innovative data augmentation strategies, hybrid encoder structures and difficult negative sample sampling mechanisms. SUMMARY

[0006] The present application proposes an unsupervised agricultural machinery trajectory classification method based on contrast learning, which mainly includes feature dimension asymmetric data augmentation, hierarchical time decoupling hybrid encoder, and adaptive difficult negative sample sampling. Through mechanisms such as multi-view enhancement, global and local time modeling, and dynamic negative sample optimization, the model can automatically learn discriminative trajectory feature representations from unlabeled data, thereby realizing unsupervised trajectory clustering and classification. The present application has the advantages of no human intervention, strong feature expression ability, stable training effect, etc., and is very suitable for large-scale intelligent analysis of agricultural machinery trajectories.

[0007] The present application also discloses a device loaded with an unsupervised agricultural machinery trajectory classification method based on contrast learning.

[0008] The detailed technical solutions of the present application are as follows: The unsupervised agricultural machinery trajectory classification method based on contrast learning comprises: S1, preprocessing the original agricultural machinery trajectory to obtain a trajectory segment dataset ; S2, constructing a contrast learning model, the contrast learning model comprising a spectral domain association-dynamic memory decoupling hybrid time encoder: S21, performing feature dimension-based asymmetric data augmentation on the trajectory segment dataset obtained in step S1 to obtain a weakly augmented sample set S22, constructing a hierarchical time decoupling hybrid time encoder based on the weakly augmented sample set obtained in step S21 and strong enhancement sample set ; S22, constructing a weak enhancement sample set and a strong enhancement sample set respectively through a feature encoder to extract the time features of individual samples, obtaining a sample set containing individual sample time features , wherein the weak enhancement sample set containing individual sample time features and the strong enhancement sample set ; S23, constructing a spectrum domain correlation-dynamic memory decoupling hybrid time sequence encoder to extract features from the sample set containing individual sample time features obtained in step S22 , obtaining feature samples after feature extraction ; S24, introducing an adaptive difficult negative sample sampling strategy to divide the negative samples in the sample output in step S23 to construct a difficult negative sample set; S25, based on the difficult negative sample set constructed in step S24, calculating a weighted contrastive loss and iteratively updating the contrastive learning model parameters through backpropagation until the model converges; S3, contrastive learning model training: using the trajectory segment dataset preprocessed in step S1 to train the contrastive learning model constructed in step S2 until the model converges, outputting a trajectory representation model; S4, unsupervised trajectory classification: inputting the data to be classified after preprocessing in step S1 into the trajectory representation model in step S3, obtaining the output features, and clustering the output features to achieve unsupervised trajectory classification.

[0009] Preferably, the preprocessing in step S1 includes: S11, performing motion feature extraction on the original agricultural machinery trajectory to generate trajectory points containing extracted motion features; S12, using the DBSCAN density clustering algorithm to preliminarily cluster the trajectory points containing extracted motion features to obtain pseudo labels; S13, based on the obtained pseudo labels, performing sliding time window on the trajectory points containing extracted motion features to construct trajectory segments, obtaining a trajectory segment dataset .

[0010] Preferably, step S21 is: The shape of the trajectory segment dataset X is (Seq_len, Channels), Channels is divided into core features and non-core features, obtaining a weak enhancement sample set and strong enhancement sample set : (1) (2) wherein, denotes the core feature, denotes a slight Gaussian noise imposed on the core feature, denotes the non-core feature, and denotes a structural level perturbation operation, including random time masking, feature translation, local scaling, etc.; Seq_len denotes the time step of the current sample, i.e. the sliding window size, and Channels denotes the number of feature channels of each sample.

[0011] Preferably, the step S23 comprises: S231, constructing a spectral domain correlation modeling module, i.e. SRM, which comprises a fast Fourier transform and a spectral change encoder, mapping the sample set containing the time features of a single sample obtained in step S22 to a frequency domain through the Fourier transform, modeling the global dependence through the frequency selection attention mechanism of the spectral change encoder, and outputting a global representation ; ; S232, constructing a time sequence state evolution modeling module, i.e. DMEN, which introduces a time decay factor and a time sequence encoder after FiLM transformation based on SRM modulation, through the dynamic gating state update mechanism of DMEN, to the sample set containing the time features of a single sample obtained in step S22 adopting a dynamic memory gating temporal network for local modeling, and outputting a local representation ; S233, constructing a cross-domain alignment fusion module, i.e. CAF, which fuses the global representation of SRM with the local representation of DMEN through the cross-domain attention regulation mechanism of the cross-domain alignment fusion module for feature-level adaptive fusion, to obtain the final encoding .

[0012] Further preferably, the step S231 of modeling the global dependence through the frequency selection attention mechanism of the spectral change encoder and outputting the global representation and the modulation vector comprises: let the hidden dimension of the contrast learning model be ; first, short-term spectral perception and projection are performed on the sample set after Fourier transform: ​​For the sample set after Fourier transform Each feature channel is obtained by performing depthwise convolution. ,Right now (3) in, This represents the short-time spectral response after independent modeling of each channel. T The total length of the time steps. D Let be the number of feature channels, and t be the t-th time step, with values ​​ranging from 1 to 2. , The set of real numbers is the field of numbers, indicating that the elements belong to this set of real numbers. The length of the temporal convolution kernel. For time offset index, For the first The depthwise convolution kernel parameters corresponding to each feature channel are processed with zero padding at the boundary positions.

[0013] Then, pointwise projection is performed to obtain the spectral domain embedding. : (4) in, The channel projection weight matrix is... For bias terms, This indicates the hidden dimension of the model. It is a spectral domain embedding sequence.

[0014] right Normalization of layers yields The formula is as follows: (5); Representation layer normalization, in Implement multi-layer, multi-head self-attention encoding based on this: Let the first Layer input is , where the initial value , No. The multi-head self-attention and feedforward calculation of the layer are as follows: (6) (7) (8) in, For learnable parameter matrix, Represents a query vector sequence. Represents a sequence of key vectors. Represents a sequence of value vectors. , , .

[0015] Multi-head self-attention is calculated as follows: (9) in, This represents the attention mechanism. The dimension representing a single attention head is used to scale the inner product result to stabilize the gradient. This represents the softmax function.

[0016] Subsequently, residual connections and a feedforward network are used for feature updates: (10) (11) in, For the first In the layer, the intermediate hidden features obtained after "multi-head self-attention + residual connection + layer normalization" are... Indicates the first A two-layer feedforward network, Indicates the first The final output of the layer. (After...) After layer encoding, the spectral domain context feature matrix is ​​obtained. .

[0017] right Perform time-series pooling to obtain the global representation With modulation vector : First, perform adaptive average pooling based on time: (12) in, Indicates average pooling. t For the current time step, Represents the global spectral domain behavior of the trajectory.

[0018] Then, a modulation vector is generated using a small projection network: (13) in, Represents the Gaussian error linear unit activation function. To calculate the linear mapping weights of the modulation vector m, This corresponds to the bias term.

[0019] More preferably, in step S232, a basic temporal state evolution model is constructed, and a time decay factor is introduced into it. The FiLM transform based on SRM modulation yields the time-series state evolution module, DMEN, which is then used to process the sample set containing the time features of individual samples obtained in step S22. After DMEN processing, the following is obtained ,right Perform attention readout based on the final modulation hidden layer, and output local representations through a fusion network. .

[0020] More preferably, the introduction of a time decay factor therein The FiLM transform based on SRM modulation yields the time-series state evolution module, DMEN, which includes: Time decay factor Designed as a learnable, exponentially decaying gate or a gate generated from time-varying features, i.e. (14) in, , It is used to generate the time decay factor. The linear mapping weight matrix, It is the corresponding bias vector. This represents the Sigmoid function. Used for dynamic decay of historical memory.

[0021] Furthermore, decay is introduced into the basic temporal state evolution model—replacing the previous hidden with a decaying hidden: (15) in, This is the hidden state from the previous time step after being modulated by the time decay factor. This represents the output at time step t-1; Simultaneously using the SRM modulation vector Scale and shift for generating FiLM: (16) (17) in, This represents the tanh activation function. and These represent the scaling factor and translation factor by channel, respectively. It is the scaling factor used to generate FiLM. The linear mapping weight matrix, For the corresponding bias vector, It is the translation factor used to generate FiLM. The linear mapping weight matrix, It is the corresponding bias vector.

[0022] The recursive form of DMEN is obtained as follows: (18) (19) (20) (twenty one) (twenty two) in, and These represent the reset gate and update gate after FiLM modulation, respectively. , , , , , , , , For learnable parameters, Indicates the candidate hidden state. These are the candidate hidden states after FiLM modulation. This represents the output at the current time step t after FiLM modulation.

[0023] The sample set obtained in step S22, which contains the time features of a single sample, is then... After DMEN processing, the following is obtained ,right Perform attention readout based on the final modulation hidden layer, and output local representations through a fusion network. : The sample set obtained in step S22, which contains the time features of a single sample, After DMEN processing, the hidden sequence at all time points is obtained. The matrix formed ,right Perform attention readout based on the final modulation hidden: Set the final time or specified cutoff time as the output ,by Perform a query and calculate the historical weighted context: (twenty three) (twenty four) in, , and For learnable parameters, For exponential mapping, To finally modulate the hidden state, The alignment score represents the correlation between the historical time t and the current local representation. is the attention weight, representing the contribution weight of the t-th time in history to the current local representation.

[0024] This yields the context vector: (25) And the local final representation is obtained through the fusion network: (26) in, Represents the local temporal evolution characteristics of the trajectory. It is the linear mapping weight matrix of the fusion network. It is the corresponding bias vector.

[0025] More preferably, step S233 includes: First, construct the condition vector of the fusion weights. : (27) in, Representation of the global spectral domain behavior of the trajectory. The local temporal evolution representation is obtained by DMEN + attention readout. This is a vector concatenation operation, representing the joint modeling of global and local features. Linear mapping weights are used to generate the network for conditional vectors, compressing the concatenated features into the hidden dimensions. For the corresponding bias term; Then, the fusion weights are generated: (28) in, For the linear mapping weights of the fusion weight generator, For the corresponding bias term, This is a vector per channel, used to control the fusion ratio of the two types of features.

[0026] The final representation is then obtained by weighting the data by channel or scalar: (29) in, This indicates element-wise multiplication. This provides a unified trajectory representation for the encoder output.

[0027] Preferably, the adaptive hard-to-separate negative sample sampling strategy described in step S24 specifically involves: within each mini-batch, based on the feature samples output in step S23... Dynamic selection and anchor points Samples with similar feature distances but different pseudo-labels To construct a high-quality negative sample set, the formula is as follows: (30) in, This represents the variable that minimizes the objective function, not the minimum value itself. Indicates the first i Feature representation of each anchor point sample This represents the feature representation of the j-th sample. , Let represent the pseudo-label of the class of the j-th, i-th sample.

[0028] Preferably, step S25 includes: S251. Calculate the weights of each category based on the pseudo-labels obtained in step S12, and calculate the average weight of each category based on the weights. The formula is as follows: (31) (32) in, N Let X be the total number of samples in the trajectory segment dataset. For the first The pseudo-labels of the categories of each sample, For the first Number of class samples As a smoothing factor, For indicator functions, i.e. The value is 1 if it is true, and 0 otherwise. The weight coefficients for category c. For the first Number of class samples .

[0029] In obtaining Then, count the number of each category in each batch. Multiply each category by its respective weight, then sum them and take the average to obtain the average category weight in a batch. ; S252, Average category weights obtained in step S251 Calculate the weighted contrast loss: The category weights obtained in step S251 By multiplying by a contrastive loss function, the dataset is balanced. The contrastive loss function is as follows: (33) in, The high-quality negative sample set constructed in Formula 35 , The negative sample weights are adaptively adjusted based on the similarity between the sample and the anchor point, so that hard-to-distinguish samples receive a larger penalty weight. This indicates the calculation of cosine similarity. This is a temperature coefficient used to control the smoothness of similarity. For positive sample feature representation, and Semantic consistency This represents the features of negative samples.

[0030] S253. Iteratively update the parameters of the comparative learning model through backpropagation until the model converges.

[0031] In another aspect of the present invention, an apparatus is provided for implementing an unsupervised agricultural machinery trajectory classification method based on contrastive learning, the apparatus comprising: Data acquisition and preprocessing module: Acquires raw agricultural machinery GNSS trajectory data, and performs data cleaning and feature construction processing on the raw agricultural machinery GNSS trajectory data to generate a continuous and uniform trajectory segment dataset. ; Feature enhancement module: used for the trajectory segment dataset Perform asymmetric data augmentation based on feature dimensions, where weak augmentation or indifference is applied to key feature dimensions reflecting the physical characteristics of the operation, while strong augmentation is applied to non-key feature dimensions, generating a weakly augmented sample set. and enhanced sample sets This is to improve the robustness of the model while avoiding damage to key discriminative features, and to generate multi-view trajectory samples for comparative learning. Feature extraction module: used to extract features from the input weakly augmented sample set. and enhanced sample sets The algorithm learns discriminative trajectory feature representations, and the feature extraction module includes a feature encoder and a spectral domain correlation-dynamic memory decoupled hybrid temporal encoder. The feature encoder is used to process the input weakly enhanced sample set. and enhanced sample sets Preliminary feature encoding is performed to uniformly represent the original or enhanced trajectory sequence, and the output is denoted as... ( include and ); Spectral domain correlation-dynamic memory decoupled hybrid timing encoders are used in In a unified feature space, the multi-level temporal semantics of trajectory sequences are further modeled, which includes a global modeling submodule, a local modeling submodule, and an adaptive feature fusion submodule; Contrastive learning training module: used to train trajectory segment datasets under unsupervised conditions. The feature extraction module is pre-trained; The difficult-to-distinguish negative sample optimization submodule is used to dynamically identify difficult-to-distinguish negative samples that are close to the feature distribution of the current trajectory sample based on trajectory feature similarity during the contrastive learning training process, and to apply higher weights to the difficult-to-distinguish negative samples to participate in the contrastive loss calculation, so as to enhance the inter-class feature discrimination ability and compress the intra-class feature distribution, thereby improving the discriminativeness and stability of trajectory representation.

[0032] Model application module: Used to deploy the trained trajectory clustering model to perform operation pattern recognition, trajectory classification or statistical analysis on newly collected agricultural machinery trajectory data, so as to support agricultural production management and intelligent decision-making applications.

[0033] Compared with the prior art, the present invention has the following beneficial effects: (1) This invention enables the model to automatically learn discriminative trajectory feature representations from unlabeled data through mechanisms such as asymmetric data augmentation, global and local temporal modeling, and dynamic negative sample optimization, thereby achieving unsupervised trajectory clustering and classification. This invention has the advantages of requiring no manual intervention, strong feature representation ability, and stable training effect, and is very suitable for large-scale intelligent trajectory analysis scenarios of agricultural machinery.

[0034] (2) The method of the present invention can completely get rid of the dependence on manual annotation and significantly reduce the application threshold: The present invention constructs an end-to-end unsupervised learning framework, which can automatically discover potential operation patterns and structural differences directly from the massive agricultural machinery trajectory data collected continuously, without any prior category information or manual experience rules, avoiding the problems of strong subjectivity, high cost and difficulty in scaling of manual annotation, and is particularly suitable for the continuous analysis of long-term operation data of multiple regions and multiple machine types.

[0035] (3) Key discriminative features are effectively protected to avoid semantic shifts introduced by augmentation: For the feature dimensions such as speed, working distance, and turning changes in agricultural machinery trajectory that play a decisive role in distinguishing the type of work, this invention designs an asymmetric data augmentation strategy based on feature dimensions. While enhancing the robustness of the model, it effectively suppresses the destruction of core physical meaning features and avoids the problems of blurred inter-class boundaries and semantic confusion caused by traditional random augmentation, thereby ensuring that the learned representation has stronger interpretability and stability.

[0036] (4) Multi-scale temporal semantic collaborative modeling significantly improves the integrity of feature expression: By introducing a dual-branch structure of "spectral domain association modeling + dynamic memory modeling", on the one hand, the periodic patterns and long-range dependencies in the agricultural machinery operation process are captured at the frequency domain level, and on the other hand, local operation behavior and short-term dynamic changes are modeled at the time domain level. Furthermore, through cross-domain modulation mechanism and adaptive feature fusion strategy, the complementarity and synergy of global trend information and local detail features are realized, thereby constructing a trajectory representation with richer layers and more complete semantics.

[0037] (5) Focusing on difficult-to-distinguish negative samples and strengthening inter-class differentiation ability: In view of the problem that there are similar trajectory shapes and blurred boundaries between different operation modes of agricultural machinery, this invention introduces an adaptive difficult-to-distinguish negative sample optimization mechanism. During the comparative learning process, it dynamically identifies and focuses on constraining high similarity negative samples, effectively expanding the feature interval between different operation modes, while compressing the feature distribution range of similar samples, so that the learned representation has stronger discriminative power in clustering and classification tasks.

[0038] (6) It has good generalization ability and engineering robustness, and is suitable for large-scale deployment: The proposed method does not depend on specific machine parameters or fixed operation rules. It can maintain stable performance under different types of agricultural machinery, different operation plots, different operation seasons and different sampling frequencies. It has strong robustness to noise, missing trajectory and uneven sampling, and has the ability to be deployed and promoted on a large scale in real agricultural production environment. Attached Figure Description

[0039] Figure 1 This is the overall model architecture of the present invention; Figure 2 This is a schematic diagram of the hybrid timing encoder model constructed in this invention; Figure 3 This is a schematic diagram of the prediction results using a trained contrastive learning model in Embodiment 1 of the present invention. Detailed Implementation

[0040] Example 1 Unsupervised agricultural machinery trajectory classification methods based on contrastive learning, such as Figure 1 As shown, the method includes: S1. Preprocess the original agricultural machinery trajectory to obtain the trajectory segment dataset. ; S11. Extract motion features from the original agricultural machinery trajectory to generate trajectory points containing the extracted motion features; The dataset used in this invention is a wheat GNSS trajectory dataset collected by the Beidou team of China Agricultural University. The original agricultural machinery GNSS trajectory data consists of multiple trajectory points arranged in chronological order. Each trajectory point includes the acquisition time, latitude and longitude, speed, heading angle, and a label. There are two types of labels: "0" represents a road point, and "1" represents a field point. The sampling frequency is 5 seconds. Next, the motion features of the trajectory points are extracted. First, the physical distance between two points must be obtained. Assuming the latitude and longitude of the two points are (…),… )and( The steps are as follows: First, convert latitude and longitude to radians: (1) in, The angle value is expressed in radians. This represents latitude and longitude values ​​expressed in angles. After conversion, the coordinates of the two points are expressed as follows: ,in, and They represent the first The latitude and longitude values ​​in radians for each point.

[0041] Then use the Haversine formula to calculate the distance between the two points: (2) in, This represents the spherical distance between two geographic coordinate points. The average radius of the Earth is usually taken as... .

[0042] After obtaining the distance between two points, calculate their motion characteristics based on the distance and time, including velocity, acceleration, heading angle, angular velocity, angular acceleration characteristics, and calculate the density of trajectory points within a fixed area based on the distance.

[0043] S12. Use the DBSCAN density clustering algorithm to perform preliminary clustering of trajectory points containing extracted motion features to obtain pseudo-labels; When constructing trajectory segments within subsequent sliding time windows, samples within a window are required to belong to the same category. However, since this invention is unsupervised, windows cannot be divided based on labels. A preliminary clustering process is needed to obtain pseudo-labels, preparing for subsequent time window division and also contributing to balancing the dataset. This is explained in detail in section S25. For agricultural machinery trajectory points, the density of field points is high due to the repeated operation of agricultural machinery on the field at a relatively slow speed. Conversely, the density of road points is low because agricultural machinery operates at higher speeds and generally does not repeatedly travel on roads. Based on this density characteristic, the DBSCAN clustering algorithm is used for preliminary clustering of trajectory points, yielding pseudo-labels with an accuracy of approximately 80%.

[0044] S13. Based on the obtained pseudo-labels, a sliding time window is applied to the trajectory points containing the extracted motion features to construct trajectory segments, resulting in a trajectory segment dataset. ; After the above steps, the conditions for a sliding time window are met. Trajectory segments are then constructed, with a time window size of 40 and a step size of 1. The time window is then slid to sort by time, placing 40 trajectory points with the same pseudo-label into a single window to form a trajectory segment as a new sample. The label of the trajectory point in the middle of the time window is selected as the label for the trajectory segment. If fewer than 40 trajectory points with the same pseudo-label remain, they are discarded. Assume the trajectory point dataset is... The data format of the trajectory segment after the sliding time window is as follows: ,

[0045] The trajectory segment dataset is .

[0046] S2. Construct a contrastive learning model, which includes a spectral domain correlation-dynamic memory decoupled hybrid temporal encoder. S21. The trajectory segment dataset obtained in step S1 Asymmetric data augmentation based on feature dimensions is performed to obtain a weakly augmented sample set. and enhanced sample sets ; In agricultural machinery operation scenarios, trajectory samples are often composed of speed. ,distance Heading angle Time interval Latitude and longitude offset It consists of multiple continuous features. Among them, speed and distance are key discriminative features that determine the job category and road type, but they are often subject to excessive perturbation in traditional contrastive learning. Existing enhancement methods, such as temporal occlusion, noise smoothing, and random jitter, apply perturbation uniformly across all feature dimensions. While this improves sample diversity, it also weakens the numerical continuity of core features and the clarity of class boundaries, thus affecting the contrast target. The similarity of positive samples is incorrectly compressed, and the difference of negative samples is diluted.

[0047] To address this issue, this invention proposes Feature-wise Asymmetric Data Augmentation, a method based on feature dimension. In the augmented view construction stage, a decoupling principle of "Strong Protection vs. Strong Disturbance" is introduced. The trajectory segment dataset, i.e., the input sample X, has a shape of (40, Channels). The Channels are divided into core features and non-core features, resulting in a weakly augmented sample set. and enhanced sample sets : (3) (4) in, This refers to the core features. This indicates that slight Gaussian noise was applied to the core features. This refers to non-core features, while This represents structural perturbation operations, including random temporal masking, feature translation, and local scaling; Channels refers to the number of feature channels per sample. Through this asymmetric design, the weak augmentation view maintains the numerical consistency of core features to preserve compactness within categories; the strong augmentation view, on the other hand, applies significant perturbations to non-core dimensions to force the encoder to learn robustness and invariance to non-critical changes during training.

[0048] In terms of weak enhancement, this invention applies slight Gaussian noise with a variance of 0.001 to the core features. In terms of strong enhancement, it first applies slight Gaussian noise with a variance of 0.001 to the non-core features, and then applies local scaling with an amplitude of 0.01 to increase the complexity of the data, force the model to learn deeper temporal features, and improve the robustness of the model.

[0049] This strategy effectively improves the encoder's feature selectivity and discriminative stability in contrastive learning. The model performs well on samples... When maintaining similarity constraints, what is actually learned is category-invariant semantic features, rather than noise-driven local differences.

[0050] Traditional trajectory data augmentation methods often apply the same augmentation strategy to all input features. However, the speed and distance features between sampling points of agricultural machinery differ significantly between road travel and field operations, and these are key features for distinguishing different operation modes. If the augmentation strategy applies excessive perturbation to the speed and distance features, it will blur the feature boundaries between the two types of operation trajectories, disrupt the positive and negative sample distribution of contrastive learning, and reduce the convergence efficiency of the model.

[0051] In contrastive learning, positive and negative samples are constructed to establish contrast relationships. During subsequent training, the model focuses on learning the similarity between positive samples and the differences between negative samples, ultimately bringing positive samples closer and pushing negative samples further away in the projection space. The overall architecture of this invention is based on the TS-TCC model, and the construction of positive and negative samples is consistent with TS-TCC, that is, for the input dataset... After data augmentation, a weakly augmented sample set is obtained. and strongly enhanced samples Assuming batch_size is 64, then for the samples in a batch Positive samples refer to different augmented views of the same sample, i.e. and Negative samples refer to different trajectories within the same batch, i.e. and .like Figure 1 As shown.

[0052] S22, Weakly enhanced sample set and enhanced sample sets Each sample's temporal features are extracted using a feature encoder, resulting in a sample set containing the temporal features of each individual sample. The Includes weakly augmented sample sets containing temporal features of individual samples. and enhanced sample sets ; After passing through S1 and S21, the trajectory segment is still a collection of motion features of each independent point. These features are high-dimensional, noisy, and chaotic. Therefore, the encoder is needed to map the original high-dimensional and noisy temporal signal to the temporal-aware latent representation space, providing stable and more discriminative features for subsequent temporal comparison learning and global modeling.

[0053] The specific configuration of the feature encoder used in this invention is as follows: First convolutional layer: kernel size is 9, stride is 1, padding is same, and output channel number is 64; The second convolutional layer has a kernel size of 9, a stride of 1, the same padding, and 128 output channels. The third convolutional layer has a kernel size of 9, a stride of 1, the same padding, and 128 output channels. Meanwhile, these three convolutional layers are not simply arranged sequentially, but interact through residual connections. After the data passes through the first convolutional layer, it is copied into two copies. The first copy passes through the second convolutional layer with an attention mechanism applied, while the second copy passes directly through a simple convolutional layer, increasing the dimension from 64 to 128. The outputs of these two parts are then added together to obtain the final output of the second convolutional layer. The same applies to the third layer. Introducing an attention mechanism and residual connections into the three-layer one-dimensional convolutional encoder can achieve adaptive weighting of key time segments and feature channels while maintaining local temporal modeling capabilities, and significantly alleviate the information degradation problem caused by deep convolutions, thereby improving the stability and discriminativeness of contrastive learning representations. After feature extraction by the feature encoder, a weakly enhanced sample set containing the temporal features of individual samples is obtained. and enhanced sample sets This makes it more suitable for subsequent time series comparison and learning.

[0054] S23. Construct a spectral domain correlation-dynamic memory decoupled hybrid temporal encoder to process the sample set obtained in step S22, which contains the temporal features of individual samples. Feature extraction is performed to obtain the feature-extracted samples. : Agricultural machinery trajectory sequences have characteristics such as cross-scale dependence, multi-segment behavior switching, high noise instability, and strong temporal continuity, which makes single coding structures prone to performance bottlenecks such as "insufficient global pattern recognition" or "limited local dynamic modeling ability," such as Transformer or RNN.

[0055] This invention proposes a spectral-temporal decoupling hybrid temporal encoder, which models multi-scale features of trajectory sequences through a parallel structure. The hybrid temporal encoder model is as follows: Figure 2 As shown: S231, Spectral Domain Awareness Branch: Construct the Spectral Relational Module (SRM), which includes a Fast Fourier Transform and a spectral change encoder. This module takes the sample set obtained in step S22, containing the temporal features of individual samples, and... The system maps the data to the spectral domain using Fourier transform, models global dependencies through a frequency-selective attention mechanism in a spectral transformation encoder, and outputs a global representation. With modulation vector ; Specifically, to address the potential periodicity, behavioral rhythmicity, and cross-regional motion similarity in long sequences, this invention first maps the input sequence to the spectral domain and models global dependencies through a frequency-selective attention mechanism: Let the hidden dimension of the contrastive learning model be In this embodiment, it is 64. First, the sample set after Fourier transform... Short-time spectral sensing and projection: For the sample set after Fourier transform... Each feature channel is subjected to a depthwise convolution, with a kernel length of [missing information]. In this embodiment, the value is 9, resulting in... ,Right now (5) in, T Let t be the total length of the time steps, and t be the t-th time step, with a value of 1. , D The number of feature channels, The set of real numbers is the field of numbers, indicating that the elements belong to this set of real numbers. For time offset index, For the first The depthwise convolution kernel parameters corresponding to each feature channel are handled with zero padding at the boundary positions. This represents the short-time spectral response after each channel is modeled independently.

[0056] Then, pointwise projection and 1×1 convolution are performed to obtain the spectral domain embedding. : (6) in, The channel projection weight matrix is... For bias terms, This indicates the hidden dimension of the model. It is a spectral domain embedding sequence.

[0057] right Normalization of layers yields The formula is as follows: (7) Representation layer normalization, in Based on this, implement a multi-layer multi-head self-attention coding module, namely the spectral domain correlation module (SRM). Let the first Layer input is , where the initial value , No. The multi-head self-attention and feedforward calculation of the layer are as follows: (8) (9) (10) in, For learnable parameter matrix, Represents a query vector sequence. Represents a sequence of key vectors. Represents a sequence of value vectors. , , .

[0058] Multi-head self-attention is calculated as follows: (11) in, This represents the attention mechanism. The dimension representing a single attention head is used to scale the inner product result to stabilize the gradient. This represents the softmax function.

[0059] Subsequently, residual connections and a feedforward network are used for feature updates: (12) (13) in, For the first In the layer, the intermediate hidden features obtained after "multi-head self-attention + residual connection + layer normalization" are... Indicates the first A two-layer feedforward network, Indicates the first The final output of the layer. (After...) The spectral domain context matrix is ​​obtained after the layer. .

[0060] right Perform time-series pooling to obtain the global representation With modulation vector : First, perform adaptive average pooling based on time: (14) in, Indicates average pooling.t For the current time step, Represents the global spectral domain behavior of the trajectory.

[0061] Then, a modulation vector is generated using a small projection network: (15) in, Represents the Gaussian error linear unit activation function. , , Used to provide global condition information to subsequent timing branches. To calculate the linear mapping weights of the modulation vector m, This corresponds to the bias term.

[0062] The above process constitutes the "Spectral Domain Correlation Modeling Module (SRM)," whose output is a global representation. With modulation vector .

[0063] SRM can explicitly model the implicit resonance relationships between long-distance behaviors, such as behavioral spectrum changes like "low-speed field operation → accelerated transition → high-speed road driving", enabling the encoder to have cross-scale global perception capabilities.

[0064] S232, Dynamic Scheduling Branch: Construct the temporal state evolution modeling module Dynamic Memory Evolution Network, i.e., DMEN. The temporal state evolution modeling module introduces a time decay factor. The timing encoder based on SRM modulation and FiLM transformation, through the dynamic gating state update mechanism of DMEN, updates the sample set containing the time features of individual samples obtained in step S22. Local modeling is performed using a dynamic memory-gated temporal network, and local representations are output. ; To extract local trends, velocity changes, and rapid turning behaviors from the trajectory, this invention designs a dynamic gating state update mechanism, which updates the sample set obtained in step S22, containing the time features of individual samples. Local modeling is performed using the Dynamic Memory Gated Temporal Network (DMEN), which outputs local representations. : Constructing a basic temporal state evolution model: This invention uses a unidirectional two-layer GRU with a hidden layer dimension of 128. Let the original recursion of the GRU be: (16) (17) (18) (19) in , . and These represent resetting the door and updating the door, respectively. , , , , , , , , For learnable parameters, Indicates the candidate hidden state. This represents the output at the current time step t. This represents the output at time step t-1. This indicates element-wise multiplication.

[0065] The original recursion of GRU can also be in a single-level unidirectional form or a multi-level / bidirectional form.

[0066] Introduce a time decay factor into the established basic time-series state evolution model. The FiLM transform based on SRM modulation yields the time-series state evolution module, DMEN: Two key enhancements are introduced in DMEN: time decay factor Used for smoothing short-term disturbances and SRM-based FiLM transform. The time decay factor is designed as a learnable exponential decay or a gate generated from time-varying features, i.e. (20) in, It is used to generate the time decay factor. The linear mapping weight matrix, It is the corresponding bias vector. This represents the Sigmoid function. Used for dynamic decay of historical memory.

[0067] Furthermore, decay is introduced into the basic temporal state evolution model—replacing the previous hidden with a decaying hidden: (twenty one) in, This is the hidden state from the previous time step after being modulated by the time decay factor. This represents the output at time step t-1; Simultaneously using the SRM modulation vector Scale and shift for generating FiLM: (twenty two) (twenty three) in, This represents the tanh activation function. and These represent the scaling factor and translation factor by channel, respectively. It is the scaling factor used to generate FiLM. The linear mapping weight matrix, For the corresponding bias vector, It is the translation factor used to generate FiLM. The linear mapping weight matrix, It is the corresponding bias vector.

[0068] Embedding the above two items into the GRU update rule yields the recursive form of DMEN: (twenty four) (25) (26) (27) (28) in, and These represent the reset gate and update gate after FiLM modulation, respectively. Indicates the candidate hidden state. These are the candidate hidden states after FiLM modulation. This represents the output at the current time step t after FiLM modulation.

[0069] The sample set obtained in step S22, which contains the time features of a single sample, is then... After DMEN processing, the following is obtained ,right Perform attention readout based on the final modulation hidden layer, and output local representations through a fusion network. : Specifically, the sample set obtained in step S22, which contains the temporal features of a single sample, is... After DMEN processing, the hidden sequences at all time points are obtained. The matrix formed To compensate for the truncation / long-term dependency issue, for Perform attention readout based on the final modulation hidden: Set the final time or specified cutoff time as the output ,by Perform a query and calculate the historical weighted context: (29) (30) in, , and For learnable parameters, For exponential mapping, To finally modulate the hidden state, The alignment score represents the correlation between the historical time t and the current local representation. is the attention weight, representing the contribution weight of the t-th time in history to the current local representation.

[0070] This yields the context vector: (31) And obtain the local final representation through the fusion network. (32) in, , Represents the local temporal evolution characteristics of the trajectory. It is the linear mapping weight matrix of the fusion network. It is the corresponding bias vector.

[0071] this This refers to the output of DMEN.

[0072] This branch introduces a learnable time decay factor and a dynamic memory update strategy, enabling the model to retain historical dependencies, suppress noise, and model local evolution, thus resisting chaotic signals caused by GNSS jitter, short-term drift, and sudden changes in operational behavior.

[0073] S233. Constructing the Cross-domain Alignment Fusion (CAF) module, a global representation of SRM. Local characterization of DMEN Feature-level adaptive fusion is performed through the cross-domain attention regulation mechanism of the cross-domain alignment fusion module to obtain the final encoding. .

[0074] To fully integrate the global pattern in the spectral domain with the local dynamics in the temporal domain, this invention designs a cross-domain attention control mechanism to achieve feature-level adaptive fusion of the global representation of SRM. Local characterization of DMEN The final code is adaptively synthesized using the Cross-Domain Alignment Fusion (CAF) module. Because there are two enhanced views, the final encoding can be displayed as follows: .

[0075] First, construct the condition vector of the fusion weights. It can be obtained by splicing two branches and passing them through a small network: (33) in, Representation of the global spectral domain behavior of the trajectory. The local temporal evolution representation is obtained by DMEN + attention readout. This is a vector concatenation operation, representing the joint modeling of global and local features. Linear mapping weights are used to generate the network for conditional vectors, compressing the concatenated features into the hidden dimensions. For the corresponding bias term; (34) in, For the linear mapping weights of the fusion weight generator, For the corresponding bias term, This is a vector per channel, used to control the fusion ratio of the two types of features.

[0076] The final representation is then obtained by weighting the data by channel or scalar. (35) in, This indicates element-wise multiplication. This provides a unified trajectory representation for the encoder output. The projection head is used to obtain the representation for contrastive learning. (36) in, Indicates batch normalization. The linear mapping weights for the projection head are used to map the representation to the contrastive learning space. For the corresponding bias term, The low-dimensional representation used for contrastive learning is used for future step prediction or InfoNCE loss calculation.

[0077] For contrastive learning scenarios used in future-step prediction, it is available. Through several linear predictors Predicting the future The original feature dimension of each step (or its low-dimensional projection): for each prediction step Calculate the prediction vector The training target is the NCE loss or InfoNCE of negative samples within the batch.

[0078] Through the above process, the model takes into account all features in the local and global, time and frequency domains, and can efficiently and accurately extract the trajectory features of agricultural machinery, and distinguish the two categories of data in the feature space, which facilitates subsequent clustering operations.

[0079] S24. Introduce an adaptive hard-to-separate negative sample sampling strategy to sample the data output in step S23. The negative samples in the sample are divided to construct a set of difficult-to-distinguish negative samples; In the loss function of contrastive learning, the selection of negative samples directly affects the convergence speed of the model and the quality of the discrimination boundary. Traditional random sampling methods introduce a large number of anchor samples. "Easily separable negative samples" with excessively large feature distances contribute very little to the loss gradient, resulting in low training efficiency.

[0080] To address this, this invention introduces an adaptive negative sample sampling strategy, Adversarial Negative Sampling (ANS). Its core idea is: within each mini-batch, based on the feature samples output in step S23... Dynamically select those related to the anchor point Samples with similar feature distances but different pseudo-labels This is to construct a high-quality negative sample set. Formalistically: (37) in, This represents the variable that minimizes the objective function, not the minimum value itself. Indicates the first i Feature representation of each anchor point sample This represents the feature representation of the j-th sample. , Let represent the pseudo-label of the class of the j-th, i-th sample.

[0081] S25. Based on the set of difficult-to-distinguish negative samples constructed in step S24, calculate the weighted contrastive loss and iteratively update the contrastive learning model parameters through backpropagation until the model converges. S251. Calculate the weights of each category based on the pseudo-labels obtained in step S12, and calculate the average weight of each category based on the weights. ; In the data preprocessing stage, pseudo-labels were generated using DBSCAN. Since the agricultural machinery trajectory data is extremely imbalanced, with a ratio of approximately 1:9 between road points and field points, the ratio of the two categories was calculated based on the pseudo-labels. Weights were then calculated based on these ratios and multiplied by the final loss function to achieve a balanced dataset. (38) (39) in, For the first Number of class samples This is a smoothing factor used to alleviate class imbalance; in this invention, it is 20000. N Let X be the total number of samples in the trajectory segment dataset. For the first The true label of each sample For indicator functions, i.e. The value is 1 if it is true, and 0 otherwise. The weight coefficients for category c. For the first Number of class samples .

[0082] In obtaining Then, count the number of each category in each batch. Multiply each category by its respective weight, then sum them and take the average to obtain the average category weight in a batch. Finally, the loss of that batch is multiplied by this weight to achieve the goal of balancing the dataset.

[0083] S252, Average category weights obtained in step S251 Calculate the weighted contrast loss: The category weights obtained in step S251 Multiplying by the contrastive loss function of this batch achieves the goal of balancing the dataset. The contrastive loss function is as follows: (40) in, The high-quality negative sample set already constructed in Formula 37 , The negative sample weights are adaptively adjusted based on the similarity between the sample and the anchor point, so that hard-to-distinguish samples receive a larger penalty weight. This indicates the calculation of cosine similarity. This is a temperature coefficient used to control the smoothness of similarity. For positive sample feature representation, and Semantic consistency This represents the features of negative samples.

[0084] For the difficult-to-distinguish negative samples proposed in S24, a higher weight is given to them in the contrastive loss; in, The model adaptively adjusts the similarity between samples and anchor points, giving greater penalty weights to difficult-to-separate samples. Essentially, this strategy introduces an "adversarially-driven contrastive optimization" into the contrast space, prompting the model to actively expand class boundaries and improve inter-class separability.

[0085] S253. Iteratively update the parameters of the comparative learning model through backpropagation until the model converges.

[0086] S3. Training the contrastive learning model: Using the trajectory segment dataset preprocessed in step S1. Train the contrastive learning model constructed in step S2 until the model converges and output the trajectory representation model; The model convergence is specifically defined as follows: the model loss fluctuates by no more than 0.1 within 5 consecutive epochs.

[0087] S4. Unsupervised trajectory classification: After the data to be classified is preprocessed in step S1, it is input into the trajectory representation model in step S3 to obtain the output features. The output features are then clustered to achieve unsupervised trajectory classification.

[0088] Application examples Clustering experiments were conducted using the method proposed in this invention, and the confusion matrix was calculated.

[0089] After step S3, a trained contrastive learning model, i.e., a trajectory representation model, is obtained. Then, a new dataset, after preprocessing in step S1, is input into this model for feature extraction. Finally, the output features are clustered using k-means. The specific configuration of k-means is as follows: The initial cluster centers are 20, the distance is calculated using DTW distance, and the number of clusters is 2.

[0090] After clustering, the two category distributions in the data are obtained. The clustering results are then compared with the true labels to calculate the confusion matrix. The specific calculation method is as follows: In binary classification problems, let the common... One sample, true category Recorded as (41) Where 1 represents the positive class and 0 represents the negative class; Model prediction The result is recorded as (42) Binary confusion matrix Represented as (43) The rows correspond to the true categories, and the columns correspond to the predicted categories. The formula for calculating each element in the confusion matrix is: (44) (45) (46) (47) Based on this, the formulas for calculating precision, recall, and F1 score are as follows: (48) (49) (50) Based on the above calculation method, the confusion matrix of this experiment is as follows: Table 1. Confusion matrix of experimental results of this invention

[0091] Prediction was performed using a pre-trained contrastive learning model, i.e., a trajectory representation model. The results are as follows: Figure 3 As shown.

[0092] This invention also conducted comparative verification experiments. Except for the following differences, the experimental conditions, data, and procedures were exactly the same as those in the above application examples: Compare with Example 1 and remove the asymmetric data augmentation in step S21; Compared to application example 2, step S23 only includes the spectrum correlation modeling module, that is, it only adopts the global modeling method; Compared with application example 3, step S23 only includes the temporal state evolution modeling module, that is, only the local modeling method is used; Compared to Application Example 4, the adaptive hard-to-separate negative sample sampling strategy without introducing step S24; The experimental results for each comparative application example are shown in Tables 2-5: Table 2 shows the confusion matrix comparing the experimental results of Application Example 1.

[0093] Compared with Table 1, asymmetric data augmentation significantly improved the ability to distinguish road categories, especially playing a key role in precision and F1 score, while having a smaller impact on the relatively stable field category.

[0094] Table 3. Confusion matrix comparing the experimental results of Application Example 2

[0095] Compared with Table 1, the accuracy of road category decreased from 87.68% to 49.05%, indicating that it is difficult to accurately depict the local temporal characteristics of road categories by using global modeling alone, resulting in more false detections and significantly increasing the error of misclassifying "fields" as "roads".

[0096] Table 4. Confusion matrix comparing the experimental results of Application Example 3

[0097] Compared with Table 1, using only local modeling significantly reduced the precision, recall, and F1 score of road categories, indicating that relying solely on local modeling leads to a large number of missed detections of road categories, demonstrating that global context plays an irreplaceable role in road trajectory recognition.

[0098] Table 5. Confusion matrix comparing the experimental results of Application Example 4

[0099] Compared with Table 1, using only local modeling significantly reduced the precision, recall, and F1 score of road categories, indicating that the negative sample optimization mechanism introduced in this invention effectively enhances the model's ability to distinguish between road and field boundary samples, especially improving the precision and stability of road categories.

[0100] Comparative experiments show that asymmetric data augmentation, global-local joint modeling, and the hard-to-distinguish negative sample optimization mechanism all play key roles in road trajectory recognition. Among them, the synergy between global and local modeling is the core factor in improving the recall rate of road categories, while asymmetric augmentation and negative sample optimization mainly improve the discrimination accuracy of road categories. The combined effect of these three mechanisms enables the model to achieve better overall performance in complex agricultural trajectory scenarios.

[0101] Example 2 This embodiment provides an apparatus loaded with an unsupervised agricultural machinery trajectory classification method based on contrastive learning, the apparatus comprising: Data acquisition and preprocessing module: Acquires raw agricultural machinery GNSS trajectory data, and performs data cleaning and feature construction processing on the raw agricultural machinery GNSS trajectory data to generate a continuous and uniform trajectory segment dataset. ; Feature enhancement module: used for the trajectory segment dataset Perform asymmetric data augmentation based on feature dimensions, where weak augmentation or indifference is applied to key feature dimensions reflecting the physical characteristics of the operation, while strong augmentation is applied to non-key feature dimensions, generating a weakly augmented sample set. and enhanced sample sets This is to improve the robustness of the model while avoiding damage to key discriminative features, and to generate multi-view trajectory samples for comparative learning. Feature extraction module: used to extract features from the input weakly augmented sample set. and enhanced sample sets The algorithm learns discriminative trajectory feature representations, and the feature extraction module includes a feature encoder and a spectral domain correlation-dynamic memory decoupled hybrid temporal encoder. The feature encoder is used to process the input weakly enhanced sample set. and enhanced sample sets Preliminary feature encoding is performed to uniformly represent the original or enhanced trajectory sequence, and the output is denoted as... ( include and ); Spectral domain correlation-dynamic memory decoupled hybrid timing encoders are used in In a unified feature space, the multi-level temporal semantics of trajectory sequences are further modeled, which includes a global modeling submodule, a local modeling submodule, and an adaptive feature fusion submodule; Contrastive learning training module: used to train trajectory segment datasets under unsupervised conditions. The feature extraction module is pre-trained; The difficult-to-distinguish negative sample optimization submodule is used to dynamically identify difficult-to-distinguish negative samples that are close to the feature distribution of the current trajectory sample based on trajectory feature similarity during the contrastive learning training process, and to apply higher weights to the difficult-to-distinguish negative samples to participate in the contrastive loss calculation, so as to enhance the inter-class feature discrimination ability and compress the intra-class feature distribution, thereby improving the discriminativeness and stability of trajectory representation.

[0102] Model application module: Used to deploy the trained trajectory clustering model to perform operation pattern recognition, trajectory classification or statistical analysis on newly collected agricultural machinery trajectory data, so as to support agricultural production management and intelligent decision-making applications.

Claims

1. An unsupervised agricultural machinery trajectory classification method based on contrastive learning, characterized in that, The method includes: S1. Preprocess the original agricultural machinery trajectory to obtain the trajectory segment dataset. ; S2. Construct a contrastive learning model, which includes a spectral domain correlation-dynamic memory decoupled hybrid temporal encoder: S21. The trajectory segment dataset obtained in step S1 Asymmetric data augmentation based on feature dimensions is performed to obtain a weakly augmented sample set. and enhanced sample sets ; S22, Weakly enhanced sample set and enhanced sample sets Each sample's temporal features are extracted using a feature encoder, resulting in a sample set containing the temporal features of each individual sample. The Includes weakly augmented sample sets containing temporal features of individual samples. and enhanced sample sets ; S23. Construct a spectral domain correlation-dynamic memory decoupled hybrid temporal encoder to process the sample set obtained in step S22, which contains the temporal features of individual samples. Feature extraction is performed to obtain feature samples after feature extraction. ; S24. Introduce an adaptive hard-to-separate negative sample sampling strategy to sample the data output in step S23. The negative samples in the sample are divided to construct a set of difficult-to-distinguish negative samples; S25. Based on the set of difficult-to-distinguish negative samples constructed in step S24, calculate the weighted contrastive loss and iteratively update the contrastive learning model parameters through backpropagation until the model converges. S3. Training the contrastive learning model: Using the trajectory segment dataset preprocessed in step S1. Train the contrastive learning model constructed in step S2 until the model converges and output the trajectory representation model; S4. Unsupervised trajectory classification: After the data to be classified is preprocessed in step S1, it is input into the trajectory representation model in step S3 to obtain the output features. The output features are then clustered to achieve unsupervised trajectory classification.

2. The unsupervised agricultural machinery trajectory classification method based on contrastive learning according to claim 1, characterized in that, The preprocessing described in step S1 includes: S11. Extract motion features from the original agricultural machinery trajectory to generate trajectory points containing the extracted motion features; S12. Use the DBSCAN density clustering algorithm to perform preliminary clustering of trajectory points containing extracted motion features to obtain pseudo-labels; S13. Based on the obtained pseudo-labels, a sliding time window is applied to the trajectory points containing the extracted motion features to construct trajectory segments, resulting in a trajectory segment dataset. .

3. The unsupervised agricultural machinery trajectory classification method based on contrastive learning according to claim 1, characterized in that, Step S21 is as follows: The trajectory segment dataset X has a shape of (Seq_len, Channels). The Channels are divided into core features and non-core features to obtain a weakly augmented sample set. and enhanced sample sets : (1) (2) in, This refers to the core features. This indicates that slight Gaussian noise was applied to the core features. This refers to non-core features, while This represents structural perturbation operations, including feature translation and local scaling; Seq_len refers to the time step of the current sample, i.e., the sliding window size, and Channels refers to the number of feature channels for each sample.

4. The unsupervised agricultural machinery trajectory classification method based on contrastive learning according to claim 1, characterized in that, Step S23 includes: S231. Construct the spectral domain correlation modeling module, i.e., SRM. The spectral domain correlation modeling module includes a fast Fourier transform and a spectral change encoder, which takes the sample set containing the temporal features of individual samples obtained in step S22. The system maps the data to the spectral domain using Fourier transform, models global dependencies through a frequency-selective attention mechanism in a spectral transformation encoder, and outputs a global representation. With modulation vector ; S232. Construct a time-series state evolution modeling module, namely DMEN, wherein the time-series state evolution modeling module introduces a time decay factor. The timing encoder based on SRM modulation and FiLM transformation, through the dynamic gating state update mechanism of DMEN, updates the sample set containing the time features of individual samples obtained in step S22. Local modeling is performed using a dynamic memory-gated temporal network, and local representations are output. ; S233. Construct the cross-domain alignment and fusion module, namely CAF, the global representation of SRM. Local characterization of DMEN Feature-level adaptive fusion is performed through the cross-domain attention regulation mechanism of the cross-domain alignment fusion module to obtain the final encoding. .

5. The unsupervised agricultural machinery trajectory classification method based on contrastive learning according to claim 4, characterized in that, Step S231 describes modeling global dependencies using a frequency-selective attention mechanism through a spectral variation encoder, and outputting a global representation. With modulation vector ,include: Let the hidden dimension of the contrastive learning model be First, the sample set after Fourier transform... Perform short-time spectral sensing and projection: For the sample set after Fourier transform Each feature channel is obtained by performing depthwise convolution. ,Right now (3) in, This represents the short-time spectral response after independent modeling of each channel. T The total length of the time steps. D Let be the number of feature channels, and t be the t-th time step, with values ​​ranging from 1 to 2. , The set of real numbers is the field of numbers, indicating that the elements belong to this set of real numbers. The length of the temporal convolution kernel. For time offset index, For the first The depth convolution kernel parameters corresponding to each feature channel are processed with zero padding at the boundary positions; Then, pointwise projection is performed to obtain the spectral domain embedding. : (4) in, The channel projection weight matrix is... For bias terms, This indicates the hidden dimension of the model. For spectral domain embedding sequences; right Normalization of layers yields The formula is as follows: (5); Representation layer normalization, in Implement multi-layer, multi-head self-attention encoding based on this: Let the first Layer input is , where the initial value , No. The multi-head self-attention and feedforward calculation of the layer are as follows: (6) (7) (8) in, For learnable parameter matrix, Represents a query vector sequence. Represents a sequence of key vectors. Represents a sequence of value vectors. , , ; Multi-head self-attention is calculated as follows: (9) in, This represents the attention mechanism. The dimension representing a single attention head is used to scale the inner product result to stabilize the gradient. This represents the softmax function; Subsequently, residual connections and a feedforward network are used for feature updates: (10) (11) in, For the first In the layer, the intermediate hidden features obtained after "multi-head self-attention + residual connection + layer normalization" are... Indicates the first A two-layer feedforward network, Indicates the first The final output of the layer; after After layer encoding, the spectral domain context feature matrix is ​​obtained. ; right Perform time-series pooling to obtain the global representation With modulation vector : First, perform adaptive average pooling based on time: (12) in, Indicates average pooling. t For the current time step, A global spectral domain representation of the trajectory's behavior; Then, a modulation vector is generated using a small projection network: (13) in, Represents the activation function of the Gaussian error linear unit. To calculate the linear mapping weights of the modulation vector m, This corresponds to the bias term.

6. The unsupervised agricultural machinery trajectory classification method based on contrastive learning according to claim 4, characterized in that, In step S232, a basic temporal state evolution model is constructed, and a time decay factor is introduced into it. The FiLM transform based on SRM modulation yields the time-series state evolution module, DMEN, which is then used to process the sample set containing the time features of individual samples obtained in step S22. After DMEN processing, the following is obtained ,right Perform attention readout based on the final modulation hidden layer, and output local representations through a fusion network. .

7. The unsupervised agricultural machinery trajectory classification method based on contrastive learning according to claim 6, characterized in that, The time decay factor is introduced therein The FiLM transform based on SRM modulation yields the time-series state evolution module, DMEN, which includes: Time decay factor Designed as a learnable, exponentially decaying gate or a gate generated from time-varying features, i.e. (14) in, , It is used to generate the time decay factor. The linear mapping weight matrix, It is the corresponding bias vector. This represents the Sigmoid function. Used for dynamic decay of historical memory; Furthermore, decay is introduced into the basic temporal state evolution model—replacing the previous hidden with a decaying hidden: (15) in, This is the hidden state from the previous time step after being modulated by the time decay factor. This represents the output at time step t-1; Simultaneously using the SRM modulation vector Scale and shift for generating FiLM: (16) (17) in, This represents the tanh activation function. and These represent the scaling factor and translation factor by channel, respectively. It is the scaling factor used to generate FiLM. The linear mapping weight matrix, For the corresponding bias vector, It is the translation factor used to generate FiLM. The linear mapping weight matrix, It is the corresponding bias vector; The recursive form of DMEN is obtained as follows: (18) (19) (20) (21) (22) in, and These represent the reset gate and update gate after FiLM modulation, respectively. , , , , , , , , For learnable parameters, Indicates the candidate hidden state. These are the candidate hidden states after FiLM modulation. This represents the output at the current time step t after FiLM modulation; The sample set obtained in step S22, which contains the time features of a single sample, is then... After DMEN processing, the following is obtained ,right Perform attention readout based on the final modulation hidden layer, and output local representations through a fusion network. : The sample set obtained in step S22, which contains the time features of a single sample, After DMEN processing, the hidden sequence at all time points is obtained. The matrix formed ,right Perform attention readout based on the final modulation hidden: Set the final time or specified cutoff time as the output ,by Perform a query and calculate the historical weighted context: (23) (24) in, , and For learnable parameters, For exponential mapping, To finally modulate the hidden state, The alignment score represents the correlation between the historical time t and the current local representation. For attention weights, we have the weight representing the contribution of the t-th time in history to the current local representation. This yields the context vector: (25) And the local final representation is obtained through the fusion network: (26) in, Represents the local temporal evolution characteristics of the trajectory. It is the linear mapping weight matrix of the fusion network. It is the corresponding bias vector.

8. The unsupervised agricultural machinery trajectory classification method based on contrastive learning according to claim 4, characterized in that, Step S233 includes: First, construct the condition vector of the fusion weights. : (27) in, Representation of the global spectral domain behavior of the trajectory. The local temporal evolution representation is obtained by DMEN + attention readout. This is a vector concatenation operation, representing the joint modeling of global and local features. Linear mapping weights are used to generate the network for conditional vectors, compressing the concatenated features into the hidden dimensions. For the corresponding bias term; Then, the fusion weights are generated: (28) in, For the linear mapping weights of the fusion weight generator, For the corresponding bias term, This is a vector per channel, used to control the fusion ratio of the two types of features; The final representation is then obtained by weighting the data by channel or scalar: (29) in, This indicates element-wise multiplication. This provides a unified trajectory representation for the encoder output.

9. The unsupervised agricultural machinery trajectory classification method based on contrastive learning according to claim 1, characterized in that, The adaptive hard-to-separate negative sample sampling strategy described in step S24 specifically involves: within each mini-batch, sampling based on the feature samples output in step S23... Dynamic selection and anchor points Samples with similar feature distances but different pseudo-labels To construct a high-quality negative sample set, the formula is as follows: (30) in, This represents the variable that minimizes the objective function, not the minimum value itself. Indicates the first i Feature representation of each anchor point sample This represents the feature representation of the j-th sample. , Let represent the pseudo-label of the class of the j-th, i-th sample; Step S25 includes: S251. Calculate the weights of each category based on the pseudo-labels obtained in step S12, and calculate the average weight of each category based on the weights. The formula is as follows: (31) (32) in, N Let X be the total number of samples in the trajectory segment dataset. For the first The pseudo-labels of the categories of each sample, For the first Number of class samples As a smoothing factor, For indicator functions, i.e. The value is 1 if it is true, and 0 otherwise. The weight coefficients for category c. For the first Number of class samples ; In obtaining Then, count the number of each category in each batch. Multiply each category by its respective weight, then sum them and take the average to obtain the average category weight in a batch. ; S252, Average category weights obtained in step S251 Calculate the weighted contrast loss: The category weights obtained in step S251 By multiplying by a contrastive loss function, the dataset is balanced. The contrastive loss function is as follows: (33) in, The high-quality negative sample set constructed in Formula 35 , The negative sample weights are adaptively adjusted based on the similarity between the sample and the anchor point, so that hard-to-distinguish samples receive a larger penalty weight. This indicates the calculation of cosine similarity. This is a temperature coefficient used to control the smoothness of similarity. For positive sample feature representation, and Semantic consistency This represents the features of negative samples; S253. Iteratively update the parameters of the comparative learning model through backpropagation until the model converges.

10. An apparatus for implementing the unsupervised agricultural machinery trajectory classification method based on contrastive learning as described in any one of claims 1-9, characterized in that, The device includes: Data acquisition and preprocessing module: Acquires raw agricultural machinery GNSS trajectory data, and performs data cleaning and feature construction processing on the raw agricultural machinery GNSS trajectory data to generate a continuous and uniform trajectory segment dataset. ; Feature enhancement module: used for the trajectory segment dataset Perform asymmetric data augmentation based on feature dimensions, where weak augmentation or indifference is applied to key feature dimensions reflecting the physical characteristics of the operation, while strong augmentation is applied to non-key feature dimensions, generating a weakly augmented sample set. and enhanced sample sets This is to improve the robustness of the model while avoiding damage to key discriminative features, and to generate multi-view trajectory samples for comparative learning. Feature extraction module: used to extract features from the input weakly augmented sample set. and enhanced sample sets The system learns discriminative trajectory feature representations, and the feature extraction module includes a feature encoder and a spectral domain correlation-dynamic memory decoupled hybrid temporal encoder; the feature encoder is used to process the input weakly enhanced sample set. and enhanced sample sets Preliminary feature encoding is performed to uniformly represent the original or enhanced trajectory sequence, and the output is denoted as... ; Spectral domain correlation-dynamic memory decoupled hybrid timing encoder is used in In a unified feature space, the multi-level temporal semantics of trajectory sequences are further modeled, which includes a global modeling submodule, a local modeling submodule, and an adaptive feature fusion submodule; Contrastive learning training module: used to train trajectory segment datasets under unsupervised conditions. The feature extraction module is pre-trained; The difficult-to-distinguish negative sample optimization submodule is used to dynamically identify difficult-to-distinguish negative samples that are close to the current trajectory sample feature distribution based on trajectory feature similarity during the contrastive learning training process, and to apply higher weights to the difficult-to-distinguish negative samples to participate in the contrastive loss calculation, so as to enhance the inter-class feature discrimination ability and compress the intra-class feature distribution, thereby improving the discriminativeness and stability of trajectory representation. Model application module: Used to deploy the trained trajectory clustering model to perform operation pattern recognition, trajectory classification or statistical analysis on newly collected agricultural machinery trajectory data, so as to support agricultural production management and intelligent decision-making applications.

Citation Information

Patent Citations

  • Agricultural machine trajectory classification method based on trajectory similarity measurement, computer readable storage medium and computer program product

    CN119046759A

  • Agricultural machine track data classification method and device, electronic equipment and storage medium

    CN120105238A

  • Traffic behavior real-time identification method based on multi-modal spatial-temporal feature fusion

    CN120689823A

  • Trajectory abnormal route detection method and system based on self-supervised trajectory representation learning

    CN120724351A

  • Robot operation track generation method based on structure perception and knowledge enhancement reasoning

    CN120765961A