Vehicle driving risk classification method based on Transform encoder and self-supervised pre-training model

Through methods based on Transformer encoder and self-supervised pre-training model, the high-dimensional time series data of intelligent network-connected vehicles is modeled and pre-trained, which solves the problems of data complexity and lack of annotation in intelligent network-connected scenarios, and improves the efficiency of automobiles. Accuracy of driving risk classification.

CN118779744APending Publication Date: 2024-10-15EAST CHINA NORMAL UNIV
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202310359102.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-04-06
Publication Date
2024-10-15

AI Technical Summary

Technical Problem

In the intelligent network connection scenario, the types of cars are diverse and the data is dense, making it difficult to widely apply the driving behavior analysis model, and there is a lack of annotated data, making it difficult to effectively predict car driving safety.

Method used

Using a method based on Transformer encoder and self-supervised pre-training model, the car driving data is modeled and pre-trained through self-attention mechanism and mask mechanism, a self-supervised pre-training data set is generated, and a small amount of annotated data is used for effective classification.

Benefits of technology

It improves the accuracy of car driving risk classification, solves the problem of complexity of high-dimensional time series data and lack of annotated data, and achieves effective classification under a small amount of annotated data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118779744A_ABST
    Figure CN118779744A_ABST
Patent Text Reader

Abstract

The invention discloses a vehicle driving risk classification method based on a Transform encoder and a self-supervision pre-training model sum. The method comprises the following steps: modeling a mutual relationship among driving time sequence data through a Transform encoder, masking an automobile driving data sequence through a random mask, predicting an original value to realize self-supervised pre-training, then predicting an automobile driving behavior to be predicted by using a trained model, and carrying out driving safety classification through a Softmax layer. The innovation point of the invention is that a self-supervised pre-trained classification model based on a Transform encoder and a sequence masking mechanism is designed for an automobile driving risk classification scene, and the automobile driving risk classification accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of computer technology and relates to a vehicle driving risk classification method based on a Transformer encoder and a self-supervised pre-training model. Background Art

[0002] In today's era of rapid development of big data and Internet of Things technology, vehicle driving safety has become a topic of increasing concern. Currently, vehicles are generally equipped with various sensors to record different driving data, including GPS, speedometers, accelerometers, power meters, etc. Over time, the database of intelligent connected vehicles continues to expand. These data cover the three dimensions of people, vehicles, and roads, and have great research value.

[0003] The large amount of real data provided by automobile sensors makes it possible for us to solve the problem of automobile driving safety prediction, but there are also some challenges:

[0004] 1. Behavioral differences in intelligent connected scenarios: There are different types of vehicles in intelligent connected scenarios, including traditional fuel vehicles, hybrid vehicles, pure electric vehicles, and other types of new energy vehicles. Due to the differences in their power systems, there are large differences between different types of vehicles in various parameters during driving, which makes the current driving behavior analysis model unable to be widely used.

[0005] 2. Data-intensive and multi-featured: At present, vehicles in intelligent connected scenarios are generally equipped with various sensors to record different driving data. An intelligent connected new energy vehicle collects at least about 10TB of data every day, and these data are typical high-dimensional time series data. It is very difficult to use traditional machine learning methods to mine patterns for solving vehicle driving safety prediction.

[0006] 3. Lack of labeling. Currently, the research on vehicle driving behavior data and driving safety is still immature, and it is difficult and costly to obtain a large amount of labeled data for training.

[0007] In recent years, multivariate time series (MTS) are an important data type, which are widely used in science, medicine, transportation, finance, engineering and industrial applications. They usually represent the changes of a set of synchronous variables (e.g., simultaneous measurements of different physical quantities) over time, as well as the corresponding changes of a set of dependent variables and common independent variables. The work related to time series analysis mainly focuses on two aspects: one is time series trend prediction, that is, using the data of historical periods as feature input to predict the trend of certain indicators in subsequent periods; the other is time series classification, that is, by studying the relationship between the features of time series data and its corresponding categories, a classifier is trained through machine learning or deep learning methods, so as to determine the category to which the given unlabeled time series data with the same data structure belongs.

[0008] In classification tasks, the autoencoder pre-trained model is mainly used. In the field of NLP, Bert introduced two strategies, Masked Language Model (MLM) and Next Sentence Prediction (NSP), which are conducive to learning general knowledge in the field. For the task of automobile driving risk classification in the field of time series data, the strategy of masking input sequence and predicting similar to MLM can also be used to learn the pattern features in automobile driving time series data.

