Image classification method and device based on fixed sparsity compression and computer device

By employing a fixed sparsity compression algorithm in image classification model training, the communication between the client and the central server is optimized, solving the problem of high communication costs caused by data silos and achieving faster, higher-performance model training and higher classification accuracy.

CN118628818BActive Publication Date: 2026-07-07NAT UNIV OF DEFENSE TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NAT UNIV OF DEFENSE TECH
Filing Date
2024-06-13
Publication Date
2026-07-07

AI Technical Summary

Technical Problem

In the training process of existing image classification models, the phenomenon of data silos makes data acquisition difficult and communication costs high, and traditional methods cannot quickly and effectively obtain high-performance models.

Method used

An image classification method based on fixed sparsity compression is adopted, which reduces communication volume and overhead by transmitting only changing parameters between client devices and central servers and using a fixed sparsity compression algorithm to optimize communication.

Benefits of technology

It improves communication efficiency, reduces communication overhead, and enhances the accuracy and convergence speed of the image classification model through an error feedback mechanism.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118628818B_ABST
    Figure CN118628818B_ABST
Patent Text Reader

Abstract

The application relates to an image classification method and device based on fixed sparsity compression and a computer device. The method comprises the following steps: after local training in a current round is completed, a preset number of client devices are randomly selected as target client devices; each client device corresponds to a local image data set and a local image classification model; if the parameters of the local image classification model of the target client device change, the corresponding updated parameters are uploaded to a central server after being compressed according to a preset first fixed sparsity, and thus an updated global image classification model is obtained; the parameters of the updated global image classification model are transmitted to all client devices by the central server after being compressed according to a preset second fixed sparsity, so that local training in a next round is performed until a preset condition is met, and a trained global image classification model is obtained. The method can quickly obtain an image classification model that can be put into use.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image classification technology, and in particular to an image classification method, apparatus and computer device based on fixed sparsity compression. Background Technology

[0002] Currently, machine learning, especially deep learning methods, has profoundly impacted our daily lives. Data collection has become more convenient, and "big data-driven" artificial intelligence is rapidly developing across various industries. People hope that more fields can utilize artificial intelligence to provide convenience for social life. However, the reality is that most fields involve large amounts of data distributed across different datasets, lacking effective communication and collaboration. Furthermore, individual datasets often have limited data volume and poor quality, and a lack of "trust" between datasets leads to the formation of "data islands."

[0003] For image classification technology, relying solely on data from a single user is far from sufficient for machine learning. Training a high-performance image classification model requires a high-quality, large-scale dataset. However, the existence of "data silos" makes data acquisition extremely difficult, and the traditional centralized training conditions for image classification models are increasingly unable to meet the demands.

[0004] In 2016, a team led by Google's McMahan designed a decentralized approach called federated learning (FL) to address the data silo problem. Using federated learning, data can be stored on client devices and used for local training. The key concept behind this approach is establishing data federation, enabling each client to access knowledge embedded throughout the dataset. While research on federated learning is extensive, this privacy-preserving form of collaborative learning consumes significant communication overhead during training. The communication capacity between client devices and the central server is limited, and as the number of nodes increases, communication costs become extremely high, leading to network connectivity uncertainty and hindering the rapid and efficient acquisition of high-performance image classification models. Summary of the Invention

[0005] Therefore, it is necessary to provide an image classification method, apparatus, and computer device based on fixed sparsity compression to address the aforementioned technical problems, thereby improving the communication efficiency between the central server and client devices and enabling faster acquisition of usable image classification models.

[0006] An image classification method based on fixed sparsity compression, the method comprising:

[0007] After the local training of the current round is completed, a preset number of client devices are randomly selected as target client devices; each client device corresponds to a local image dataset and a local image classification model.

[0008] If the parameters of the local image classification model of the target client device change, the corresponding updated parameters are compressed according to the preset first fixed sparsity rate and uploaded to the central server, thereby obtaining the updated global image classification model.

[0009] The central server compresses the parameters of the updated global image classification model according to the preset second fixed sparsity rate and transmits them to all client devices for the next round of local training until the preset conditions are met and the trained global image classification model is obtained.

