Safe and efficient vehicle condition prediction federated learning method in Internet of Vehicles
By introducing blockchain technology, incentive mechanism, Mahayana distance and geometric median aggregation in the Internet of Vehicles environment, the problems of privacy risks, data heterogeneity, communication overhead and malicious attacks in the Internet of Vehicles vehicle condition prediction are solved, and a high-precision, robust and secure vehicle condition prediction model is achieved.
Patent Information
- Application Number
- CN202510210067.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-25
- Publication Date
- 2025-06-13
AI Technical Summary
In the Internet of Vehicles environment, traditional vehicle condition prediction methods have privacy risks, data heterogeneity lead to poor generalization capabilities of models, large communication overhead, long training delays, and vulnerability to malicious node attacks.
Blockchain technology is adopted to avoid single-point attacks, introduce incentive mechanisms to encourage high-quality data contributions, use Mahayana distance to eliminate malicious gradients, and design a geometric median aggregation mechanism for model aggregation to improve the accuracy and robustness of the model.
It realizes that without revealing privacy, improves the accuracy and robustness of the vehicle condition prediction model, reduces communication overhead and training delay, and enhances the security and real-time nature of the system.
Smart Images

Figure CN120146221A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of blockchain, federated learning, normalization technology, Mahalanobis distance, etc., and particularly relates to a secure and efficient vehicle condition prediction federated learning method in the Internet of Vehicles. Background Art
[0002] With the rapid development of intelligent connected vehicles and Internet of Vehicles technology, vehicle state monitoring and traffic flow prediction have become important research directions for improving road safety, optimizing traffic management, and enhancing the driving experience. In the Internet of Vehicles environment, vehicles can collect a large amount of vehicle condition data such as engine state, brake system operation, tire pressure, and fuel consumption in real time through on-vehicle sensors. These data are of great significance for predicting vehicle failures, optimizing maintenance strategies, and improving driving safety. However, how to safely and efficiently utilize these data for vehicle condition prediction still faces many challenges.
[0003] Traditional vehicle condition prediction methods usually store vehicle data centrally in the cloud and perform unified training. This centralized method has the following problems: First, vehicle data involves sensitive information such as driver behavior, vehicle operation status, and driving trajectory. Directly uploading it to the cloud server may bring privacy risks. Second, the data generated by vehicles in different regions, different brands, and different models have large heterogeneity and distribution differences. If only relying on a certain fixed data source for model training, the prediction model may perform poorly in some scenarios. In addition, the centralized data storage and processing method is also easily affected by factors such as network bandwidth, storage load, and single-point failure, reducing the reliability and real-time performance of the system.
[0004] To address the above problems, federated learning, as a decentralized machine learning method, provides a feasible solution for vehicle condition prediction in the Internet of Vehicles environment. It allows each vehicle or edge computing node to perform model training locally and only upload model parameters or gradients without directly sharing the original data, thereby achieving cross-vehicle or cross-region joint training without revealing privacy. This method can not only make full use of the data resources scattered in different vehicles and road environments to improve the generalization ability of the model, but also reduce the communication overhead caused by data transmission and improve the real-time performance of the system.
[0005] However, in the context of the Internet of Vehicles (IoV), federated learning still faces many challenges. Firstly, due to the limited computing power of vehicles and the unstable network connection status, traditional federated learning methods may lead to high communication overhead and training latency, affecting the real-time update and application of the model. Secondly, the data in the IoV is highly heterogeneous, and factors such as different types of vehicles, driving styles, and road conditions will all affect the data distribution, making it difficult for the trained model to maintain high accuracy in all scenarios. In addition, the IoV system may also be attacked by malicious nodes. For example, some vehicles may deliberately upload abnormal updates or tamper with model parameters, affecting the convergence and robustness of federated learning. Therefore, how to construct a federated learning method in the IoV environment that can protect data privacy, efficiently train a vehicle condition prediction model, and have strong robustness at the same time is an important technical problem that needs to be solved urgently. Summary of the Invention
[0006] The object of the present invention is to provide a secure and efficient vehicle condition prediction federated learning method in the Internet of Vehicles. By using blockchain technology to avoid single-point attacks and improve security, an incentive mechanism is introduced to encourage IoV users to contribute high-quality data. Mahalanobis distance is used to eliminate malicious gradients and a geometric median aggregation mechanism is designed for model aggregation to improve the accuracy of the model and enhance the robustness in heterogeneous scenarios.
[0007] The inventive concept of the present invention is as follows: Firstly, the traffic department TR creates a blockchain network and registers an account on the blockchain to publish federated learning tasks. Each IoV user registers an account in the blockchain system. Next, the IoV user pledges a certain amount of currency, then uses the initial model parameters and local dataset for training, and normalizes the local gradient, and uploads the local gradient to the blockchain. The cloud server SE first checks whether the gradient has been normalized, and then SE calculates the Mahalanobis distance of each gradient and eliminates abnormal gradients according to the set malicious gradient threshold. In the model aggregation stage, the aggregation node uses the geometric median method for gradient aggregation. Finally, the IoV user obtains the aggregated gradient from the DFMS and uses it to update the local model. TR tests the training results of this round. If the model accuracy meets the standard, the federated learning task ends; otherwise, a new round of training loop continues. After the federated learning task is completed, TR executes a reward and punishment mechanism for all IoV users according to the list of gradients not eliminated in each round to incentivize honest participants and suppress malicious behaviors, thereby improving the security and training efficiency of the system.
[0008] Specifically: Firstly, in the system initialization stage, the traffic department TR creates a blockchain network and registers an account on the blockchain to publish federated learning tasks. Each IoV user registers an account in the blockchain system and obtains account attributes AT = {pk, sk, id, ad, de} for participating in subsequent model training. TR sets the initial parameters of federated learning, including the initial model parameter W0 , learn the learning rate η and the model topic keyword, and publish the federated learning task through blockchain transactions. Then, in the local model training phase, vehicle network users voluntarily choose whether to participate in the training based on the model topic. All users participating in the training generate a transaction AF Di , declaring the existence of their dataset D i , and pledge a certain amount of currency from the deposit de as training collateral. Then, the user uses the initial model parameters W 0 and the learning rate η to train in combination with the local dataset, obtain the local gradient, and normalize the gradient. The normalized local gradient is stored in the distributed file management system (DFMS). Subsequently, the user generates a transaction AF i,t , records the hash address of the file storing the local gradient to the blockchain to ensure the traceability and integrity of the data. Next, in the malicious gradient detection phase, the cloud server SE obtains the local gradients of all vehicle users from the DFMS. SE checks whether the gradients are normalized and eliminates the unnormalized gradients. Subsequently, SE calculates the Mahalanobis distance of each gradient, and according to the set malicious gradient threshold, eliminates the abnormal gradients whose Mahalanobis distance exceeds the threshold to ensure that malicious users cannot affect the model training process. The processed list of valid gradients is sent to TR and stored in the DFMS and the blockchain. In the model aggregation phase, the blockchain formula committee selects an aggregation node. This aggregation node obtains the filtered local gradients from the DFMS and aggregates the gradients using the geometric median method. The aggregated gradients are stored in the DFMS and uploaded to the blockchain. Finally, in the model update and reward distribution phase, vehicle network users obtain the aggregated gradients of this round from the DFMS and use these gradients to update the local model. The traffic department TR tests the aggregated gradients of this round of training. If the model accuracy reaches the set threshold, this federated learning task ends; if the accuracy does not meet the standard, a new round of training continues, repeating the processes of local training, malicious gradient detection, model aggregation, and model update. After the federated learning task is completed, TR rewards and punishes all vehicle network users participating in the training according to the list of gradients not eliminated in each round to encourage more honest vehicle network users to participate in the training and prevent the influence of malicious behaviors, thereby improving the security and training efficiency of the entire system.
[0009] To achieve the above invention purpose, the technical solution adopted by the present invention is specifically: A secure and efficient vehicle condition prediction federated learning method in a vehicle network, mainly including three entities: the traffic department TR, the cloud server SE, and the vehicle network user U i , including the following steps:
[0010] S10. System initialization. First, the traffic department TR creates a blockchain network. TR registers an account on the blockchain to publish federated learning tasks. Then, each participating vehicle network user registers an account on this blockchain system and obtains a set of account attributes AT = {pk, sk, id, ad, de}. The user participates in model training through this account. Next, TR sets the initial model parameters W, the learning rate η, and the model theme keyword for the federated learning task, and TR initiates a blockchain transaction to publish the federated learning task; 0 , the learning rate η, and the model theme keyword, and TR initiates a blockchain transaction to publish the federated learning task;
[0011] S20. Local model training. The vehicle network users voluntarily choose whether to participate in model training according to the model theme keyword. All participating users generate a transaction AF Di to indicate that they own the dataset D i , and at the same time pledge a certain amount of currency from the deposit de. Next, the vehicle network users use the initial model parameters W 0 and the learning rate η, combine with the local dataset for model training, and then normalize the training results. The normalized local gradients are stored in the distributed file management system DFMS. Finally, the vehicle network users generate a transaction AF i and record the hash address of the file storing the local gradients into the blockchain;
[0012] S30. Malicious gradient detection. The cloud server SE obtains all the local gradients of the vehicle network users from the DFMS according to the transaction AF i generated by the vehicle network users. SE first detects whether these gradients have been normalized and eliminates the non-normalized gradients. Then SE calculates the Mahalanobis distance of the remaining gradients, sets a malicious gradient threshold, and eliminates the gradient values with a Mahalanobis distance greater than the threshold. Finally, SE sends the list of all uneliminated gradients to TR, and at the same time stores the remaining gradient values in the DFMS and uploads them to the blockchain;
[0013] S40. Model aggregation. The blockchain first selects an aggregation node. The aggregation node obtains the local gradients from the DFMS, and then the aggregation node aggregates these gradients using the geometric median method. Next, the aggregation node stores the aggregated gradients in the DFMS, generates a transaction, and uploads it to the blockchain;
[0014] S50, Model Update and Reward Distribution. The vehicle network users obtain the aggregated gradients of this round from the DFMS and update their local gradients according to the aggregated gradients. The traffic department TR tests the aggregated gradients of this round. If the accuracy meets the standard, the current federated learning task ends. If the accuracy does not meet the standard, repeat steps S20, S30, S40, and S50. After the federated learning task ends, TR rewards and punishes all vehicle network users according to the list of gradients not excluded in each round;
[0015] Furthermore, step S10 includes the following steps:
[0016] S101. First, the traffic department TR creates a blockchain network. TR registers an account on the blockchain to publish the federated learning task. Then, the vehicle network users register an account on this blockchain system and obtain a set of account attributes AT = {pk, sk, id, ad, de}. Among them, pk and sk are a pair of public and private keys. The vehicle network users can use this pair of public and private keys to construct a secret channel when transmitting information to another party. id is the unique identity identifier of the vehicle network user on this blockchain system. ad is the wallet address of the vehicle network user, used to create transactions. de is the deposit of the vehicle network user;
[0017] S102. TR publishes the federated learning task to the vehicle network users by creating a transaction. First, TR sets the initial model parameters W 0 , the learning rate η, and the model theme keyword for this federated learning task. Then, TR creates a transaction AF TR = {num, "keyword", Sign sk (W 0 ), Hash(W 0 ), η}, where num is the model number of this federated learning task, Sign sk (W 0 ) represents the digital signature generated by TR using its private key sk for the initial model parameters W 0 , Hash(W 0 ) represents the hash address of the initial model parameters W 0 ;
[0018] Furthermore, step S20 includes the following steps:
[0019] S201. The vehicle network user U i joins this federated learning task by creating a transaction. U i first obtains the model theme keyword and the hash address Hash(W TR of the initial model parameters W 0 from the transaction AF 0) and the learning rate η, U i Select the model to participate in this model training based on the model theme keyword. Then, U i Create a transaction AF Di ={index,"keyword",Hash(AF TR ),Hash(D i ),Sign sk (Hash(D i ))}, used to declare that you own the local dataset D i , where index is the Internet of Vehicles user U i Number, Hash(AF TR ) represents U i Choose to participate in the federated learning task released by TR, Hash(D i ) is U i Dataset D i Hash address, Sign sk (Hash(D i )) is for U i The digital signature used to prove that U i Indeed, we have dataset D i ;
[0020] S202, U i Initiate a pledge request to the blockchain system, the blockchain system first passes U i The unique identity identifier id is used to verify the identity. After the verification is passed, the system will i Pledged digital currency A i Lock, during the lock time, A i It cannot be used for transactions or transfers. After the lock is completed, the system generates a unique hash transaction value H t =Hash(id,A i ,T start ,T lock ), where T start and T lock Respectively represent the start time and lock period of the pledge, and the pledge information I i ={id,A i ,T start ,T lock ,H t}Recorded on the blockchain. i Staking a certain amount of currency on the blockchain before participating in training can not only increase the cost of malicious users to do evil and reduce the proportion of malicious users, but also reward honest users after the training is completed, encouraging Internet of Vehicles users to contribute high-quality data and honestly participate in training;
[0021] S203, Internet of Vehicles User Ui According to the initial model parameters W 0 to obtain the hash address Hash(W 0 ) of the initial model parameters W 0 . Then, combined with the learning rate η and the local dataset D i train to obtain the local gradient. In the t-th round of iteration, U i trains to obtain the gradient v of this iteration based on the aggregated gradient W of the (t - 1)-th round t-1 v = (v i,t , v 0 , …, v 1 ), where n represents the dimension of the gradient v n-1 ; i,t
[0022] S204. The vehicle networking user U i normalizes the local gradient. First, calculate the norm ||v i,t || of the gradient v i,t :
[0023]
[0024] Next, perform a normalization operation on each element in the gradient v i,t to obtain
[0025]
[0026] U i After normalizing the gradient v i,t , the norm of the gradient v i,t is limited to 1, which can not only balance the uneven data distribution in the vehicle networking scenario, improve the unity among models, promote the rapid convergence of the overall model and improve its accuracy, but also effectively defend against non-target attacks launched by malicious participants by enhancing the gradient. Finally, U i stores the normalized gradient in DFMS, generates the hash address of and uses the private key sk to perform a digital signature on to obtain Then generate a transaction and upload it to the blockchain.
[0027] Furthermore, the step S30 includes the following steps:
[0028] S301. The cloud server SE obtains from the transaction AF i uploaded by the vehicle networking user U i,t Then SE downloads the local gradient of U in DFMS according to the hash address in DFMS i ;
[0029] S302. The cloud server SE calculates the norm of each local gradient according to Equation (1) ; Then SE eliminates the gradients that are not equal to 1, and adds the gradients equal to 1 to the list L 1 ;
[0030] S303. For the gradients in the list L 1 , the cloud server SE first calculates the mean gradient μ t of all gradients:
[0031]
[0032] where |L 1 | represents the number of gradients in the list L 1 . Then, SE calculates the covariance matrix S i,t :
[0033]
[0034] where represents the transpose of the vector . Next, SE calculates the inverse matrix S i,t of the covariance matrix S i,t -1 , and then calculates the Mahalanobis distance 1 of each gradient in the list L
[0035]
[0036] S304. Since the Mahalanobis distance follows a chi-square distribution, the cloud server SE uses the chi-square distribution to set the threshold τ for abnormal gradients. First, SE sets the significance level α = 0.01, and then defines the probability density function of the chi-square distribution:
[0037]
[0038] where Γ(n / 2) is a gamma function, and its expression is:
[0039]
[0040] Next, the threshold τ for abnormal gradients is calculated through the definite integral formula:
[0041]
[0042] S305. The cloud server SE eliminates abnormal gradient values. For each gradient in the list L 1 in the list If then the gradient is considered a normal gradient. If then the gradient is considered abnormal or malicious. The SE eliminates the eliminated gradient, and adds the gradient to the list L 2 in the list. Finally, the SE sends the list L 2 to the traffic department TR, and at the same time generates a transaction The transaction AF L2 is uploaded to the blockchain.
[0043] Furthermore, the step S40 includes the following steps:
[0044] S401. The blockchain randomly selects a part of the nodes from all consensus nodes to form a consensus committee, and selects a node AG from the committee as the aggregation node;
[0045] S402. The aggregation node AG downloads the local gradient according to the hash address in the transaction AF L2 in the transaction AF Then AG calculates the aggregation result by minimizing the sum of the Euclidean distances from all gradients to a certain point v global That is:
[0046]
[0047] where v global represents the aggregation result, ||·|| 2 represents the Euclidean distance between two vectors. Assuming Then:
[0048]
[0049] Since the result of Equation (9) cannot be directly calculated, AG uses an iterative algorithm to approximately solve Equation (9). First, AG randomly selects a gradient from and records it as Then, iterative calculation is performed using Equation (11):
[0050]
[0051] where and respectively represent the results of the t-th iteration and the (t + 1)-th iteration. After each round of iteration, AG calculates If stop the iteration. At this time, represents the aggregated gradient. For the sake of easy representation, the aggregated gradient is uniformly represented as v global ;
[0052] S403. After obtaining the aggregated gradient, AG generates a transaction AF agg ={t, "keyword", Hash(AF TR ), Hash(v global ), Sign sk (Hash(v global ))}, and then packs the transactions of this round to generate a new block block new ;
[0053] S404. The remaining consensus nodes in the consensus committee verify the new block block new . If the node believes that the aggregation result is correct, it generates a transaction AF agree ={"keyword", Hash(AF TR ), Hash(block new ), Sign sk (Hash(block new ))}, and agrees to generate a new block. If the consensus nodes that agree to generate a new block account for more than 2 / 3 of the total nodes, this new block is accepted by the blockchain, and all consensus nodes broadcast this block; otherwise, the consensus committee reselects the aggregation node and repeats steps S402 and S403 until consensus is reached. Setting up a consensus committee in the aggregation stage can effectively prevent single-point failures and at the same time can effectively avoid malicious aggregation by the server.
[0054] Furthermore, the step S50 includes the following steps:
[0055] S501. The vehicle network user U i obtains the hash address of the aggregated gradient v agg from the transaction AF global , and then downloads the aggregated gradient v global from the DFMS according to the hash address;
[0056] S502. The vehicle network user U i updates the local model W global using the aggregated gradient v r :
[0057] W t = W t-1 - ηv global(12)
[0058] S503. The traffic department TR conducts an accuracy test on the updated model. If the accuracy reaches the expected value, it indicates that the current training task is completed; otherwise, the vehicle networking user U i executes step S20 to perform local gradient training for the (t + 1)-th round;
[0059] S504. After the training task is completed, the traffic department TR counts the contributions of each vehicle networking user U i to this training, and calculates the contribution value val i of U i . First, TR sets the contribution value val i of all vehicle networking users U i to 0. Then, according to the list L 2 in S305, TR adds 1 to the val i of each vehicle networking user who honestly participates in the training. At the same time, according to S404, TR adds 1 to the val i of the aggregation nodes that pass the consensus, and subtracts 1 from the val i of the aggregation nodes that do not pass the consensus. If the final contribution value val i of U i is less than 0, then TR resets it to 0. Finally, TR obtains the contribution value val i of all vehicle networking users U i ;
[0060] S505. The traffic department TR re - distributes the currency ac i locked on the blockchain system for the vehicle networking user U i according to formula (13):
[0061]
[0062] where m represents the total number of vehicle networking users participating in the training, and reward i represents the currency obtained by U i after re - distribution.
[0063] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0064] 1. The present invention uses normalization technology to process the local gradients of vehicle networking users, uses Mahalanobis distance to eliminate malicious gradients, and designs a geometric median mechanism to enhance the robustness during model aggregation, ensuring that the aggregation result has high accuracy.
[0065] 2. The present invention introduces a blockchain mechanism and sets up an incentive mechanism, which can enhance the security, transparency, and fairness of the federated learning system and improve the credibility of the model. Existing federated learning methods usually rely on a centralized server for aggregation and are vulnerable to single-point failures. The present invention introduces a blockchain, which can effectively avoid single-point attacks and enhance security. At the same time, it can ensure that the gradients submitted by vehicle network users are tamper-proof and prevent malicious nodes from forging updated data. In addition, an incentive mechanism is introduced to reward users with great contributions and punish malicious users, so as to encourage vehicle network users to contribute high-quality data, participate in training honestly, and improve the overall training quality.
[0066] 3. The present invention uses the Mahalanobis distance to eliminate malicious gradients. The cloud server calculates the Mahalanobis distance of the gradients uploaded by each vehicle network, sets a threshold according to the chi-square distribution, and eliminates malicious gradients according to the threshold. The traditional Euclidean distance method is sensitive to feature scales, cannot handle data with different distributions, and cannot handle features with high correlations. The Mahalanobis distance method of the present invention takes into account the correlations between features and can normalize the scales of different features, enabling more accurate identification of malicious gradients.
[0067] 4. The present invention designs a geometric median aggregation mechanism for model aggregation. Existing methods usually rely on statistical methods such as Krum, Median, and Trim-mean. These methods have low model accuracy when the proportion of malicious participants is high and are less robust to heterogeneous data. The geometric median method of the present invention can find an optimal center point for all gradient updates, which is not only unaffected by the proportion of malicious participants but also can maintain high model accuracy in heterogeneous scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] The drawings are used to provide a further understanding of the present invention and constitute a part of the specification. They are used together with the embodiments of the present invention to explain the present invention and do not constitute a limitation to the present invention.
[0069] Figure 1 It is a flowchart of a secure and efficient vehicle condition prediction federated learning method in a vehicle network according to an embodiment of the present invention.
[0070] Figure 2 It is a system model diagram of a secure and efficient vehicle condition prediction federated learning method in a vehicle network according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0071] In order to make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the drawings and embodiments. Of course, the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0072] Embodiment 1
[0073] See Figure 1 and Figure 2 , this embodiment provides its technical solution as a secure and efficient vehicle condition prediction federated learning method in a vehicle networking, as Figure 1 shown, mainly including a traffic department TR, a cloud server SE, and vehicle networking users U i three entities, including the following steps:
[0074] S10. System initialization. First, the traffic department TR creates a blockchain network. TR registers an account on the blockchain to publish federated learning tasks. Then, each vehicle networking user participating in the training registers an account on this blockchain system and obtains a set of account attributes AT = {pk, sk, id, ad, de}, and the user participates in model training through this account. Next, TR sets the initial model parameters W 0 , learning rate η, and model theme keyword for the federated learning task, and TR starts a blockchain transaction to publish the federated learning task;
[0075] S20. Local model training. The vehicle networking users voluntarily choose whether to participate in model training according to the model theme keyword. All users participating in the training generate a transaction AF Di to indicate that they own the dataset D i , and at the same time pledge a certain amount of currency from the deposit de. Next, the vehicle networking users use the initial model parameters W 0 and learning rate η to combine with the local dataset for model training, and then perform normalization processing on the training results. The normalized local gradients are stored in the distributed file management system DFMS. Finally, the vehicle networking users generate a transaction AF i,t , and record the hash address of the file storing the local gradients into the blockchain;
[0076] S30. Malicious gradient detection. The cloud server SE obtains the local gradients of all vehicle users from the DFMS according to the transaction AF i,t generated by the vehicle networking users. SE first detects whether these gradients have been normalized and eliminates the non-normalized gradients. Then SE calculates the Mahalanobis distance of the remaining gradients, sets a malicious gradient threshold, and eliminates the gradient values with a Mahalanobis distance greater than the threshold. Finally, SE sends the list of all uneliminated gradients to TR, and at the same time stores the remaining gradient values in the DFMS and uploads them to the blockchain;
[0077] S40. Model aggregation. The blockchain first selects an aggregation node. This aggregation node obtains the local gradients from the DFMS, and then the aggregation node aggregates these gradients using the geometric median method. Next, the aggregation node stores the aggregated gradients in the DFMS, generates a transaction, and uploads it to the blockchain;
[0078] S50, Model Update and Reward Distribution. The vehicle networking users obtain the aggregated gradients of this round from the DFMS and update their local gradients according to the aggregated gradients. The traffic department TR tests the aggregated gradients of this round. If the accuracy meets the standard, the current federated learning task ends. If the accuracy does not meet the standard, repeat steps S20, S30, and S40, S50. After the federated learning task ends, TR rewards and punishes all vehicle networking users according to the list of gradients not excluded in each round;
[0079] Among them, the DFMS is used to store the local gradients and aggregated gradients of vehicle networking users. The hash addresses of these data are stored in the blockchain, and each entity in this system can download the corresponding data through this address.
[0080] As Figure 2 shown, a secure and efficient vehicle condition prediction federated learning method in vehicle networking includes a traffic department TR, a cloud server SE, and vehicle networking users U i Three entities. The traffic department TR is a government agency and a trustworthy entity, responsible for creating a blockchain system; the cloud server SE is a server cluster, responsible for detecting the gradients uploaded by vehicle networking users and excluding malicious or abnormal gradient values; the vehicle networking users participating in the training are responsible for training local gradients using local datasets, normalizing the local gradients, and then uploading the local gradients through the blockchain.
[0081] The step S10 includes the following steps:
[0082] S101. First, the traffic department TR creates a blockchain network. TR registers an account on the blockchain to publish the federated learning task. Then, the vehicle networking users register an account on this blockchain system and obtain a set of account attributes AT = {pk, sk, id, ad, de}. Among them, pk and sk are a pair of public and private keys. The vehicle networking users can use this pair of public and private keys to construct a secret channel when transmitting information with another party. id is the unique identity identifier of the vehicle networking user on this blockchain system. ad is the wallet address of the vehicle networking user, used to create transactions, and de is the deposit of the vehicle networking user;
[0083] S102. TR publishes the federated learning task to the vehicle networking users by creating a transaction. First, TR sets the initial model parameters W 0 , the learning rate η, and the model topic keyword for this federated learning task. Then, TR creates a transaction AF TR = {num, "keyword", Sign sk (W 0 ), Hash(W 0),η}, where num is the model number of this federated learning task, Sign sk (W 0 ) represents the effect of TR on the initial model parameters W 0 Use your own private key sk to generate a digital signature, Hash(W 0 ) represents the initial model parameter W 0 The hash address of .
[0084] The step S20 comprises the following steps:
[0085] S201, Internet of Vehicles User U i Join this federated learning task by creating a transaction. i First create a transaction AF from TR TR Get the model topic keyword and initial model parameters W 0 The hash address Hash(W 0 ) and the learning rate η, U i Select the model to participate in this model training based on the model theme keyword. Then, U i Create a transaction AF Di ={index,"keyword",Hash(AF TR ),Hash(D i ),Sign sk (Hash(D i ))}, used to declare that you own the local dataset D i , where index is the Internet of Vehicles user U i Number, Hash(AF TR ) indicates U i Choose to participate in the federated learning task released by TR, Hash(D i ) is U i Dataset D i Hash address, Sign sk (Hash(D i )) is for U i The digital signature used to prove that U i Indeed, we have dataset D i ;
[0086] S202, U i Initiate a pledge request to the blockchain system, the blockchain system first passes U i The unique identity identifier id is used to verify the identity. After the verification is passed, the system will i Pledged currency ac i Lock, during the lock time, ac iIt cannot be used for trading or transferring. After the locking is completed, the system generates a unique hash transaction value H t = Hash(id,ac i ,T start ,T lock ), where T start and T lock represent the start time of pledge and the lock-up period respectively;
[0087] S203. The vehicle networking user U i obtains the initial model parameter W 0 according to the hash address Hash(W 0 ). Then, combined with the learning rate η and the local dataset D 0 , the local gradient is trained. In the t-th round of iteration, U i trains to obtain the gradient v i of this iteration based on the aggregated gradient W t-1 of the (t - 1)-th round, where v i,t =(v 0 ,v 1 ,…,v n-1 ), and n represents the dimension of the gradient v i,t ;
[0088] S204. The vehicle networking user U i normalizes the local gradient. First, calculate the norm ||v i,t || of the gradient v i,t :
[0089]
[0090] Next, perform a normalization operation on each element in the gradient v i,t to obtain
[0091]
[0092] Finally, U i stores the normalized gradient in DFMS, generates the hash address of and uses the private key sk to perform a digital signature on to obtain Then a transaction is generated
[0093] and it is uploaded to the blockchain.
[0094] S301. The cloud server SE obtains from the vehicle networking user U iUploaded transaction AF i,t obtained from Then SE downloads U in DFMS according to the hash address local gradients of i ;
[0095] S302. The cloud server SE calculates the modulus of each local gradient according to Equation (1) ; Then SE eliminates gradients not equal to 1, and adds gradients equal to 1 to the list L 1 ;
[0096] S303. For the gradients in the list L 1 , the cloud server SE first calculates the mean gradient μ of all gradients t :
[0097]
[0098] where |L 1 | represents the number of gradients in the list L 1 . Then, SE calculates the covariance matrix S i,t :
[0099]
[0100] where represents the transpose of the vector . Next, SE calculates the inverse matrix S i,t of the covariance matrix S i,t -1 , and then calculates the Mahalanobis distance 1 of each gradient in the list L
[0101]
[0102] S304. The cloud server SE sets the threshold τ of the abnormal gradient using the chi-square distribution. First, SE sets the significance level α = 0.01, and then defines the probability density function of the chi-square distribution:
[0103]
[0104] where Γ(n / 2) is a gamma function, and its expression is:
[0105]
[0106] Next, the threshold τ of the abnormal gradient is calculated through the definite integral formula:
[0107]
[0108] S305. The cloud server SE eliminates abnormal gradient values. For each gradient in the list L 1 in the list If then the gradient is considered a normal gradient. If then the gradient is considered abnormal or malicious. SE eliminates the gradient and adds the gradient to the list L 2 in the list. Finally, SE sends the list L 2 to the traffic department TR and generates a transaction and uploads the transaction AF L2 to the blockchain.
[0109] The step S40 includes the following steps:
[0110] S401. The blockchain randomly selects a part of the nodes from all consensus nodes to form a consensus committee, and selects a node AG as the aggregation node from the committee;
[0111] S402. The aggregation node AG downloads the local gradient according to the hash address in the transaction AF L2 in the transaction. Then AG calculates the aggregation result by minimizing the sum of the Euclidean distances of all gradients to a certain point v That is: global where:
[0112]
[0113] where v global represents the aggregation result, ||·|| 2 represents the Euclidean distance between two vectors. Assuming Then:
[0114]
[0115] Since the result of Equation (9) cannot be directly calculated, AG uses an iterative algorithm to approximately solve Equation (9). First, AG randomly selects a gradient from and denotes it as Then, iterative calculation is performed using Equation (11):
[0116]
[0117] where: and respectively represent the results of the t-th iteration and the (t + 1)-th iteration. After each round of iteration, AG calculates If stop the iteration. At this time, represents the aggregated gradient. For the sake of easy representation, the aggregated gradient is uniformly represented as v global ;
[0118] S403. After obtaining the aggregated gradient, AG generates a transaction AF agg ={t, "keyword", Hash(AF TR ), Hash(v global ), Sign sk (Hash(v global ))}, and then packs the transactions of this round to generate a new block block new ;
[0119] S404. The remaining consensus nodes in the consensus committee verify the new block block new . If the node believes that the aggregation result is correct, it generates a transaction AF agree ={"keyword", Hash(AF TR ), Hash(block new ), Sign sk (Hash(block new ))}, and agrees to generate a new block. If the number of consensus nodes that agree to generate a new block accounts for more than 2 / 3 of the total nodes, this new block is accepted by the blockchain, and all consensus nodes broadcast this block; otherwise, the consensus committee reselects the aggregation node and repeats steps S402 and S403 until consensus is reached.
[0120] The step S50 includes the following steps:
[0121] S501. The vehicle networking user U i obtains the hash address of the aggregated gradient v agg from the transaction AF global , and then downloads the aggregated gradient v global from the DFMS according to the hash address;
[0122] S502. The vehicle networking user U i updates the local model W global using the aggregated gradient v r :
[0123] W t = W t-1 - ηv global (12)
[0124] S503. The transportation department TR conducts an accuracy test on the updated model. If the accuracy reaches the expected value, it indicates that the current training task is completed; otherwise, the vehicle networking user U i executes step S20 to perform local gradient training for the (t + 1)-th round;
[0125] S504. After the training task is completed, the transportation department TR counts the contributions of each vehicle networking user U i to this training, and calculates the contribution value val i of U i . First, TR sets the contribution value val i of all vehicle networking users U i to 0. Then, according to the list L 2 in S305, TR adds 1 to the val i of each vehicle networking user who honestly participates in the training. At the same time, according to S404, TR adds 1 to the val i of the aggregation nodes that pass the consensus, and subtracts 1 from the val i of the aggregation nodes that do not pass the consensus. If the final contribution value val i of U i is less than 0, then TR resets it to 0. Finally, TR obtains the contribution value val i of all vehicle networking users U i ;
[0126] S505. The transportation department TR reallocates the currency ac i locked by the vehicle networking user U i on the blockchain system according to Equation (13):
[0127]
[0128] where m represents the total number of vehicle networking users participating in the training, and reward i represents the currency obtained by U i after the reallocation.
[0129] Table 1 explains and describes the symbols that appear in the method of this example.
[0130] Table 1 Symbol Explanation
[0131]
[0132]
[0133] Embodiment 2
[0134] To verify the vehicle condition prediction method of the present invention in the vehicle networking scenario, the present invention conducted multiple groups of experiments and compared them with the traditional federated learning method (FedAvg) and the federated learning method without security mechanism (FedSGD).
[0135] First, this experiment selected the PEMS-BAY dataset. The PEMS-BAY dataset is an open-source dataset for traffic flow prediction and is sourced from the highway management system in the Bay Area of California, USA. This dataset was collected by 325 traffic sensor nodes and covers traffic data from January 2017 to June 2017.
[0136] This experiment was implemented on a local network. This network uses an Intel(R) Core(TM) i7-7700HQ 2.80GHz CPU, 8GB of RAM, runs the Windows 10 operating system, and uses Python + PyTorch for model training. PyTorch is an open-source deep learning framework based on Python.
[0137] This experiment used the following metrics to evaluate the superiority of the method of the present invention:
[0138] (1) Prediction accuracy (MAE, RMSE): Measures the error of the vehicle condition prediction model. MAE represents the mean absolute error, and RMSE represents the root mean square error:
[0139]
[0140] Among them, m represents the number of samples, and v i and represent the true value and the predicted value of the model, respectively.
[0141] (2) Training convergence speed (number of iterations): The number of training rounds required for the model to converge.
[0142] (3) Security (accuracy of malicious gradient detection): The accuracy of detecting and removing abnormal gradients uploaded by malicious users.
[0143] (4) Computational overhead (communication cost): Used to quantify the computational resource consumption of the system.
[0144] Due to the use of Mahalanobis distance to detect malicious gradients + normalization technology, the present invention effectively reduces the impact of outliers on model training. As shown in Table 2, the prediction error of the method of the present invention is 26.6% lower than that of FedAvg and 37.9% lower than that of FedSGD, indicating that its vehicle condition prediction is more accurate.
[0145] Table 2 Comparison of vehicle condition prediction accuracies
[0146]
[0147] The present invention uses normalization processing to make the gradient more stable, geometric median aggregation to improve the stability of the model, and blockchain distributed storage to reduce data transmission latency. As shown in Table 3, the training convergence speed of the method of the present invention is increased by more than 25%, indicating that it has obvious advantages in terms of convergence and computational efficiency.
[0148] Table 3 Comparison of training convergence speeds
[0149]
[0150] Due to the adoption of Mahalanobis distance detection + chi-square distribution outlier screening, malicious gradients can be effectively identified and eliminated, reducing the possibility of the model being attacked. At the same time, geometric median aggregation can further reduce the impact of abnormal gradients. As shown in Table 4, the malicious gradient detection accuracy of the method of the present invention is as high as 94.5% - 98.5%, significantly higher than that of FedAvg (55.6% - 85.4%) and FedSGD (43.8% - 73.2%).
[0151] Table 4 Security comparison (malicious gradient detection accuracy)
[0152]
[0153] The present invention stores the gradient hash value using blockchain instead of directly transmitting the model parameters, and malicious gradients are filtered in advance to reduce the transmission of invalid gradients. At the same time, gradient normalization compresses the amount of information, thus improving the transmission efficiency. As shown in Table 5, the communication cost of the method of the present invention is reduced by 34.6% compared with FedAvg and 54.6% compared with FedSGD, indicating that the method of the present invention can effectively reduce the communication overhead and improve the bandwidth utilization rate.
[0154] Table 5 Computational overhead (comparison of communication costs)
[0155]
[0156] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A safe and efficient vehicle condition prediction federated learning method in the Internet of Vehicles, characterized in that: The following steps are involved: S10, system initialization. First, the traffic department TR creates a blockchain system. TR registers an account on the blockchain to publish federated learning tasks. Then, each Internet of Vehicles user participating in the training registers an account on the blockchain system and obtains a set of account attributes AT = {pk, sk, id, ad, de}. Users participate in model training through this account. Next, TR sets the initial model parameter W0, learning rate η and model topic keyword for the federated learning task. TR starts a blockchain transaction to publish the federated learning task. S20, local model training, IoV users voluntarily choose whether to participate in model training based on the model theme keyword. All users participating in the training generate a transaction AF before the training starts. Di To show that you have the data set D i , and pledge a certain amount of currency from the deposit de. The Internet of Vehicles user uses the initial model parameters W0 and the learning rate η, combined with the local data set to train the model, and then normalizes the training results. The normalized local gradients are stored in the distributed file management system DFMS. Finally, the Internet of Vehicles user generates a transaction AF i,t , record the hash address of the file storing the local gradient into the blockchain; S30, malicious gradient detection, cloud server SE based on the transaction AF generated by the Internet of Vehicles user i,t , obtain the local gradients of all vehicle users from DFMS. SE first detects whether these gradients are normalized and removes the normalized gradients. Then SE calculates the Mahalanobis distance of the remaining gradients, sets the malicious gradient threshold, and removes the gradient values whose Mahalanobis distance is greater than the threshold. Finally, SE sends a list of all non-removed gradients to TR, and stores the remaining gradient values in DFMS and uploads them to the blockchain. S40, model aggregation, the blockchain first selects an aggregation node, which obtains local gradients from DFMS, and then aggregates these gradients using the geometric median method. The aggregation node stores the aggregated gradients in DFMS, generates a transaction, and uploads it to the blockchain; S50, model update and reward distribution. The Internet of Vehicles users obtain the aggregated gradient of this round from DFMS and update their local gradients based on the aggregated gradients. The transportation department TR tests the aggregated gradient of this round. If the accuracy meets the standard, the federated learning task is terminated. If the accuracy does not meet the standard, the above steps S20 to S50 are repeated. After the federated learning task is completed, TR rewards or punishes all Internet of Vehicles users based on the list of gradients that have not been eliminated in each round.
2. The safe and efficient vehicle condition prediction federated learning method in the Internet of Vehicles according to claim 1 is characterized in that: The step S10 comprises the following steps: S101. First, the transportation department TR creates a blockchain network. TR registers an account on the blockchain to publish federated learning tasks. The Internet of Vehicles user registers an account on the blockchain system and obtains a set of account attributes AT = {pk, sk, id, ad, de}, where pk and sk are a pair of public and private keys. The Internet of Vehicles user uses this pair of public and private keys to build a secret channel when transmitting information to the other party. id is the unique identity identifier of the Internet of Vehicles user on the blockchain system. ad is the wallet address of the Internet of Vehicles user, which is used to create transactions. de is the deposit of the Internet of Vehicles user. S102, TR publishes the federated learning task to the Internet of Vehicles users by creating a transaction. First, TR sets the initial model parameter W0, learning rate η and model topic keyword for this federated learning task. Then, TR creates a transaction AF TR ={num,"keyword",Sign sk (W0), Hash(W0), η}, where num is the model number of this federated learning task, Sign sk (W0) represents the digital signature generated by TR for the initial model parameter W0 using its own private key sk, and Hash(W0) represents the hash address of the initial model parameter W0.
3. The safe and efficient vehicle condition prediction federated learning method in the Internet of Vehicles according to claim 1 is characterized in that: The step S20 comprises the following steps: S201, Internet of Vehicles User U i Join this federated learning task by creating a transaction. i First create a transaction AF from TR TR Get the model topic keyword, the hash address Hash(W0) of the initial model parameter W0 and the learning rate η, U i According to the model theme keyword, select to participate in this model training, and then, U i Create a transaction AF Di ={index,"keyword",Hash(AF TR ),Hash(D i ),Sign sk (Hash(D i ))}, used to declare that you own the local dataset D i , where index is the Internet of Vehicles user U i Number, Hash(AF TR ) indicates U i Choose to participate in the federated learning task released by TR, Hash(D i ) is U i Dataset D i Hash address, Sign sk (Hash(D i )) is for U i The digital signature used to prove that U i Indeed, we have dataset D i ; S202, U i Initiate a pledge request to the blockchain system, the blockchain system first passes U i The unique identity identifier id is used to verify the identity. After the verification is passed, the system will i Pledged currency ac i Lock, during the lock time, ac i It cannot be used for transactions or transfers. After the lock is completed, the system generates a unique hash transaction value H t =Hash(id,ac i ,T start ,T lock ), where T start and T lock Respectively represent the start time and lock-up period of the pledge; S203, Internet of Vehicles User U i The initial model parameter W0 is obtained according to the hash address Hash(W0) of the initial model parameter W0, and then, combined with the learning rate η and the local data set D i The local gradient is obtained by training. In the tth iteration, U i Based on the aggregated gradient W of the t-1th round t-1 Train to get the gradient v of this iteration i,t =(v0,v1,…,v n-1 ), n represents the gradient v i,t The dimension of S204, Internet of Vehicles User U i Normalize the local gradient and first calculate the gradient v i,t The module||v i,t ||: Next, the gradient v i,t Each element in is normalized one by one, and we get Finally, U i The normalized gradient Stored in DFMS, generated Hash address And use the private key sk Digitally sign and get Then generate the transaction Upload it to the blockchain.
4. The safe and efficient vehicle condition prediction federated learning method in the Internet of Vehicles according to claim 1 is characterized in that: The step S30 comprises the following steps: S301, cloud server SE receives data from Internet of Vehicles user U i Uploaded Transaction AF i,t Obtained Then SE based on the hash address Download U in DFMS i The local gradient S302, the cloud server SE calculates each local gradient according to formula (1) Model Then SE is eliminated The gradient is not equal to 1. Gradients equal to 1 are added to list L1; S303, for the gradients in list L1, the cloud server SE first calculates the mean gradient μ of all gradients t : Where |L1| represents the number of gradients in list L1. Then, SE calculates the covariance matrix S i,t : in, Representation vector Next, SE calculates the covariance matrix S i,t The inverse matrix S i,t -1 , and then calculate the Mahalanobis distance of each gradient in list L1 S304, the cloud server SE uses the chi-square distribution to set the threshold τ of the abnormal gradient. First, SE sets the significance level α=0.01, and then defines the probability density function of the chi-square distribution: Where Γ(n / 2) is a gamma function, which is expressed as: Next, the threshold τ of the abnormal gradient is calculated by the definite integral formula: S305: The cloud server SE removes abnormal gradient values. For each gradient in list L1, like The gradient is considered a normal gradient if The gradient Considered abnormal or malicious, SE removes The gradient of The gradient is added to the list L2. Finally, SE sends the list L2 to the transportation department TR and generates a transaction Will trade AF L2 Upload to blockchain.
5. The safe and efficient vehicle condition prediction federated learning method in the Internet of Vehicles according to claim 1, characterized in that: The step S40 comprises the following steps: S401. The blockchain randomly selects a portion of nodes from all consensus nodes to form a consensus committee, and selects a node AG from the committee as an aggregation node; S402, the aggregation node AG according to the transaction AF L2 Download local gradients from the hash address in Then AG minimizes all gradients to a certain point v global The sum of the Euclidean distances is calculated to get the aggregation result, namely: Among them, v global represents the aggregation result, ||·||2 represents the Euclidean distance between two vectors, assuming but: Since the result of formula (9) cannot be calculated directly, AG uses an iterative algorithm to approximate the solution of formula (9). First, AG calculates A gradient is randomly selected from Then use formula (11) to perform iterative calculation: in, and They represent the results of the tth iteration and the t+1th iteration respectively. After each round of iteration, AG calculates like Stop the iteration. Represents the aggregation gradient, which is represented by v global ; S403. After obtaining the aggregate gradient, AG generates a transaction AF agg ={t,"keyword",Hash(AF TR ),Hash(v global ),Sign sk (Hash(v global ))}, and then package the transactions of this round to generate a new block new ; S404: The remaining consensus nodes in the consensus committee agree on the new block. new Verify, if the node believes that the aggregation result is correct, then generate transaction AF agree ={"keyword",Hash(AF TR ),Hash(block new ),Sign sk (Hash(block new ))}, agree to generate a new block. If the consensus nodes that agree to generate a new block account for more than 2 / 3 of the total nodes, the new block is accepted by the blockchain and all consensus nodes broadcast the block; otherwise, the consensus committee reselects the aggregation node and repeats steps S402 and S403 until consensus is reached.
6. The safe and efficient vehicle condition prediction federated learning method in the Internet of Vehicles according to claim 1 is characterized in that: The step S50 comprises the following steps: S501, Internet of Vehicles user U i From Transaction AF agg The aggregate gradient v is obtained from global The hash address of the aggregated gradient v is then downloaded from DFMS according to the hash address. global ; S502, Internet of Vehicles user U i Using aggregate gradient v global Update local model W r : W t =W t-1 -ηv global (12) S503: The traffic department TR performs an accuracy test on the updated model. If the accuracy reaches the expected value, it means that the training task is completed. Otherwise, the Internet of Vehicles user U i Execute step S20 to perform the t+1th round of local gradient training; S504. After the training task is completed, the traffic department TR counts the U of each vehicle network user i Contribution to this training, calculate U i The contribution value val i First, TR will collect all Internet of Vehicles users U i The contribution value val i is set to 0, and then TR sets the val of each IoV user who honestly participates in the training according to the list L2 in S305. i Add 1, and TR is calculated based on S404, and the val of the aggregation node through consensus i Add 1, the val of the aggregation node that failed to pass the consensus i Minus 1, if U i The final contribution value val i If it is less than 0, TR resets it to 0. Finally, TR obtains all the Internet of Vehicles users U i The contribution value val i ; S505: The transportation department TR calculates the vehicle network user U according to formula (13). i Currency locked in the blockchain system i To redistribute: Among them, m represents the total number of Internet of Vehicles users participating in the training, reward i Indicates U i The currency obtained after redistribution.
7. The safe and efficient vehicle condition prediction federated learning method in the Internet of Vehicles according to claim 1, characterized in that: In step S50, DFMS is used to store the local gradient and aggregated gradient of the Internet of Vehicles users. The hash addresses of these data are stored in the blockchain, and each entity in the system downloads the corresponding data through the address.