An Image Classification Method Based on Parameter Correction of Batch Normalization Layers in Federated Learning
By correcting the batch mean and batch variance gradient optimization parameters of the batch standardization layer, the training performance problem of federated learning under different data distributions is solved, and high-precision image classification in heterogeneous data environment is achieved.
Patent Information
- Application Number
- CN202211632746.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-19
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2042-12-19
AI Technical Summary
When training deep neural network models with batch standardization layers, existing federated learning algorithms cannot maintain good training performance when different clients have different data distributions, resulting in a significant reduction in model classification accuracy.
By correcting the batch mean and batch variance and gradient during local model training, the parameters of the batch standardization layer are optimized, training deviations are reduced, and image classification accuracy is improved.
Under different data distributions, federated learning algorithms can achieve good training results and improve the accuracy of image classification. Especially when different clients have different local database distributions, the test accuracy is significantly improved.
Smart Images

Figure CN115953626B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to image classification, and particularly to an image classification method based on batch normalization layer parameter correction for federated learning. Background Art
[0002] With the rise of the Internet of Things and the increasing awareness of user data privacy protection, the federated learning (FL) framework has been proposed. It trains a deep neural network (DNN) model by jointly training multiple edge clients without accessing the original data of the clients. At the same time, many DNN models adopt batch normalization (BN) to improve the training speed and generalization ability of the model.
[0003] In actual training, the local data sets of different clients are often heterogeneous, which will lead to a significant decline in the performance of federated learning when training a DNN model containing BN. Therefore, it is necessary to design a federated learning algorithm for DNN models containing BN layers so that the DNN model can achieve good training performance under different data distributions.
[0004] When different clients have different local data distributions, the current federated learning algorithms cannot achieve good training effects and cannot ensure that the model parameters can converge to a good solution.
[0005] For example, use the federated learning framework to train a ResNet-20 model to classify the data in the CIFAR-10 database. When the local data sets of different clients have the same distribution, the classification accuracy of the trained model on the test data set can reach about 90%; while when different clients have local data sets with different distributions, the classification accuracy of the trained model will drop significantly and may only reach about 40%. Summary of the Invention
[0006] The purpose of the present invention is to overcome the deficiencies of the prior art and provide an image classification method based on batch normalization layer parameter correction for federated learning. By correcting the batch mean and batch variance during local model training, as well as the gradients of the batch mean and batch variance, the training bias of the local model is reduced, and the accuracy of image classification is improved.
[0007] The purpose of the present invention is achieved by the following technical solutions: An image classification method based on batch normalization layer parameter correction for federated learning, comprising the following steps:
[0008] S1. Construct a federated learning scenario, including 1 cloud server and N clients distributed at different locations, and the cloud server is connected to each client through a network;
[0009] S2. Each client continuously collects image samples, represents the collected image samples as an RGB matrix, and marks the RGB matrix using the image category as a label to form a local database at each client;
[0010] S3. The cloud server constructs a DNN model including a BN layer for image classification, initializes the parameters of the DNN model, and sets the federated learning parameters;
[0011] S4. In any round of the iterative process, first initialize the local model parameters, then each client updates the local model using the local database, and then uploads the update result to the server, and the server updates the global model;
[0012] S5. Repeat step S4, perform R rounds of iterative training on the global model, obtain the final DNN model and distribute it to each client, and the client classifies the image to be recognized according to the obtained DNN model.
[0013] The beneficial effects of the present invention are as follows: By correcting the batch mean and batch variance during local model training, as well as the gradients of the batch mean and batch variance, the present invention reduces the training bias of the local model, thereby enabling the federated learning algorithm to achieve good training results and improving the accuracy of image classification. Description of the Drawings
[0014] Figure 1 is the flowchart of the method of the present invention;
[0015] Figure 2 is a schematic diagram of the relationship between the number of iterations and the test accuracy when different clients have the same local database distribution;
[0016] Figure 3 is a schematic diagram of the relationship between the number of iterations and the test accuracy when different clients have different local database distributions. Detailed Embodiments
[0017] The technical solution of the present invention will be further described in detail below with reference to the drawings, but the protection scope of the present invention is not limited to the following.
[0018] As Figure 1 shown, an image classification method based on federated learning with batch normalization layer parameter correction, characterized by comprising the following steps:
[0019] S1. Construct a federated learning scenario, including 1 cloud server and N clients distributed at different locations, and the cloud server is connected to each client through a network;
[0020] S2. Each client continuously collects image samples, represents the collected image samples as RGB matrices, and marks the RGB matrices with the image categories as labels to form a local database at each client;
[0021] S201. For any client i, first continuously collect image samples locally, and then represent each new image sample as an RGB matrix ξ of dimension M×M×3 i,new :
[0022]
[0023] where, X red , Y green and Z blue respectively represent the data matrices of the red, green, and blue color channels, and x jk , y jk and z jk are respectively the pixel values at the j-th row and k-th column of X red , Y green and Z blue , j, k = 1,..., M; Meanwhile, client i determines the category to which the image sample ξ i,new belongs, with each category represented by a different number; mark the label of ξ i,new as label(ξ i,new );
[0024] For example, for the CIFAR-10 dataset, each image is an RGB color image of dimension 32×32×3. The CIFAR-10 dataset contains a total of 10 categories: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, and truck. In this scenario, the category to which the image belongs is the name of these objects, i.e., airplane, automobile, etc. The image label can be defined as 0 to 9, with the number 0 corresponding to airplane and the number 9 corresponding to truck.
[0025] S202. Client i puts the newly collected image sample data ξ i,new and its label label(ξ i,new ) into the local database and updates the local database to that is, after each image is collected, the image sample and the corresponding label are saved to the local database;
[0026] S203. When i = 1,..., N, repeat steps S201 - S202 for each client, and a local database is obtained in each client.
[0027] S3. The cloud server constructs a DNN model for image classification that includes a BN layer, initializes the parameters of the DNN model, and sets the federated learning parameters; in the actual execution process, the selected DNN model can be some mature image classification DNN models, such as ResNet, etc.
[0028] In the step S3, the set federated learning parameters include: the total number of iteration rounds R, the number of local model updates E for each round by the client, and the weight p of user i i , i = 1,..., N;
[0029] Initialize the DNN model parameters as where is the gradient parameter, that is, the parameter directly updated by the gradient in the DNN model, is the statistical parameter, that is, the batch mean and batch variance parameters in the BN layer.
[0030] Among them, BN (batch normalization) refers to batch normalization: that is, the input data of the intermediate layer of the DNN is normalized so that the output follows a normal distribution, thus avoiding the problem of variable distribution deviation. Specifically, denote the input data of BN layer l as Y l , where Y l,j is the j-th dimensional data of Y l . Then, in the BN layer, each dimensional data of Y l is normalized to:
[0031]
[0032] where γ l,j is the scale parameter, β l,j is the drift parameter, ∈ is a very small value, μ l,j is the batch mean, (σ l,j ) 2 is the batch variance. During the training process of the DNN model, the calculation process of μ l,j and (σ l,j ) 2 is as follows:
[0033]
[0034]
[0035] where is the mean relative to the batch sample .
[0036] S4. In any round of iteration, first initialize the local model parameters, then each client updates the local model using the local database, and then uploads the update result to the server, where the server updates the global model;
[0037] S401. Suppose that in the first round of iteration, the cloud server sends the initialized DNN model parameters to each client; then, in the r-th (r = 2,..., M) round of iteration, the cloud server sends the globally updated DNN model parameters after the previous round of iteration to each client, where is the gradient parameter, is the statistical parameter;
[0038] S402. Each client i (i = 1,..., N) initializes the parameters of its local DNN model to that is,
[0039] S403. Each client performs E local model updates.
[0040] The step S403 includes:
[0041] A1. In the first local update, each client i corrects the batch mean and batch variance of the BN layer layer by layer to obtain the temporary statistical parameter i = 1,..., N;
[0042] The step A1 includes:
[0043] A101: Each client i randomly selects a batch of samples from the latest local database where ξ i,b (b = 1,..., B) is the b-th image sample data in, and B is the number of selected samples; at the same time, obtain the image sample label set where the b-th element label(ξ i,b ) in is the label of the image sample data ξ i,b , i = 1,..., N;
[0044] A102: Each client i inputs the B image sample data in into its local DNN model in parallel, and calculates the output of each network layer layer by layer from the input layer to the output layer. This process is the forward propagation process;
[0045] When the network layer is a non-BN layer, directly calculate the output of this network layer where Gζ (·, ·) is the arithmetic expression of this network layer, and X ζ is the input of this network layer, is the gradient parameter of this network layer,
[0046] Otherwise, perform steps A103 to A112;
[0047] A103: For client i, when the network layer is the BN layer, denote as the input of BN layer l, where, (b = 1, …, B) corresponds to the DNN input sample ξ i,b , M l is the dimension of, (j = 1, …, M l ) is the j-th dimensional element in;
[0048] A104: Each client i calculates that the batch mean of is
[0049] A105: Each client i uploads the local batch mean to the cloud server;
[0050] A106: The cloud server calculates the global batch mean as and sends it to each client;
[0051] A107: Each client i corrects the value of the local batch mean to that is
[0052] A108: Each client i calculates that the batch variance of is
[0053] A109: Each client i uploads the local batch variance to the cloud server;
[0054] A110: The server calculates the global batch mean as and sends it to each client;
[0055] A111: Each client i corrects the value of the local batch variance to that is
[0056] A112: Each client i normalizes the input of BN layer l to where, each element of each dimension in (b = 1, …, B) is normalized to
[0057]
[0058] where γ l,j is the scale parameter, β l,j is the drift parameter, ∈ is a very small value, is the output of BN layer l, the scale parameter γ l,j and the drift parameter β l,j belong to the gradient parameters, that is the batch mean and the batch variance belong to the statistical parameters, that is
[0059] A113: For each BN layer included in the DNN model, repeat steps A103 to A112, correct the batch mean and batch variance of all BN layers, complete the forward propagation process, and obtain the statistical parameters where is the set of batch mean parameters and the batch variance parameters of all BN layers in the DNN model; at the same time, obtain the output of the local DNN model
[0060] A2. Each client i (i = 1, …, N) corrects the batch mean gradient and batch variance gradient of the BN layer layer by layer, and calculates the gradient of the gradient parameter
[0061] The said step A2 includes the following sub-steps:
[0062] A201: Client i calculates the DNN model cost function when the gradient parameter is according to the DNN model output and the image sample label set as where is the loss function of each image sample, is the loss value of the image sample ξ i,b ;
[0063] A202: Client i calculates the gradient of each network layer parameter layer by layer from the output layer to the input layer, and this process is the backpropagation process; when the network layer is a non-BN layer, calculate the gradient parameter of this network layer where is the arithmetic expression of the gradient of the model parameter of this network layer, and X ζ is the input of this network layer
[0064] Otherwise, proceed to steps A203 to A209;
[0065] A203: For client i, when the network layer is the BN layer, denote as the function For (i.e., the output of BN layer l) gradient;
[0066] A204: Each client i calculates the local batch variance gradient as where the j-th element of
[0067] A205: Each client i calculates the local batch mean gradient as where the j-th element of
[0068] A206: Each client i uploads the local batch mean gradient and the batch variance gradient to the cloud server;
[0069] A207: The cloud server calculates the global batch mean gradient as the global batch variance gradient as and sends and to each client;
[0070] A208: Each client i corrects the value of the local batch mean gradient to i.e., and corrects the value of the local batch variance gradient to i.e.,
[0071] A209: Each client i calculates the gradient of the scale parameter as the gradient of the drift parameter β l,j as where the scale parameter γ l,j and the drift parameter β l,j belong to the gradient parameters, i.e., and calculates the gradient of the BN layer input as where the j-th element of
[0072] A210: For each BN layer included in the DNN model, repeat steps A203 to A209 to correct the batch mean gradient and batch variance gradient of all BN layers, complete the backpropagation process, and obtain the gradient of the gradient parameter.
[0073] A3. Each client i (i = 1,..., N) updates the local statistical parameters to where ρ is the decay coefficient, and at the same time updates the local gradient parameter to
[0074] A4. After completing the first local update, each client i (i = 1,..., N) then performs E - 1 local DNN model updates using the gradient descent method.
[0075] The step A4 includes the following sub - steps:
[0076] A401: At the t - th step of local update, each client i randomly selects a batch of samples from the latest local database where ξ i,b is the b - th image sample data in and B is the number of samples; at the same time, obtain the image sample label set where i,b the b - th element label(ξ i,b ) in
[0077] is the label of the image sample data ξ , i = 1,..., N; A402: Client i inputs the B image sample data in in parallel into the DNN with gradient parameter . When the network layer is a non - BN layer, calculate the gradient of the gradient parameter ζ of this network layer, where is the arithmetic expression of the gradient of the model parameter of this network layer, X
[0078] is the input of the BN layer l for client i, where (b = 1,..., B) corresponds to the DNN input sample ξ i,b , M l is the dimension of (j = 1,..., M l ) is the j - th dimension element in ;
[0079] A404: Each client i calculates The batch mean of is And calculates The batch variance of is
[0080] A405: Each client i normalizes To Where, Each dimensional element in Is normalized to
[0081]
[0082] Where, γ l,j Is the scale parameter, β l,j Is the drift parameter, ∈ is a very small value, Is the output of BN layer l;
[0083] A406: For each BN layer included in the DNN model, repeat steps A403 to A405, correct the batch mean and batch variance of all BN layers, complete the forward propagation process, and obtain the statistical parameters Where, Is the set of batch mean parameters of all BN layers in the DNN model And the batch variance parameter At the same time, obtain the output of the local DNN model
[0084] A407: Client i calculates the gradient parameter according to the DNN model output And the image sample label set The DNN model cost function when is Where, Is the loss function of each image sample, Is the loss value of the image sample ξ Is the image sample ξ i,b Of the loss value;
[0085] A408: Client i calculates the gradient of each network layer parameter layer by layer from the output layer to the input layer. This process is the backpropagation process; when the network layer is a non-BN layer, calculate the gradient parameter Of the gradient Where, Is the arithmetic expression of the gradient of the network layer model parameter, X ζ Is the input of this network layer, Otherwise, perform steps A409 to A411;
[0086] A409: For client i, when the network layer is a BN layer, denote For the function For (i.e., the output of BN layer l);
[0087] A410: Each client i calculates the local batch variance gradient as The local batch mean gradient is Where The j-th element of The j-th element of
[0088] A411: Each client i calculates the gradient of the scale parameter as The drift parameter β l,j The gradient of is And calculates the input of the BN layer The gradient of is Where The j-th element of
[0089] A412: For each BN layer included in the DNN model, repeat steps A409 to A411, correct the batch mean gradient and batch variance gradient of all BN layers, complete the backpropagation process, and obtain the gradient of the gradient parameter
[0090] A413: Each client i updates the statistical parameter as And updates the local gradient parameter as
[0091] A414: At t = 2,..., E, repeat steps A401 to A403 to complete the E - 1 step update of the local DNN model.
[0092] A5. Perform the update of the global model:
[0093] Each client i (i = 1,..., N) sends the updated local DNN model To the cloud server; the cloud server takes the mean of the local DNN models of all clients and updates the global DNN model as Where
[0094] S5. Repeat step S4 to perform R rounds of iterative training on the global model, obtain the final DNN model and distribute it to each client, and the client classifies the image to be recognized according to the obtained DNN model.
[0095] The said step S5 includes the following sub - steps:
[0096] S501. Perform R rounds of iterative training on the global DNN model according to step S4 to obtain the final DNN model
[0097] S502. The cloud server distributes the DNN model obtained from the federated training to each client i, where i = 1, …, N.
[0098] S503. For a newly collected image at client i (i = 1, …, N), the image sample data ξ is obtained according to step S2 i,test , and client i uses the trained DNN model to classify ξ i,test and identify the category to which the image sample data belongs.
[0099] In the embodiments of the present application, by correcting the batch mean, batch variance and their gradients of the local DNN model during the training process, the federated learning can effectively improve the training performance under different data distributions when training the DNN model containing the batch normalization layer. The following experimental parameters are set for the simulation experiment:
[0100] Training dataset: CIFAR-10, where both the training dataset and the test data contain data samples of 10 categories;
[0101] DNN model for training: ResNet-20;
[0102] Number of clients N = 5;
[0103] Number of updates E of the local DNN model = 5;
[0104] Learning rate γ: from the 1st to the 6000th iteration, γ = 0.5; from the 6001st to the 10000th iteration, γ = 0.05;
[0105] Decay coefficient ρ = 0.1;
[0106] When different clients have the same local database distribution, each client contains data samples of 10 categories, and the proportion of data samples of each category is the same; when different clients have different local database distributions, each client only contains data samples of 2 categories;
[0107] For each federated learning method, 5 independent experiments are carried out, and the average value of the results of these 5 experiments is taken as the final result.
[0108] The relationship between the number of iterations and the test accuracy when different clients have the same local database distribution is as Figure 2 shown, and the relationship between the number of iterations and the test accuracy when different clients have different local database distributions is as Figure 3As shown, it can be seen from the figure that compared with the FedAvg and FedBN algorithms, the proposed algorithm can achieve good training effects under different data distributions. Among them, when different clients have the same local database distribution, the classification accuracies (i.e., test accuracies) of the FedAvg and FedBN algorithms on the test dataset can reach 89.42% and 88.83% respectively. When different clients have different local database distributions, the test accuracies of these two algorithms can only reach 36.65% and 19.24% respectively. For the image classification method proposed in this patent, its test accuracies are 89.32% and 86.69% respectively under the same and different local database distributions, and good training effects of the image classification model are achieved in both cases.
[0109] The above description shows and describes a preferred embodiment of the present invention. However, as mentioned above, it should be understood that the present invention is not limited to the form disclosed herein, should not be regarded as excluding other embodiments, but can be used in various other combinations, modifications, and environments, and can be changed within the scope of the inventive concept described herein through the above teachings or the techniques or knowledge in related fields. Any changes and variations made by those skilled in the art without departing from the spirit and scope of the present invention shall fall within the protection scope of the appended claims of the present invention.
Claims
1. An image classification method based on batch normalization layer parameter correction for federated learning, characterized in that: Including the following steps: S1. Construct a federated learning scenario, including 1 cloud server and N clients distributed at different locations. The cloud server is connected to each client through a network respectively; S2. Each client continuously collects image samples, represents the collected image samples as an RGB matrix, and marks the RGB matrix with the image category as the label to form a local database at each client; S3. The cloud server constructs a DNN model including a BN layer for image classification, initializes the parameters of the DNN model, and sets the federated learning parameters; In the said step S3, the set federated learning parameters include: the total number of iterations R, the number of times E for the client to update the local model in each round, and the weight p of user i i , where i = 1, …, N; Initialize the DNN model parameters as wherein, is the gradient parameter, that is, the parameter directly updated by the gradient in the DNN model, is the statistical parameter, that is, the batch mean and batch variance parameters in the BN layer; S4. In any round of iteration process, first initialize the local model parameters, then each client updates the local model using the local database, and then uploads the update result to the server for the server to update the global model; The step S4 includes the following sub-steps: S401. Suppose that in the first round of iteration, the cloud server sends the initialized DNN model parameters to each client; then, in the r-th round, r = 2, …, M, the cloud server sends the globally updated DNN model parameters after the previous round of iteration to each client, where are gradient parameters are statistical parameters; S402. For each client i, where i = 1, …, N, initialize the parameters of the local DNN model to that is S403. Each client performs E local model updates; The step S403 includes: A1. At the first local update, each client i corrects the batch mean and batch variance of the BN layer layer by layer to obtain temporary statistical parameters A2. For each client i, where i = 1, …, N, the batch mean gradient and batch variance gradient of the BN layer are corrected layer by layer to calculate the gradient of the gradient parameter A3. For each client \(i\), where \(i = 1,\ldots,N\), update the local statistical parameters to where \(\rho\) is the decay coefficient, and simultaneously update the local gradient parameters to A4. After completing the first local update, each client i, i = 1,..., N then uses the gradient descent method to perform E - 1 local DNN model updates; A5. Perform the update of the global model: Each client \(i\), \(i = 1,\ldots,N\), will send the updated local DNN model to the cloud server; the cloud server takes the mean of the local DNN models of all clients and updates the global DNN model to where S5. Repeat step S4, perform R rounds of iterative training on the global model, obtain the final DNN model and distribute it to each client. The client classifies the image to be recognized according to the obtained DNN model.
2. The image classification method based on batch normalization layer parameter correction for federated learning according to claim 1, wherein: The step S2 includes the following sub-steps: S201. For any client i, first continuously collect image samples locally, and then represent each new image sample as an RGB matrix ξ of dimension M×M×3 i,new : Among them, X red , Y green and Z blue respectively represent the data matrices of the red, green, and blue color channels. x jk , y jk and z jk are respectively the pixel values at the j-th row and k-th column of X red , Y green and Z blue , where j, k = 1,..., M; meanwhile, the client i marks the label of ξ i,new according to the category to which the image sample ξ i,new belongs, and each category is represented by a different number; the label of ξ i,new is marked as label(ξ i,new ); S202. The client i puts the newly collected image sample data ξ i,new and its label label(ξ i,new ) into the local database , and updates the local database to that is, after each image is collected, the image sample and the corresponding label are saved to the local database; S203. When i = 1,..., N, repeat steps S201 - S202 for each client, and a local database is obtained in each client.
3. The image classification method based on batch normalization layer parameter correction for federated learning according to claim 1, characterized in that: The step A1 includes: A101: Each client $i$ randomly selects a batch of samples from the latest local database where, $\xi$ where, $\xi$ i,b , $b = 1, \ldots, B$, is the $b$-th image sample data in , and $B$ is the number of selected samples; meanwhile, an image sample label set is obtained, where the $b$-th element $\text{label}(\xi$ i,b ) in i,b is the label of the image sample data $\xi$, and $i = 1, \ldots, N$; A102: Each client i will input B image sample data in parallel into its local DNN model, and calculate the output of each network layer layer by layer from the input layer to the output layer. This process is the forward propagation process; When the network layer is not a BN layer, directly calculate the output of this network layer Among them, G ζ (·, ·) is the arithmetic expression of this network layer, X ζ is the input of this network layer, is the gradient parameter of this network layer, Otherwise, perform steps A103 to A112; A103: For client i, when the network layer is the BN layer, denote as the input of BN layer l, where b = 1, …, B, corresponding to the DNN input sample ξ i,b , M l is the dimension of (j = 1, …, M l ) is the j-th dimensional element in A104: Each client i calculates The batch mean of A105: Each client i uploads the local batch mean value to the cloud server; A106: The cloud server calculates the global batch mean value as and sends it to each client; A107: Each client i corrects the value of the local batch mean to that is A108: Each client i calculates The batch variance of A109: Each client i uploads the local batch variance to the cloud server; A110: The server calculates the global batch mean as and sends it to each client; A111: Each client i corrects the value of the local batch variance to i.e., A112: Each client i normalizes the input of BN layer l to be normalized to wherein, each element of each dimension in is normalized to Among them, γ l,j is the scale parameter, β l,j is the drift parameter, ∈ is a very small value, is the output of the BN layer l, the scale parameter γ l,j and the drift parameter β l,j belong to the gradient parameters, that is, the batch mean and the batch variance belong to the statistical parameters, that is, A113: For each BN layer included in the DNN model, repeat steps A103 to A112 to correct the batch means and batch variances of all BN layers, complete the forward propagation process, and obtain the statistical parameters where is the set of batch mean parameters of all BN layers in the DNN model and the batch variance parameters ; meanwhile, obtain the output of the local DNN model 4. The image classification method based on batch normalization layer parameter correction for federated learning according to claim 1, characterized in that: The step A2 includes the following sub-steps: A201: The client i outputs according to the DNN model and the image sample label set to calculate the gradient parameter as when the cost function of the DNN model is where is the loss function of each image sample, and i,b is the loss value of the image sample ξ A202: The client i calculates the gradient of each network layer parameter layer by layer from the output layer to the input layer, and this process is the backpropagation process; when the network layer is a non-BN layer, calculate the gradient parameter of this network layer of the gradient where is the arithmetic expression of the gradient of the model parameter of this network layer, and X ζ is the input of this network layer, Otherwise, perform steps A203 to A209; A203: For client i, when the network layer is the BN layer, denote as the function For That is, the gradient of the output of BN layer l; A204: Each client $i$ calculates the local batch variance gradient as where the $j$-th element of A205: Each client \(i\) calculates the local batch mean gradient as where the \(j\)-th element of A206: Each client i uploads the local batch mean gradient and the batch variance gradient to the cloud server; A207: The cloud server calculates the global batch mean gradient as The global batch variance gradient is and sends and to each client; A208: Each client i corrects the value of the local batch mean gradient to that is and corrects the value of the local batch variance gradient to that is A209: Each client i calculates the gradient of the scale parameter as the drift parameter β l,j for the gradient of where the scale parameter γ l,j and the drift parameter β l,j belong to the gradient parameters, i.e., γ l,j , and calculates the gradient of the input to the BN layer as where the j-th element of A210: For each BN layer included in the DNN model, repeat steps A203 to A209 to correct the batch mean gradient and batch variance gradient of all BN layers, complete the backpropagation process, and obtain the gradient of the gradient parameter 5. A method for image classification based on batch normalization layer parameter correction in federated learning according to claim 1, characterized in that: The step A4 includes the following sub-steps: A401: At the local update in step t, each client i randomly selects a batch of samples from the latest local database where ξ is the b-th image sample data in i,b , and B is the number of samples. At the same time, an image sample label set is obtained, where the b-th element label(ξ ) in is the label of the image sample data ξ i,b , and i = 1,..., N i,b . A402: The client i inputs B image sample data in in parallel into the DNN with gradient parameter . When the network layer is not a BN layer, calculate the gradient of the gradient parameter of this network layer where is the arithmetic expression of the gradient of the model parameter of this network layer, X ζ is the input of this network layer, Otherwise, proceed to steps A403 to A405; A403: For client i, when the network layer is the BN layer, denote as the input of BN layer l, where corresponds to the DNN input sample ξ i,b , M l is the dimension of, is the j-th dimensional element in; A404: Each client i calculates The batch mean of and calculates The batch variance of A405: Each client i will normalize it to where each dimensional element in is normalized to Among them, γ l,j is the scale parameter, β l,j is the drift parameter, ∈ is a minimum value, is the output of the BN layer l; A406: For each BN layer included in the DNN model, repeat steps A403 to A405 to correct the batch means and batch variances of all BN layers, complete the forward propagation process, and obtain the statistical parameters where is the set of batch mean parameters of all BN layers in the DNN model and the batch variance parameters ; meanwhile, obtain the output of the local DNN model A407: The client i outputs according to the DNN model and the image sample label set to calculate the gradient parameter as the DNN model cost function when where is the loss function for each image sample, is the loss value of the image sample ξ i,b ; A408: The client i calculates the gradients of each network layer parameter layer by layer from the output layer to the input layer, and this process is the backpropagation process; when the network layer is not a BN layer, calculate the gradient parameter of this network layer of the gradient Among them, is the arithmetic expression of the gradient of the model parameter of this network layer, X ζ is the input of this network layer, Otherwise, proceed to steps A409 to A411; A409: For client i, when the network layer is the BN layer, denote as the function For That is, the gradient of the output of BN layer l; A410: Each client i calculates the local batch variance gradient as The local batch mean gradient is where The j-th dimensional element of The j-th dimensional element of A411: Each client i calculates the gradient of the scale parameter as the drift parameter β l,j for the gradient of and calculates the input of the BN layer for the gradient of where the j-th element of A412: For each BN layer included in the DNN model, repeat steps A409 to A411 to correct the batch mean gradient and batch variance gradient of all BN layers, complete the backpropagation process, and obtain the gradient of the gradient parameter A413: Each client i updates the statistical parameters to while updating the local gradient parameters to A414: When t = 2,..., E, repeat steps A401 to A403 to complete E - 1 steps of update of the local DNN model.
6. A method for image classification based on parameter correction of batch normalization layer in federated learning according to claim 1, characterized in that: The step S5 includes the following sub-steps: Perform R rounds of iterative training on the global DNN model according to step S4 to obtain the final DNN model S502. The cloud server distributes the DNN model obtained from the federated training to each client i, where i = 1,..., N; For a newly acquired image of client i, where i = 1,..., N, obtain the image sample data ν according to step S2 i,test , and client i uses the trained DNN model to classify ν i,test and identify the category to which the image sample data belongs.
Citation Information
Patent Citations
Coal mine goaf crack identification method and detection system based on unmanned aerial vehicle
CN110147714A
Federal learning classification model training method based on depth deterministic strategy gradient
CN115062710A