[0010] Image classification is performed based on a trained global image classification model.

[0011] An image classification device based on fixed sparsity compression, the device comprising:

[0012] The target client determination module is used to randomly select a preset number of client devices as target client devices after the local training of the current round is completed; each client device corresponds to a local image dataset and a local image classification model;

[0013] The parameter compression module is used to compress the corresponding updated parameters according to a preset first fixed sparsity rate and upload them to the central server if the parameters of the local image classification model of the target client device change, thereby obtaining the updated global image classification model.

[0014] The global parameter transmission module is used to transmit the parameters of the updated global image classification model to all client devices through the central server after compression according to the preset second fixed sparsity rate, so as to carry out the next round of local training until the preset conditions are met and the trained global image classification model is obtained.

[0015] The image classification module is used to classify images based on a trained global image classification model.

[0016] A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program performing the following steps:

[0017] After the local training of the current round is completed, a preset number of client devices are randomly selected as target client devices; each client device corresponds to a local image dataset and a local image classification model.

[0018] If the parameters of the local image classification model of the target client device change, the corresponding updated parameters are compressed according to the preset first fixed sparsity rate and uploaded to the central server, thereby obtaining the updated global image classification model.

[0019] The central server compresses the parameters of the updated global image classification model according to the preset second fixed sparsity rate and transmits them to all client devices for the next round of local training until the preset conditions are met and the trained global image classification model is obtained.

[0020] Image classification is performed based on a trained global image classification model.

[0021] A computer-readable storage medium having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0022] After the local training of the current round is completed, a preset number of client devices are randomly selected as target client devices; each client device corresponds to a local image dataset and a local image classification model.

[0023] If the parameters of the local image classification model of the target client device change, the corresponding updated parameters are compressed according to the preset first fixed sparsity rate and uploaded to the central server, thereby obtaining the updated global image classification model.

[0024] The central server compresses the parameters of the updated global image classification model according to the preset second fixed sparsity rate and transmits them to all client devices for the next round of local training until the preset conditions are met and the trained global image classification model is obtained.

[0025] Image classification is performed based on a trained global image classification model.

[0026] In the aforementioned image classification method, apparatus, and computer device based on fixed sparsity compression, only the parameters that have changed after the current training round of the local image classification model are transmitted to the central server, rather than all model parameters. This limits the transmission of changes to a small portion of the parameters. Furthermore, during the training of the global image classification model, this invention randomly selects a portion of the changed parameters of the local image classification models on client devices and uploads them to the central server in each round, thus significantly reducing the amount of data transmitted. Further, this invention compresses the changed parameters of the local image classification model and the parameters of the global image classification model using a fixed sparsity rate. After removing "unimportant" model parameters, the optimization direction becomes clearer, communication efficiency is improved, communication overhead is reduced, and the target image classification model can be obtained more quickly for image classification tasks. Attached Figure Description

[0027] Figure 1 This is a flowchart illustrating an image classification method based on fixed sparsity compression.

[0028] Figure 2 This is a schematic diagram of the matrix compression process;

[0029] Figure 3 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0030] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0031] In one embodiment, such as Figure 1 As shown, an image classification method based on fixed sparsity compression is provided, including the following steps:

[0032] Step 102: After the local training of the current round is completed, randomly select a preset number of client devices as target client devices.

[0033] Each client device corresponds to a local image dataset and a local image classification model.

[0034] To enhance the robustness of image representation, image enhancement on client devices requires various operations such as random cropping, random translation, and random affine transformation. A combination of convolutional neural network (CNN) models and logistic regression models can be used for image feature extraction and classification.

[0035] In convolutional neural network models, layers such as convolutional layers, pooling layers, fully connected layers, and classification layers are commonly used for image feature extraction, data compression, and classification. Convolutional layers extract different details and complex features from the input image through convolution operations, which are difficult to construct manually. Pooling layers reduce the amount of data in the convolutional network by applying pooling operations, enabling faster computation. Hierarchical features are often obtained by repeating convolution and pooling operations to deepen the network layers and gain a more comprehensive understanding of the input image's features. Fully connected layers pass the extracted feature information to the fully connected layers. The parameters of these layers are trained using a loss function. When the loss function converges, the network model is trained and can be used for tasks such as object detection and classification.

