Model training method and system based on decentralized learning, client and medium
Patent Information
- Application Number
- CN202610990498.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-03
- Publication Date
- 2026-10-30
AI Technical Summary
[0003]目前去中心化学习方法大多依赖模型整体参数平均或邻域加权平均进行参数聚合,以及基于参数交换、参数重组或扰动训练的方法,但是此方式对于损失空间探索能力不足,可能使复杂模型陷入局部次优解,并且容易忽略客户端在本地数据上学习到的特有知识,导致整体训练性能受限,以及通常缺乏对不同训练阶段中探索强度与收敛稳定性的动态调节机制,容易在训练后期由于参数扰动或交换强度过高造成模型震荡,影响收敛稳定性,进而导致训练得到的模型性能不佳
[0010]本申请提供一种基于去中心化学习的模型训练方法、系统、客户端及介质,本申请响应于模型训练请求,根据本地样本数据集对神经网络模型进行训练,以更新神经网络模型,获取更新后的神经网络模型的模型参数作为第一模型参数;获取至少一个目标客户端发送的第二模型参数和模型损失值,其中,目标客户端为与所述第一客户端存在关联的所述第二客户端,第二模型参数和模型损失值是所述目标客户端基于本地样本数据集对神经网络模型进行训练后得到的;根据每个目标客户端各自对应的模型训练损失值,确定动态截断比例;根据动态截断比例、第一模型参数和每个目标客户端各自对应的第二模型参数对多个网络层进行分组,得到第一网络层组和第二网络层组;根据一个所述目标客户端中各所述网络层的第二模型参数对第一网络层组中各匹配网络层的第一模型参数进行替换更新,以及根据每个目标客户端各所述网络层的第二模型参数对第二网络层组中各匹配网络层的第一模型参数进行参数平均聚合更新,得到去中心化学习之后神经网络模型的目标模型参数;基于将模型参数更新为目标模型参数的神经网络模型执行根据本地样本数据集对神经网络模型进行训练,以更新神经网络模型的步骤,直至得到收敛的神经网络模型。本申请中将去中心化学习的模型参数融合由模型级扩展至网络层级,使客户端能够针对不同网络层分别执行融合操作,从而能够有效地提高模型参数更新的准确性,以及通过将动态截断比例将各网络层分为第一网络层组和第二网络层组,并使得第一网络层组中的各网络层执行参数交换更新,以及使得第二网络层组中各网络层执行参数平均更新,有效地解决了单纯平均探索不足和单纯交换收敛不稳定的问题,进而有效地提高了去中心化学习的效率和准确性。
Smart Images