[0009] Finally, Transformer-based models can also be used for time series modeling. Transformer is an important and recently developed deep learning model. A key factor in its widespread success in NLP is its ability to learn how to represent natural language through unsupervised pre-training. The attention mechanism in Transformer is a multi-head attention mechanism. The introduction of the self-attention mechanism makes it easier to capture long-distance interdependent features in the sequence. Transformer takes advantage of the parallelism of the self-attention mechanism and uses multi-head attention to divide the model into multiple heads to form multiple subspaces, so that the model can pay attention to information in different directions. Multi-head self-attention is obtained by splicing multiple single-head attention results. This feature makes it particularly suitable for modeling time series data. Summary of the invention

[0010] In order to solve the deficiencies in the prior art, the purpose of the present invention is to provide a method for classifying automobile driving risks based on a Transformer encoder and a self-supervised pre-training model. The automobile driving safety analysis problem is modeled as a multivariate time series data prediction task, and a corresponding model is established for learning and training. By processing and analyzing these driving data, a method of establishing a self-supervised pre-training model solves the problem of raw data, which has great practical significance for research work related to vehicle driving safety.

[0011] The specific technical solution for achieving the purpose of the present invention is:

[0012] A method for classifying automobile driving risks based on a Transformer encoder and a self-supervised pre-training model comprises the following steps:

[0013] Step 1: Collect and process car driving data to generate a self-supervised pre-training data set Veh_Train (accounting for 20% of the total driving sequence) and a prediction data set Veh_Test (the remaining 80%); the driving sequence refers to a parameter sequence obtained by constructing the instantaneous parameters of the car at each moment in a certain driving process according to time;

[0014] Step 2: Construct a 6-layer Transformer encoder network for time series data modeling, where each layer includes a self-attention layer and two sub-layers of a feedforward network. Each encoder has the same structure and uses different weight parameters. Use the self-supervised pre-training dataset Veh_Train for masking-based self-supervised pre-training;

[0015] Step 3: For each driving data segment I in Veh_Test, use the Transformer encoder to obtain the initial representation of the dataset Veh_Test to be predicted, use the pre-trained model fine-tuned in step 2 to learn the dataset Veh_Test to be predicted, and obtain the attention score;

[0016] Step 4: Iterate the training of the classifier, calculate the attention score for the sequence, and obtain the classification result through Softmax at the output layer.

[0017] In step one, the collected and processed automobile driving data includes GPS information, speed, acceleration, battery level, turn signal on / off status, throttle opening / closing degree, brake opening / closing degree, total mileage, etc.; the processing refers to deleting duplicate values ​​in the above data, interpolating missing values, deleting abnormal values, and segmenting the driving data according to the instantaneous speed from the start to the final stop. The data segments collected and processed through the above operations represent the instantaneous parameters of the automobile at each moment during a driving process.

[0018] In step 2, the self-supervised training dataset Veh_Train is used to fine-tune the driving time series data pre-training model (Transformer model), specifically in the following way:

[0019] The driving sequence in Veh_Train is used as the input sequence for self-supervised pre-training, with 15% of the random input sequence set to 0, and then the Transformer model is asked to give predictions for the masked values. For each round of training, the pre-trained model will independently create a binary noise mask M, masking the input through vector element-wise multiplication: in, represents the input after masking, and X represents the original input; the length of each masked segment follows a geometric distribution with an average value of 3. The masked sequence is embedded after adding position encoding. The prediction of the masked sequence is given by training the Transformer model. The loss function is as follows:

[0020]

[0021] Where x represents the actual value of the input driving sequence data, represents the model's predicted value for the masked driving sequence data, is the mean square error loss function, (j,i) is the label of the masked driving sequence data element;

[0022] This masking pattern encourages the Transformer model to learn to pay attention to the values ​​of the previous and next periods of a single feature at each moment, as well as the contemporary values ​​of other features in the time series at this moment, in order to learn to model the interdependencies between variables. The Transformer encoder outputs the final representation vector r t After the linear layer, the classification model will give a prediction for the original input vector.

[0023]

[0024] Among them, W m , b m It is a learnable parameter that will be adaptively optimized during the training process. Represents the predicted value of the model for the original input driving sequence data at time t.

[0025] In step 3, each dimension of each driving data segment in the driving data training sample Veh_Test is subtracted from the mean of the training set sample and divided by its variance using the Transformer encoder model, and then linearly projected into the vector space of the sequence element representation dimension of the Transformer model:

[0026] z t =w p x t +b p

[0027] Z′=Z+P