[0036] Logistic regression is a commonly used binary classification model that maps input feature vectors to either class 0 or class 1. Its core principle is to use the following function to perform a non-linear transformation on the output of the linear regression model to obtain a probability estimate.

[0037] ;

[0038] in For input values.

[0039] The training process for logistic regression involves solving for the model parameters through maximum likelihood estimation. and Specifically, we use what we already know. Sample ), in It is the input feature quantity. The labels are used to maximize the likelihood function. Its expression is:

[0040] ;

[0041] Our goal is to find the optimal set of model parameters. and This allows the likelihood function to reach its maximum value. This process is typically performed by calculating the gradient, that is, by taking the partial derivative of the likelihood function. and The gradient is calculated, and the model parameters are iteratively updated using gradient descent. and This enables the training of an image classification model.

[0042] Step 104: If the parameters of the local image classification model of the target client device change, the corresponding updated parameters are compressed according to the preset first fixed sparsity rate and uploaded to the central server, thereby obtaining the updated global image classification model.

[0043] To conserve network resources, this method randomly selects a subset of client-side local image classification model parameters for each round of training and uploads them to the central server for gradient aggregation. Assuming a total of N client devices, at the beginning of round t, K client devices are randomly selected to participate in the aggregation of the global image classification model for that round. The value of K is fixed, and the same number of client devices are selected each time.

[0044] In theory, after sparsification, each pixel in the image only needs to transmit a small retained value. If we consider the parameters of each layer as a matrix, the original matrix is ​​dense, where color depth represents the magnitude of the values. However, the method proposed in this invention generates a sparse matrix by retaining larger values ​​and setting smaller values ​​to 0. The compression method used in this invention follows... Figure 2 The process is shown.

[0045] Step 106: The parameters of the updated global image classification model are compressed according to the preset second fixed sparsity rate and transmitted to all client devices through the central server for the next round of local training until the preset conditions are met and the trained global image classification model is obtained.

[0046] Fixed sparsity rate compression methods are primarily designed to accelerate parallel training in data centers. Currently, they mainly compress upstream communication because the sparsity patterns of updates from different client devices are often different. Since the elements sent from the client to the server are always sparse, this paper proposes extending the idea of ​​fixed sparsity rate compression to downstream compression, applying the same compression mechanism at the central server to compress downstream communication.

[0047] First, the central server initializes a global image classification model, typically a randomized, pre-trained model. Then, the central server receives compressed model variation parameters from client devices. The central server performs a weighted average of these parameters, assigning a weight to each client's compressed model variation parameter. This weight is determined based on factors such as the size of the client device's image dataset and its computing resources. Next, by performing a weighted average of all compressed model variation parameters, a global image classification model is obtained. Specifically, for each compressed model variation parameter, the parameter from each client device is multiplied by its corresponding weight. Then, all weighted variation parameters are summed, and finally, the result is divided by the sum of all weights. This yields the corresponding parameters for the global image classification model. Finally, the central server sends the generated global image classification model parameters to all client devices participating in the joint learning process.

[0048] The above preset conditions can be designed as needed. For example, training rounds can be set during the training process, and training can be stopped after the training rounds are reached.

[0049] Step 108: Classify the image based on the trained global image classification model.

[0050] In summary, this invention proposes a fixed sparse compression algorithm to address the communication efficiency problem in collaborative learning within the context of multi-client collaborative training of image classification models. The federated learning framework based on this algorithm employs bidirectional compression between client devices and the central server, transmitting only changed parameters during client updates, thereby improving communication efficiency and reducing communication overhead.

[0051] In one embodiment, the method further includes: when uploading the corresponding update parameters to the central server after compression according to a preset first fixed sparsity rate, calculating and retaining the error before and after compression of the update parameters, and accumulating it in the next round of local training.

