Internet of vehicles data privacy protection method based on block chain and ternary federated learning
By combining blockchain and ternary federated learning technology in the Internet of Vehicles, the problems of single point failure and privacy leakage in traditional federated learning are solved, efficient data privacy protection and communication efficiency improvement are achieved, and system security is enhanced.
Patent Information
- Application Number
- CN202410888759.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-04
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-07-04
AI Technical Summary
In traditional federated learning, Internet of Vehicles data has problems such as single point of failure attack, privacy leakage, member reasoning attacks and high communication overhead, especially under a centralized architecture that depends on central servers.
Using a blockchain-based and ternary federated learning method, through combining it in the application layer and the blockchain layer, using Gaussian noise, TernGrad ternary gradient, federated differential privacy and smart contracts to achieve distributed training and data privacy protection. , reduce communication costs and improve security.
It effectively solves the problems of single point of failure attacks and privacy leakage, improves data privacy protection and communication efficiency, and enhances the security and credibility of the system.
Smart Images

Figure CN119046973A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of Internet of Vehicles data processing, and relates to an Internet of Vehicles data privacy protection method based on blockchain and ternary federated learning. Background Art
[0002] In the era of rapid development of the automobile industry, the construction of intelligent transportation systems has become an inevitable trend. In this information age, it has become possible to use vehicle data to achieve intelligent traffic management and services. As an emerging technology, the Internet of Vehicles (IoV) is gradually becoming popular and applied. Figure 1 As shown in the figure, the vehicle transmits the data obtained from the advanced vehicle equipment to the cloud through the edge node to better improve the level of vehicle-related services. The Internet of Vehicles is not only an extension of vehicle networks, vehicle telematics and intelligent transportation systems, but also provides various services for vehicles and transportation systems as well as people inside and outside the vehicle by integrating vehicles, sensors and mobile devices into a global network.
[0003] It is precisely because of the continuous advancement of Internet of Vehicles technology that information exchange and communication between vehicles, between vehicles and road infrastructure, and between vehicles and the cloud have become more convenient and efficient. However, with its popularization and application, the privacy protection of Internet of Vehicles data has gradually become prominent. Various data generated by vehicles, including vehicle driving trajectory, speed, acceleration, in-vehicle environment, vehicle photography images, motor operation status and other information, may leak the owner's personal privacy, and may even be maliciously used to cause security risks. Therefore, how to protect the privacy and security of Internet of Vehicles data has become one of the urgent problems to be solved in the development of intelligent transportation systems. Federated learning, as a new type of data training technology, has become one of the important methods to solve the privacy and security problems of Internet of Vehicles data with its advantages of distributed local training. However, there are major security and privacy challenges in aggregating large amounts of private data on a central server for training, and it will also increase communication costs. More specifically:
[0004] 1) Single point failure attack: Traditional federated learning usually relies on a central server to coordinate and integrate model updates of various devices. This centralized architecture is easily targeted by attackers. Once the central server is attacked or fails, the entire system will face serious single point failure problems, resulting in system unavailability or data loss.
[0005] 2) Privacy issues: Although federated learning keeps data on local devices for model training, there are still certain privacy risks. During the model update process, some private information may be leaked to the central server or other devices through model parameters, especially during the model parameter aggregation process, which may expose the private information of individual devices;
[0006] 3) Membership inference attack: Membership inference attack in federated learning means that the attacker infers the information of local devices participating in training by observing the update of global model parameters. By analyzing the update of model parameters, the attacker may be able to infer the distribution or characteristics of training data of certain devices, thereby infringing the privacy of users;
[0007] 4) Communication overhead,The communication overhead between devices and the central server in federated learning is a challenge. Each round of model update requires the device to transmit local model parameters to the central server and receive updates to global model parameters, which will lead to a lot of communication overhead, especially when there are a large number of devices and limited bandwidth. Summary of the invention
[0008] The technical solution adopted by the present invention is: a data privacy protection method for the Internet of Vehicles based on blockchain and ternary federated learning. The method is: in the application layer, the data requester first issues a task request. After receiving the task, the local vehicle will train the local model locally, and add Gaussian noise during training to prevent member inference attacks. After the training is completed, the original gradient is converted into a ternary gradient and uploaded to the server. The server aggregates the ternary gradient and returns the result to the client (each local vehicle). Then the user delays the result to a floating point number and updates the model copy for subsequent training;
[0009] At the blockchain layer, edge nodes (RSUs) refer to edge nodes that are usually equipped with certain computing and communication resources. Due to their powerful computing, communication and storage capabilities, they can serve as blockchain miners. Verification values and local model updates are stored in data blocks by edge nodes (i.e., blockchain miners) verified by the consensus algorithm, and their local models are broadcast in the network through the P2P broadcast function in the blockchain, where the verification value is generated by a smart contract to verify the user's relevant information. Finally, the vehicle downloads the latest local model updates of all vehicles from the blockchain and aggregates the global model.
[0010] The Internet of Vehicles data privacy protection method based on blockchain and ternary federated learning includes the following specific steps:
[0011] Step 1: The requester (Roadside Unit) publishes a training task, that is, the requester sends the model to be trained and related parameters to the participants, requiring them to train the model on local data; this step is intended to encourage the participants to jointly train the model while protecting data privacy, thereby achieving global improvement of the model;
[0012] Step 2: Each vehicle or each participant uses its local data to train the model without sending the data to a central server. Each participant performs model training based on a local data set and updates its local model to adapt to its local environment. This distributed training method helps protect data privacy, reduce data transmission, and enables the model to better adapt to the specific circumstances of each participant.
[0013] Step 3: In the process of federated learning, in order to protect the data privacy of participants, a certain degree of Gaussian noise and the verification value generated for the local vehicle in the blockchain are added to the model update; this helps to increase data confusion during the model training process, making it difficult for attackers to infer the specific data information of individual participants, thereby protecting the privacy of the data;
[0014] Step 4: During the federated learning process, each participant will verify the model trained locally to ensure its performance and accuracy. If the model performs well in the local verification, the participant will choose to update it to the global model, thereby jointly improving the model effect of the entire system;
[0015] Step 5: After training the federated learning model, the training results are recorded on the blockchain to ensure the immutability and transparency of the data and prevent the data from being tampered with or stolen. At the same time, blockchain technology can also provide a distributed data storage and verification mechanism to further enhance data protection and security. This blockchain-based federated learning method provides an effective solution for data privacy protection in the Internet of Vehicles, which can improve the credibility and security of data while ensuring data privacy;
[0016] Step 6: In this step, the blockchain system will select some nodes from edge nodes (including roadside units, traffic signal controllers, surveillance cameras and sensors, smart street lights, on-board units, etc.) and vehicle nodes as miners to perform mining operations on the blockchain. The selection operation will follow the set consensus algorithm. These miner nodes are responsible for verifying transactions and packaging them into blocks to ensure the normal operation of the blockchain network. By selecting edge nodes as miners, distributed storage and processing of data can be achieved while protecting the privacy and security of data.
[0017] Step 7: After the selected miner performs the mining operation, it is first verified by the smart contract, and the verification value is written into the blockchain. The verified block is then broadcast through the P2P network, thus achieving the credibility of the transaction and the security of the network.
[0018] Step 8: In this step, the blockchain will aggregate the model updates collected from various participants into a global model, which will comprehensively consider the updates from various participants to obtain a more accurate and comprehensive model. Through the aggregation of model updates, the advantages of federated learning can be effectively utilized and the shortcomings of aggregating models on a central server can be overcome, that is, while protecting data privacy, the continuous optimization and improvement of the model can be achieved.
[0019] The local model adopts the ternary federated learning model. The ternary federated learning model introduces the TernGrad ternary gradient technology, which quantizes the previous gradient from floating point numbers into three discrete values: -1, 0, and +1, and introduces layered ternary valueization and gradient clipping technology. The layered ternary valueization divides the gradient into multiple levels, and quantizes and transmits them separately. The gradient clipping technology controls the size of the gradient.
[0020] Furthermore, the training method of the above ternary federated learning model is as follows:
[0021] Worker (client: vehicle node or edge node): i = 1, 2, ..., Ν
[0022] 1) Input A small batch of part of a training sample (such as motor operation data, vehicle status data, sensor data, environment and traffic data, driving behavior data, vehicle communication data, user and passenger data, etc.);
[0023] 2) Calculate The gradient below
[0024] 3) Gradient clipping
[0025] 4) The clipped gradient Layered and ternary:
[0026]
[0027] 5) Push ternary to the server;
[0028] 6) Pull the average gradient from the server
[0029] 7) Update parameters where ω t+1 and ω t are the parameter weights at time points t+1 and t respectively; η is the learning rate
[0030] Server:
[0031] 8) Average ternary gradient:
[0032] Furthermore, the method for converting the above original gradient into ternary gradient is:
[0033] Let the ternary conversion function be, and its quantized gradient is as follows:
[0034]
[0035] Among them, b t is a random binary vector, g t is the original gradient, s t For the scaler, is the Hadamard product, sign(·) is the sign of each element;
[0036] Zoomers t Using a shared scaling factor: represents the scaler of the i-th gradient;
[0037] For a given g t and b t , each element of which follows a Bernoulli distribution independently:
[0038]
[0039] Among them, b tk and g tk are randomly entered b t and g t The kth element in , after ternary conversion, the client will Replace the original gradient g t Upload to the server, and the server aggregates the ternary gradients and returns the result to the client.
[0040] Furthermore, in the above-mentioned layer-by-layer ternary and gradient clipping method, each gradient g in g is i The size limits are:
[0041]
[0042] Where σ is the standard deviation of the gradient in the gradient g, c is a hyperparameter, and c best =2.5.
[0043] Furthermore, the above-mentioned Internet of Vehicles data privacy protection method based on blockchain and ternary federated learning also includes data privacy protection methods on the client and server. The data privacy protection methods all adopt a federated differential privacy protection algorithm. When the federated differential privacy is trained locally on the client, it is necessary to trim the parameters after each local iteration; for the federated differential privacy on the server side, the client will be randomly selected according to probability and asked to perform local model training; and after receiving the model parameters of each client, the server will perform an aggregation operation. In terms of noise addition, the variance of the Gaussian noise distribution is obtained, and the Gaussian distribution is used to generate noise data, which is used to add noise data in the global model aggregation operation to obtain new global model parameters, and the steps are repeated until the model converges.
[0044] Furthermore, when the client performs local training of federated learning, the model is compressed using a model compression method based on layer sensitivity. The layer sensitivity is: Let the current model be represented by G = {g1, g2, ..., g L}, in round t, client C j When performing federated learning local training, the model will be trained from G t =G becomes
[0045]
[0046] The change of the i-th layer is recorded as
[0047]
[0048] The mean change of each layer's parameters, δ, is called sensitivity. It refers to the mean of the parameter updates of the i-th layer after the t-th round of local training of federated learning.
[0049] Furthermore, the above smart contracts include clientManager contract, NetworkManager contract and VerifySignature contract;
[0050] Among them, the clientManager contract is used to implement the client registration function. Each client calls the register function to register itself and is assigned a unique client ID. The client address is mapped to the client ID by using the mapping data structure. A counter nextId is maintained to generate the ID of the next client. The NetworkManager contract is used to manage network participants and training result records in federated learning. The VerifySignature contract is used to provide the functions of generating, saving and verifying digital signatures.
[0051] Assume that all clients adopt the same time allocation strategy for local training and mining, that is, all clients start training at the same time and then switch to the mining phase at the same time. In this case, for each global model update and block generation, an integration round is defined - combining the communication round of federated learning and the mining round of blockchain. The steps of the block mining process and the k-th cycle of the blockchain layer are as follows:
[0052] 1) Local model verification and propagation: Each client performs local training by iterating the learning algorithm t times to update its own model ω i k , where i is the identifier of each client, and verifies and broadcasts the updated model - through the smart contract, each client signs its model with a digital signature and propagates the model as a transaction it requests.
[0053] 2) Block mining: a number of miners are selected through a consensus algorithm to select a miner with the right to mine the kth block. After receiving the models of other clients, all clients generate a global model, and then the selected miner mines the kth block. The consensus algorithm adopts the PoW consensus algorithm;
[0054] 3) Local model update. When the kth block passes the verification, all clients will append the new block to the local ledger. After receiving the verified transactions in this block, each client updates its local model, and then the system enters the k+1th cycle.
[0055] Beneficial effects of the present invention: Compared with the prior art, the effects of the present invention are as follows:
[0056] (1) A blockchain-based federated learning vehicle network data communication method Fast-CFLB (Fast-CarFederated Learning Blockchain) is proposed. This part replaces the central server in federated learning with blockchain, thereby solving the single point attack in traditional federated learning.
[0057] (2) Introducing federated differential privacy protection technology, which is used to defend against member reasoning attacks encountered in federated learning. It can not only ensure the privacy of each client's local data, but also ensure the information security between clients.
[0058] (3) Introducing model compression technology based on layer sensitivity, which can reduce the redundancy of model parameters during the training process when the training results are almost the same, and resist attackers from using global information inversion attacks to infer the original data, thereby improving the security and communication efficiency of the system;
[0059] (4) A ternary federated learning technology is proposed. This part starts with the training gradient and replaces the floating-point gradient in federated learning with the ternary gradient, thereby greatly improving the communication efficiency and reducing the communication cost, so as to further achieve the goal of low energy consumption and high efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 This is the overall structure diagram of the Internet of Vehicles;
[0061] Figure 2 is a graph of adjacent data sets;
[0062] Figure 3 It is a graph of user adjacent datasets;
[0063] Figure 4 This is a conceptual diagram of the Gaussian mechanism;
[0064] Figure 5 This is a diagram of the data sharing framework for the Internet of Vehicles;
[0065] Figure 6 is a ternary federated learning graph;
[0066] Figure 7 This is a diagram of the block mining process;
[0067] Figure 8 This is the structure diagram of the CNNSVHN model;
[0068] Fig. 9 This is a comparison chart of the accuracy of the federated differential privacy scheme and the traditional centralized differential privacy scheme;
[0069] Fig.10 Training accurate value graph for federated differential privacy own parameter pairs;
[0070] Fig.11 For three datasets (MNIST handwriting dataset, SVHN street view number dataset, Cifar10 object classification dataset), we compare the gradient size (after ternary conversion) uploaded by the client to the server and the gradient size map sent by the server to the client.
[0071] Fig.12 The training effect diagram of the model is to compare the stochastic gradient descent with ternary conversion and the ordinary stochastic gradient descent using the MNIST and SVHN datasets respectively;
[0072] Fig.13 The transmission ratio rate is 91%, 94%, 97%, and 100% respectively as experimental variables to observe the influence of changing the transmission layer parameters on the training effect;
[0073] Fig.14 Comparison of the convergence curves of the models with and without blockchain. DETAILED DESCRIPTION
[0074] The present invention is further described below in conjunction with specific embodiments.
[0075] The first thing to explain is: ternary gradient theory, federated differential privacy, and the full text symbol introduction is shown in Table 1.
[0076] Table 1 Symbols and their meanings
[0077]
[0078]
[0079] Example 1: Figure 1-14 As shown, the Internet of Vehicles architecture of the present invention is composed of a blockchain layer and an application layer. The blockchain layer includes on-chain mechanisms and off-chain mechanisms, and the application layer includes model training and updating, model aggregation and fusion, differential privacy protection, etc.
[0080] like Figure 5 As shown, the following is a detailed explanation and introduction of the architecture:
[0081] Local data: refers to the data received by the local vehicle during operation, such as motor operation data, camera shooting data, in-vehicle application data, user feedback data, etc. These local data are used for local training.
[0082] Local model: refers to the local model used by the local vehicle to train local data.
[0083] Gaussian noise: In the federated score privacy protection mechanism, in order to defend against member inference attacks, Gaussian noise is introduced so that attackers cannot infer personal sensitive information or specific sensitive attributes by analyzing or querying the data.
[0084] Edge nodes refer to edge nodes that are usually equipped with certain computing and communication resources. They also act as miners of the blockchain and participate in the consensus process.
[0085] Miners: Miners are edge nodes, and edge nodes select some of them as miners through a consensus algorithm to perform mining and broadcasting operations.
[0086] Verify Signing Smart Contract: This contract is used to generate and verify digital signatures and related information. The client can call the generate_verifications function to generate verification information and save it in the contract. Other users can then call the verifySignature function to verify that the passed in digital signature, key, timestamp, and client ID match the information saved in the contract.
[0087] The invention discloses a data privacy protection method for Internet of Vehicles based on blockchain and ternary federated learning. The method is as follows: in the application layer, the data requester first issues a task request. After receiving the task, the local vehicle will train the local model locally, and add Gaussian noise during training to prevent member inference attacks. After the training is completed, the original gradient is converted into a ternary gradient and uploaded to the server. The server aggregates the ternary gradient and returns the result to the client (each local vehicle). The user then delays the result to a floating point number and updates the model copy for subsequent training.
[0088] At the blockchain layer, edge nodes (RSUs) refer to edge nodes that are usually equipped with certain computing and communication resources. Due to their powerful computing, communication and storage capabilities, they can serve as blockchain miners. Verification values and local model updates are stored in data blocks by edge nodes (i.e., blockchain miners) verified by the consensus algorithm, and their local models are broadcast in the network through the P2P broadcast function in the blockchain, where the verification value is generated by a smart contract to verify the user's relevant information. Finally, the vehicle downloads the latest local model updates of all vehicles from the blockchain and aggregates the global model.
[0089] The Internet of Vehicles data privacy protection method based on blockchain and ternary federated learning includes the following specific steps:
[0090] Step 1: The requester (Roadside Unit) publishes a training task, that is, the requester sends the model to be trained and related parameters to the participants, requiring them to train the model on local data; this step is intended to encourage the participants to jointly train the model while protecting data privacy, thereby achieving global improvement of the model;
[0091] Step 2: Each vehicle or each participant uses its local data to train the model without sending the data to a central server. Each participant performs model training based on a local data set and updates its local model to adapt to its local environment. This distributed training method helps protect data privacy, reduce data transmission, and enables the model to better adapt to the specific circumstances of each participant.
[0092] Step 3: In the process of federated learning, in order to protect the data privacy of participants, a certain degree of Gaussian noise and the verification value generated for the local vehicle in the blockchain are added to the model update; this helps to increase data confusion during the model training process, making it difficult for attackers to infer the specific data information of individual participants, thereby protecting the privacy of the data;
[0093] Step 4: During the federated learning process, each participant will verify the model trained locally to ensure its performance and accuracy. If the model performs well in the local verification, the participant will choose to update it to the global model, thereby jointly improving the model effect of the entire system;
[0094] Step 5: After training the federated learning model, the training results are recorded on the blockchain to ensure the immutability and transparency of the data and prevent the data from being tampered with or stolen. At the same time, blockchain technology can also provide a distributed data storage and verification mechanism to further enhance data protection and security. This blockchain-based federated learning method provides an effective solution for data privacy protection in the Internet of Vehicles, which can improve the credibility and security of data while ensuring data privacy;
[0095] Step 6: In this step, the blockchain system will select some nodes from edge nodes (including roadside units, traffic signal controllers, surveillance cameras and sensors, smart street lights, on-board units, etc.) and vehicle nodes as miners to perform mining operations on the blockchain. The selection operation will follow the set consensus algorithm. These miner nodes are responsible for verifying transactions and packaging them into blocks to ensure the normal operation of the blockchain network. By selecting edge nodes as miners, distributed storage and processing of data can be achieved while protecting the privacy and security of data.
[0096] Step 7: After the selected miner performs the mining operation, it is first verified by the smart contract, and the verification value is written into the blockchain. The verified block is then broadcast through the P2P network, thus achieving the credibility of the transaction and the security of the network.
[0097] Step 8: In this step, the blockchain will aggregate the model updates collected from various participants into a global model, which will comprehensively consider the updates from various participants to obtain a more accurate and comprehensive model. Through the aggregation of model updates, the advantages of federated learning can be effectively utilized and the shortcomings of aggregating models on a central server can be overcome, that is, while protecting data privacy, the continuous optimization and improvement of the model can be achieved.
[0098] The local model adopts the ternary federated learning model. The ternary federated learning model introduces the TernGrad ternary gradient technology, which quantizes the previous gradient from floating point numbers into three discrete values: -1, 0, and +1, and introduces layered ternary valueization and gradient clipping technology. The layered ternary valueization divides the gradient into multiple levels, and quantizes and transmits them separately. The gradient clipping technology controls the size of the gradient.
[0099] In previous distributed training, the need to improve communication efficiency and high-cost network communication have become bottlenecks. To address this issue, the TernGrad ternary gradient technology is introduced to quantize the previous gradient from floating point numbers to three discrete values: -1, 0, and +1 to achieve gradient sparsity. This quantization method can significantly reduce the amount of communication, because only the discrete representation of the gradient needs to be transmitted instead of floating point numbers, thereby reducing the overhead of network transmission. For the convergence problem existing in the ternary gradient, hierarchical ternary valueization and gradient clipping techniques are introduced to improve its convergence. Hierarchical ternary valueization divides the gradient into multiple levels, and quantizes and transmits them separately, thereby improving the accuracy and efficiency of the gradient. The gradient clipping technology can control the size of the gradient to prevent it from being too large or too small, thereby further improving the convergence and stability of the model. By adopting the ternary federated learning technology, the communication overhead in distributed training can be effectively reduced, and the training efficiency and performance of the model can be improved. For ternary federated learning, its conceptual diagram is as follows Figure 6 The corresponding algorithm pseudo code is shown in Table 2.
[0100] Table 2 Algorithm pseudo code
[0101]
[0102] The training method of the ternary federated learning model is as follows:
[0103] Worker (client: vehicle node or edge node): i = 1, 2, ..., Ν
[0104] 1) Input A partial mini-batch of a training sample;
[0105] 2) Calculate The gradient below
[0106] 3) Gradient clipping
[0107] 4) The clipped gradient Layered and ternary:
[0108]
[0109] 5) Push ternary to the server;
[0110] 6) Pull the average gradient from the server
[0111] 7) Update parameters Server:
[0112] 8) Average ternary gradient:
[0113] The gradient clipping used is a common technique in optimization algorithms to limit the size of the gradient to avoid the problem of gradient explosion. The basic idea of gradient clipping is to set a threshold. When the norm of the gradient (that is, the length of the gradient) exceeds this threshold, the gradient is scaled to a specified range, thereby limiting the size of the gradient, as shown. This ensures the stability of the gradient update and prevents numerical overflow or instability caused by excessive gradients. Through gradient clipping, you can add restrictions to the gradient range.
[0114] To perform gradient clipping, you can use the pytorch library
[0115] torch.nn.utils.clip_grad_norm_(parameters,max_norm).
[0116] Hierarchical ternary is a technique that decomposes the gradient into multiple levels and quantizes and transmits each level separately. In this way, the accuracy and efficiency of the gradient can be improved.
[0117] In layer-wise ternaryization, the gradients in each layer are ternaryized independently using a layer-wise scaler. More specifically, the gradients of the bias and weight in each layer are ternaryized using Equation 1, respectively. Wherein, can represent the gradient of the bias or weight in each layer.
[0118] To get closer to the standard performance bound, the gradient can be divided into more buckets and each bucket is ternary processed independently. However, this will introduce more floating point scales and increase communication overhead. When the bucket size is 1, this method degenerates to floating point gradient processing.
[0119] Finally, the quantized gradients are transmitted to the server for further processing and updating.
[0120] TernGrad ternary gradient belongs to gradient quantization, and its gradient ternary is an orthogonal sparse method - gradient quantization refers to reducing the accuracy or representation of the gradient by mapping the gradient value to a finite discrete set. In this case, TernGrad quantizes the gradient value into three discrete values: -1, 0, and +1 to achieve gradient sparsity. Gradient ternary is often used to reduce the storage space and communication cost of the gradient, and helps improve the efficiency of model training. The method of converting the original gradient to the ternary gradient is:
[0121] Let the ternary conversion function be, and its quantized gradient is as follows:
[0122]
[0123] Among them, b t is a random binary vector, g t is the original gradient, s t For the scaler, is the Hadamard product, sign(·) is the sign of each element;
[0124] Zoomers t Using a shared scaling factor: Represents the scaler of the i-th gradient
[0125] For a given g t and b t , each element of which follows a Bernoulli distribution independently:
[0126]
[0127] Among them, b tk and g tk are randomly entered b t and g t The kth element in , after ternary conversion, the client will Replace the original gradient g t Upload to the server, and the server aggregates the ternary gradients and returns the result to the client.
[0128] Compared to 32-bit floating point numbers, two assumptions are made:
[0129] Assumption 1: Assume that the number of transmissions of each gradient value is proportional to its number of bits.
[0130] Assumption 2: Assume that there are N gradient values that need to be transmitted.
[0131] For 32-bit floating point numbers, each gradient value needs to be transmitted 32 bits. For ternary gradients, each gradient value only needs to be transmitted 2 bits. Therefore, in terms of the number of transmitted bits, the formula for the number of transmitted bits that will be reduced by the ternary gradient is:
[0132]
[0133] Since each gradient value has three possible values (-1, 0, 1), log23 can be used to represent the number of bits required for each gradient value when using 3-base encoding. Therefore, the total reduction ratio is:
[0134]
[0135] That is, even encoding the ternary gradient in 2 bits can still reduce the client-to-server traffic by 16 times.
[0136] When using the ternary gradient technique, the gradient will be represented as {-1,0,1}, which means that the gradient representation is more compact to reduce the amount of communication transmitted to the server. When the ternary gradient is uploaded from the client to the server, another problem may arise when the server aggregates it - the aggregation operation may cause the result to be represented no longer as three values, but as more possible levels. This problem is particularly prominent when the working nodes use different scaling factors. In order to minimize the number of levels, a solution of sharing scaling factors is proposed:
[0137]
[0138] We named this technique “scaler sharing”. The sharing process requires the transmission of an additional 2N floating-point scalers. By integrating parameter positioning and scaler sharing, the final average gradient The maximum level in is reduced to 2N+1. Therefore, the communication from the server to the worker node can be reduced by 32 / log2(1+2N) times, unless N≥2 30 .
[0139] Next, let’s analyze the convergence of TernGrad’s ternary gradient. The loss function Q(·) is used to measure the performance of the current system with parameters ω and input z, and the minimization goal is to reduce the expected value of the loss as much as possible:
[0140]
[0141] The parameter ω will be adjusted according to the learning rate γ t To update:
[0142] ω t+1 =ω t -γ t g t =ω t -γ t ▽ ω Q(z t ,ω t ) (3-8)
[0143]
[0144] Therefore, by combining Formula 3-1, Formula 3-6 and Formula 3-7, we can know that the parameter ω in TernGrad can be updated as:
[0145]
[0146] For a given z t ,ω t , Formula 3-3 can be equivalent to:
[0147]
[0148] In the randomly given ω t Under this condition, the expected value of the ternary gradient will satisfy the following formula:
[0149]
[0150] This formula is also the minimization objective in Formula 5 - the unbiased gradient.
[0151] For the convergence analysis of ternary gradient, two hypotheses are proposed here.
[0152] Assumption 3: Assume that C(ω) has a unique minimum value ω * , and the descending gradient Always point to ω * That is, for any positive number ∈>0, when ω is close enough to ω * When , it will satisfy:
[0153]
[0154] Among them, ||ω-ω * || represents ω and ω * The Euclidean norm between * ) T Represents the vector ω-ω * Transpose, Denote the gradient of C(ω) with respect to ω. Convexity is a subset of Assumption 3, and it is easy to find non-convex functions that satisfy it.
[0155] Assumption 4: Set the learning rate γ t is a positive number and is subject to the following formula:
[0156]
[0157] This constraint ensures that γ t The rate of descent is moderate.
[0158] Let parameter ω t With the minimum value ω * The square of the difference between is:
[0159]
[0160] Among them, ||·|| is Under assumptions 3 and 4, the following lemma can be obtained using the Lyapunov process and Quasi-Martingales convergence theory:
[0161] Lemma 1 If there exist positive constants A and B such that the following formula holds:
[0162]
[0163] Then the function C(z, ω) moves towards the minimum value ω * Convergence, that is A further assumption about the gradient can be made from this.
[0164] Assumption 5: Assume that the gradient g is constrained to be:
[0165] E{||g|| ∞ ||g||1}≤A+B||ω-ω * || 2 (3-17)
[0166] Among them, A and B are positive numbers, and ||·||1 is Therefore, by combining Assumption 5 and Lemma 1, we can prove the following Theorem 1.
[0167] Theorem 1 When the system uses ternary gradients and updates as follows:
[0168]
[0169] Its gradient will converge to the minimum value ω with a high probability * .
[0170] When the scalar s in formulas 1 and 3 t When is large, most gradients are likely to be ternaryized to 0, leaving only a few gradients with large magnitudes. This situation will lead to a serious parameter update mode - most parameters remain unchanged, while other parameters may be over-adjusted, which will introduce a large training variance. To solve this problem, the layer-by-layer ternaryization and gradient clipping method is introduced to convert each gradient g in g i The size limits are:
[0171]
[0172] Where σ is the standard deviation of the gradient in the gradient g, c is a hyperparameter, and c best =2.5.
[0173] Furthermore, the above-mentioned Internet of Vehicles data privacy protection method based on blockchain and ternary federated learning also includes data privacy protection methods on the client and server. The data privacy protection methods all adopt a federated differential privacy protection algorithm. When the federated differential privacy is trained locally on the client, it is necessary to trim the parameters after each local iteration; for the federated differential privacy on the server side, the client will be randomly selected according to probability and asked to perform local model training; and after receiving the model parameters of each client, the server will perform an aggregation operation. In terms of noise addition, the variance of the Gaussian noise distribution is obtained, and the Gaussian distribution is used to generate noise data, which is used to add noise data in the global model aggregation operation to obtain new global model parameters, and the steps are repeated until the model converges.
[0174] Compared with ordinary differential privacy, federated differential privacy protection requires not only the privacy security of each client's local data, but also the information security between clients. That is, when a user receives a local model from a client on the server, it cannot infer which client uploaded it, nor can it infer whether a client has participated in the current training. In the invention, a federated differential privacy protection algorithm is used on both the client and the server to resist member attack reasoning. The pseudo code of the client algorithm is shown in Table 3, and the pseudo code of the server algorithm is shown in Table 4.
[0175] Table 3 Pseudo code of client federated differential privacy algorithm
[0176]
[0177] When federated differential privacy is trained locally on the client, the parameters need to be trimmed after each local iteration. The role of this differential privacy algorithm on the client is to prevent attackers from inferring the information of the uploading client and the training client through the received local model.
[0178] Table 4 Pseudo code of server-side differential privacy algorithm
[0179]
[0180]
[0181] For federated differential privacy on the server side, clients are randomly selected by probability and asked to perform local model training; after receiving the model parameters of each client, the server performs the aggregation operation. In terms of noise addition, the variance of the Gaussian noise distribution is calculated, and the noise data is generated using the Gaussian distribution to add the noise data to the global model aggregation operation to obtain new global model parameters. The above steps are repeated until the model converges.
[0182] Compared with ordinary differential privacy mechanisms, federated differential privacy mechanisms not only need to consider privacy security at the data level, but also security issues at the user level.
[0183] Definition 1: Adjacent data sets: Suppose there are two data sets D and D′. If there is only one data difference between them, then the data is called an adjacent data set.
[0184] For the security issues at the user level, the concept of user adjacent data sets is proposed.
[0185] Definition 2 User Adjacent Dataset: Suppose there are n clients and for any 0≤i≤n, such that each client c i The corresponding local dataset is d i , D and D′ are two sets of user data if and only if D removes or adds a client c i The local dataset d i Then it becomes D′, and D and D′ are defined as user adjacent data sets.
[0186] Adjacent datasets such as Figure 2 As shown, the schematic diagram of the user adjacent data set is as follows Figure 3 shown.
[0187] Definition 3(∈,δ) - Differential Privacy: Assuming a Randomized Algorithm For two user adjacent datasets D and D′,
[0188] And any output If and only if the algorithm satisfies:
[0189]
[0190] The random algorithm M is said to provide (∈, δ) - Differential privacy protection. In the formula, ∈ represents the privacy budget and δ represents the failure probability.
[0191] definition Global sensitivity: For randomized algorithms As well as user adjacent datasets D and D′, the L2 global sensitivity is defined as follows:
[0192]
[0193] Definition 5 Gaussian mechanism: For a given data set D, there is a function f(·), whose sensitivity is set to Δf (Definition 4), for any:
[0194]
[0195] Then the random algorithm Provide (∈, δ)- Differential privacy protection, where L~Gaussian(0,σ 2 ) is the probability density function of the added random noise, that is, it obeys the parameter
[0196] The Gaussian distribution of is, and its probability distribution function is
[0197]
[0198] Gaussian mechanism concept diagram Figure 4 shown.
[0199] Federated learning and centralized training are essentially both based on deep learning to train models, so there is a problem with model parameters - model parameter redundancy. That is to say, in most deep network learning, using fewer weights can achieve the same effect of training global information. Therefore, model compression plays a role in reducing transmission overhead and improving system security.
[0200] The codes for layer sensitivity transmission are shown in Table 5 and Table 6.
[0201] Table 5 Part of the local training function
[0202]
[0203] By formula Calculate the change value of each layer before and after training and sort them. After modifying the client, you also need to perform aggregation operations on the server. Since the client uploads by layer, you also need to aggregate by layer when aggregating:
[0204] Table 6 Model aggregation functions
[0205]
[0206] Furthermore, when the client performs local training of federated learning, the model is compressed using a model compression method based on layer sensitivity. The layer sensitivity is: Let the current model be represented by G = {g1, g2, ..., g L}, in round t, client C j When performing federated learning local training, the model will be trained from G t =G becomes
[0207]
[0208] The change of the i-th layer is recorded as
[0209]
[0210] The mean change of each layer's parameters, δ, is called sensitivity. It refers to the mean of the parameter updates of the i-th layer after the t-th round of local training of federated learning.
[0211] How blockchain is combined with federated learning, starting from smart contracts and consensus mechanisms, explains the important role that blockchain plays in distributed systems.
[0212] Smart contracts are one of the core components of blockchain technology. They are code-based, automated contracts that can execute and manage transactions without the need for an intermediary. In federated learning, smart contracts can be used to achieve collaboration and data exchange between participants. Through smart contracts, participants can share model updates, verify data, and execute reward mechanisms in a secure and transparent manner, thereby facilitating the conduct of federated learning.
[0213] Smart contracts include clientManager contract, NetworkManager contract and VerifySignature contract, as shown in Table 7;
[0214] The clientManager contract is used to implement the client registration function. Each client calls the register function to register itself and is assigned a unique client ID. The client address is mapped to the client ID by using the mapping data structure. A counter nextId is maintained to generate the ID of the next client.
[0215] The NetworkManager contract is used to manage network participants and training result records in federated learning; the FLMeta structure in the NetworkManager contract is used to save the metadata information of federated learning; the TrainResult structure in the NetworkManager contract is used to record the training results of the client; the mapping data structure is used to map the client address to the corresponding training result; the fl_init function in the NetworkManager contract is used to initialize the metadata information of federated learning, including the number of participating clients, the number of training rounds, and the federated learning algorithm. Only the owner of the contract can call this function; the is_duplicate_client function in the NetworkManager contract is used to check whether the specified client has been registered; the client_regist function in the NetworkManager contract is used to allow the client to register itself and ensure that the client has not registered repeatedly; the upload_result function in the NetworkManager contract allows the client to upload the training results and only the client participating in federated learning can call this function;
[0216] The VerifySignature contract is used to provide the functions of generating, saving and verifying digital signatures. The Verify structure in the VerifySignature contract is used to save digital signature information, including signature, key, timestamp and client ID, where the mapping type can map the user address to the corresponding digital signature information; verifyBit and verificationThresho in the VerifySignature contract are used to specify the number of bits and verification threshold of the digital signature; the generate_verifications function in the VerifySignature contract is used to generate and save digital signature information; the getVerification function in the VerifySignature contract is used to obtain the digital signature information of the specified user; the verifySignature function in the VerifySignature contract is used to verify the validity of the digital signature.
[0217] Table 7 Smart contract functions
[0218]
[0219] Assume that all clients adopt the same time allocation strategy for local training and mining, that is, all clients start training at the same time and then switch to the mining phase at the same time. In this case, for each global model update and block generation, an integration round is defined, which combines the communication round of federated learning and the mining round of blockchain. The block mining process (such as Figure 7 As shown in Figure 2, the k-th cycle steps of the blockchain layer are as follows:
[0220] 1) Local model verification and propagation: Each client performs local training by iterating the learning algorithm t times to update its own model Where i is the identifier of each client, and the updated model is verified and broadcasted - through the smart contract, each client signs its model with a digital signature and propagates the model as the transaction it requested.
[0221] 2) Block mining: a number of miners are selected through a consensus algorithm to select a miner with the right to mine the kth block. After receiving the models of other clients, all clients generate a global model, and then the selected miner mines the kth block. The consensus algorithm adopts the PoW consensus algorithm;
[0222] 3) Local model update. When the kth block passes the verification, all clients will append the new block to the local ledger. After receiving the verified transactions in this block, each client updates its local model, and then the system enters the k+1th cycle.
[0223] When the system is performing global aggregation, no third party intervention is required, which makes single point failure attacks difficult to achieve, thereby improving data privacy protection performance. When selecting miners, the consensus algorithm used is PoW (Proof of Work), which is widely used in blockchain technology due to its high security, decentralization, fairness and anti-censorship. It is precisely because of the PoW consensus algorithm that the system can be truly decentralized, thereby ensuring the tamper-proof nature of model updates in a trusted blockchain network.
[0224] The PoW proof-of-work process consists of three steps:
[0225] Step 1 Generate Merkle root hash. In blockchain, generating Merkle root hash is an important step. It involves hashing all transactions according to the Merkle tree algorithm and finally generating a root hash. This root hash is included in the block header and becomes part of the proof of work. Therefore, generating Merkle root hash is one of the three elements of proof of work;
[0226] Step 2 Assemble the block header. The block header is one of the key components of the block, which contains information such as version number, hash value of the previous block, Merkle root hash, etc. In the proof of work, the block header will be used as an input parameter for the calculation output. Therefore, the generated Merkle root hash and other components of the block header are assembled into a complete block header for subsequent proof of work calculations;
[0227] Step 3 Calculate the output of the proof of work. The output of the proof of work is obtained by hashing the block header. Specifically, the output of the proof of work is the result of two SHA256 hash calculations on the block header. If this output is less than the set target value, then the workload is considered completed. If the output is greater than or equal to the target value, the random number in the block header needs to be adjusted and the hash calculation is performed again until the target value is reached. The calculation of the target value is usually explained in the difficulty value setting.
[0228] In order to illustrate the effect of the present invention, the following simulation experiment is carried out:
[0229] In the simulation training experiment, the model is built based on the PyTorch framework, and mainly uses the SVHN dataset (created by Google, the images are extracted from Google Street View images, and contain numbers of various styles, sizes, and directions. The numbers in the SVHN dataset are labeled by real humans, so they are of high quality and accuracy) to simulate the street view images captured by the vehicle while driving. The dataset contains 73,257 training images and 26,032 test images. It is a public dataset for digital recognition tasks, mainly used to recognize numbers in street view images. The main training model used in the experiment is CNN - three convolutional layers, three maximum pooling layers, and two fully connected layers, such as Figure 8 shown.
[0230] In this experiment, the number of vehicles (clients) is set to 100, batch_size is set to 32, learning rate is 0.01, local training rounds are 20 rounds, global training rounds are 20 rounds, and weight_decay is set to 0.001.
[0231] Federated differential privacy mechanism: The model of the present invention uses a differential privacy scheme, that is, noise is added before the vehicle node uploads the local model update. In order to protect the privacy of data sharing, Gaussian noise is selected. However, unlike the traditional centralized differential privacy scheme, the present invention adopts federal differential privacy protection. Compared with the traditional centralized differential privacy scheme, this scheme needs to trim the parameters after each local iterative update, and then perform local model training in the randomly selected client and upload the training model parameters to the server, perform aggregation operations, and then add noise data in the global model aggregation process to obtain new global model parameters.
[0232] exist Fig. 9 In ((a) σ=0.003; (b) σ=0.005), the federated differential privacy scheme proposed in the present invention is compared with the traditional centralized differential privacy scheme. By comparing different Gaussian noise distribution variances σ (here σ=0.003 and σ=0.005 are selected), the impact of the change of σ on the accuracy and the advantages of the federated differential privacy scheme are obtained. The learning rate is set to 0.001 during training, and the batch size is set to 32. The experimental data set is randomly divided and assigned to each vehicle node as a local data set. By observing the accuracy under different variances in Figures (a) and (b), it can be intuitively seen that the accuracy of the federated differential privacy scheme proposed in the present invention is closer to the accuracy of the non-privacy protection scheme than the traditional centralized differential privacy scheme.
[0233] In addition, the influence of the parameters of federated differential privacy on the training accuracy is also explored. In the Federated Differential Privacy Algorithm - Server Part (step 4.4 in algorithm code 3), it is mentioned that: t The values are clipped:
[0234]
[0235] Here C refers to the clipping boundary value, so we will measure the corresponding training accuracy by adjusting different clipping boundary values, so as to observe the impact of the federated differential privacy parameters on the training accuracy. Fig.10 It can be seen intuitively that the accuracy is basically stable when C>1. Among the five sets of measured data, C=9 has the best effect during training, and C=1 has the worst effect. Therefore, it is more appropriate to take C>1 as the clipping boundary value in subsequent experiments.
[0236] Ternary federated learning test: According to the ternary gradient theory, the gradient after the ternary conversion function is For the original 32-bit floating point number, the ternary gradient will be 16× lower than the original gradient. Therefore, in this section, three datasets (MNIST handwriting dataset, SVHN street view number dataset, Cifar10 object classification dataset) will be used to compare the gradient size uploaded by the client to the server (after ternary conversion) and the gradient size sent by the server to the client (after decompression). Fig.11 The reduction factor is shown in Table 8. It can be seen that under different data sets, the reduction factor of the ternary gradient is about 16×. Therefore, the application of ternary gradient in federated learning can greatly reduce the transmission amount of model parameters, thereby reducing the communication bandwidth to reduce the communication cost.
[0237] Table 8 Gradient reduction multiples for different data sets
[0238]
[0239] After comparing the amount of model parameter transfer between ternary gradients and ordinary floating-point numbers, the next step is to compare the model training effect of stochastic gradient descent with ternary conversion and ordinary stochastic gradient descent. The MNIST and SVHN datasets are used for comparison. The results are as follows: Fig.12 As shown, Fig.12 (a)(b) shows the loss and accuracy of the MNSIT dataset training data set; (c)(d) shows the loss and accuracy of the SVHN dataset training data set.
[0240] In the training, the learning rate is set to 0.005, the number of training rounds is 20, 20 clients (here refers to the vehicle edge nodes) are selected for training in each round, the number of local training rounds is 3, and the batch size is set to 32. As can be seen from the figure, in the training process of the MNIST dataset and the SVHN dataset, TernarySGD has a higher initial accuracy value and a lower initial loss value than ordinary SGD (stochastic gradient descent), and can reach the accuracy value stable state faster in subsequent rounds. Although the accuracy value tends to decrease slightly in the later rounds, it does not affect the overall accuracy value trend. Therefore, during the training process, the ternary gradient stochastic gradient descent has better communication efficiency while still not affecting the overall training effect.
[0241] Model compression verification based on layer sensitivity transfer
[0242] The implementation process of layer-based sensitivity model compression is as follows: for any selected client c j After the local model training is completed, according to the formula Calculate the change of each layer of the model The change amount of each layer is sorted from small to large. The larger the change, the more sensitive the layer. The algorithm will upload the layer with the highest sensitivity, and the layer with low sensitivity will not be uploaded. Therefore, in this experiment, the transmission rate is taken as 91%, 94%, 97%, and 100% as experimental variables to observe the impact of changing the transmission layer parameters on the training effect.
[0243] Fig.13 Compression curves of the medium model: the orange line represents the uncompressed transmission; the blue line represents the curve of the top 97% layers sorted by change magnitude before transmission; the red line represents the curve of the top 94% layers sorted by change magnitude before transmission; the black line represents the curve of the top 91% layers sorted by change magnitude before transmission.
[0244] exist Fig.13 It can be seen intuitively that when the transmission is not compressed, the training effect is the best. Although the accuracy of other compressed transmission layers is slightly lower, it does not affect the overall trend, and its accuracy is similar to that of the original network.
[0245] Blockchain and Federated Learning Verification: In this invention, the effectiveness of the blockchain scheme is evaluated by observing the loss of the model with and without blockchain.
[0246] from Fig.14It can be intuitively seen that the model without blockchain converges faster than the model with blockchain. This is because the model without blockchain uses a centralized server, so it does not need to complete the model aggregation step, which will reduce the convergence speed. However, the values of the two schemes are roughly the same. In addition, by establishing a consortium blockchain, the model gets rid of the dependence on the central node, can resist single point failure attacks, and has higher security when the performance is equivalent.
[0247] Summary of simulation experiments: This invention proposes a data sharing model for the Internet of Vehicles that combines ternary federated learning with blockchain. In order to further solve the problem of member reasoning attacks that federated learning may suffer, a federated learning scheme based on federated differential privacy is proposed. The experimental results show that this scheme has better performance than the traditional centralized differential privacy federated learning scheme. In addition, the model compression function based on layer sensitivity is added to model training, which can improve system security while reducing transmission overhead. In addition, in order to resist single point failure attacks and fake clients, the local model update verification is incorporated into the blockchain consensus process, which can effectively improve the security of the model. In order to solve the problem of high communication cost and low communication efficiency caused by the combination of blockchain and federated learning, ternary gradients are combined with federated learning to propose ternary federated learning. Starting from the training gradient, while ensuring training accuracy, the communication cost is greatly reduced and the communication efficiency is improved.
[0248] Therefore, the advantages of the model of the present invention are shown in Table 9.
[0249] Table 9 Comparison of the effects of blockchain-based and federated learning algorithms with other algorithms
[0250]
[0251] Reference [4]: Chen, Y., Li, J., Wang, F., Yue, K., Li, Y., Xing, B., ... & Chen, L. (2021). DS2PM: A privacy-preserving data sharing model based on blockchain and federated learning. IEEE Internet of Things Journal, 10(14), 12112-12125.
[0252] Reference [6]: Chen, H., Asif, S. A., Park, J., Shen, C. C., & Bennis, M. (2021). Robust blockchain federated learning using model verification and proof-of-stake inspired consensus. arXiv preprint arXiv:2101.03300.
[0253] Reference [7]: Li, J., Shao, Y., Wei, K., Ding, M., Ma, C., Shi, L., ... & Poor, H. V. (2021). Blockchain-assisted decentralized federated learning (BLADE-FL): performance analysis and resource allocation. IEEE Transactions on Parallel and Distributed Systems, 33(10), 2401-2415.
[0254] Reference [8]: Che, C., Li, X., Chen, C., He, X., & Zheng, Z. (2022). Establishing a decentralized federated learning framework via a committee mechanism with convergence guarantees. IEEE Transactions on Parallel and Distributed Systems, 33(12), 4783-4800.
[0255] Reference
[11] : McMahan, HB, Ramage, D., Talwar, K., & Zhang, L. (2017). Learning differentiable private recursive language models. arXiv preprint arXiv:1710.06963.
[0256] Reference
[15] : Huang, X., Xu, C., Wang, P., & Liu, H. (2018). LNSC: Electric vehicle and charging pile management security model based on blockchain ecosystem. IEEE access, 6, 13565-13574.
[0257] Reference
[16] : Hatim, S. M., Elias, S. J., Ali, R. M., Jasmis, J., Aziz, A. A., & Mansor, S. (2020, December). Blockchain-based Internet of Vehicles (biov): An approach to smart city development. 2020 5th IEEE International Conference on Recent Advances and Innovations in Engineering (ICRAIE) (pp. 1-4). IEEE.
[0258] Reference
[22] : Kim, H., Park, J., Bennis, M., & Kim, SL (2019). Federated learning of blockchain devices. IEEE Communications Letters, 24(6), 1279-1283.
[0259] References
[24] Wen, W., Xu, C., Yan, F., Wu, C., Wang, Y., Chen, Y., & Li, H. (2017). Terngrad: Ternary gradients for reduced communication in distributed deep learning. Advances in Neural Information Processing Systems, 30.
[0260] References
[45] Dong, Y., Chen, X., Shen, L., & Wang, D. (2020). Eastfly: Efficient and secure ternary joint learning. Computers and Security, 94, 101824.
[0261] In summary, the Internet of Vehicles technology based on federated learning in this invention plays an important role in solving data privacy security compared to centralized training. However, the single point failure attacks, member reasoning attacks, privacy issues and communication costs caused by this still need to be further improved. This paper adopts federated differential privacy protection to defend against member reasoning attacks, and combines blockchain technology to solve the single point failure problem; the ternary gradient technology and model compression are introduced to further reduce communication costs. In the differential privacy experiment, by comparing different Gaussian noise distribution variances σ, we concluded that compared with traditional differential privacy protection, federated score privacy protection is closer to the accuracy of the non-privacy protection scheme, and the effect is best when C ≥ 2; in the ternary gradient experiment, we measured that the training gradients of the three data sets were reduced by 14.99×, 15.54×, and 15.97×, respectively, indicating that the ternary gradient can better reduce the communication cost; in the layer sensitivity experiment, we measured that the accuracy when top = 97%, 94%, and 91% is almost the same as the accuracy when top = 100% (uncompressed); in the blockchain experiment, we measured that since the blockchain needs to complete model aggregation, although the convergence speed of the model without blockchain is faster than that of the model with blockchain, the training effect and overall trend are roughly the same.
Claims
1. A data privacy protection method for Internet of Vehicles based on blockchain and ternary federated learning, characterized by: The method is as follows: in the application layer, the data requester first publishes a task request. After receiving the task, the local vehicle will train the local model locally, add Gaussian noise during training, and after the training is completed, convert the original gradient into a ternary gradient and upload it to the server. The server aggregates the ternary gradient and returns the result to the client. Then the user delays the result into a floating point number and updates the model copy for subsequent training. At the blockchain layer, edge nodes act as blockchain miners. Verification values and local model updates are stored in data blocks by edge nodes after verification by the consensus algorithm. Local models are broadcast in the network through the P2P broadcast function in the blockchain, where verification values are generated by smart contracts to verify user-related information. Finally, vehicles download the latest local model updates of all vehicles from the blockchain and aggregate the global model.
2. The method for protecting data privacy in Internet of Vehicles based on blockchain and ternary federated learning according to claim 1 is characterized by: The method comprises the following specific steps: Step 1: The requester publishes the training task, that is, the requester sends the model to be trained and related parameters to the participants, requiring them to perform model training on local data; Step 2: Each vehicle or each participant uses its local data to train the model. Each participant performs model training based on the local data set and updates its local model to adapt to its local environment. Step 3: During the federated learning process, add Gaussian noise and the verification value generated for the local vehicle in the blockchain to the model update; Step 4: During the federated learning process, each participant will verify the model trained locally. If the model performs well in the local verification, the participant will choose to update it to the global model. Step 5: After training the federated learning model, the training results are recorded on the blockchain. At the same time, blockchain technology also provides a distributed data storage and verification mechanism; Step 6: In this step, the blockchain system will select some nodes from the edge nodes and vehicle nodes as miners to perform mining operations on the blockchain. The selection operation will follow the set consensus algorithm. These miner nodes are responsible for verifying transactions and packaging them into blocks; Step 7: After the selected miner performs the mining operation, it will first be verified by the smart contract, and the verification value will be written into the blockchain. The verified block will then be broadcasted through the P2P network. Step 8. In this step, the blockchain will aggregate the model updates collected from various participants into a global model. This global model will comprehensively consider the updates from various participants, that is, while protecting data privacy, it will achieve continuous optimization and improvement of the model.
3. The method for protecting data privacy in Internet of Vehicles based on blockchain and ternary federated learning according to claim 1 is characterized in that: The local model adopts the ternary federated learning model. The ternary federated learning model introduces the TernGrad ternary gradient technology, which quantizes the previous gradient from floating point numbers into three discrete values: -1, 0, and +1, and introduces layered ternary valueization and gradient clipping technology. The layered ternary valueization divides the gradient into multiple levels, and quantizes and transmits them separately. The gradient clipping technology controls the size of the gradient.
4. The method for protecting data privacy in Internet of Vehicles based on blockchain and ternary federated learning according to claim 3 is characterized by: The training method of the ternary federated learning model is as follows: Client: i = 1, 2, ..., N 1) Input A partial mini-batch of a training sample; 2) Calculate The gradient below 3) Gradient clipping 4) The clipped gradient Layered and ternary: 5) Push ternary to the server; 6) Pull the average gradient from the server 7) Update parameters where ω t+1 and ω t are the parameter weights at time points t+1 and t respectively; η is the learning rate Server side: 8) Average ternary gradient:
5. The method for protecting data privacy in Internet of Vehicles based on blockchain and ternary federated learning according to claim 4 is characterized in that: The method of converting the original gradient into a ternary gradient is: Let the ternary conversion function be, and its quantized gradient is as follows: Among them, b t is a random binary vector, g t is the original gradient, s t For the zoomer, is the Hadamard product, sign(·) is the sign of each element; Zoomers t Using a shared scaling factor: represents the scaler of the i-th gradient; For a given g t and b t , each element of which follows a Bernoulli distribution independently: Among them, b tk and g tk are randomly entered b t and g t The kth element in g is converted by the client after ternary conversion. t Replace the original gradient g t Upload to the server, and the server aggregates the ternary gradients and returns the result to the client.
6. The method for protecting data privacy in Internet of Vehicles based on blockchain and ternary federated learning according to claim 2 is characterized in that: Introducing the layer-by-layer ternary and gradient clipping method, each gradient g in g i The size limits are: Where σ is the standard deviation of the gradient in the gradient g, and c is a hyperparameter.
7. The method for protecting data privacy in Internet of Vehicles based on blockchain and ternary federated learning according to claim 2 is characterized in that: It also includes data privacy protection methods on the client and server. The data privacy protection methods all use the federated differential privacy protection algorithm. When the federated differential privacy is trained locally on the client, the parameters need to be trimmed after each local iteration. For federated differential privacy on the server side, clients are randomly selected by probability and asked to perform local model training. After receiving the model parameters from each client, the server performs aggregation operations. In terms of noise addition, the variance of the Gaussian noise distribution is calculated, and noise data is generated using the Gaussian distribution. The noise data is then added to the global model aggregation operation to obtain new global model parameters. The steps are repeated until the model converges.
8. The method for protecting data privacy in Internet of Vehicles based on blockchain and ternary federated learning according to claim 2 is characterized in that: When the client performs local training of federated learning, the model is compressed using a model compression method based on layer sensitivity. The layer sensitivity is: Let the current model be represented as G = {g1, g2, ..., g L }, in round t, client C j When performing federated learning local training, the model will be trained from G t =G becomes The change of the i-th layer is recorded as The change in the mean parameter value of each layer is called sensitivity. It refers to the mean of the parameter updates of the i-th layer after the t-th round of local training of federated learning.
9. The method for protecting data privacy in Internet of Vehicles based on blockchain and ternary federated learning according to claim 2 is characterized in that: Smart contracts include clientManager contract, NetworkManager contract and VerifySignature contract; Among them, the clientManager contract is used to implement the client registration function. Each client calls the register function to register itself and is assigned a unique client ID. The client address is mapped to the client ID by using the mapping data structure. A counter nextId is maintained to generate the ID of the next client. The NetworkManager contract is used to manage network participants and training result records in federated learning. The VerifySignature contract is used to provide the functions of generating, saving and verifying digital signatures.
10. The method for protecting data privacy in Internet of Vehicles based on blockchain and ternary federated learning according to claim 2 is characterized in that: Assume that all clients adopt the same time allocation strategy for local training and mining, that is, all clients start training at the same time and then switch to the mining phase at the same time. In this case, for each global model update and block generation, an integration round is defined - combining the communication round of federated learning and the mining round of blockchain. The steps of the block mining process and the k-th cycle of the blockchain layer are as follows: 1) Local model verification and propagation: Each client performs local training by iterating the learning algorithm t times to update its own model Where i is the identifier of each client, and the updated model is verified and broadcasted - through the smart contract, each client signs its model with a digital signature and propagates the model as the transaction it requested. 2) Block mining: a number of miners are selected through a consensus algorithm to select a miner with the right to mine the kth block. After receiving the models of other clients, all clients generate a global model, and then the selected miner mines the kth block. The consensus algorithm adopts the PoW consensus algorithm; 3) Local model update. When the kth block passes the verification, all clients will append the new block to the local ledger. After receiving the verified transactions in this block, each client updates its local model, and then the system enters the k+1th cycle.
Citation Information
Patent Citations
Federated learning lower edge end collaborative channel adaptability gradient compression method
CN113098806A
Federal learning model compression method based on model rarefaction and weight quantization
CN113222179A
Systems and Methods for Providing a Modified Loss Function in Federated-Split Learning
US20220029971A1
Cited By
Power grid segmentation learning method and system based on V2G network
CN119887188A
Federal learning privacy protection method, electronic equipment and storage medium
CN120074882A
Self-adaptive privacy protection personalized federal learning method for data isomerism
CN122310586A
A data-heterogeneous-oriented adaptive privacy protection personalized federated learning method
CN122310586B