Figure CN123014052A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a model training method, system, client, and medium based on decentralized learning. Background Technology
[0002] With the rapid development of artificial intelligence and distributed computing technologies, decentralized learning has received widespread attention and research. Existing research usually improves model training performance by aggregating weight adjustments, local training constraints, sparse parameter updates, gradient correction, or parameter reorganization, so as to alleviate the impact of client data distribution differences and communication topology limitations.
[0003] Currently, most decentralized learning methods rely on averaging the overall model parameters or neighborhood weighted averaging for parameter aggregation, as well as training methods based on parameter exchange, parameter recombination, or perturbation. However, these methods are insufficient in exploring the loss space, which may cause complex models to get stuck in local suboptimal solutions. They also tend to ignore the unique knowledge learned by the client on local data, resulting in limited overall training performance. Furthermore, they usually lack dynamic adjustment mechanisms for the exploration intensity and convergence stability in different training stages. In the later stages of training, excessive parameter perturbation or exchange intensity can cause model oscillations, affecting convergence stability and leading to poor performance of the trained model.
[0004] Therefore, improving the efficiency and accuracy of decentralized learning is an urgent problem to be solved. Summary of the Invention
[0005] The main purpose of this application is to provide a model training method, system, client, and medium based on decentralized learning, aiming to improve the efficiency and accuracy of decentralized learning.
[0006] In a first aspect, this application provides a model training method based on decentralized learning, applied to a first client, wherein the first client and multiple second clients constitute a decentralized learning system, and both the first client and each of the second clients load an initialized neural network model, the neural network model comprising multiple network layers, the method comprising: In response to a model training request, the neural network model is trained based on a local sample dataset to update the neural network model, and the updated model parameters of the neural network model are obtained as the first model parameters. Obtain at least one second model parameter and model loss value sent by a target client, wherein the target client is a second client associated with the first client, and the second model parameter and the model loss value are obtained by the target client after training the neural network model based on a local sample dataset; The dynamic truncation ratio is determined based on the model training loss value corresponding to each of the target clients. The multiple network layers are grouped according to the dynamic truncation ratio, the first model parameters, and the second model parameters corresponding to each target client to obtain a first network layer group and a second network layer group. The first model parameters of each matching network layer in the first network layer group are replaced and updated according to the second model parameters of each network layer in the target client, and the first model parameters of each matching network layer in the second network layer group are updated by parameter averaging aggregation according to the second model parameters of each network layer in the target client, so as to obtain the target model parameters of the neural network model after decentralized learning. The neural network model, whose model parameters are updated to the target model parameters, is trained based on a local sample dataset to update the neural network model until a converged neural network model is obtained.
[0007] Secondly, this application also provides a decentralized learning system, which includes a first client and multiple second clients. Each of the first client and each of the second clients loads an initialized neural network model, which includes multiple network layers, wherein: The first client is configured to respond to a model training request, train the neural network model based on a local sample dataset to update the neural network model, and obtain the updated model parameters of the neural network model as the first model parameters. The second client is used to respond to a model training request, train the neural network model based on a local sample dataset to update the neural network model, and obtain the updated model parameters of the neural network model as the second model parameters. The first client is further configured to obtain second model parameters and model loss values sent by at least one target client, wherein the target client is the second client associated with the first client; Based on the model training loss value corresponding to each target client, a dynamic truncation ratio is determined; based on the dynamic truncation ratio, the first model parameters, and the second model parameters corresponding to each target client, the multiple network layers are grouped to obtain a first network layer group and a second network layer group. The first model parameters of each matching network layer in the first network layer group are replaced and updated according to the second model parameters of each network layer in the target client, and the first model parameters of each matching network layer in the second network layer group are updated by parameter averaging aggregation according to the second model parameters of each network layer in the target client, so as to obtain the target model parameters of the neural network model after decentralized learning. The neural network model, whose model parameters are updated to the target model parameters, is trained based on a local sample dataset to update the neural network model until a converged neural network model is obtained.
[0008] Thirdly, this application also provides a client, which includes a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, it implements the steps of the decentralized learning-based model training method described above.
[0009] Fourthly, this application also provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the steps of the decentralized learning-based model training method described above.
[0010] This application provides a model training method, system, client, and medium based on decentralized learning. In response to a model training request, this application trains a neural network model using a local sample dataset to update the neural network model, obtaining the updated model parameters as first model parameters; it then obtains second model parameters and model loss values sent by at least one target client, wherein the target client is a second client associated with the first client, and the second model parameters and model loss values are obtained by the target client after training the neural network model based on the local sample dataset; a dynamic truncation ratio is determined based on the model training loss value corresponding to each target client; and the dynamic truncation ratio and the first model parameters are then used to determine the dynamic truncation ratio. Multiple network layers are grouped according to the second model parameters corresponding to each target client to obtain a first network layer group and a second network layer group. The first model parameters of each matching network layer in the first network layer group are replaced and updated according to the second model parameters of each network layer in one of the target clients. The first model parameters of each matching network layer in the second network layer group are updated by parameter averaging and aggregation according to the second model parameters of each network layer in each target client to obtain the target model parameters of the neural network model after decentralized learning. Based on the neural network model with updated model parameters to target model parameters, the neural network model is trained according to the local sample dataset to update the neural network model until a converged neural network model is obtained. This application extends the fusion of model parameters in decentralized learning from the model level to the network layer level, enabling clients to perform fusion operations on different network layers separately. This effectively improves the accuracy of model parameter updates. Furthermore, by dynamically truncating the network layers into a first network layer group and a second network layer group, and by having each network layer in the first network layer group perform parameter exchange updates and each network layer in the second network layer group perform parameter average updates, this effectively solves the problems of insufficient simple average exploration and unstable convergence of simple exchange, thereby effectively improving the efficiency and accuracy of decentralized learning. Attached Figure Description
[0011] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 A flowchart illustrating a model training method based on decentralized learning provided in this application embodiment; Figure 2 A schematic diagram of a scenario for implementing the decentralized learning-based model training method provided in this embodiment; Figure 3 for Figure 1 A flowchart illustrating the sub-steps of a decentralized learning-based model training method. Figure 4 for Figure 1 A flowchart illustrating the sub-steps of a decentralized learning-based model training method. Figure 5 A schematic block diagram of a decentralized learning system provided in this application embodiment; Figure 6 This is a schematic block diagram of a client structure provided in an embodiment of this application.
[0013] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0014] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0015] The flowchart shown in the attached diagram is for illustrative purposes only and does not necessarily include all content and operations / steps, nor does it necessarily have to be performed in the order described. For example, some operations / steps can be broken down, combined, or partially merged, so the actual execution order may change depending on the actual situation.
[0016] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.
[0017] Foundational technologies for artificial intelligence generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0018] With the rapid development of artificial intelligence and distributed computing technologies, decentralized learning has received widespread attention and research. Existing research usually improves model training performance by aggregating weight adjustments, local training constraints, sparse parameter updates, gradient correction, or parameter reorganization, so as to alleviate the impact of client data distribution differences and communication topology limitations.
[0019] Currently, most decentralized learning methods rely on averaging the overall model parameters or neighborhood weighted averaging for parameter aggregation, as well as training methods based on parameter exchange, parameter recombination, or perturbation. However, these methods are insufficient in exploring the loss space, which may cause complex models to get stuck in local suboptimal solutions. They also tend to ignore the unique knowledge learned by the client on local data, resulting in limited overall training performance. Furthermore, they usually lack dynamic adjustment mechanisms for the exploration intensity and convergence stability in different training stages. In the later stages of training, excessive parameter perturbation or exchange intensity can cause model oscillations, affecting convergence stability and leading to poor performance of the trained model.
[0020] To address the aforementioned problems, this application provides a model training method, system, client, and medium based on decentralized learning. The decentralized learning-based model training method includes: responding to a model training request, training the neural network model based on a local sample dataset to update the neural network model, and obtaining the updated model parameters of the neural network model as first model parameters; obtaining second model parameters and model loss values sent by at least one target client, wherein the target client is a second client associated with the first client, and the second model parameters and model loss values are obtained by the target client after training the neural network model based on the local sample dataset; determining a dynamic truncation ratio based on the model training loss value corresponding to each target client; and determining the dynamic truncation ratio based on the dynamic truncation ratio. The first model parameters and the second model parameters corresponding to each target client are used to group the multiple network layers to obtain a first network layer group and a second network layer group. The first model parameters of each matching network layer in the first network layer group are replaced and updated according to the second model parameters of each network layer in a target client. The first model parameters of each matching network layer in the second network layer group are then updated by parameter averaging and aggregation according to the second model parameters of each network layer in each target client, resulting in the target model parameters of the neural network model after decentralized learning. Based on the neural network model with updated model parameters to the target model parameters, the neural network model is trained using a local sample dataset to update the neural network model, until a converged neural network model is obtained.
[0021] The decentralized learning-based model training method can be applied to clients, which can be electronic devices such as mobile phones, tablets, laptops, desktop computers, personal digital assistants, and wearable devices.
[0022] The following detailed description of some embodiments of this application is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0023] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating a model training method based on decentralized learning, provided as an embodiment of this application.
[0024] like Figure 1 As shown, the model training method based on decentralized learning includes steps S101 to S106.
[0025] Step S101: In response to the model training request, train the neural network model based on the local sample dataset to update the neural network model, and obtain the updated model parameters of the neural network model as the first model parameters.
[0026] The decentralized learning model training method is applied to a first client, which, together with multiple second clients, constitutes a decentralized learning system. The first client and multiple second clients form a decentralized communication topology according to a preset communication relationship. Each first client only interacts with its target client to exchange model parameters or model status information, without needing to collect, aggregate, and distribute models through a central server. Both the first client and each second client load an initialized neural network model, which includes multiple network layers.
[0027] For example, such as Figure 2 As shown, the decentralized learning system includes client 1, client 2, client 3, client 4, client 5, and client 6. When client 1 is the first client, clients 2, 3, 4, and 6 are determined as target clients according to a preset communication relationship. That is, client 1 only interacts with clients 2, 3, 4, and 6 to exchange model parameters or model status information. Similarly, when client 3 is the first client, clients 1, 2, and 6 are determined as target clients according to a preset communication relationship. That is, client 3 only interacts with clients 1, 2, and 6 to exchange model parameters or model status information. The same applies to other clients as the first client, and this embodiment will not be elaborated further.
[0028] The preset communication relationship is determined based on physical communication connection, network distance, channel quality, device location, task association relationship or preset connection rules, and this application embodiment does not specifically limit it.
[0029] It should be noted that this neural network model includes, but is not limited to, Convolutional Neural Networks (CNN) models, Deep Neural Networks (DNN) models, Recurrent Neural Networks (RNN) models, Factorisation Machine supported Neural Networks (FNN) models, Neural Factorization Machines (NFM) models, Attentional Factorization Machines (AFM) models, image processing models based on neural networks, face recognition models based on neural networks, speech recognition models based on neural networks, and text translation models based on neural networks.
[0030] In some embodiments, in response to a model training request, the neural network model is trained based on a local sample dataset to update the neural network model. The updated model parameters are then used as the first model parameters. Training the neural network model using the local sample dataset allows for accurate training of the local model. It should be noted that training the neural network model based on a local sample dataset is a conventional technique, and this application will not elaborate on it in detail.
[0031] It should be noted that this neural network model includes multiple network layers, and the model parameters include the network layer-level model parameters for each network layer, for example, Among them, the These are the model parameters for the neural network model. These are the model parameters for the first network layer. Let R be the model parameters of the Rth network layer. The updated neural network model is shown in the formula. Among them, the For the updated model parameters, this The model parameters before the update To improve model learning efficiency.
[0032] In some embodiments, in each second client, in response to a model training request, the neural network model is trained based on a local sample dataset to update the neural network model, and the updated model parameters are obtained as second model parameters. Similarly, each second client trains the neural network model based on the local sample dataset, accurately completing the training of the local model to provide a model parameter foundation for subsequent decentralized learning. Likewise, the updating of model parameters in each second client can refer to the aforementioned method for updating the model in the first client.
[0033] Step S102: Obtain at least one second model parameter and model loss value sent by a target client, wherein the target client is the second client associated with the first client, and the second model parameter and the model loss value are obtained by the target client after training the neural network model based on a local sample dataset.
[0034] The target client is a second client that is associated with the first client. This association is determined based on a preset communication relationship. This application embodiment does not specifically limit this relationship. The second model parameters and the model loss value are obtained by the target client after training the neural network model based on the local sample dataset.
[0035] Based on a preset communication relationship, at least one target client is determined from multiple second clients, and the second model parameters generated by each target client during model training, as well as the model loss value during the model training process, are obtained. The second model parameters are obtained by the target client training the neural network model based on the local sample dataset to update the neural network model and obtaining the updated neural network model parameters.
[0036] Step S103: Determine the dynamic truncation ratio based on the model training loss value corresponding to each target client.
[0037] Here, the dynamic truncation ratio is the relative proportion of the model's dynamic confidence level.
[0038] In some embodiments, such as Figure 3 As shown, step S103 includes sub-steps S1031 to S1033.
[0039] Sub-step S1031: Determine the stability score of model training based on the model training loss value corresponding to each of the target clients.
[0040] Calculate the variance of the model training loss value corresponding to each target client to obtain the training loss variance; obtain multiple historical training loss variances, which are determined based on the model training loss values generated by each target client during decentralized learning before the current time point; calculate the standard deviation of the training loss variance and multiple historical training loss variances, and determine the calculated standard deviation as the stability score.
[0041] It should be noted that the stability score can also be determined based on training other parameter values of the neural network model, and this application does not impose specific limitations on this.
[0042] Sub-step S1032: When the stability score is greater than or equal to the preset stability score, the preset first threshold is determined as the dynamic truncation ratio.
[0043] The preset stability score can be set according to the actual situation. This application embodiment does not make specific limitations on this. For example, the preset stability score can be set to 0.6.
[0044] In some embodiments, when the stability score is greater than or equal to a preset stability score, a preset first threshold is determined as the dynamic cutoff ratio. This preset first threshold can be set according to actual conditions, and this application embodiment does not impose a specific limitation on it. For example, the preset first threshold can be set to 0.75.
[0045] For example, when the stability score is 0.8 and the preset stability score is 0.6, the stability score is greater than the preset stability score, and the preset first threshold is determined as the dynamic truncation ratio.
[0046] Sub-step S1033: When the stability score is less than the preset stability score, determine the dynamic truncation ratio according to the preset first threshold and the preset second threshold, wherein the preset first threshold is greater than the preset second threshold.
[0047] The preset second threshold can be set according to the actual situation. This application embodiment does not make specific limitations on this. For example, the preset second threshold can be set to 0.25.
[0048] In some embodiments, when the stability score is less than a preset stability score, the value of the dynamic cutoff ratio gain minus a preset first threshold is determined as the dynamic cutoff ratio, wherein the dynamic cutoff ratio gain is determined based on the preset first threshold and a preset second threshold.
[0049] In some embodiments, the method for determining the dynamic truncation ratio gain can be as follows: when the stability score is less than a preset stability score, the decentralized training epoch is obtained and determined as the standard decentralized training epoch. The decentralized training epoch is the cumulative number of times the decentralized training started from the beginning of the neural network model until the current decentralized training; the current decentralized training epoch is obtained; and the standard decentralized training epoch, the current decentralized training epoch, a preset first threshold, and a preset second threshold are calculated based on a preset decay function to obtain the dynamic truncation ratio gain. The preset decay function can be selected according to actual conditions, and this embodiment does not specifically limit it. For example, the preset decay function can be a sigmoid function, a linear decay function, an exponential decay function, a step decay function, a cosine decay function, and an adaptive threshold function, etc.
[0050] In some embodiments, the dynamic truncation ratio gain is obtained by calculating the standard decentralized training epoch, the current decentralized training epoch, a preset first threshold, and a preset second threshold based on a preset decay function. This can be achieved by using a Sigmoid function as the preset decay function, obtaining the Sigmoid function, and defining the Sigmoid function as follows: ,Should To dynamically cut off the proportional gain, this For the Sigmoid function, this For the current decentralized training round, this For standard decentralized training rounds, this Preset coefficient, this To preset the first threshold, the A second preset threshold is used; based on the Sigmoid function, the dynamic truncation ratio gain is calculated for the standard decentralized training epoch, the current decentralized training epoch, the preset first threshold, and the preset second threshold. Wherein, It can be set according to the actual situation, for example, this It can be the product of the total number of times the neural network model is trained and the proportion of decentralized training rounds to the total number of times the neural network model is trained.
[0051] As can be seen from the above, the dynamic truncation ratio is a decaying process, which is based on the decentralized learning training rounds gradually decreasing from the preset first threshold to the preset second threshold.
[0052] Step S104: Group the multiple network layers according to the dynamic truncation ratio, the first model parameters, and the second model parameters corresponding to each target client to obtain a first network layer group and a second network layer group.
[0053] The first and second network layer groups comprise the total network layers of the neural network model.
[0054] In some embodiments, such as Figure 4 As shown, step S104 includes sub-steps S1041 to S1042.
[0055] Sub-step S1041: Based on the first model parameters and the second model parameters corresponding to each of the target clients, determine the similarity between each network layer in the first client and the corresponding network layer in each of the target clients.
[0056] For each network layer in the first client, the similarity between the first model parameters of that network layer and the second model parameters of the corresponding network layer in each target client is calculated to obtain the similarity between each network layer in the first client and the corresponding network layer in each target client.
[0057] For example, the target clients include target client 1, target client 2, and target client 3, and the neural network includes network layer 1, network layer 2, and network layer 3. For network layer 1 in the first client, the similarity between the first model parameters of network layer 1 in the first client and the second model parameters of network layer 1 in target client 1 is calculated to obtain a first similarity; the similarity between the first model parameters of network layer 1 in the first client and the second model parameters of network layer 1 in target client 2 is calculated to obtain a second similarity; the similarity between the first model parameters of network layer 1 in the first client and the second model parameters of network layer 1 in target client 3 is calculated to obtain a third similarity. Similarly, for network layer 2 in the first client, the similarity between the first model parameters of network layer 2 in the first client and the second model parameters of network layer 2 in target client 1 is calculated to obtain a fourth similarity; the similarity between the first model parameters of network layer 2 in the first client and the second model parameters of network layer 2 in target client 2 is calculated to obtain a fifth similarity; the similarity between the first model parameters of network layer 2 in the first client and the second model parameters of network layer 2 in target client 3 is calculated to obtain a sixth similarity.
[0058] Similarly, for network layer 3 in the first client, the similarity between the first model parameters of network layer 2 in the first client and the second model parameters of network layer 3 in the target client 1 is calculated to obtain the seventh similarity; the similarity between the first model parameters of network layer 3 in the first client and the second model parameters of network layer 3 in the target client 2 is calculated to obtain the eighth similarity; the similarity between the first model parameters of network layer 3 in the first client and the second model parameters of network layer 3 in the target client 3 is calculated to obtain the ninth similarity.
[0059] The methods for calculating the similarity between the first model parameters of the network layer and the second model parameters of the corresponding network layer in each target client include, but are not limited to, cosine similarity, Euclidean distance, KL divergence, JS divergence, correlation coefficient, gradient similarity, parameter distribution distance, and feature response similarity, etc.
[0060] Sub-step S1042: Group the multiple network layers according to the dynamic truncation ratio and the similarity between each network layer in the first client and the corresponding network layer in each target client to obtain a first network layer group and a second network layer group.
[0061] In some embodiments, for each network layer, the minimum similarity between it and the corresponding network layer in each target client is determined as the target similarity of the network layer in the first client; the network layers are sorted according to the target similarity from smallest to largest to obtain a network layer queue; the network layer queue is divided according to the dynamic truncation ratio to obtain a first network layer group and a second network layer group, wherein the target similarity of each network layer in the first network layer group is less than the target similarity of each network layer in the second network layer group.
[0062] For example, for each network layer, the minimum similarity between it and the corresponding network layer in each target client can be determined as the target similarity of the network layer in the first client as follows: For network layer 1, the similarity between network layer 1 in the first client and the corresponding network layer 1 in target client 1 is 0.3, the similarity between network layer 1 in the first client and the corresponding network layer 1 in target client 2 is 0.5, and the similarity between network layer 1 in the first client and the corresponding network layer 1 in target client 3 is 0.2. Then, the minimum similarity between network layer 1 in the first client and the corresponding network layer 1 in target client 3 is 0.2, and the target similarity of network layer 1 in the first client is determined as 0.2.
[0063] For example, the network layers can be sorted from smallest to largest according to their target similarity to obtain a network layer queue. The target similarity of network layer 1 is 0.5, the target similarity of network layer 2 is 0.6, and the target similarity of network layer 3 is 0.2. The network layers are sorted from smallest to largest according to their target similarity to obtain a network layer queue of network layer 3, network layer 1, and network layer 2.
[0064] In some embodiments, the method of dividing the network layer queue according to the dynamic truncation ratio to obtain the first network layer group and the second network layer group can be as follows: the network layer queue is divided according to the dynamic truncation ratio to obtain two network layer groups after division, the network layer group with lower similarity is determined as the first network layer group, and the network layer group with higher similarity is determined as the second network layer group.
[0065] For example, the network layer queue includes network layer 3, network layer 1 and network layer 2. The dynamic truncation ratio is 0.33, which divides the network layer queue into network layer group of network layer 3, network layer group of network layer 1 and network layer 2. The network layer group in which network layer 3 is located is determined as the first network layer group, and the network layer group in which network layer 1 and network layer 2 are located is determined as the second network layer group.
[0066] For example, a preset client grouping formula is obtained, which includes... , Among them, the As the first network layer group, this This is the second network layer group. As a layer of the network, this For the selected network layer, this Let r be the proportion of the r-th layer in the entire network layer queue position. As a dynamic truncation ratio, based on the preset client grouping formula, each network layer is grouped according to its position ratio in the entire network layer queue and the dynamic truncation ratio, resulting in a first network layer group and a second network layer group.
[0067] It should be noted that if the dynamic truncation ratio cannot completely divide a network layer, the network layers at the critical point of division will be randomly grouped, or the groups with a large proportion of network layers at the critical point of division will be grouped. For example, if the network layer queue includes network layer 3, network layer 1, and network layer 2, and the dynamic truncation ratio is 0.4, then the network layer group containing network layer 3 will be determined as the first network layer group, and the network layer group containing network layers 1 and network layer 2 will be determined as the second network layer group.
[0068] Step S105: Replace and update the first model parameters of each matching network layer in the first network layer group according to the second model parameters of each network layer in the target client, and perform parameter averaging aggregation update on the first model parameters of each matching network layer in the second network layer group according to the second model parameters of each network layer in the target client, to obtain the target model parameters of the neural network model after decentralized learning.
[0069] In some embodiments, for each network layer in the first network layer group, the second model parameters of the target network layer that matches the network layer in the first target client are obtained. The first target client is selected from multiple target clients based on the number of local sample datasets of each target client. The first model parameters of the network layer are then replaced and updated with the second model parameters of the target network layer. By replacing and updating the model parameters of each network layer in the first network layer group, the first model parameters can be updated effectively and quickly.
[0070] Among them, the target client with the largest number of local sample datasets is determined as the first target client.
[0071] For example, for network layer 1 in the first network layer group, the target client 2, which has the largest number of local sample datasets, is determined as the first target client. The second model parameters of network layer 1 in target client 2 are obtained, and the first model parameters of network layer 1 in the first network layer group are replaced and updated with the second model parameters of network layer 1 in target client 2. Similarly, the parameter replacement and update are performed on other network layers in the same way.
[0072] In some embodiments, for each network layer in the first network layer group, the second model parameters of the target network layer that matches the network layer in the first target client are obtained, wherein the first target client is randomly selected from a plurality of target clients; and the first model parameters of the network layer are replaced and updated with the second model parameters of the target network layer.
[0073] In some embodiments, for each network layer in the first network layer group, the second model parameters of the target network layer that matches the network layer in the second target client are obtained. The second target client is the target client with the smallest similarity to the model parameters of the network layers in the first network layer group. The first model parameters of the network layer are replaced and updated with the second model parameters of the target network layer.
[0074] For example, a preset parameter exchange formula is obtained, which includes... ,or Among them, the The updated model parameters for the network layers. For the model parameters of the second target client, this These are the model parameters for the first target client. Based on this preset parameter exchange formula, the network layers in the first network layer group are updated by exchanging parameters according to the model parameters of the matching network layers in the second target client or the first target client.
[0075] In some embodiments, for each network layer in the second network layer group, the second model parameters of the target network layer that matches the network layer in each target client are obtained to obtain at least one second model parameter of the target network layer; the first model parameter of the network layer and the second model parameter of the at least one target network layer are averaged and aggregated to obtain a third model parameter; the first model parameter of the network layer is replaced and updated with the third model parameter.
[0076] For example, a preset parameter aggregation formula is obtained, which is: ,Should The updated model parameters for the network layer of the first client. The weight coefficients for aggregation on target client j. Here are the model parameters for the network layer of the target client j. Based on this preset parameter aggregation formula, the model parameters of each matching network layer in the first client are updated according to the model parameters of the network layer of each target client.
[0077] Step S106: Based on the neural network model with updated model parameters to the target model parameters, perform the step of training the neural network model according to the local sample dataset to update the neural network model until a converged neural network model is obtained.
[0078] After updating the model parameters of the neural network model to the target model parameters, the process proceeds to train the neural network model using the local sample dataset to update the model. It then determines whether the neural network model has converged. If it has not converged, the process continues to obtain the updated model parameters as the first model parameters, until a converged neural network model is obtained. Similarly, each second client also trains the neural network model using the local sample dataset to update the model.
[0079] It should be noted that determining whether a neural network model has converged is a common technique for training neural network models, and this application does not elaborate on or limit the specific training process of the model.
[0080] The decentralized learning-based model training method provided in the above embodiments extends the fusion of decentralized learning model parameters from the model level to the network layer level, enabling the client to perform fusion operations on different network layers separately. This effectively improves the accuracy of model parameter updates. Furthermore, by dividing each network layer into a first network layer group and a second network layer group through a dynamic truncation ratio, and by having each network layer in the first network layer group perform parameter exchange updates and each network layer in the second network layer group perform parameter average updates, the method effectively solves the problems of insufficient simple average exploration and unstable convergence of simple exchange, thereby effectively improving the efficiency and accuracy of decentralized learning.
[0081] Please see Figure 5 , Figure 5 This is a schematic block diagram of a decentralized learning system provided in an embodiment of this application.
[0082] like Figure 5 As shown, the decentralized learning system 200 includes a first client 210 and multiple second clients 220. Each of the first client and each of the second clients loads an initialized neural network model, which includes multiple network layers, wherein: The first client 210 is configured to respond to a model training request, train the neural network model based on a local sample dataset to update the neural network model, and obtain the updated model parameters of the neural network model as the first model parameters. The second client 220 is used to respond to a model training request, train the neural network model based on a local sample dataset to update the neural network model, and obtain the updated model parameters of the neural network model as the second model parameters. The first client 210 is further configured to obtain second model parameters and model loss values sent by at least one target client, wherein the target client is the second client associated with the first client; Based on the model training loss value corresponding to each target client, a dynamic truncation ratio is determined; based on the dynamic truncation ratio, the first model parameters, and the second model parameters corresponding to each target client, the multiple network layers are grouped to obtain a first network layer group and a second network layer group. The first model parameters of each matching network layer in the first network layer group are replaced and updated according to the second model parameters of each network layer in the target client, and the first model parameters of each matching network layer in the second network layer group are updated by parameter averaging aggregation according to the second model parameters of each network layer in the target client, so as to obtain the target model parameters of the neural network model after decentralized learning. The neural network model, whose model parameters are updated to the target model parameters, is trained based on a local sample dataset to update the neural network model until a converged neural network model is obtained.
[0083] In some embodiments, the first client 210 is further configured to: Based on the model training loss value corresponding to each of the target clients, a model training stability score is determined; When the stability score is greater than or equal to the preset stability score, the preset first threshold is determined as the dynamic truncation ratio; When the stability score is less than the preset stability score, a dynamic truncation ratio is determined based on the preset first threshold and the preset second threshold, wherein the preset first threshold is greater than the preset second threshold.
[0084] In some embodiments, the first client 210 is further configured to: Calculate the variance of the model training loss value corresponding to each of the target clients to obtain the training loss variance; Multiple historical training loss variances are obtained, which are determined based on the model training loss values generated by each target client during decentralized learning before the current time point; Calculate the standard deviation of the training loss variance and the variance of the plurality of historical training losses, and determine the calculated standard deviation as the stability score.
[0085] In some embodiments, the first client 210 is further configured to: Based on the first model parameters and the second model parameters corresponding to each target client, the similarity between each network layer in the first client and the corresponding network layer in each target client is determined. The multiple network layers are grouped according to the dynamic truncation ratio and the similarity between each network layer in the first client and the corresponding network layer in each target client to obtain a first network layer group and a second network layer group.
[0086] In some embodiments, the first client 210 is further configured to: For each network layer, the minimum similarity between it and the corresponding network layer in each target client is determined as the target similarity of the network layer in the first client. The network layers are sorted from smallest to largest according to the similarity of the targets to obtain a network layer queue; The network layer queue is divided according to the dynamic truncation ratio to obtain a first network layer group and a second network layer group. The target similarity of each network layer in the first network layer group is less than that of each network layer in the second network layer group.
[0087] In some embodiments, the first client 210 is further configured to: For each network layer in the first network layer group, the second model parameters of the target network layer that matches the network layer in the first target client are obtained. The first target client is obtained by filtering from multiple target clients based on the number of local sample datasets of each target client. The first model parameters of the network layer are replaced and updated with the second model parameters of the target network layer.
[0088] In some embodiments, the first client 210 is further configured to: For each network layer in the second network layer group, obtain the second model parameters of the target network layer that matches the network layer in each target client, and obtain at least one second model parameter of the target network layer; The first model parameters of the network layer and the second model parameters of the at least one target network layer are averaged and aggregated to obtain the third model parameters. The first model parameters of the network layer are replaced and updated with the third model parameters.
[0089] It should be noted that each second client 220 can also serve as a first client for decentralized learning model training. The process of each second client 220 serving as a first client for decentralized learning model training can refer to the specific method of the aforementioned embodiments, and this application will not elaborate further on this.
[0090] It should be noted that those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the above-mentioned decentralized learning system can be referred to the corresponding process in the aforementioned embodiments of the decentralized learning-based model training method, and will not be repeated here.
[0091] Please see Figure 6 , Figure 6 This is a schematic block diagram of a client structure provided in an embodiment of this application.
[0092] like Figure 6 As shown, the client 300 includes a processor 302 and a memory 303 connected via a system bus 301, wherein the memory 303 may include a storage medium and internal memory.
[0093] The storage medium may store a computer program. This computer program includes program instructions that, when executed, cause the processor to perform any method for training a model based on decentralized learning.
[0094] Processor 302 provides computing and control capabilities to support the operation of the entire client.
[0095] Internal memory provides an environment for the execution of computer programs stored in the storage medium. When the computer program is executed by the processor, it enables the processor to perform any model training method based on decentralized learning.
[0096] Those skilled in the art will understand that Figure 6 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 client to which the present application is applied. A specific client may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0097] It should be understood that processor 302 can be a Central Processing Unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among these, the general-purpose processor can be a microprocessor or any conventional processor.
[0098] In one embodiment, the processor 302 is configured to run a computer program stored in a memory to perform the following steps: In response to a model training request, the neural network model is trained based on a local sample dataset to update the neural network model, and the updated model parameters of the neural network model are obtained as the first model parameters. Obtain at least one second model parameter and model loss value sent by a target client, wherein the target client is a second client associated with the first client, and the second model parameter and the model loss value are obtained by the target client after training the neural network model based on a local sample dataset; The dynamic truncation ratio is determined based on the model training loss value corresponding to each of the target clients. The multiple network layers are grouped according to the dynamic truncation ratio, the first model parameters, and the second model parameters corresponding to each target client to obtain a first network layer group and a second network layer group. The first model parameters of each matching network layer in the first network layer group are replaced and updated according to the second model parameters of each network layer in the target client, and the first model parameters of each matching network layer in the second network layer group are updated by parameter averaging aggregation according to the second model parameters of each network layer in the target client, so as to obtain the target model parameters of the neural network model after decentralized learning. Based on the neural network model whose model parameters are updated to the target model parameters, the steps of training the neural network model according to the local sample dataset to update the neural network model are performed until a converged neural network model is obtained.
[0099] In one embodiment, when the processor 302 determines the dynamic truncation ratio based on the model training loss value corresponding to each of the target clients, it is configured to: Based on the model training loss value corresponding to each of the target clients, a model training stability score is determined; When the stability score is greater than or equal to the preset stability score, the preset first threshold is determined as the dynamic truncation ratio; When the stability score is less than the preset stability score, a dynamic truncation ratio is determined based on the preset first threshold and the preset second threshold, wherein the preset first threshold is greater than the preset second threshold.
[0100] In one embodiment, when implementing the step of determining the stability score of model training based on the model training loss value corresponding to each of the target clients, the processor 302 is configured to: Calculate the variance of the model training loss value corresponding to each of the target clients to obtain the training loss variance; Multiple historical training loss variances are obtained, which are determined based on the model training loss values generated by each target client during decentralized learning before the current time point; Calculate the standard deviation of the training loss variance and the variance of the plurality of historical training losses, and determine the calculated standard deviation as the stability score.
[0101] In one embodiment, when the processor 302 implements the process of grouping the plurality of network layers according to the dynamic truncation ratio, the first model parameter, and the second model parameter corresponding to each of the target clients to obtain a first network layer group and a second network layer group, it is configured to: Based on the first model parameters and the second model parameters corresponding to each target client, the similarity between each network layer in the first client and the corresponding network layer in each target client is determined. The multiple network layers are grouped according to the dynamic truncation ratio and the similarity between each network layer in the first client and the corresponding network layer in each target client to obtain a first network layer group and a second network layer group.
[0102] In one embodiment, when the processor 302 implements the process of grouping the plurality of network layers according to the dynamic truncation ratio and the similarity between each network layer in the first client and the corresponding network layer in each target client to obtain a first network layer group and a second network layer group, it is configured to: For each network layer, the minimum similarity between it and the corresponding network layer in each target client is determined as the target similarity of the network layer in the first client. The network layers are sorted from smallest to largest according to the similarity of the targets to obtain a network layer queue; The network layer queue is divided according to the dynamic truncation ratio to obtain a first network layer group and a second network layer group. The target similarity of each network layer in the first network layer group is less than that of each network layer in the second network layer group.
[0103] In one embodiment, when the processor 302 performs the replacement and update of the first model parameters of each matching network layer in the first network layer group according to the second model parameters of each network layer in the target client, it is configured to: For each network layer in the first network layer group, the second model parameters of the target network layer that matches the network layer in the first target client are obtained. The first target client is obtained by filtering from multiple target clients based on the number of local sample datasets of each target client. The first model parameters of the network layer are replaced and updated with the second model parameters of the target network layer.
[0104] In one embodiment, when the processor 302 performs parameter averaging aggregation update on the first model parameters of each matching network layer in the second network layer group based on the second model parameters of each network layer of each target client, it is configured to: For each network layer in the second network layer group, obtain the second model parameters of the target network layer that matches the network layer in each target client, and obtain at least one second model parameter of the target network layer; The first model parameters of the network layer and the second model parameters of the at least one target network layer are averaged and aggregated to obtain the third model parameters. The first model parameters of the network layer are replaced and updated with the third model parameters.
[0105] It should be noted that those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the client described above can be referred to the corresponding process in the aforementioned embodiments of the decentralized learning-based model training method, and will not be repeated here.
[0106] This application also provides a computer-readable storage medium storing a computer program, the computer program including program instructions, and the method implemented when the program instructions are executed can refer to various embodiments of the decentralized learning-based model training method of this application.
[0107] The computer-readable storage medium can be an internal storage unit of the client as described in the foregoing embodiments, such as the client's hard drive or memory. The computer-readable storage medium can be non-volatile or volatile. Alternatively, the computer-readable storage medium can be an external storage device of the client, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the client.
[0108] It should be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification, unless the context clearly indicates otherwise, the singular forms “a,” “an,” and “the” are intended to include the plural forms.
[0109] It should also be understood that the term "and / or" as used in this specification refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations. It should be noted that, herein, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0110] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments. The above descriptions are merely specific implementations of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.
Claims
1. A model training method based on decentralized learning, characterized in that, The method is applied to a first client, which, together with multiple second clients, constitutes a decentralized learning system. Each of the first and second clients loads an initialized neural network model, which includes multiple network layers. The method includes: In response to a model training request, the neural network model is trained based on a local sample dataset to update the neural network model, and the updated model parameters of the neural network model are obtained as the first model parameters. Obtain at least one second model parameter and model loss value sent by a target client, wherein the target client is a second client associated with the first client, and the second model parameter and the model loss value are obtained by the target client after training the neural network model based on a local sample dataset; The dynamic truncation ratio is determined based on the model training loss value corresponding to each of the target clients. The multiple network layers are grouped according to the dynamic truncation ratio, the first model parameters, and the second model parameters corresponding to each target client to obtain a first network layer group and a second network layer group. The first model parameters of each matching network layer in the first network layer group are replaced and updated according to the second model parameters of each network layer in the target client, and the first model parameters of each matching network layer in the second network layer group are updated by parameter averaging aggregation according to the second model parameters of each network layer in the target client, so as to obtain the target model parameters of the neural network model after decentralized learning. Based on the neural network model whose model parameters are updated to the target model parameters, the steps of training the neural network model according to the local sample dataset to update the neural network model are performed until a converged neural network model is obtained.
2. The model training method based on decentralized learning as described in claim 1, characterized in that, The step of determining the dynamic truncation ratio based on the model training loss value corresponding to each target client includes: Based on the model training loss value corresponding to each of the target clients, a model training stability score is determined; When the stability score is greater than or equal to the preset stability score, the preset first threshold is determined as the dynamic truncation ratio; When the stability score is less than the preset stability score, a dynamic truncation ratio is determined based on the preset first threshold and the preset second threshold, wherein the preset first threshold is greater than the preset second threshold.
3. The model training method based on decentralized learning as described in claim 2, characterized in that, The step of determining the stability score of model training based on the model training loss value corresponding to each of the target clients includes: Calculate the variance of the model training loss value corresponding to each of the target clients to obtain the training loss variance; Multiple historical training loss variances are obtained, which are determined based on the model training loss values generated by each target client during decentralized learning before the current time point; Calculate the standard deviation of the training loss variance and the variance of the plurality of historical training losses, and determine the calculated standard deviation as the stability score.
4. The model training method based on decentralized learning as described in claim 1, characterized in that, The step of grouping the multiple network layers according to the dynamic truncation ratio, the first model parameters, and the second model parameters corresponding to each target client to obtain a first network layer group and a second network layer group includes: Based on the first model parameters and the second model parameters corresponding to each target client, the similarity between each network layer in the first client and the corresponding network layer in each target client is determined. The multiple network layers are grouped according to the dynamic truncation ratio and the similarity between each network layer in the first client and the corresponding network layer in each target client to obtain a first network layer group and a second network layer group.
5. The model training method based on decentralized learning as described in claim 4, characterized in that, The step of grouping the multiple network layers according to the dynamic truncation ratio and the similarity between each network layer in the first client and the corresponding network layer in each target client to obtain a first network layer group and a second network layer group includes: For each network layer, the minimum similarity between it and the corresponding network layer in each target client is determined as the target similarity of the network layer in the first client. The network layers are sorted from smallest to largest according to the similarity of the targets to obtain a network layer queue; The network layer queue is divided according to the dynamic truncation ratio to obtain a first network layer group and a second network layer group. The target similarity of each network layer in the first network layer group is less than that of each network layer in the second network layer group.
6. The model training method based on decentralized learning as described in claim 1, characterized in that, The step of replacing and updating the first model parameters of each matching network layer in the first network layer group according to the second model parameters of each network layer in the target client includes: For each network layer in the first network layer group, the second model parameters of the target network layer that matches the network layer in the first target client are obtained. The first target client is obtained by filtering from multiple target clients based on the number of local sample datasets of each target client. The first model parameters of the network layer are replaced and updated with the second model parameters of the target network layer.
7. The model training method based on decentralized learning as described in claim 1, characterized in that, The step of updating the first model parameters of each matching network layer in the second network layer group based on the second model parameters of each network layer of each target client includes: For each network layer in the second network layer group, obtain the second model parameters of the target network layer that matches the network layer in each target client, and obtain at least one second model parameter of the target network layer; The first model parameters of the network layer and the second model parameters of the at least one target network layer are averaged and aggregated to obtain the third model parameters. The first model parameters of the network layer are replaced and updated with the third model parameters.
8. A decentralized learning system, characterized in that, The decentralized learning system includes a first client and multiple second clients. Each of the first client and each of the second clients loads an initialized neural network model, which includes multiple network layers, wherein: The first client is configured to respond to a model training request, train the neural network model based on a local sample dataset to update the neural network model, and obtain the updated model parameters of the neural network model as the first model parameters. The second client is used to respond to a model training request, train the neural network model based on a local sample dataset to update the neural network model, and obtain the updated model parameters of the neural network model as the second model parameters. The first client is further configured to obtain second model parameters and model loss values sent by at least one target client, wherein the target client is the second client associated with the first client; Based on the model training loss value corresponding to each target client, a dynamic truncation ratio is determined; based on the dynamic truncation ratio, the first model parameters, and the second model parameters corresponding to each target client, the multiple network layers are grouped to obtain a first network layer group and a second network layer group. The first model parameters of each matching network layer in the first network layer group are replaced and updated according to the second model parameters of each network layer in the target client, and the first model parameters of each matching network layer in the second network layer group are updated by parameter averaging aggregation according to the second model parameters of each network layer in the target client, so as to obtain the target model parameters of the neural network model after decentralized learning. The neural network model, whose model parameters are updated to the target model parameters, is trained based on a local sample dataset to update the neural network model until a converged neural network model is obtained.
9. A client, characterized in that, The client includes a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, it implements the steps of the model training method based on decentralized learning as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, it implements the steps of the model training method based on decentralized learning as described in any one of claims 1 to 7.