[0052] By accumulating and feeding back the errors, an accuracy similar to that of algorithms without compression can be achieved, while improving convergence speed and significantly reducing the amount of communication in each round. This error feedback mechanism can further improve the accuracy of image classification models.

[0053] In one embodiment, when the corresponding update parameters are compressed according to a preset first fixed sparsity rate and uploaded to the central server, the error before and after compression of the update parameters is calculated and retained, and accumulated in the next round of local training. Specifically:

[0054] ;

[0055] ;

[0056] ;

[0057] in, Indicates the first Model parameters after error accumulation before the start of each round of local training. Indicates the first After the first round of local training, the The parameters of the local image classification model updated by each target client device. Indicates the first After the first round of local training, the The parameters of the local image classification model obtained from the updates of each target client device. It is the first The updated parameters of the local image classification model obtained after the first round of local training. Indicates the first The error in updating parameters before and after compression for each round of local training.

[0058] In the Before the start of each round of local training, first according to the first The sum of the errors of the local image classification model obtained after each round of local training and its corresponding updated parameters before and after compression is obtained as the first... Initial values ​​of image classification model parameters trained locally in each round Then according to Proceed to the first Rounds of local training, then... In other words, each round of local training only requires adding the compression error from the previous round. If the client device corresponding to the previous round was not selected, then the compression error of the previous round can be understood as 0.

[0059] In one embodiment, if the parameters of the local image classification model of the target client device change, the corresponding updated parameters are compressed according to a preset second fixed sparsity rate and uploaded to the central server to obtain an updated global image classification model, including:

[0060] ;

[0061] in, Indicates the first The global image classification model parameters before the update in each round, Indicates the first The updated global image classification model parameters in each round Indicates the first The target client device in the first After each round of local training, the corresponding changes in the model parameters of the local image classification model are as follows: Indicates the number of target client devices. Indicates the first The total number of samples in the local image dataset corresponding to each target client device Representative before selection The largest element, This is the assignment operator.

[0062] In one embodiment, the update parameter is calculated as follows:

[0063] ;

[0064] ;

[0065] in, Indicates the first After the first round of local training, the Model parameters corresponding to each target client device Indicates the first Before the start of the next round of local training, the first Model parameters corresponding to each target client device Indicates the learning rate. Indicates the first The gradients generated during each round of local training.

[0066] In one embodiment, the method further includes: when transmitting the parameters of the updated global image classification model to all client devices after compression according to a preset second fixed sparsity rate via a central server, calculating and retaining the error before and after compression of the parameters of the updated global image classification model, and accumulating it into the next round of global training.

[0067] In one embodiment, the first fixed sparsity rate and the second fixed sparsity rate are equal.

[0068] In summary, the contribution of this invention is to propose a federated learning algorithm with a fixed sparsity rate. Based on this fixed sparsity rate, the number of overall parameters is effectively reduced by selectively discarding parameters. This reduction leads to improved communication efficiency and reduced communication overhead. Furthermore, the use of fixed sparsity compression helps reduce the risk of overfitting. In addition, this invention includes an error feedback mechanism, which significantly improves the accuracy of image classification. Overall, these innovations bring significant optimization and progress to the field of federated learning.

[0069] It should be understood that, although Figure 1 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figure 1 At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.

[0070] In one embodiment, an image classification apparatus based on fixed sparsity rate compression is provided, comprising: a target client determination module, an update parameter compression module, a global parameter transmission module, and an image classification module, wherein:

[0071] The target client determination module is used to randomly select a preset number of client devices as target client devices after the local training of the current round is completed; each client device corresponds to a local image dataset and a local image classification model;

[0072] The parameter compression module is used to compress the corresponding updated parameters according to a preset first fixed sparsity rate and upload them to the central server if the parameters of the local image classification model of the target client device change, thereby obtaining the updated global image classification model.

[0073] The global parameter transmission module is used to transmit the parameters of the updated global image classification model to all client devices through the central server after compression according to the preset second fixed sparsity rate, so as to carry out the next round of local training until the preset conditions are met and the trained global image classification model is obtained.

[0074] The image classification module is used to classify images based on a trained global image classification model.