[0028] Where W p , b p is the learnable model parameter, zt is the encoded driving data time series vector. t The driving data time series matrix composed of Z′ is the matrix used as the model input after adding the position code to Z. P is the position code. Z′ is multiplied by the corresponding linear transformation matrix W. q , W k , W v After (W q , W k , W v Adaptively optimized during model training) will become the query, key, and value of the self-attention layer, and calculate the attention score:

[0029]

[0030] Q is the query vector, K is the key vector, V is the value vector, d k are the dimensions of the key vector and query vector.

[0031] In step 4, the representation vectors of all time steps will be concatenated into a vector r O , used as input to the linear output layer:

[0032]

[0033]

[0034] W o , b o During the training process, the algorithm model will be adaptively optimized and the prediction results will be obtained through cyclic iteration. It will be passed to the softmax layer to obtain the classification result (safe or dangerous). The cross entropy loss function is used to optimize the classification effect. is the cross entropy loss function, batch_size is the batch size, y is the actual value output by the linear layer, is the predicted value output by the linear layer.

[0035] The beneficial effects of the present invention include:

[0036] 1. Based on the Transformer encoder and sequence mask mechanism, a self-supervised pre-training scheme suitable for car driving data is designed, and its performance is verified through experiments.

[0037] 2. It solves the problem of high dimension and lack of data annotation of driving data from automobile sensors, and improves the classification accuracy of the current driving behavior classification model.

[0038] 3. The self-supervised pre-training technology of automobile driving data of the present invention realizes effective classification of automobile driving behavior under the premise of using only a small amount of labeled data (20% of the total number of data sets). BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 The figure is a schematic diagram of the data classification principle flow of the present invention.

[0040] Figure 2 It is a data flow diagram of the present invention.

[0041] Figure 3 It is a framework diagram of the present invention.

[0042] Figure 4 This is a comparison diagram of the effects achieved by the present invention. Figure 5 It is a flow chart of the method of the present invention. DETAILED DESCRIPTION

[0043] The invention is further described in detail with reference to the following specific embodiments and drawings. The process, conditions, experimental methods, etc. for implementing the present invention, except for the contents specifically mentioned below, are all common knowledge and common common sense in the art, and the present invention has no special restrictions.

[0044] The present invention proposes a vehicle driving risk classification method based on a Transformer encoder and a self-supervised pre-training model. The Transformer encoder is used to model the relationship between driving time series data, and the car driving data sequence is masked by a random mask and the original value is predicted to achieve self-supervised pre-training, and then the trained model is used to predict the car driving behavior to be predicted and the driving safety classification is performed through the Softmax layer. The innovation of the present invention is that it is aimed at the car driving risk classification scenario, and a classification model based on the Transformer encoder and the sequence masking mechanism is designed for self-supervised pre-training, which improves the accuracy of car driving risk classification.

[0045] The present invention proposes a vehicle driving risk classification method based on Transformer encoder and self-supervised pre-training model. Figure 5 As shown, the method comprises the following steps:

[0046] Step 1: Collect and process car driving data to generate a self-supervised pre-training dataset Veh_Train (accounting for 20% of the total driving sequences) and a dataset to be predicted Veh_Test (the remaining 80%);

[0047] Step 2: Construct a 6-layer Transformer encoder network for time series data modeling, where each layer includes a self-attention layer and two sub-layers of a feedforward network. Each encoder has the same structure and uses different weight parameters. The self-supervised pre-training dataset Veh_Train is used for masking-based self-supervised pre-training.

[0048] Step 3: Use the Transformer encoder to obtain the initial representation of the dataset Veh_Test to be predicted, use the pre-trained model fine-tuned in step 2 to learn the dataset Veh_Test to be predicted, and obtain the attention score.

[0049] Step 4: Iterate the training of the classifier, calculate the attention score for the sequence, and obtain the classification result through Softmax at the output layer.

[0050] like Figure 1 As shown in the figure, Veh_Train adds position encoding as the input of the mask-based unsupervised pre-training module, and predicts the mask value through the Transformer encoder; the remaining 80% of the data is fine-tuned in the trained Transformer encoder to obtain the output, and the output of the Transformer encoder module passes through a linear layer and is classified by a normalized exponential function (Softmax function).

[0051] like Figure 2 As shown, the data flow in the present invention is as follows: original data → data after cleaning, segmentation and enhancement → 20% as data Veh_Train for mask-based unsupervised pre-training, and 80% as data Veh_Test for fine-tuning Transformer encoder classification.

[0052] Specifically, the method of the present invention comprises the following steps:

[0053] Step 1: Collect and process car driving data to generate a self-supervised pre-training dataset Veh_Train (accounting for 20% of the total driving sequences) and a dataset to be predicted Veh_Test (the remaining 80%);

[0054] The car driving pre-training data set Evs in the embodiment comes from the driving data of 100 taxis collected for 12 days. The original data is collected by various sensors installed in the vehicle (GPS, speedometer and accelerometer, power meter, etc.). The frequency of the data is 1HZ, covering multiple dimensions, and is a high-dimensional time series data with a large amount of data. Because the car driving data may also encounter problems such as unstable transmission, weather conditions, obstacles and other surrounding environmental interference when collecting and uploading, resulting in data loss or data transmission failure in the data transmitted by the vehicle terminal, thereby causing the lack and abnormality of vehicle operation data, therefore, different data will also be processed differently to improve data accuracy. Since the sensor data records the entire journey of the vehicle, it is necessary to segment the original sensor data, divide the data segments from starting to finally stopping according to the instantaneous speed, and determine the best time window (generally speaking, between 60s and 120s) by adjusting the parameters through experiments, generate the training data set Veh_Train, and the data set to be predicted Veh_Test.

[0055] Step 2: Build a Transformer encoder network and use the self-supervised pre-training dataset Veh_Train for masking-based self-supervised pre-training.

[0056] For each training mini-batch, the input is masked by vector element-wise multiplication using the created random binary noise mask M: represents the input after masking, and X represents the original input; the length of each masked segment follows a geometric distribution with an average value of 3. The masked sequence is embedded after adding position encoding. The prediction of the masked sequence is given by training the Transformer model. The mean square error loss function is as follows:

[0057]

[0058] Where x represents the actual value of the input driving sequence data, It represents the predicted value of the model for the masked driving sequence data, and (j,i) is the label of the masked driving sequence data element.

[0059] The Transformer encoder outputs the final representation vector r t After the linear layer, the classification model will give a prediction for the original input vector.

[0060]

[0061] Among them, W m , b m It is a learnable parameter that will be adaptively optimized during the training process. Represents the predicted value of the model for the original input driving sequence data at time t.

[0062] Step 3: Use the fine-tuned pre-trained model to learn the prediction dataset Veh_Test and obtain the initial representation for the driving data training sample Each driving data segment is a multivariate time series of length n and d different dimensions, consisting of a series of feature vectors x t ∈R d For each dimension, the Transformer encoder model subtracts the mean of the training set samples and divides it by its variance, and then linearly projects it into the vector space of the sequence element representation dimension of the Transformer model:

[0063] z t =W p x t +b p

[0064] Z′=Z+P

[0065] Where W p , b p is the learnable model parameter, z t is the time series vector of the encoded driving data. t The driving data time series matrix composed of Z′ is the matrix used as the model input after adding the position code to Z, and P is the position code;

[0066] Z adds the positional encoding and multiplies the corresponding linear transformation matrix W q , W k , W v After that, the input vector becomes the query, key, and value of the self-attention layer, and the attention score is calculated:

[0067]

[0068] Q is the query vector, K is the key vector, V is the value vector, d k are the dimensions of the key vector and query vector.

[0069] Step 4: The representation vectors of all time steps will be concatenated into a vector r o , used as input to the linear output layer:

[0070]

[0071] Iterative algorithm model, predictive results It will be passed to the softmax layer to obtain the classification result (safe or dangerous). The loss function is:

[0072]

[0073] Example

[0074] Through the above operations, experiments are conducted on the following scenario datasets to evaluate the effectiveness of the proposed car driving risk classification method based on the Transformer encoder and the self-supervised pre-training model. The experiment uses accuracy to evaluate the classifier effect, that is, the proportion of correct predictions by the model.

[0075] Scenario data set: The car driving data sets Taxi and Evs mainly come from the collected data of about 200,000 vehicle sensors (GPS, speedometer and accelerometer, power meter, etc.). The Taxi driving data set is ordinary car driving data, and Evs is electric vehicle driving data.

[0076] Table 1 Accuracy of the model of the present invention and the model in the prior art regarding the car driving classification method

[0077]

[0078] Table 1 is Figure 4 The numerical results show that, compared with the existing models, the accuracy of the present invention in car driving classification is improved, with an improvement of 2.6%-8.7% on ordinary cars and 2.1%-5.7% on electric cars.

[0079] Experiments show that the method proposed in the present invention surpasses many previous methods, which proves the effectiveness of the method.

[0080] The protection content of the present invention is not limited to the above embodiments. Without departing from the spirit and scope of the inventive concept, changes and advantages that can be thought of by those skilled in the art are included in the present invention and are protected by the attached claims.

