Federal positioning method based on adaptive aggregation and feature alignment
By adopting adaptive aggregation and feature alignment methods in federated learning, the impact of non-independent homogeneous data on global model performance is solved, and higher positioning accuracy and floor recognition rate are achieved.
Patent Information
- Application Number
- CN202510095329.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-21
- Publication Date
- 2025-04-25
AI Technical Summary
When applied to WiFi fingerprint location, the existing federated learning method faces the problem of global model performance degradation caused by non-independent and homogeneous data.
The federated positioning method based on adaptive aggregation and feature alignment is adopted to reduce the impact of non-independent homogeneous data on the global model through dynamically changing aggregation coefficients and feature alignment constraints. Specific steps include model testing in the local client update stage, quantification of feature characterization constraints and aggregation weights, and aggregation of global models and feature centers of mass in the central server aggregation stage.
It effectively alleviates the impact of Non-IID data on the performance of the global model, improves the positioning accuracy and floor recognition rate of the global model, and reduces the average positioning error.
Smart Images

Figure CN119893434A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a federated positioning method based on adaptive aggregation and feature alignment, and belongs to the technical field of indoor positioning. Background Art
[0002] Since the Global Positioning System (GPS) performs poorly in indoor scenarios, it is critical and necessary to use existing network infrastructure for indoor positioning. Wi-Fi fingerprint positioning is widely used for indoor positioning because of its easy implementation, low cost, easy promotion and no need to deploy additional hardware equipment. The key idea of fingerprint positioning is to build a database consisting of labeled radio frequency measurement information for training deep learning models to provide real-time positioning services for users. However, building such a large fingerprint database is very time-consuming and costly, so a crowdsourcing method is proposed to solve this problem. However, ordinary crowdsourcing methods require users to upload raw data to a central server, which can easily lead to privacy leakage, such as sensitive location information. In recent years, with the improvement of user privacy protection and data security awareness and the implementation of various data privacy regulations, data collection and sharing have become increasingly difficult. Data owners only allow data to be kept in their own hands, thus forming isolated data islands. Federated learning (FL), as a privacy-preserving distributed machine learning framework, has been introduced into indoor fingerprint positioning. The basic idea of FL is to collaborate with multiple user devices to train models using their local data sets, and only upload model parameters or gradients to the server without uploading the original data. The server then aggregates the local models to build a shared global model. Therefore, compared with crowdsourcing methods, FL scenarios can protect user privacy and reduce communication overhead, achieving a good balance between privacy protection and application requirements.
[0003] Although federated learning has the above significant advantages, when applying federated learning to WiFi fingerprint positioning, it still faces the key problem that the local client data is not independent and identically distributed. Most of the existing federated aggregation methods alleviate the impact of non-independent and identically distributed data on the global model by constraining the update direction of the model during local training or eliminating local models with large differences during the aggregation stage. However, this solution is not conducive to obtaining a global model that is close to the ideal.
[0004] In order to overcome the above difficulties, the present invention proposes a federated positioning method based on adaptive aggregation and feature alignment, which uses dynamically changing aggregation coefficients and feature alignment constraints to reduce the impact of non-independent and identically distributed data on the global model. Specifically, the algorithm quantifies the change in performance of the local model before and after training through the coefficient of variation, and provides a more accurate aggregation coefficient for global aggregation. Considering that the difference in client data distribution will cause the local model representation to have their own preferences, feature alignment constraints are used to limit the local model representation to avoid overfitting of the local model. Then, the optimization is iterated continuously until the global model converges or the maximum number of iterations is reached. Summary of the invention
[0005] This method designs a federated positioning method based on adaptive aggregation and feature alignment, which effectively alleviates the impact of Non-IID data on the performance of the global model without involving user privacy information. The proposed TCFAFed method can be roughly divided into two parts: the local client update stage and the central server aggregation stage. Specifically, in the local client update stage, the local data is first tested with the global model to obtain the adaptability of the current global model to the local data; the global representation constraint is added during the local model training to achieve feature alignment; after the local model is trained, the local data is tested again, and the performance of the local model is quantified according to the changes before and after the test. In the central server aggregation stage, the coefficient of variation obtained in the local update stage is used for federated aggregation to obtain a new global model, and then the new global feature centroid is obtained by aggregation based on the data volume of each type of label samples and the local feature centroid, which is used for the next round of federated training until the global model converges.
[0006] In order to achieve the above object, the present invention provides the following scheme:
[0007] A federated positioning method based on adaptive aggregation and feature alignment, the method comprising:
[0008] Step 1: Local client update phase
[0009] Step 2: Central server aggregation stage
[0010] Step 3: Repeat steps 1 and 2 until the global model converges or the maximum number of iterations is reached.
[0011] The local client update phase specifically includes the following steps:
[0012] (1) Model testing
[0013] Before updating the local client, first test the local training dataset with the global model to obtain the adaptability of the global model to the local data:
[0014]
[0015] Where L(·) is the loss function, mean(·) and var(·) are the mean and standard deviation respectively. start The larger the value, the lower the adaptability of the current global model to the local data of the client. start Indicates that the loss value of each batch deviates from μ start After the local client is updated, the updated local model w is used i Test on the training data set (without updating parameters), and similarly obtain the corresponding mean μ end With standard deviation σ end . Due to the differences in label distribution among clients, only relying on the loss mean to determine the aggregation weight will bias towards samples with more data distribution, while the standard deviation of the loss value can help the global model learn more sample categories, so both the mean and standard deviation are considered. Although adding tests on the global model and the local model in the local model update phase increases the amount of calculation, it is still within the processing capacity of the IoT device. In addition, from the overall effect of subsequent experiments, by adding model testing, the convergence of the global model can be accelerated, thereby reducing the number of training times and the amount of communication.
[0016] (2) Feature representation constraints
[0017] When testing the local model in (1), the local feature centroid of each class label is calculated at the same time. In general, the hidden layer input of the penultimate linear layer in the position decoder is selected as the local feature representation emb of the sample. c , as attached Figure 1 As shown, it can be expressed as:
[0018]
[0019] Where Y represents the position sequence {B, F, LO, LA}, c represents the client label, and y represents the target position sequence with the start identifier. Each training sample position sequence has four label values. Here, all four label values correspond to this feature representation, and then the local feature centroid emb of each category is calculated based on the sample data volume of each label value. c,k .
[0020]
[0021] Among them, k represents the label value, there are K label values in total; l represents the number of training samples; h l represents the feature encoder output of the lth sample. Afterwards, the calculated local feature centroid is uploaded to the central server.
[0022] Due to the difference in data distribution among clients, the feature representation learned by local clients deviates from the global optimal representation, resulting in overfitting of the local model. In order to achieve feature representation alignment, global representation constraints are introduced during local model training, and the global feature representation is used to guide the learning of local feature representation, where the global feature centroid emb g,k is the centroid of the local features of each client emb c,k The weighted aggregation result of will be described in detail later. The feature alignment constraint can be expressed as:
[0023]
[0024] Among them, λ is used to adjust the influence of the constraint term; s represents the number of samples. The constraint term is combined with the standard cross entropy loss function into a new loss function to update the local model. While minimizing the model prediction error, the feature representation constraint is realized by narrowing the gap between the local feature centroid and the global feature centroid.
[0025] (3) Quantification of aggregation weights
[0026] Through the global model test in (1), we can get the mean value μ of the training data loss value start With standard deviation σ start , after local training, the corresponding mean μ can also be obtained end With standard deviation σ end In order to consider both the mean and standard deviation, the TCFAFed algorithm in this paper selects the coefficient of variation as the quantitative standard for the aggregation weight. In probability theory and statistics, the coefficient of variation is also called the "coefficient of variation", which is a normalized measure of the degree of dispersion of a probability distribution and is defined as the ratio of the standard deviation to the mean:
[0027]
[0028] Among them, ∈ is a smoothing term to prevent the denominator from being 0, and then the coefficient of variation coef of the global model test can be obtained start :
[0029]
[0030] Similarly, the coefficient of variation coef after local model training can be obtained end
[0031] Considering that if only coef start Assigning larger weights to larger local models will make the model biased towards samples that need more learning, which is not conducive to improving the performance of the global model. Therefore, the coef start and coef endThe value of .
[0032] The central server aggregation includes the following steps:
[0033] When the server receives the model parameters w uploaded by each local client i , coef start and coef end After that, first calculate coef start With coef end The ratio between them is used as the evaluation index of the aggregation weight. In order to avoid the reference value being negative, the sigmoid function is used to smooth it:
[0034]
[0035] Then Normalize and calculate the final aggregation coefficient a i :
[0036]
[0037] During the global model aggregation phase, the server obtains the new global model according to the following expression:
[0038]
[0039] At the same time, the local feature centroid emb of each label of each local client i,k Perform weighted averaging to obtain the global feature centroid emb of each label g,k :
[0040]
[0041] Among them, n i,k is the sample data volume of the i-th client with label value k; C is the number of clients, and K is the number of label categories. After obtaining the new global feature centroid, it can be used as the feature alignment constraint in the next round of federated training.
[0042] Step 3: Repeat steps 1 and 2, and continue iterating training until the global model converges or the maximum number of iterations is reached.
[0043] Beneficial effects:
[0044] The present invention proposes a federated positioning method based on adaptive aggregation and feature alignment. In view of the "client drift" problem caused by Non-IID data in the federated aggregation stage, the impact of Non-IID data on the global model is reduced from two aspects: the federated aggregation coefficient and the feature representation constraint, and a better performance is obtained, which is better than the comparison method. In the public dataset UJIIndoor, the floor recognition rate can reach 94.6%, and the average positioning error can be reduced to 8.45m, and the average positioning error reaches the current best effect. In the Tampere dataset, the floor recognition rate can reach 95.63%, and the average positioning error can be reduced to 6.52m. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 It is an overall flow chart of the federated positioning method TCFAFed based on adaptive aggregation and feature alignment provided by the present invention. DETAILED DESCRIPTION
[0046] The purpose of the present invention is to provide a federated positioning method based on adaptive aggregation and feature alignment, which can alleviate the "client drift" problem caused by Non-IID data without involving user privacy information, so as to improve the performance of the global model.
[0047] The present invention will be described in detail below in conjunction with the accompanying drawings. It should be noted that the described embodiments are only intended to facilitate the understanding of the present invention and do not have any limiting effect on the present invention.
[0048] Figure 1 It is an overall flow chart of the TCFAFed method provided by the present invention.
[0049] The federated positioning method based on adaptive aggregation and feature alignment provided by the present invention specifically includes:
[0050] Step 1: Local client update phase
[0051] The local client update phase includes model testing, feature representation constraints, and quantification of aggregation weights.
[0052] Step 2: Central server aggregation stage
[0053] The central server aggregation stage includes two aggregation operations: aggregation of the global model and aggregation of the global feature centroid.
[0054] Step 3: Continue iterating the optimization until the global model converges or the maximum number of iterations is reached.
[0055]
[0056]
[0057] TCFAFed algorithm pseudo code
[0058]
[0059] Table 1 Related concepts
[0060] Implementation details
[0061] The experiment uses the UJIIndoorLoc dataset and the Tampere dataset. In order to achieve the setting of non-independent and identically distributed data for each client, the dataset is divided into p subsets according to the device identifier in the dataset, and then each m subset is merged to form the data of a client, forming p / m clients. In particular, for the UJIIndoorLoc dataset, m is 2, and for the Tampere dataset, m is 4 (considering that the coverage of the dataset is relatively small, the value of m is larger). The experiment is implemented in PyTorch 1.13.0, and all experimental training processes are carried out on a computer equipped with Ubuntu 20.04. The computer configuration is as follows: CPU: Intel i9-14900K, GPU: NVIDIA GeForce RTX 3090 24GB, RAM: 64GB. In addition, when training the local client, the batch_size is set to 8, the number of local iterations local_epoch is set to 1, the initial learning rate is set to 0.0001, and the number of global iterations is set to 300.
[0062] In order to prove the effectiveness of the proposed TCFAFed method, the proposed method is compared with the training results of the classic aggregation methods FedAvg, FedScaffold, FedProx and IID conditions. The training set in the UJIIndoorLoc dataset is used for training, and the validation set is used to test the performance of the obtained global model; the larger dataset in the Tampere dataset is used as the training set, and the other is used as the test set. The evaluation indicators used to evaluate the performance include the average positioning error and the floor prediction accuracy.
[0063] Table 2 Performance comparison of various methods
[0064]
[0065] As can be seen from Table 2, on the UJIIndoorLoc dataset, for the average positioning error, FedAvg achieved the lowest positioning performance (13.28m), while the error of the TCFAFed algorithm (8.45m) was better than that of FedAvg (13.28m), FedScaffold (9.65m) and FedProx (12.88m). For the floor prediction accuracy, the TCFAFed method is higher than the comparison methods. In addition, from the perspective of the model effect, the effect of the TCFAFed algorithm is closest to the model effect under the IID state. On the Tampere dataset, for the average positioning error, the TCFAFed algorithm (6.52m) achieved better results than the Scaffold (12.6m) method and the FedAvg (6.87m) method, and the TCFAFed algorithm (6.52m) and FedProx (6.51m) algorithms are very close to the positioning accuracy under independent and identically distributed conditions (6.12m). Although the TCFAFed algorithm is slightly lower than FedProx, its performance in the large scene of UJIIndoorLoc is better than all the comparison methods. Because the Tampere scene is small, the global model drift after each aggregation is not large, which is suitable for FedProx, but the performance of the TCFAFed algorithm is still not weak. For the floor prediction accuracy, Scaffold achieved poor results (93.1%), and the TCFAFed algorithm was 0.01% and 0.39% higher than FedProx and FedAvg, which is better than all the comparison methods. In addition, compared with the Scaffold algorithm and the FedProx algorithm, the TCFAFed algorithm can achieve good performance in both the large scene of UJIIndoorLoc and the small scene of Tampere, and is better than the comparison methods.
[0066] The present invention designs a federated positioning method TCFAFed based on adaptive aggregation and feature alignment, which can be roughly divided into two parts: local client update and central server aggregation. In the local client update stage, the local training data is tested with the initial global model and the trained local model respectively to obtain the adaptability of the local model and the local data before and after training; at the same time, when training the local client, the global representation constraint is added to achieve feature alignment. In the central server aggregation stage, the aggregation coefficient obtained in the local update stage is first used to perform federated aggregation to obtain a new global model, and then the new global representation is aggregated according to the data amount and local representation of each client, and then it is continuously iterated and optimized until the global model converges. This method can be applied to the field of federated indoor positioning, and can effectively alleviate the impact of non-independent and identically distributed data on the performance of the global model, and improve the positioning accuracy of the global model.
[0067] The above description is only a specific implementation of the present invention, but the protection scope of the present invention is not limited thereto. Any person familiar with the technology can understand and think of changes and substitutions within the technical scope disclosed by the present invention, which should be included in the scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A federated positioning method based on adaptive aggregation and feature alignment, characterized in that: The method comprises: Step 1: In the local client update phase, the global model and the trained local model are used to test the local data. The aggregation coefficient of each local model is quantified by the change in performance before and after training. The local client adds global representation constraints during training to avoid overfitting of the local model. Step 2: In the central server aggregation phase, the relevant aggregation coefficients in the local update phase are used for federated aggregation to obtain a new global model. Then, the local feature representations are weighted and aggregated according to the data volume of each label sample to obtain a new global representation for the next round of federated training. Step 3: Repeat steps 1 and 2 until the global model converges or the maximum number of iterations is reached.
2. The federated positioning method based on adaptive aggregation and feature alignment according to claim 1, characterized in that: The specific steps of the local client update phase described in step 1 are as follows: Model testing: Use the global model and the trained local model to test the local training data set to obtain the adaptability of the model to the local data: μ start =mean(L(w g ,D i )) σ start =var(L(w g ,D i )) Where L(·) is the loss function, mean(·) and var(·) are the mean and standard deviation respectively; Get the mean μ corresponding to the local model test end With standard deviation σ end , the TCFAFed algorithm selects the coefficient of variation as the quantitative standard for the aggregation weight, which is defined as the ratio of the standard deviation to the mean: Among them, ∈ is a smoothing term, in order to prevent the denominator from being 0; and then obtain the coefficient of variation coef of the global model test start : And the calculated coef start and coef ena Upload to the server; Global representation constraint; when testing the local model, the local feature centroid emb of each category label is calculated simultaneously c,k : In order to implement the feature alignment constraint, a new regularization term is introduced into the local training objective: The new loss function obtained by combining the regular constraint term with the cross entropy loss function is used to update the model by gradient descent to avoid overfitting of the local model.
3. The federated positioning method based on adaptive aggregation and feature alignment according to claim 1, characterized in that: The specific steps of the central server aggregation phase described in step 2 are as follows: When the server receives the model parameters w uploaded by each local client i , coef stare and coef ena After that, calculate the final aggregation coefficient a i : in During the global model aggregation phase, the server obtains the new global model according to the following expression: At the same time, the local feature centroid emb of each label of each local client i,k Perform weighted averaging to obtain the global feature centroid emb of each label g,k : After obtaining the new global feature centroid, it is used as the feature alignment constraint in the next round of federated training.
Citation Information
Cited By
Data heterogeneous adaptive federal learning method, medium and equipment
CN120124779A
A Data Heterogeneity Adaptive Federated Learning Method, Medium and Device
CN120124779B