[0075] Specific limitations regarding the image classification device based on fixed sparsity compression can be found in the limitations of the image classification method based on fixed sparsity compression mentioned above, and will not be repeated here. Each module in the aforementioned image classification device based on fixed sparsity compression can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0076] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 3 As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external terminals via a network connection. When executed by the processor, the computer program implements an image classification method based on fixed sparsity rate compression. The display screen can be a liquid crystal display (LCD) or an e-ink display. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.

[0077] Those skilled in the art will understand that Figure 1 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0078] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0079] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0080] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. An image classification method based on fixed sparsity compression, characterized in that, The method includes: After the local training of the current round is completed, a preset number of client devices are randomly selected as target client devices; each client device corresponds to a local image dataset and a local image classification model. If the parameters of the local image classification model of the target client device change, the corresponding updated parameters are compressed according to the preset first fixed sparsity rate and uploaded to the central server, thereby obtaining the updated global image classification model. The central server compresses the parameters of the updated global image classification model according to the preset second fixed sparsity rate and transmits them to all client devices for the next round of local training until the preset conditions are met and the trained global image classification model is obtained. Image classification is performed based on a trained global image classification model; The method further includes: when uploading the corresponding update parameters to the central server after compression according to a preset first fixed sparsity rate, calculating and retaining the error before and after compression of the update parameters, and accumulating it in the next round of local training; When the corresponding update parameters are compressed according to a preset first fixed sparsity rate and uploaded to the central server, the error before and after compression is calculated and retained, and accumulated in the next round of local training. Specifically: ; ; ; in, Indicates the first Model parameters after error accumulation before the start of each round of local training. Indicates the first After the first round of local training, the The parameters of the local image classification model updated by each target client device. Indicates the first After the first round of local training, the The parameters of the local image classification model obtained from the updates of each target client device. It is the first The updated parameters of the local image classification model obtained after the first round of local training. Indicates the first The error in parameter update before and after compression for each round of local training. Representative before selection The largest element.

2. The method according to claim 1, characterized in that, If the parameters of the local image classification model on the target client device change, the corresponding updated parameters are compressed according to a preset second fixed sparsity rate and uploaded to the central server to obtain an updated global image classification model, including: ; in, Indicates the first The global image classification model parameters before the update in each round, Indicates the first The updated global image classification model parameters in each round Indicates the first The target client device in the first After each round of local training, the corresponding changes in the model parameters of the local image classification model are as follows: Indicates the number of target client devices. Indicates the first The total number of samples in the local image dataset corresponding to each target client device This is the assignment operator.

3. The method according to claim 2, characterized in that, The update parameters are calculated as follows: ; ; in, Indicates the first After the first round of local training, the Model parameters corresponding to each target client device Indicates the first Before the start of the next round of local training, the first Model parameters corresponding to each target client device Indicates the learning rate. Indicates the first The gradients generated during each round of local training.

4. The method according to claim 1, characterized in that, The method further includes: when transmitting the parameters of the updated global image classification model to all client devices after compression according to a preset second fixed sparsity rate through the central server, calculating and retaining the error before and after compression of the parameters of the updated global image classification model, and accumulating it into the next round of global training.

5. The method according to claim 1, characterized in that, The first fixed sparsity rate and the second fixed sparsity rate are equal.

6. An image classification device based on fixed sparsity compression, characterized in that, The apparatus comprising the method according to any one of claims 1 to 5, wherein the apparatus includes: The target client determination module is used to randomly select a preset number of client devices as target client devices after the local training of the current round is completed; each client device corresponds to a local image dataset and a local image classification model; The parameter compression module is used to compress the corresponding updated parameters according to a preset first fixed sparsity rate and upload them to the central server if the parameters of the local image classification model of the target client device change, thereby obtaining the updated global image classification model. The global parameter transmission module is used to transmit the parameters of the updated global image classification model to all client devices through the central server after compression according to the preset second fixed sparsity rate, so as to carry out the next round of local training until the preset conditions are met and the trained global image classification model is obtained. The image classification module is used to classify images based on a trained global image classification model.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.