A distributed training method for traffic recommendation system based on federated learning
By adopting a distributed training method based on federated learning in the Internet of Vehicles scenario, analyzing the label and feature distribution of vehicle data, selecting collaborators and calculating adaptive aggregation weights, the problem of global loss function convergence caused by data heterogeneity in the Internet of Vehicles scenario is solved, and high-precision and low-latency traffic recommendation system training is achieved.
Patent Information
- Application Number
- CN202411566650.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2044-11-05
AI Technical Summary
In the Internet of Vehicles scenario, the non-independent homogeneity of vehicle data leads to difficulty in converging global loss functions, and the existing federated learning methods have latency and accuracy problems when dealing with data heterogeneity.
A distributed training method for traffic recommendation system based on federated learning is proposed. Through the end-edge collaboration network of vehicle systems, Shannon entropy and sparseness vectors are used to analyze the label and feature distribution of vehicle data, select collaborators with similar data distributions, and calculate adaptive aggregation weights for model aggregation and training.
It improves the training accuracy of the traffic recommendation system, reduces training delay, and realizes fast, high-precision and personalized recommendation services in the Internet of Vehicles scenarios, improving user travel experience and efficiency.
Smart Images

Figure CN119067202B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a distributed training method for a traffic recommendation system based on federated learning, and belongs to the technical field of edge computing. Background Art
[0002] The Internet of Vehicles has realized "vehicle-to-everything" (V2X) communication, which has completely changed the automotive industry, enabling vehicles to analyze the traffic environment and provide a large number of related intelligent services (such as obstacle recognition, traffic flow prediction, and traffic recommendation system). The traffic recommendation system aims to provide passengers and drivers with personalized content, including music, videos, and the best driving routes, to enhance the user's travel experience and ensure the safety of drivers and passengers.
[0003] Traditional recommendation systems based on collaborative filtering have difficulty making accurate recommendations when input data is sparse. This means that recommendation systems based on collaborative filtering are not suitable for application in Internet of Vehicles scenarios, where service providers need to provide accurate recommendation services under any circumstances. Considering the excellent learning ability of deep learning models in various fields, they provide a feasible solution for traffic recommendation systems. In order to provide enough data for model training and ensure learning results, the traditional method is to train the model using a large number of data samples from different users on a central server. However, the central server is not always trustworthy and may be subject to external attacks. In addition, exposing the user's original data for a long time during transmission may also lead to privacy leakage.
[0004] Federated learning is a feasible solution to the above privacy issues. In the process of federated learning, each user only uses local data to train his own local deep learning model, and only the gradient or parameters of the model are shared for global aggregation. Subsequently, the parameters obtained by global aggregation are sent to each user for local update. Therefore, federated learning not only effectively protects user privacy by avoiding sharing sensitive raw data, but also ensures model training performance through global aggregation. From this point of view, the training framework based on federated learning is very suitable for privacy-oriented traffic recommendation systems.
[0005] However, the data of vehicles in actual IoV scenarios are usually non-IID (heterogeneous). Due to the heterogeneity of data on different vehicles, the local gradient update direction on each vehicle is different in each round of global update, which seriously hinders the convergence of the global loss function. In addition, federated learning is an iterative process that causes a lot of delays, thereby reducing the quality of IoV intelligent services. In scenarios where data is not independent and identically distributed, most existing federated learning studies focus only on one of the label distribution bias and feature distribution bias, without considering that these two types of data heterogeneity may occur at the same time. In addition, for research on federated learning acceleration, existing work mainly focuses on reducing communication overhead, while with the rapid development of communication technology, transmission delay will be greatly reduced in the future. Therefore, shortening the local update time while ensuring learning accuracy is a more important and urgent optimization direction. Summary of the invention
[0006] Objective: In view of at least one of the above technical problems, the present invention provides a distributed training method for a traffic recommendation system based on federated learning, which fully considers the label and feature distribution of local data of different users in the Internet of Vehicles scenario, improves the training accuracy of the traffic recommendation system, and reduces the training delay of the traffic recommendation system.
[0007] Technical solution: To solve the above technical problems, the technical solution adopted by the present invention is:
[0008] In a first aspect, the present invention provides a distributed training method for a traffic recommendation system based on federated learning, comprising:
[0009] Based on the end-to-edge collaborative Internet of Vehicles system consisting of vehicles and edge servers with heterogeneous data samples, each edge server corresponds to each preset area one by one. For the deep learning model training task corresponding to the traffic recommendation system on each vehicle in the preset area, the end-to-edge collaborative Internet of Vehicles system performs the following steps:
[0010] Step A: For each vehicle, use Shannon entropy to generate the label distribution of local data samples on the vehicle, use the local data samples on the vehicle to perform local training on the initial local model, obtain the local model parameters obtained after training and all feature maps output by the last convolutional layer of the local model; use the sparsity vector to generate the feature distribution of the local data samples on the vehicle according to the feature map; and upload the label distribution, feature distribution and local model parameters of the local data samples on the vehicle to the corresponding edge server;
[0011] Step B: The edge server obtains the label distribution and feature distribution of the local data samples on each vehicle in the corresponding area, selects a collaborator for each vehicle based on the similarity of the label distribution and feature distribution of the local data samples on each vehicle, and sends the latest local model parameters of the collaborator in the current global update to the corresponding vehicle;
[0012] Step C: For each vehicle, obtain the latest local model parameters of the collaborators in the current global update, calculate the aggregation weight of each collaborator, aggregate the local model parameters of the vehicle, the latest local model parameters of all collaborators and the aggregation weight to obtain the globally updated local model parameters, and use the local data samples on the vehicle to perform local training on the globally updated local model, obtain the local model parameters obtained after training and all feature maps output by the last convolutional layer of the local model, and generate the feature distribution of the local data samples on the vehicle using the sparsity vector according to the feature map; and upload the feature distribution of the local data samples on the vehicle and the local model parameters to the edge server for updating;
[0013] Step D: Repeat steps B to C until the global loss function converges.
[0014] In some embodiments, in step A, using Shannon entropy to generate a label distribution of local data samples on the vehicle includes:
[0015] For the preset area Vehicles ,vehicle The number of local data samples is , the number of categories involved in the sample is , belongs to The number of samples in each category is , according to Shannon entropy, the label distribution of local data samples on the vehicle for:
[0016] .
[0017] In some embodiments, in step A and step C, generating a feature distribution of local data samples on the vehicle using a sparsity vector according to the feature map includes:
[0018] For vehicles The feature map output by the last convolutional layer of the local model in , Represents all feature maps The sum of the number of 0 elements in the channels, represents the sum of all elements in the 𝑘th channel of all feature maps, then the The sparsity of the channels is expressed as ; According to the sparsity of each channel in the feature map, construct the vehicle The sparsity vector of vehicle Feature distribution of local data samples :
[0019] ;
[0020] In the formula, Represents the number of channels for each feature.
[0021] In some embodiments, in step B, selecting a collaborator for each vehicle based on similarity of label distribution and similarity of feature distribution of local data samples on each vehicle includes:
[0022] Based on the similarity of the label distribution of the local data samples on each vehicle, preliminary collaborators are screened for each vehicle from all vehicles in the corresponding area;
[0023] At the initial stage of each round of global update, a cooperator is selected for each vehicle from the preliminary cooperators based on the similarity of the feature distributions of the local data samples on each vehicle.
[0024] In some embodiments, based on the similarity of the label distribution of the local data samples on each vehicle, preliminary collaborators are screened for each vehicle from all vehicles in the corresponding area, including:
[0025] For vehicles , based on the following formula from the vehicle Initial collaborators are selected from all vehicles in the corresponding area:
[0026] ;
[0027] In the formula, is the first threshold, , Respectively represent , The label distribution of local data samples on vehicles, .
[0028] In some embodiments, at the initial stage of each round of global update, a collaborator is selected for each vehicle from preliminary collaborators based on the similarity of feature distributions of local data samples on each vehicle, including:
[0029] For vehicles , the final collaborators are selected from the preliminary collaborators based on the following formula:
[0030] ;
[0031] In the formula, is the second threshold, , represents the Euclidean distance, , Respectively represent , Feature distribution of local data samples on each vehicle.
[0032] In some embodiments, in step C, the local model parameters after global update are obtained by aggregating the local model parameters of the vehicle, the latest local model parameters of all collaborators in the current global update, and the aggregation weight, including:
[0033] For vehicles , in In the round of global update, the aggregation formula of local model parameters is:
[0034] ;
[0035] In the formula, For vehicles In the The local model parameters after the global update, For vehicles In the The local model parameters before the global update, For Collaborators In the The local model parameters before the global update, For vehicles In the The number of collaborators in a round of global updates, For the Global update of vehicles Collaborators The corresponding aggregation weight; It is a vehicle In the The loss obtained by using local data samples for prediction in the global update round; Is a collaborator In the Using vehicles in global updates The loss obtained by making predictions on local data samples.
[0036] In some embodiments, in step C, calculating the aggregate weight of each collaborator includes:
[0037] The vehicle is calculated using the approximate calculation formula of the aggregation weight The aggregate weights corresponding to all collaborators of The aggregation weights corresponding to all collaborators are normalized as the final aggregation weights corresponding to each collaborator; the approximate calculation formula for the aggregation weight is:
[0038] ;
[0039] In the formula, is the calculated aggregate weight before normalization, is the learning rate for global updates, It is a vehicle In the The loss obtained by using local data samples for prediction in the global update round; Is a collaborator In the Using vehicles in global updates The loss obtained by predicting the local data samples, For vehicles In the The number of collaborators in a round of global updates, For vehicles In the The local model parameters before the global update, For vehicles In the The loss obtained by using local data samples for prediction in the global update round;
[0040] ;
[0041] In the formula, For the Global update of vehicles Collaborators The corresponding aggregation weight; It means that if the value of the aggregation weight is negative, the local model parameters of the corresponding partner will not participate in this aggregation.
[0042] In some embodiments, in step C, locally training the globally updated local model using local data samples on the vehicle includes:
[0043] The loss function of local training is: Use cross entropy loss;
[0044] L i t ' =- 1 Q ∑ q=1 Q [ y q log y ̂ q +(1- y q ) log (1- y ̂ q ) ] ;
[0045] In the formula, is the number of samples in each batch, and They are respectively The real label and predicted label of each sample. During the training process, the small batch gradient descent method is used to update the local model parameters:
[0046] ;
[0047] In the formula vehicle In the The local model parameters after rounds of local training are In the Local model parameters before the global update; For vehicles In the The local model parameters after the global update, is the learning rate for local training, Indicates vehicle In the The loss of the local training round For Vehicles In the Local model parameters after global update The partial derivative of .
[0048] In some embodiments, in step D, the global loss function for:
[0049] ;
[0050] In the formula, Represents the total number of data samples on all vehicles in the preset area, is the total number of vehicles, For vehicles The number of local data samples, For vehicles In the The local model parameters after the global update, Indicates vehicle In the The loss for the local training round.
[0051] Beneficial effects: The distributed training method of the traffic recommendation system based on federated learning provided by the present invention proposes a federated learning algorithm named FedRS. FedRS provides efficient and personalized recommendation services for each vehicle based on adaptive local aggregation. The core idea is to analyze the data distribution of each vehicle and select collaborators with similar data distribution for each vehicle; for each vehicle, the model aggregation weight corresponding to each collaborator is calculated, and the local model aggregation and training tasks are performed. The entire algorithm has the characteristics of user privacy protection, real-time analysis of data distribution characteristics, personalized local aggregation, and rapid convergence of global losses. It can meet the needs of fast, high-precision, and personalized training of recommendation systems in vehicle networking scenarios where data is not independent and identically distributed, and realize safe, efficient, and personalized recommendation services for vehicle networking scenarios, thereby improving the user's travel experience and efficiency. In addition, the present invention designs corresponding analysis methods for the label distribution and feature distribution of data samples, respectively. Through this method, the similarity of the label distribution and feature distribution of data samples on different vehicles can be effectively calculated, and then the collaborators can be screened for each vehicle in a targeted manner, thereby avoiding a single global model and promoting the personalization of services for different users in vehicle networking scenarios. At the same time, the present invention derives a universal approximate calculation formula for aggregation weights for the rapid calculation of aggregation weights. In each round of global update, each vehicle directly and adaptively calculates the aggregation weights of the model parameters of each collaborator based on this formula, thereby reducing local calculation delays while ensuring personalization. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 This is a schematic diagram of an application scenario of a distributed training method for a traffic recommendation system based on federated learning according to an embodiment of the present invention. DETAILED DESCRIPTION
[0053] The present invention will be further described below in conjunction with the accompanying drawings and embodiments. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the protection scope of the present invention.
[0054] In the description of the present invention, "several" means more than one, "many" means more than two, "greater than", "less than", "exceed", etc. are understood to exclude the number itself, and "above", "below", "within", etc. are understood to include the number itself. If there is a description of "first" or "second", it is only used for the purpose of distinguishing the technical features, and cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.
[0055] In the description of the present invention, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0056] The present invention proposes a distributed training method for a traffic recommendation system based on federated learning, that is, a personalized federated learning framework for recommendation systems in Internet of Vehicles scenarios, named FedRS. Like most personalized federated learning algorithms, FedRS can adapt well to scenarios where data is not independent and identically distributed, and its advantage is that it more fully considers the heterogeneity of different types of data, promoting personalization and global loss convergence. In addition, the present invention derives a general approximate calculation formula for aggregation weights for the rapid calculation of aggregation weights. In each round of global updates, each vehicle directly and adaptively calculates the aggregation weights of the model parameters of each collaborator according to the formula, thereby reducing local computing delays while ensuring personalization. It is suitable for Internet of Vehicles scenarios with local data heterogeneity and high user mobility, and can achieve safe, efficient, and personalized recommendation services for Internet of Vehicles scenarios, improving user travel experience and efficiency.
[0057] First, a federated learning model of the traffic recommendation system in the end-edge collaborative Internet of Vehicles scenario is given.
[0058] like Figure 1 As shown, in the Internet of Vehicles scenario, an edge server is set up in the target area, using a collection represents the set of vehicles in the area corresponding to the edge server, is the total number of vehicles. The data on the vehicles are non-independent and identically distributed. When each vehicle trains the deep learning model locally, it generates its local data distribution information (including label distribution and feature distribution) and uploads it to the edge server together with the deep learning model parameters at the beginning of the first round of global update. The edge server then searches for collaborators with similar data distribution for each vehicle and sends the latest model parameters of these collaborators to the vehicle. After receiving the model parameters of the collaborators, each vehicle performs adaptive model aggregation and model training. The above process is repeated until the global loss function converges. It should be noted that the label distribution of the vehicle only needs to be analyzed in the first round of global update, and the feature distribution of the vehicle needs to be re-analyzed and adjusted based on the latest model parameters in each round of global update.
[0059] In addition, the present invention assumes that each vehicle can complete local model aggregation and training with acceptable latency in each round of global update. The edge server also has sufficient computing and storage resources to save the deep learning model parameters of all vehicles and quickly select collaborators for each vehicle. At the same time, it is assumed that the communication between the vehicle and the edge server is realized through 5G or 6G cellular network, which can achieve millisecond-level data transmission.
[0060] Example 1
[0061] In a first aspect, this embodiment provides a distributed training method for a traffic recommendation system based on federated learning, including:
[0062] Based on the end-edge collaborative Internet of Vehicles system composed of vehicles and edge servers with heterogeneous data samples, each edge server corresponds to each preset area one by one. For the deep learning model training task corresponding to the traffic recommendation system on each vehicle in the preset area, the end-edge collaborative Internet of Vehicles system performs the following steps to obtain the collaborator screening and local model aggregation strategy for each vehicle, and realize personalized federated learning in the Internet of Vehicles scenario where data is not independent and identically distributed:
[0063] Step A: For each vehicle, use Shannon entropy to generate the label distribution of local data samples on the vehicle, use the local data samples on the vehicle to perform local training on the initial local model, obtain the local model parameters obtained after training and all feature maps output by the last convolutional layer of the local model; use the sparsity vector to generate the feature distribution of the local data samples on the vehicle according to the feature map; and upload the label distribution, feature distribution and local model parameters of the local data samples on the vehicle to the corresponding edge server;
[0064] Step B: The edge server obtains the label distribution and feature distribution of the local data samples on each vehicle in the corresponding area, selects a collaborator for each vehicle based on the similarity of the label distribution and feature distribution of the local data samples on each vehicle, and sends the latest local model parameters of the collaborator in the current global update to the corresponding vehicle;
[0065] Step C: For each vehicle, obtain the latest local model parameters of the collaborators in the current global update, calculate the aggregation weight of each collaborator, aggregate the local model parameters of the vehicle, the latest local model parameters of all collaborators and the aggregation weight to obtain the globally updated local model parameters, and use the local data samples on the vehicle to perform local training on the globally updated local model, obtain the local model parameters obtained after training and all feature maps output by the last convolutional layer of the local model, and generate the feature distribution of the local data samples on the vehicle using the sparsity vector according to the feature map; and upload the feature distribution of the local data samples on the vehicle and the local model parameters to the edge server for updating;
[0066] Step D: Repeat steps B to C until the global loss function converges.
[0067] In some embodiments, in step A, using Shannon entropy to generate a label distribution of local data samples on the vehicle includes:
[0068] For the preset area Vehicles ,vehicle The number of local data samples is , the number of categories involved in the sample is , belongs to The number of samples in each category is , according to Shannon entropy, the label distribution of local data samples on the vehicle for:
[0069] ;
[0070] It should be noted that the label distribution of local data samples on the vehicle is prior knowledge and only needs to be analyzed in the first round of global update.
[0071] In some embodiments, in step A and step C, generating a feature distribution of local data samples on the vehicle using a sparsity vector according to the feature map includes:
[0072] For vehicles The feature map output by the last convolutional layer of the local model in , Represents all feature maps The sum of the number of 0 elements in the channels, represents the sum of all elements in the 𝑘th channel of all feature maps, then the The sparsity of the channels is expressed as ; According to the sparsity of each channel in the feature map, construct the vehicle The sparsity vector of vehicle Feature distribution of local data samples :
[0073] ;
[0074] In the formula, Represents the number of channels for each feature.
[0075] In some embodiments, in step B, selecting a collaborator for each vehicle based on similarity of label distribution and similarity of feature distribution of local data samples on each vehicle includes:
[0076] Step B1: Based on the similarity of the label distribution of the local data samples on each vehicle, preliminary collaborators are screened for each vehicle from all vehicles in the corresponding area, including:
[0077] For vehicles , based on the following formula from the vehicle Initial collaborators are selected from all vehicles in the corresponding area:
[0078] ;
[0079] In the formula, is the first threshold, , Respectively represent , The label distribution of local data samples on vehicles, It should be noted that this step of screening preliminary collaborators only needs to be performed in the first round of global updates.
[0080] Step B2: Narrow the search space by screening preliminary collaborators for each vehicle. At the initial stage of each round of global update, collaborators are selected for each vehicle from the preliminary collaborators based on the similarity of the feature distribution of local data samples on each vehicle, including:
[0081] For vehicles , the final collaborators are selected from the preliminary collaborators based on the following formula:
[0082] ;
[0083] In the formula, is the second threshold, , represents the Euclidean distance, , Respectively represent , Feature distribution of local data samples on each vehicle.
[0084] The core of the adaptive update of local model parameters lies in the calculation of aggregation weights, that is, the derivation of the aggregation weight calculation formula.
[0085] In some embodiments, in step C, the local model parameters after global update are obtained by aggregating the local model parameters of the vehicle, the latest local model parameters of all collaborators in the current global update, and the aggregation weight, including:
[0086] For vehicles , in In the round of global update, the aggregation formula of local model parameters is:
[0087] ;
[0088] In the formula, For vehicles In the The local model parameters after the global update, For vehicles In the The local model parameters before the global update, For Collaborators In the The local model parameters before the global update, For vehicles In the The number of collaborators in a round of global updates, For the Global update of vehicles Collaborators The corresponding aggregation weight (variable to be solved); It is a vehicle In the The loss obtained by using local data samples for prediction in the global update round; Is a collaborator In the Using vehicles in global updates The loss obtained by making predictions on local data samples.
[0089] The present invention derives an approximate general formula for the rapid calculation of the aggregation weight; to facilitate subsequent calculations, the aggregation formula of the above local model parameters is approximated:
[0090]
[0091] In the formula, is included A one-dimensional vector with elements whose values are all 1; is the learning rate for global updates, For vehicles In the The local model parameters before the global update, For vehicles In the The loss obtained by using local data samples for prediction in the global update round; express for The partial derivative of .
[0092] From this we can get:
[0093]
[0094] Constructing new functions :
[0095]
[0096] when When , we get:
[0097]
[0098] when When , we get:
[0099]
[0100] According to the first-order Taylor formula, we can get:
[0101]
[0102] make , we can get:
[0103]
[0104] From this we can get As an approximate calculation formula for the aggregation weight; for vehicles ,In order to ensure that the sum of the aggregation weights corresponding to all collaborators is equal to 1 when aggregating the local model, the aggregation weight calculated by the above formula needs to be normalized.
[0105] Therefore, in step C, the aggregate weight of each partner is calculated, including:
[0106] The vehicle is calculated using the approximate calculation formula of the aggregation weight The aggregate weights corresponding to all collaborators of The aggregation weights corresponding to all collaborators are normalized as the final aggregation weights corresponding to each collaborator; the approximate calculation formula for the aggregation weight is:
[0107] ;
[0108] In the formula, is the calculated aggregate weight before normalization, is the learning rate for global updates, It is a vehicle In the The loss obtained by using local data samples for prediction in the global update round; Is a collaborator In the Using vehicles in global updates The loss obtained by predicting the local data samples, For vehicles In the The number of collaborators in a round of global updates, For vehicles In the The local model parameters before the global update, For vehicles In the The loss obtained by using local data samples for prediction in the global update round;
[0109] ;
[0110] In the formula, For the Global update of vehicles Collaborators The corresponding aggregation weight; If the aggregation weight is negative, the local model parameters of the corresponding partner will not participate in this aggregation. When the corresponding aggregation weight is negative, it indicates that the local model parameters of the partner are not suitable for the vehicle A sample of local data.
[0111] In some embodiments, in step C, locally training the globally updated local model using local data samples on the vehicle includes:
[0112] The loss function of local training is: Use cross entropy loss;
[0113] L i t ' =- 1 Q ∑ q=1 Q [ y q log y ̂ q +(1- y q ) log (1- y ̂ q ) ] ;
[0114] In the formula, is the number of samples in each batch, and They are respectively The real label and predicted label of each sample. During the training process, the small batch gradient descent method is used to update the local model parameters:
[0115] ;
[0116] In the formula vehicle In the The local model parameters after rounds of local training are In the Local model parameters before the global update; For vehicles In the The local model parameters after the global update, is the learning rate for local training, Indicates vehicle In the The loss of the local training round For Vehicles In the Local model parameters after global update The partial derivative of .
[0117] In some embodiments, in step D, the global loss function for:
[0118] ;
[0119] In the formula, Represents the total number of data samples on all vehicles in the preset area, is the total number of vehicles, For vehicles The number of local data samples, For vehicles In the The local model parameters after the global update, Indicates vehicle In the The loss for the local training round.
[0120] Simulation application example: NVIDIA L20 GPU is used for experiments, and Python 3.8 and PyTorch 2.0.0 are used to build the simulation environment. The number of cars participating in federated learning in the simulated Internet of Vehicles scenario is set to [20, 30, 40, 50, 60]. The dataset uses Cifar-10, which is used as the dataset for classification tasks. It contains 10 categories, 50,000 training samples and 10,000 test samples, and the size of each sample is . All samples in the Cifar-10 dataset are assigned to each vehicle in a pathological non-IID manner. The number of global update rounds is set to 30. The neural network model to be trained uses AlexNet. As a classic convolutional neural network model, AlexNet contains 5 convolutional layers, 4 pooling layers, and 3 fully connected layers. The specific neural network configuration is shown in Table 1:
[0121] Table 1 AlexNet configuration
[0122]
[0123] The existing FedAvg, FedProx, FedNTD, FedRoD, FedRep, Per-FedAvg and the distributed training method of the traffic recommendation system based on federated learning of the present application are respectively used to train all local models in the vehicle networking simulation scenario of the embodiment, and the training accuracy is shown in Table 2:
[0124] Table 2 Comparison of federated learning accuracy
[0125]
[0126] As can be seen from Table 2, the training accuracy of the distributed training method for the traffic recommendation system based on federated learning in this application is higher than 85%, which is significantly better than several other existing methods.
[0127] The latency required for several federated learning methods to achieve 80% training accuracy is shown in Table 3:
[0128] Table 3. Comparison of federated learning latency
[0129]
[0130] As can be seen from Table 3, the training delay of the distributed training method for the traffic recommendation system based on federated learning in this application is less than 300 seconds, which is significantly better than several other existing methods. In addition, since the three federated learning methods FedAvg, FedProx, and FedNTD cannot achieve 80% accuracy within 30 rounds of global updates, their training delays are not listed in Table 3.
[0131] The above proves that this application effectively improves the accuracy and speed of federated learning in scenarios where data is not independent and identically distributed, and it is feasible in distributed training of intelligent transportation recommendation systems.
[0132] In summary, the present invention designs a distributed training method for a traffic recommendation system based on federated learning, and the invention proposes a federated learning algorithm named FedRS. FedRS provides efficient and personalized recommendation services for each vehicle based on adaptive local aggregation. The core idea is to analyze the data distribution of each vehicle in the end-edge collaborative Internet of Vehicles scenario, and select collaborators with similar data distribution for each vehicle; for each vehicle, the model aggregation weights corresponding to each collaborator are calculated, and local model aggregation and training tasks are performed. The entire algorithm has the characteristics of user privacy protection, real-time analysis of data distribution characteristics, personalized local aggregation, and rapid convergence of global losses, which can meet the needs of fast, high-precision, and personalized training of recommendation systems in Internet of Vehicles scenarios where data is not independent and identically distributed. At the same time, the present invention designs an analysis method based on Shannon entropy and channel sparsity for the label distribution and feature distribution of data samples, respectively. Through this method, the similarity of the label distribution and feature distribution of data samples on different vehicles can be effectively calculated, and then collaborators can be screened for each vehicle in a targeted manner. The present invention also derives a universal approximate calculation formula for aggregation weights for the rapid calculation of aggregation weights. In each round of global update, each vehicle directly and adaptively calculates the model parameter aggregation weights of each collaborator based on this formula, thereby reducing local calculation delays while ensuring personalization.
[0133] Example 2
[0134] In a second aspect, based on Embodiment 1, this embodiment provides a distributed training system for a traffic recommendation system based on federated learning, including a processor and a storage medium;
[0135] The storage medium is used to store instructions;
[0136] The processor is configured to operate according to the instructions to execute the method according to embodiment 1.
[0137] Example 3
[0138] In a third aspect, based on embodiment 1, this embodiment provides a device, including a memory; a processor; and a computer program;
[0139] The computer program is stored in the memory and is configured to be executed by the processor to implement the method described in Example 1.
[0140] Example 4
[0141] In a fourth aspect, based on Embodiment 1, this embodiment provides a storage medium on which a computer program is stored, and when the computer program is executed by a processor, the method described in Embodiment 1 is implemented.
[0142] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0143] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram and the combination of the processes and / or blocks in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0144] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0145] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0146] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A distributed training method for a traffic recommendation system based on federated learning, characterized in that: The method includes: based on an end-to-edge collaborative Internet of Vehicles system composed of vehicles and edge servers with heterogeneous data samples, each edge server corresponds to each preset area one by one, and for the deep learning model training task corresponding to the traffic recommendation system on each vehicle in the preset area, the end-to-edge collaborative Internet of Vehicles system performs the following steps: Step A: For each vehicle, use Shannon entropy to generate the label distribution of local data samples on the vehicle, use the local data samples on the vehicle to perform local training on the initial local model, obtain the local model parameters obtained after training and all feature maps output by the last convolutional layer of the local model; use the sparsity vector to generate the feature distribution of the local data samples on the vehicle according to the feature map; and upload the label distribution, feature distribution and local model parameters of the local data samples on the vehicle to the corresponding edge server; Step B: The edge server obtains the label distribution and feature distribution of the local data samples on each vehicle in the corresponding area, selects a collaborator for each vehicle based on the similarity of the label distribution and feature distribution of the local data samples on each vehicle, and sends the latest local model parameters of the collaborator in the current global update to the corresponding vehicle; Step C: For each vehicle, obtain the latest local model parameters of the collaborators in the current global update, calculate the aggregation weight of each collaborator, aggregate the local model parameters of the vehicle, the latest local model parameters of all collaborators and the aggregation weight to obtain the globally updated local model parameters, and use the local data samples on the vehicle to perform local training on the globally updated local model, obtain the local model parameters obtained after training and all feature maps output by the last convolutional layer of the local model, and generate the feature distribution of the local data samples on the vehicle using the sparsity vector according to the feature map; and upload the feature distribution of the local data samples on the vehicle and the local model parameters to the edge server for updating; Step D: Repeat steps B to C until the global loss function converges; In step C, the aggregate weight of each partner is calculated, including: The vehicle is calculated using the approximate calculation formula of the aggregation weight The aggregate weights corresponding to all collaborators of The aggregation weights corresponding to all collaborators are normalized as the final aggregation weights corresponding to each collaborator; the approximate calculation formula for the aggregation weight is: ; In the formula, is the calculated aggregate weight before normalization, is the learning rate for global updates, It is a vehicle In the The loss obtained by using local data samples for prediction in the global update round; Is a collaborator In the Using vehicles in global updates The loss obtained by predicting the local data samples, For vehicles In the The number of collaborators in a round of global updates, For vehicles In the The local model parameters before the global update, For vehicles In the The loss obtained by using local data samples for prediction in the global update round; ; In the formula, For the Global update of vehicles Collaborators The corresponding aggregation weight; It means that if the value of the aggregation weight is negative, the local model parameters of the corresponding partner will not participate in this aggregation.
2. The method according to claim 1, characterized in that: In step A, Shannon entropy is used to generate the label distribution of local data samples on the vehicle, including: For the preset area Vehicles ,vehicle The number of local data samples is , the number of categories involved in the sample is , belongs to The number of samples in each category is , according to Shannon entropy, the label distribution of local data samples on the vehicle for: 。 3. The method according to claim 1, characterized in that In step A and step C, the feature distribution of the local data sample on the vehicle is generated using the sparsity vector according to the feature map, including: For vehicles The feature map output by the last convolutional layer of the local model in , Represents all feature maps The sum of the number of 0 elements in the channels, Represents all feature maps The sum of the number of elements in the channels, then The sparsity of the channels is expressed as ; According to the sparsity of each channel in the feature map, construct the vehicle The sparsity vector of vehicle Feature distribution of local data samples : ; In the formula, Represents the number of channels for each feature.
4. The method according to claim 1, characterized in that: In step B, a collaborator is selected for each vehicle based on the similarity of the label distribution and the similarity of the feature distribution of the local data samples on each vehicle, including: Based on the similarity of the label distribution of the local data samples on each vehicle, preliminary collaborators are screened for each vehicle from all vehicles in the corresponding area; At the initial stage of each round of global update, a cooperator is selected for each vehicle from the preliminary cooperators based on the similarity of the feature distributions of the local data samples on each vehicle.
5. The method according to claim 4, characterized in that Based on the similarity of the label distribution of local data samples on each vehicle, preliminary collaborators are screened for each vehicle from all vehicles in the corresponding area, including: For vehicles , based on the following formula from the vehicle Initial collaborators are selected from all vehicles in the corresponding area: ; In the formula, is the first threshold, , Respectively represent , label distribution of local data samples on j vehicles, j≠i.
6. The method according to claim 4, characterized in that At the initial stage of each round of global update, a collaborator is selected for each vehicle from the preliminary collaborators based on the similarity of the feature distribution of the local data samples on each vehicle, including: For vehicles , the final collaborators are selected from the preliminary collaborators based on the following formula: ; In the formula, is the second threshold, j≠i, represents the Euclidean distance, , Respectively represent , characteristic distribution of local data samples on j vehicles.
7. The method according to claim 1, characterized in that In step C, the local model parameters after global update are obtained by aggregating the local model parameters of the vehicle, the latest local model parameters of all collaborators in the current global update, and the aggregation weights, including: For vehicles , in In the round of global update, the aggregation formula of local model parameters is: ; In the formula, For vehicles In the The local model parameters after the global update, For vehicles In the The local model parameters before the global update, For Collaborators In the The local model parameters before the global update, For vehicles In the The number of collaborators in a round of global updates, For the Global update of vehicles Collaborators The corresponding aggregation weight; It is a vehicle In the The loss obtained by using local data samples for prediction in the global update round; Is a collaborator In the Using vehicles in global updates The loss obtained by making predictions on local data samples.
8. The method according to claim 1, characterized in that In step C, the local data samples on the vehicle are used to perform local training on the globally updated local model, including: The loss function of local training is: Use cross entropy loss; ; In the formula, is the number of samples in each batch, and They are respectively The real label and predicted label of each sample. During the training process, the small batch gradient descent method is used to update the local model parameters: ; In the formula vehicle In the The local model parameters after rounds of local training are In the Local model parameters before the global update; For vehicles In the The local model parameters after the global update, is the learning rate for local training, Indicates vehicle In the The loss of the local training round For Vehicles In the Local model parameters after global update The partial derivative of .
9. The method according to claim 1, characterized in that: In step D, the global loss function for: ; In the formula, Represents the total number of data samples on all vehicles in the preset area, is the total number of vehicles, For vehicles The number of local data samples, For vehicles In the The local model parameters after the global update, Indicates vehicle In the The loss for the local training round.
Citation Information
Patent Citations
Asynchronous federated learning method, system, device and terminal for mobile vehicle
CN114116198A
Narrow-sense asynchronous personalized federated learning adaptive aggregation method
CN115796274A