Claims

1. A vehicle driving risk classification method based on Transformer encoder and self-supervised pre-training model, characterized in that: The steps include: Step 1: Collect and process car driving data to generate a self-supervised pre-training dataset Veh_Train that accounts for 20% of the total driving sequences and a to-be-predicted dataset Veh_Test that accounts for the remaining 80% of the total driving sequences; Step 2: Build the Transformer encoder network and use the self-supervised pre-training dataset Veh_Train for masking-based self-supervised pre-training; Step 3: For each driving data segment I in Veh_Test, use the Transformer encoder to get the initial representation of I, use the fine-tuned pre-trained model to learn the prediction dataset Veh_Test, and get the Attention score; Step 4: Use the iterative algorithm to train the classifier and obtain the classification result through Softmax.

2. The classification method according to claim 1, characterized in that: In step one, the vehicle driving data includes GPS information, speed, acceleration, battery level, turn signal on / off status, throttle opening / closing degree, brake opening / closing degree, and total mileage; the processing refers to deleting duplicate values ​​in the vehicle driving data, interpolating missing values, deleting abnormal values, and segmenting the driving data according to the instantaneous speed from start to final stop. The data segments collected and processed through the above operations represent the instantaneous parameters of the vehicle at each moment during a driving process.

3. The classification method according to claim 2, characterized in that: The time window for segmenting driving data is 60s-120s.

4. The classification method according to claim 1, characterized in that: In step 2, the Transformer encoder network has 6 layers, each layer includes two sub-layers: a self-attention layer and a feedforward network. Each encoder has the same structure and uses different weight parameters.

5. The classification method according to claim 1, characterized in that: In step 2, the training dataset Veh_Train is used to perform masked self-supervised learning on the driving time series data pre-trained model. 15% of the random input sequence is set to 0, and then the Transformer model is required to give a prediction of the masked value. For each round of training, the pre-trained model will independently create a binary noise mask M, masking the input by vector element multiplication: represents the input after masking, and X represents the original input; the length of the masked segment follows a geometric distribution with an average value of 3; the masked sequence is embedded after adding position encoding, and the prediction of the masked sequence is given by training the Transformer model, and the loss function is as follows: Where x represents the actual value of the input driving sequence data, represents the model's predicted value for the masked driving sequence data, is the mean square error loss function, (j,i) is the label of the masked driving sequence data element.

6. The classification method according to claim 5, characterized in that: In step 2, the Transformer encoder outputs the final representation vector r t After passing through the linear layer, the classification model will give a prediction for the original input vector. Among them, W m , b m It is a learnable parameter that will be adaptively optimized during the training process. Represents the predicted value of the model for the original input driving sequence data at time t.

7. The classification method according to claim 1, characterized in that: For each dimension of each driving data segment in the driving data training sample Veh_Test, the Transformer encoder model subtracts the mean of the training set sample and divides it by its variance, and then linearly projects it into the vector space of the sequence element representation dimension of the Transformer model: z t =W p x t +b p , Z′=Z+P, Among them, W p , b p is the learnable model parameter, z t is the encoded driving data time series vector, Z is the t The driving data time series matrix composed of Z′ is the matrix used as the model input after adding the position code to Z, and P is the position code; Z adds the positional encoding and multiplies the corresponding linear transformation matrix W q , W k , W v After that, the input vector becomes the query, key, and value of the self-attention layer, and the attention score is calculated: Q is the query vector, K is the key vector, V is the value vector, d k are the dimensions of the key vector and query vector.

8. The classification method according to claim 1, characterized in that: In step 4, the representation vectors of all time steps will be concatenated into a vector r O , used as the input of the linear output layer, the prediction result is the output of the linear layer: W o , b o During the training process, the algorithm model will be adaptively optimized and the prediction results will be obtained through cyclic iteration. It will be passed to the softmax layer to obtain the safe or dangerous classification result.

9. The classification method according to claim 8, characterized in that: The cross entropy loss function is used to optimize the classification effect. is the cross entropy loss function, batch_size is the batch size, y is the actual value output by the linear layer, The predicted value output by the linear layer is:

Citation Information

Cited By

  • Road transport vehicle collision risk prediction method and system

    CN121093070A

  • Road transport vehicle crash risk prediction method and system

    CN121093070B

  • Vehicle stability evaluation method and system based on GPS-INS equipment, medium and vehicle

    CN122524466A

  • Method, device, and medium for generating lane change prediction model

    WO2026207855A1