WO2022111639A1 - 联邦学习方法、装置、设备、系统及计算机可读存储介质 - Google Patents

联邦学习方法、装置、设备、系统及计算机可读存储介质 Download PDF

Info

Publication number
WO2022111639A1
WO2022111639A1 PCT/CN2021/133579 CN2021133579W WO2022111639A1 WO 2022111639 A1 WO2022111639 A1 WO 2022111639A1 CN 2021133579 W CN2021133579 W CN 2021133579W WO 2022111639 A1 WO2022111639 A1 WO 2022111639A1
Authority
WO
WIPO (PCT)
Prior art keywords
information
model
federated learning
devices
gain information
Prior art date
Application number
PCT/CN2021/133579
Other languages
English (en)
French (fr)
Inventor
张彦芳
常庆龙
丁伋堃
张亮
孙旭东
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP21897139.8A priority Critical patent/EP4235522A4/en
Publication of WO2022111639A1 publication Critical patent/WO2022111639A1/zh
Priority to US18/325,533 priority patent/US20230306311A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0464Convolutional networks [CNN, ConvNet]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/09Supervised learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/098Distributed learning, e.g. federated learning

Definitions

  • the present application relates to the field of artificial intelligence technology, and in particular, to a federated learning method, apparatus, device, system, and computer-readable storage medium.
  • Federated learning means that in the process of machine learning, each participant can use the data of other parties to conduct joint modeling. There is no need for all parties to share data resources, that is, when the data is not local, data joint training is performed to establish a shared machine learning model.
  • the data on each device is independently generated by the device/user, the non-homologous data of different devices/users has different distribution characteristics, and each device uses the
  • the training data is non-independently and identically distributed (Non-IID). Therefore, according to different data distribution situations, how to improve the efficiency of federated learning is of great significance to federated learning.
  • the present application provides a federated learning method, apparatus, device, system, and computer-readable storage medium, which are used to solve the problems of poor flexibility and low efficiency in obtaining a model.
  • a federated learning method includes: first, a first device receives data distribution information sent by multiple second devices participating in the federated learning.
  • the data distribution information sent by the any second device includes at least one of first gain information and tag type information.
  • the first gain information is used to indicate the degree of correction required for the first model obtained through the last round of training to adapt to the current training sample of any second device
  • the label type information is used to indicate the type corresponding to the label of the current training sample.
  • the first device selects a matching federated learning strategy according to the data distribution information sent by the plurality of second devices.
  • the first device sends the parameter reporting policy corresponding to the federated learning policy to at least one second device among the plurality of second devices, and any second device among the at least one second device is used to report the reporting policy based on the received parameter and the second gain information obtained from the current training sample, where the second gain information is used to obtain the second model of any second device.
  • each second device participating in federated learning sends their respective data distribution information to the first device, so that the first device can judge the distribution of the current training samples of different second devices according to the respective data distribution information, that is, The degree of non-IID of current training samples of different second devices is grasped.
  • the first device selects the federated learning strategy according to the degree of non-IID, and sends the corresponding parameter reporting strategy to each second device based on the selected federated learning strategy, so that each second device updates the model according to the federated learning strategy. . Therefore, the non-IID phenomenon of training data between different second devices is avoided, which interferes with the federated learning process, so that the models obtained by each second device through federated learning have better performance, such as higher accuracy.
  • the first device selects a matching federated learning strategy according to data distribution information sent by multiple second devices, including: the first device selects a matching federated learning strategy according to the difference between the data distributions, and the data The difference between the distributions is determined based on the data distribution information sent by the plurality of second devices.
  • the data distribution information sent by any second device includes first gain information and label type information, and before the first device selects the matching federated learning strategy according to the difference between the data distributions, further includes: The first device determines feature distribution information according to the first gain information of multiple second devices, and the feature distribution information is used to indicate whether the feature distributions of the current training samples of different second devices are the same; the first device determines the feature distribution information according to the feature distribution information and the multiple second devices.
  • the tag type information of the two devices determines the difference between the data distributions.
  • the first device selects a matching federated learning strategy according to the difference between the data distributions, including: indicating based on the feature distribution information that the current training samples of different second devices have the same feature distribution, and different second devices have the same feature distribution. If the label type information of the devices is the same, the matching federated learning strategy is selected as the model average fusion, and the model average fusion is used for federated learning in a way of averaging the gain information.
  • the first device selects a matching federated learning strategy according to the difference between the data distributions, including: indicating that the current training samples of different second devices have different feature distributions based on the feature distribution information, and different second devices have different feature distributions. If the label type information of the devices is the same, the matching federated learning strategy is selected as the model differential update, and the model differential update is used for federated learning by means of differential processing of gain information.
  • the first device selects a matching federated learning strategy according to the difference between the data distributions, including: indicating based on the feature distribution information that the current training samples of different second devices have the same feature distribution, and different second devices have the same feature distribution. If the label type information of the device is different, the matching federated learning strategy is selected for the model partial update, and the model partial update is used for federated learning by averaging the partial gain information.
  • the first device selects a matching federated learning strategy according to the difference between the data distributions, including: indicating that the current training samples of different second devices have different feature distributions based on the feature distribution information, and different second devices have different feature distributions. If the label type information of the device is different, the matching federated learning strategy is selected as the partial differential update of the model, and the partial differential update of the model is used for federated learning by means of differential processing of partial gain information.
  • the data distribution information sent by any second device includes first gain information, and before the first device selects the matching federated learning strategy according to the difference between the data distributions, the method further includes: The first gain information of the plurality of second devices determines feature distribution information, and the feature distribution information is used to indicate whether the feature distributions of current training samples of different second devices are the same; the first device determines the difference between the data distributions according to the feature distribution information.
  • the first device selects the matching federated learning strategy according to the difference between the data distributions, including: indicating that the feature distributions of the current training samples of different second devices are the same based on the feature distribution information, then selecting the matching federated learning strategy
  • the federated learning strategy is model average fusion, and model average fusion is used to perform federated learning in the form of average gain information.
  • the first device selects the matching federated learning strategy according to the difference between the data distributions, including: indicating that the feature distributions of the current training samples of different second devices are different based on the feature distribution information, then selecting the matching federated learning strategy.
  • the federated learning strategy is model differential update, which is used to perform federated learning by means of differential processing of gain information.
  • the data distribution information sent by any second device includes tag type information
  • the first device selects the matching federated learning strategy according to the difference between the data distributions, further includes: determining based on the tag type information Differences between data distributions.
  • the first device selects the matching federated learning strategy according to the difference between the data distributions, including: based on the same label type information of different second devices, selecting the matching federated learning strategy is model average fusion , the model-averaged fusion is used for federated learning in a way that the gain information is averaged.
  • the first device selects the matching federated learning strategy according to the difference between the data distributions, including: based on the difference in the label type information of different second devices, selecting the matching federated learning strategy as part of the model update , the model partial update is used for federated learning with partial gain information averaging.
  • the method further includes: the first device receives the data sent by the plurality of second devices. the second gain information of the first device; the first device performs federated fusion of the second gain information based on the federated learning strategy to obtain the third gain information corresponding to each second device; Corresponding third gain information is sent, or a second model obtained based on the corresponding third gain information and the first model of any second device.
  • the method further includes: the first device receives the data sent by the plurality of second devices
  • the training sample feature information is used to represent the label distribution or the number of samples;
  • the first device sends the parameter reporting strategy corresponding to the federated learning strategy to at least one second device among the plurality of second devices, and also includes: for at least one second device Any second device in a second device, the first device sends hyperparameters to any second device, the hyperparameters are determined based on the training sample feature information sent by any second device, and the hyperparameters are used for any second device.
  • the training sample feature information includes label distribution information or the number of samples; the label distribution information includes at least one of label proportion information and the number of labels of each type, and the label proportion information is used to indicate each The proportion of the type of labels in the labels of the current training sample; the sample number information is used to indicate the number of samples included in the current training sample.
  • the first model obtained in the last round of training includes the first model of any second device
  • the first gain information includes gain information corresponding to the first model of any second device
  • the first model of any second device The gain information corresponding to the first model of the second device is used to indicate the degree of correction required by the first model of any second device to adapt to the current training sample of any second device; or, the first model obtained from the last round of training includes The first model of any second device and the first models of other second devices participating in federated learning
  • the first gain information includes the gain information corresponding to the first model of any second device and the first models of other second devices
  • the gain information corresponding to the first models of the other second devices is used to indicate the degree of correction required by the first models of the other second devices to adapt to the current training samples of any second device.
  • the method before the first device receives the data distribution information sent by multiple second devices participating in the federated learning, the method further includes: the first device sends the first device of the other second devices to any second device Model.
  • a federated learning method includes: a second device obtains data distribution information, where the data distribution information includes at least one of first gain information and label type information, and the first gain information is used to indicate that the In order to adapt to the correction degree required by the current training sample of the second device for the first model obtained by the round of training, the label type information is used to indicate the type corresponding to the label of the current training sample; the second device sends the data distribution information to the first device, the data The distribution information is used by the first device to select a matching federated learning strategy; the second device receives the parameter reporting strategy corresponding to the federated learning strategy sent by the first device, and obtains second gain information based on the received parameter reporting strategy and the current training sample, and the first The second gain information is used to obtain a second model of the second device.
  • the second devices participating in federated learning send their respective data distribution information to the first device, so that the first device can judge the distribution of the current training samples of different second devices according to the respective data distribution information, that is, grasp the distribution of the current training samples of different second devices.
  • the degree of non-IID of the current training samples of different second devices the second device receives the corresponding parameter reporting policy sent by the first device to each second device based on the selected federated learning policy, so that the second device can report the corresponding second gain information according to the parameter reporting policy to implement model update. Therefore, the non-IID phenomenon of training data between different second devices is avoided, which interferes with the federated learning process, so that the models obtained by each second device through federated learning have better performance, such as higher accuracy.
  • the method further includes: the second device sends the second gain information to the first device; the second device receives the first gain information The device sends the corresponding third gain information based on the second gain information, the second device obtains the second model based on the third gain information and the first model of the second device, or the second device receives the corresponding third gain information sent by the first device.
  • the third gain information and the second model obtained from the first model of the second device.
  • the method further includes: the second device sends training sample feature information to the first device, and the training sample feature information is used by the first device to determine hyperparameters; the second device receives the hyperparameters sent by the first device ;
  • Obtaining the second gain information based on the received parameter reporting policy and the current training sample includes: the second device obtaining the second gain information based on the received parameter reporting policy, the current training sample and the hyperparameter.
  • the training sample feature information includes label distribution information or the number of samples; the label distribution information includes at least one of label proportion information and the number of labels of each type, and the label proportion information is used to indicate each The proportion of the type of labels in the labels of the current training sample; the sample number information is used to indicate the number of samples included in the current training sample.
  • the first model obtained from the last round of training includes the first model of the second device
  • the first gain information includes gain information corresponding to the first model of the second device
  • the first model of the second device The corresponding gain information is used to indicate the degree of correction required by the first model of the second device to adapt to the current training sample of the second device; or, the first model obtained from the last round of training includes the first model of the second device and the participating federation
  • the learned first models of other second devices, the first gain information includes gain information corresponding to the first models of the second devices and gain information corresponding to the first models of other second devices, and the first models of other second devices correspond to The gain information of is used to indicate the degree of correction required by the first models of other second devices to adapt to the current training samples of the second device.
  • the method before the second device obtains the data distribution information, the method further includes: the second device receives a first model of another second device sent by the first device.
  • a federated learning device comprising:
  • the receiving module is used for the first device to receive data distribution information sent by multiple second devices participating in federated learning, and the data distribution information sent by any second device includes at least one of first gain information and tag type information, and the first A gain information is used to indicate the degree of correction required by the first model obtained through the last round of training in order to adapt to the current training sample of any second device, and the label type information is used to indicate the type corresponding to the label of the current training sample;
  • a selection module used for the first device to select a matching federated learning strategy according to the data distribution information sent by a plurality of second devices;
  • the sending module is used for the first device to send the parameter reporting policy corresponding to the federated learning policy to at least one second device in the plurality of second devices, and any second device in the at least one second device is used for reporting based on the received data.
  • the selection module is used for the first device to select a matching federated learning strategy according to the difference between the data distributions, and the difference between the data distributions is determined based on the data distribution information sent by a plurality of second devices.
  • the data distribution information sent by any second device includes first gain information and tag type information
  • the apparatus further includes:
  • the first determination module is used for the first device to determine feature distribution information according to the first gain information of multiple second devices, and the feature distribution information is used to indicate whether the feature distributions of the current training samples of different second devices are the same;
  • the feature distribution information and the tag type information of the plurality of second devices determine the difference between the data distributions.
  • the selection module is configured to indicate, based on the feature distribution information, that the feature distributions of the current training samples of different second devices are the same, and the label type information of different second devices is the same, then select a matching federated learning strategy For model-average fusion, model-average fusion is used for federated learning in a way that the gain information is averaged.
  • the selection module is configured to indicate, based on the feature distribution information, that the feature distributions of the current training samples of different second devices are different, and the label type information of different second devices is the same, then select a matching federated learning strategy
  • the model differential update is used for federated learning in a manner of differential processing of gain information.
  • the selection module is configured to indicate, based on the feature distribution information, that the feature distributions of the current training samples of different second devices are the same, and the label type information of different second devices is different, then select a matching federated learning strategy For the model part update, the model part update is used for federated learning with partial gain information averaging.
  • the selection module is configured to indicate, based on the feature distribution information, that the feature distributions of the current training samples of different second devices are different, and the label type information of different second devices is different, then select a matching federated learning strategy For the model partial differential update, the model partial differential update is used for federated learning in a way of differential processing of partial gain information.
  • the data distribution information sent by any second device includes the first gain information
  • the apparatus further includes:
  • the second determination module is used for the first device to determine feature distribution information according to the first gain information of multiple second devices, and the feature distribution information is used to indicate whether the feature distributions of the current training samples of different second devices are the same; Feature distribution information determines differences between data distributions.
  • the selection module is used to indicate that the feature distributions of the current training samples of different second devices are the same based on the feature distribution information, and the matching federated learning strategy is selected as model average fusion, and model average fusion is used to Federated learning is performed in a way of averaging the gain information.
  • the selection module is used to indicate that the feature distributions of the current training samples of different second devices are different based on the feature distribution information, and the matching federated learning strategy is selected as the model differential update, and the model differential update uses It is used for federated learning in a way of differential processing of gain information.
  • the apparatus further includes: a third determination module, configured to determine the difference between the data distributions based on the tag type information.
  • the selection module is used to select the matching federated learning strategy based on the same label type information of different second devices as model average fusion, and the model average fusion is used to perform federation by averaging the gain information. study.
  • the selection module is used to select the matching federated learning strategy as part of the model update based on different label type information of different second devices, and the part of the model update is used to average the partial gain information. Federated Learning.
  • the receiving module is also used for the first device to receive the second gain information sent by multiple second devices;
  • the device further includes: a fusion module for the first device to perform federated fusion of the second gain information based on the federated learning strategy to obtain third gain information corresponding to each second device;
  • the sending module is further configured for the first device to send the corresponding third gain information to any second device in the at least one second device, or obtain the corresponding third gain information based on the corresponding third gain information and the first model of any second device Second model.
  • the receiving module is further configured for the first device to receive training sample feature information sent by a plurality of second devices, and the training sample feature information is used to represent the label distribution or the number of samples;
  • the sending module is further configured to send hyperparameters from the first device to any second device for any second device in the at least one second device, the hyperparameters are determined based on the feature information of the training samples sent by any second device, and the hyperparameters are determined based on the feature information of the training samples sent by any second device.
  • the parameter is used for any second device to obtain the second gain information.
  • the training sample feature information includes label distribution information or the number of samples; the label distribution information includes at least one of label proportion information and the number of labels of each type, and the label proportion information is used to indicate each The proportion of the type of labels in the labels of the current training sample; the sample number information is used to indicate the number of samples included in the current training sample.
  • the first model obtained in the last round of training includes the first model of any second device
  • the first gain information includes gain information corresponding to the first model of any second device
  • the first model of any second device The gain information corresponding to the first model of the second device is used to indicate the degree of correction required by the first model of any second device to adapt to the current training sample of any second device;
  • the first model obtained in the last round of training includes the first model of any second device and the first models of other second devices participating in federated learning
  • the first gain information includes the corresponding first model of any second device.
  • the gain information and the gain information corresponding to the first models of other second devices, and the gain information corresponding to the first models of other second devices is used to indicate that the first models of other second devices are adapted to the current training samples of any second device. degree of correction required.
  • the sending module is further configured for the first device to send the data of other second devices to any second device. first model.
  • a federated learning device comprising:
  • the obtaining module is used for the second device to obtain data distribution information, the data distribution information includes at least one of first gain information and label type information, and the first gain information is used to indicate that the first model obtained through the last round of training is suitable for the first model.
  • the degree of correction required for the current training sample of the second device, and the label type information is used to indicate the type corresponding to the label of the current training sample;
  • a sending module used for the second device to send data distribution information to the first device, where the data distribution information is used by the first device to select a matching federated learning strategy
  • the receiving module is used for the second device to receive the parameter reporting strategy corresponding to the federated learning strategy sent by the first device, obtain second gain information based on the received parameter reporting strategy and the current training sample, and the second gain information is used to obtain the second device the second model.
  • the sending module is further configured for the second device to send the second gain information to the first device;
  • the receiving module is further configured for the second device to receive the corresponding third gain information sent by the first device based on the second gain information, and the second device to obtain the second model based on the third gain information and the first model of the second device, or, The second device receives the second model sent by the first device and obtained based on the corresponding third gain information and the first model of the second device.
  • the sending module is further configured for the second device to send training sample feature information to the first device, and the training sample feature information is used for the first device to determine hyperparameters;
  • the receiving module is further configured for the second device to receive the hyperparameter sent by the first device, and to obtain the second gain information based on the received parameter reporting policy, the current training sample and the hyperparameter.
  • the training sample feature information includes label distribution information or the number of samples; the label distribution information includes at least one of label proportion information and the number of labels of each type, and the label proportion information is used to indicate each The proportion of the type of labels in the labels of the current training sample; the sample number information is used to indicate the number of samples included in the current training sample.
  • the first model obtained from the last round of training includes the first model of the second device
  • the first gain information includes gain information corresponding to the first model of the second device
  • the first model of the second device The corresponding gain information is used to indicate the degree of correction required by the first model of the second device to adapt to the current training sample of the second device
  • the first model obtained from the last round of training includes the first model of the second device and the first models of other second devices participating in federated learning
  • the first gain information includes gain information corresponding to the first model of the second device and other
  • the gain information corresponding to the first model of the second device, and the gain information corresponding to the first models of other second devices is used to indicate the degree of correction required by the first models of other second devices to adapt to the current training samples of the second device.
  • the receiving module is further configured for the second device to receive the first models of other second devices sent by the first device.
  • a communication device comprising: a communication interface and a processor.
  • the communication device further includes a memory.
  • the communication interface, the memory and the processor communicate with each other through an internal connection path, the memory is used for storing instructions, and the processor is used for executing the instructions stored in the memory to control the communication interface to receive signals and control the communication interface to send signals , and when the processor executes the instructions stored in the memory, the processor is caused to execute the method in the first aspect or any possible implementation manner of the first aspect.
  • a communication device comprising: a communication interface and a processor.
  • the communication device further includes a memory.
  • the communication interface, the memory and the processor communicate with each other through an internal connection path, the memory is used for storing instructions, and the processor is used for executing the instructions stored in the memory to control the communication interface to receive signals and control the communication interface to send signals , and when the processor executes the instructions stored in the memory, the processor is caused to execute the method in the second aspect or any possible implementation manner of the second aspect.
  • processors there are one or more processors and one or more memories.
  • the memory may be integrated with the processor, or the memory may be provided separately from the processor.
  • the memory can be a non-transitory memory, such as a read only memory (ROM), which can be integrated with the processor on the same chip, or can be separately set in different On the chip, the present application does not limit the type of memory and the manner of setting the memory and the processor.
  • ROM read only memory
  • a communication system in a seventh aspect, includes a first communication device and a second communication device, and the first communication device is configured to execute the first aspect or any of the possible implementations of the first aspect.
  • the second communication device is configured to execute the federated learning method provided by the second aspect or any possible implementation manner of the second aspect.
  • a computer program comprising: computer program code, when the computer program code is executed by a computer, the computer executes the methods in the above aspects.
  • a computer-readable storage medium stores programs or instructions, and when the programs or instructions are run on a computer, the methods in the above aspects are executed.
  • a chip including a processor for invoking and executing instructions stored in the memory from a memory, so that a communication device on which the chip is installed performs the methods in the above aspects.
  • another chip comprising: an input interface, an output interface, a processor, and a memory, the input interface, the output interface, the processor, and the memory are connected through an internal connection path, and the processor is used to execute codes in the memory , when the code is executed, the processor is used to perform the methods in the above aspects.
  • FIG. 1 is a schematic diagram of a federated learning provided by an embodiment of the present application
  • FIG. 2 is a schematic diagram of federated learning in a related technology provided by an embodiment of the present application
  • FIG. 3 is a schematic diagram of the architecture of a federated learning system provided by an embodiment of the present application.
  • FIG. 4 is a flowchart of a federated learning method provided by an embodiment of the present application.
  • FIG. 5 is a schematic flowchart of selecting a federated learning strategy provided by an embodiment of the present application.
  • FIG. 6 is a schematic flowchart of a federated learning provided by an embodiment of the present application.
  • FIG. 7 is a schematic structural diagram of a federated learning device provided by an embodiment of the present application.
  • FIG. 8 is a schematic structural diagram of a federated learning device provided by an embodiment of the present application.
  • FIG. 9 is a schematic structural diagram of a communication device provided by an embodiment of the present invention.
  • AI technology With the development and improvement of artificial intelligence (AI) technology, AI technology has gradually attracted widespread attention in various fields. Among them, AI technology relies on the learning process of a large amount of labeled data. In practical applications, objects holding data sources often face the problem of insufficient label data volume in the data source. Moreover, due to the type limitation of data sources and privacy protection, it is difficult to share data sources between different objects. As a result, AI technology faces the problem of "data silos" in practical applications.
  • FIG. 1 shows a federated learning architecture, including N clients and a server, and each client is respectively connected to the server in communication. Among them, the client is in one-to-one correspondence with the participants of federated learning, and the client performs model training in the domain through the data source provided by the participant. After that, upload the model training results to the server, the server integrates the model training results uploaded by each client to obtain a shared machine learning model, and sends the shared machine learning model to each client for use.
  • the training data used to train a machine learning model follows an independently identical distribution (IID).
  • IID independently identical distribution
  • the label data in each data source is often non-independent and has a strong inter-dependent relationship with other factors, and the label data between different data sources often has different probability distributions. , so that the training data in the federated learning process follows a non-independent and identical distribution (non-IID).
  • non-IID non-independent and identical distribution
  • the server manages a label data set with a uniform probability distribution, the server obtains a data subset from the label data set, and trains a model based on the data subset.
  • the model trained by the server is used to determine the weight of each client, and the server sends a subset of data to each client based on the determined weight.
  • client 1 has a weight of ⁇ 1
  • client 2 has a weight of ⁇ 2 .
  • each client performs model training based on the weighted data subset and the data source in the domain, and uploads the model training results to the server.
  • the server integrates the model training results uploaded by each client to obtain a shared machine learning model.
  • the embodiment of the present application provides a federated learning method, which can be applied to the federated learning system as shown in FIG. 3 .
  • a first device and N second devices (N ⁇ 2) are included, and each of the second devices is respectively connected to the first device in communication.
  • the first device is used as a server (also referred to as a central node) in the federated learning process
  • the second device is used as a client (also referred to as an edge node) in the federated learning process.
  • the first device includes a data distribution offset module, a joint learning strategy module, and a model updating module
  • each second device includes a gain information computing module and a model updating module, respectively.
  • the modules shown in Figure 3 are described as follows:
  • Gain information calculation module used to calculate and obtain first gain information based on the current training sample, where the first gain information is used by the first device to select a federated learning strategy. It is also used to calculate and obtain second gain information based on the parameter reporting strategy corresponding to the federated learning strategy and the corresponding training samples, where the second gain information is used for the first device to perform federated fusion.
  • Model updating module used to update the model obtained by itself in the last round of training based on the first gain information or the second gain information obtained by the gain information calculation module.
  • the second device further includes a data preprocessing module, configured to preprocess the samples included in the current training sample to obtain the preprocessed samples.
  • the preprocessing includes, but is not limited to, data complement and feature extraction.
  • the gain information calculation module is configured to calculate and obtain the first gain information based on the preprocessed samples. It is also used to calculate the second gain information based on the parameter reporting strategy corresponding to the federated learning strategy and the preprocessed samples.
  • Data distribution offset module configured to determine the feature distribution of current training samples of different second devices according to the first gain information of each second device.
  • Joint learning strategy module used to select a matching federated learning strategy according to the feature distribution of the current training samples of different second devices.
  • Model fusion module used for federated fusion based on the federated learning strategy and the second gain information of different second devices to obtain third gain information corresponding to the second device.
  • the third gain information is sent to the corresponding second device, for the second device to acquire the second model of the second device based on the third gain information.
  • the second model is obtained based on the third gain information and the corresponding first model of the second device, and the second model is sent to the corresponding second device.
  • the second device A completes the federated learning process through A-1, A-2, A-3, A-4, and A-5 in sequence.
  • the process of completing the federated learning by other second devices is the same as the process of completing the federated learning by the second device A.
  • the second device B shown in FIG. 3 completes the federated learning process through B-1, B-2, B-3, B-4, and B-5 shown in FIG. 3 in sequence, and details are not repeated here.
  • an embodiment of the present application provides a federated learning method. Taking the implementation of the federated learning method through the interaction between the first device and the second device as an example, see FIG. 4 , the method includes the following processes.
  • the second device obtains data distribution information
  • the data distribution information includes at least one of first gain information and label type information
  • the first gain information is used to indicate that the first model obtained through the last round of training is adapted to the second device.
  • the correction degree required for the current training sample, and the label type information is used to indicate the type corresponding to the label of the current training sample.
  • the federated learning is jointly participated by the first device and multiple second devices, and the federated learning often includes multiple rounds of training processes.
  • the execution time of 401 is between any two adjacent training rounds in the multi-round training process.
  • the round of training process that has ended when 401 is executed is referred to as the last round of training process, and the round of training process that has not started when 401 is executed is referred to as the current training process.
  • the second device will receive the model sent by the first device, and the second device will obtain the first model of the second device, which is used as the upper The first model obtained by training rounds.
  • the second device has corresponding training samples in the current round of training, that is, the current training samples.
  • This embodiment of the present application does not limit the acquisition method of the current training sample of the second device.
  • the last round of training samples corresponding to the second device may change, so that the training samples corresponding to the second device are updated from the last round of training samples to the current training samples. For example, new samples are added to the training samples of the previous round to form the current training samples.
  • a new training sample is obtained for this round of training as the current training sample. It should be understood that, whether it is a training sample of the last round or a current training sample, it includes a plurality of samples with corresponding labels, that is, the samples include labels.
  • the second device needs to retrain the first model corresponding to the second device based on the current training sample. Before retraining, the second device performs 401 to obtain data distribution information. The data distribution information is used for the first device to obtain the federated learning strategy, so that the second device can perform retraining according to the federated learning strategy in the current training process.
  • the data distribution information includes at least one of first gain information and tag type information.
  • first gain information and the tag type information will be described separately below.
  • the first gain information sent by the second device is used to indicate the degree of correction required for the first model obtained through the last round of training to adapt to the current training sample of the second device.
  • the second device is any second device participating in federated learning.
  • the first model obtained from the last round of training includes the first model of the second device
  • the first gain information includes the first model of the second device
  • the gain information corresponding to the first model of the second device is used to indicate the degree of correction required by the first model of the second device in order to adapt to the current training sample of the second device;
  • the first model obtained from the last round of training includes the first model of the second device and the first models of other second devices participating in federated learning
  • the first gain information includes gain information corresponding to the first model of the second device and the gain information corresponding to the first model of the other second device
  • the gain information corresponding to the first model of the other second device is used to indicate that the first model of the other second device needs to adapt to the current training sample of the second device. degree of correction.
  • the first gain information is a running result obtained by running the current training sample on the first model.
  • Gain information corresponding to the first model of the second device For the acquisition method of the gain information corresponding to the first model of the other second device, reference may be made to the above-mentioned calculation method of the gain information corresponding to the first model of the second device, which will not be repeated here.
  • the above-mentioned first gain information is gradient information, and this embodiment can be used according to When the function value of the loss function determines the first gain information, an error back propagation algorithm is used. Or, based on the fact that the first model is a decision tree model, the above-mentioned first gain information is split information.
  • the decision tree model includes a plurality of nodes, each node except the bottom node corresponds to a decision condition and two branches, and each branch includes at least one sample.
  • the above-mentioned split information refers to the decision conditions corresponding to each node and the number of samples included in the branches corresponding to each node.
  • the method provided in this embodiment further includes: for any second device, the first model A device sends the first model of any second device to other second devices in the plurality of second devices except any second device.
  • the second device receives the first models of other second devices participating in the federated learning sent by the first device.
  • the first device sends the first model of device B and the first model of device C to device A, and the first device sends the first model of device B to device B.
  • the first model of the A device and the first model of the C device, and the first device sends the first model of the A device and the first model of the B device to the C device.
  • the first device may directly send the first model according to the requirements of each second device.
  • each second device uploads its first model to the first device, and then the first device according to the needs of each second device The transmission of the first model is performed.
  • the first device first applies for permission to the second device corresponding to the first model to be sent, and after obtaining the permission After authorization, the first model is sent.
  • the first device wants to send the first model of the B device to the A device, the first device applies to the B device for the permission to issue the first model of the B device, and after obtaining the authorization of the B device, it sends the B device to the A device.
  • the first model of the device if the first device wants to send the first model of the B device to the A device, the first device applies to the B device for the permission to issue the first model of the B device, and after obtaining the authorization of the B device, it sends the B device to the A device.
  • the first model of the device is if the first device wants to send the first model of the B device to the A device.
  • the first models of the respective second devices may or may not be the same. Based on the same first model of each second device, the first device respectively sending the first models of other second devices to each second device will obviously cause a waste of resources. therefore. In this embodiment, when the first models of different second devices are different, the first device sends the first model.
  • Label type information is used to indicate the type corresponding to the label of the current training sample.
  • the multiple samples included in the current training sample all have labels, and the label of the current training sample is the label of the sample included in the current training sample.
  • the type corresponding to the label of the current training sample refers to the type of the label of each sample in the current training sample.
  • the label type information is used to indicate that the label of the current training sample corresponds to three types of A, B, and C, that is, the label of the current training sample includes three types of labels A, B, and C.
  • the samples included in the current training samples have three types of labels, A, B, and C, and the number of labels of various types is not limited.
  • the label corresponding to the current training sample includes two types, one type of label indicates that the recognition result is abnormal, and the other type of label indicates that the recognition result is abnormal.
  • the recognition result is non-anomalous.
  • the second device sends data distribution information to the first device.
  • each second device After each second device obtains the data distribution information, each second device sends the data distribution information to the first device, so that the first device selects a matching federated learning strategy based on the data distribution information sent by the second device.
  • the first device receives data distribution information sent by multiple second devices participating in the federated learning.
  • each second device participating in federated learning sends data distribution information to the first device, the first device can receive data distribution information sent by multiple second devices participating in federated learning.
  • the first device selects a matching federated learning strategy according to the data distribution information sent by the plurality of second devices.
  • the first device selects a matching federated learning strategy according to data distribution information sent by a plurality of second devices, including: the first device selects a matching federated learning strategy according to a difference between data distributions, the data distribution The difference between them is determined based on the data distribution information sent by the plurality of second devices.
  • the data distribution information includes at least one of first gain information and label type information.
  • the data distribution information includes gain information and label type information.
  • the method further includes: the first device determines feature distribution information according to the first gain information of the plurality of second devices, and the feature distribution information is used to indicate different Whether the feature distributions of the current training samples of the second device are the same; the first device determines the difference between the data distributions according to the feature distribution information and the label type information of multiple second devices.
  • the first model used by the second device in the process of obtaining the first gain information may be the first model of the second device itself, or may also include The first model of the other second device.
  • the first gain information includes the gain information corresponding to the first model of the second device
  • the distance between the first gain information of the two second devices is less than the threshold, it indicates that the two second devices are currently training
  • the feature distributions of the samples are the same.
  • the first gain information obtained by device A running on the first model A of device A is d1A
  • the first gain information obtained by device B running on the first model B of device B is d2B. If the distance (d1A, d2B) between d1A and d2B is less than the threshold, it means that the feature distributions of the current training samples of device A and device B are the same.
  • the first gain information includes the gain information corresponding to the first model of the second device and the gain information corresponding to the first models of other second devices
  • the The distance between the first gain information of is less than the threshold value, it means that the feature distributions of the current training samples of the two second devices are the same.
  • the first gain information obtained by device A running on the first model B of device B is d2A
  • the first gain information obtained by device B running on the first model A of device A is d1B. If the distance (d2A, d1B) between d2A and d1B is less than the threshold, it means that the feature distributions of the current training samples of device A and device B are the same.
  • the second device participating in federated learning also includes device C.
  • the first gain information obtained by device A running on the first model C of device C is d3A
  • the first gain information obtained by device B running on the first model of device C is d3A
  • the gain information is d3B.
  • the distance between the first gain information obtained by the two second devices running on the same first model of the second device is smaller than the threshold, it means that the feature distributions of the current training samples of the two second devices are the same.
  • the first model of device A is A
  • the first model of device B is B.
  • the first gain information obtained by device A running on the first model A and the first model B are d1A and d2A respectively
  • the first gain information obtained by the device B running on the first model A and the first model B are d1B and d2A respectively. d2B.
  • the distance (d1A, d1B) between the first gain information d1A and d1B obtained by device A and device B running on the same first model A is less than the threshold, and device A and device B are on the same first model B
  • the distance (d2A, d2B) between the first gain information d2A and d2B obtained by running is smaller than the threshold, it means that the feature distributions of the current training samples of device A and device B are the same.
  • the process of determining whether the feature distributions are the same is transitive between different second devices. For example, according to the method in the above description, it is determined that the feature distributions of the current training samples of device A and device B are the same, and it is determined that the feature distributions of the current training samples of device B and device C are the same, it means that device A, device B and device C have three The feature distributions of the current training samples are the same. When the number of second devices participating in federated learning is large, the probability that the feature distributions of the current training samples of all the second devices are the same is often small. However, all of the second devices can include at least one set of second devices having the same feature portion of the current training samples.
  • the current training samples of devices 1-5 have the same feature distribution
  • the current training samples of devices 6-10 have the same feature distribution
  • devices 1-5 have the same feature distribution as devices 1-5.
  • the feature distribution of the current training samples of 6-10 is different.
  • the first gain information includes the gain information of each model parameter in the first model.
  • the sub-distances between the gain information of the corresponding model parameters in the first gain information are obtained first, and a plurality of sub-distances are obtained. Afterwards, weighted summation is performed on the plurality of sub-distances, and the obtained weighted summation value is determined as the distance between the first gain information of the two second devices.
  • the first model includes a convolution layer, a sampling layer, a fully connected layer, and the like.
  • model parameters of the same type of layer correspond.
  • the model parameters belonging to the convolution layer in the first gain information of the device A and the device B are the corresponding model parameters
  • the model parameters belonging to the sampling layer are the corresponding model parameters.
  • different types of layers correspond to the same or different weights according to actual needs. Exemplarily, for any type of layer, the weight of the sub-distance calculated from the gain information of the model parameters of the type of layer is equal to the weight corresponding to the any type of layer.
  • the nodes in the decision tree model include a root node and a plurality of leaf nodes, and the leaf nodes are located at different levels. Among them, the root node or the leaf node of the same level corresponds.
  • the weights corresponding to the root node and each leaf node are the same or different. Exemplarily, in this embodiment, the weight corresponding to the root node is the largest, and the lower the leaf node is, the smaller the weight is.
  • the first device selects the matching federated learning strategy according to the difference between the data distributions.
  • this embodiment selects the federated learning strategy according to the process shown in FIG. 5 .
  • the selection process includes but is not limited to the following Four situations.
  • the matching federated learning strategy is selected as model average fusion, and model average fusion is used to Federated learning is performed in a way of averaging the gain information.
  • the gain information is the second gain information reported by the second device to the first device according to the parameter reporting policy corresponding to the average fusion of the model.
  • the second gain information please refer to the description in Case B1 below. That is, the first device is configured to, after receiving the second gain information uploaded by the second device, calculate an average value of the received second gain information based on the federated learning strategy of the model average fusion.
  • the matching federated learning strategy is selected as the model differential update, and the model differential update uses It is used for federated learning in a way of differential processing of gain information.
  • gain information please refer to the description in Case 1 above.
  • the first device is configured to, after receiving the gain information uploaded by the second device, perform differential processing on the gain information based on the differentially updated federated learning strategy of the model.
  • process of differential processing please refer to the description in the following case C2.
  • Case 3 Based on the feature distribution information indicating that the feature distributions of the current training samples of different second devices are the same, and the label type information of different second devices is different, the matching federated learning strategy is selected as the model part update, and the model part update is used to Partial gain information is averaged for federated learning.
  • the partial gain information is the second gain information reported by the second device to the first device according to the parameter reporting policy corresponding to the partial model update.
  • the first device is configured to, after receiving the second gain information, perform an average calculation on the received partial gain information based on a federated learning strategy partially updated by the model.
  • Case 4 Based on the feature distribution information, it is indicated that the feature distributions of the current training samples of different second devices are different, and the label type information of different second devices is different, then the matching federated learning strategy is selected as the model partial differential update, and the model partial differential update The update is used for federated learning in a way that partial gain information is differentially processed.
  • the gain information please refer to the description in Case 3, and for the process of differential processing, please refer to the description in Case C4 below, which will not be repeated here.
  • the selected federated learning strategy is used by the first device to deliver the corresponding parameter reporting strategy to the second device, and if the selected federated learning strategy is different, the parameter reporting strategy sent by the first device to the second device is also different. See the description in 406 below for details. It should be understood that the four federated learning strategies shown in FIG. 5 are only examples, and are not used to limit the federated learning strategies.
  • the data distribution information includes the first gain information.
  • the method further includes: the first device determines feature distribution information according to the first gain information of the plurality of second devices, and the feature distribution information is used to indicate different Whether the feature distributions of the current training samples of the second device are the same; the first device determines the difference between the data distributions according to the feature distribution information.
  • the first device selects a matching federated learning strategy according to the difference between the data distributions, including but not limited to the following two situations.
  • the matching federated learning strategy is selected as model average fusion.
  • the matching federated learning strategy is selected as the model differential update.
  • the matching federated learning strategy is selected as the model average fusion based on FIG. 5 .
  • the matching federated learning strategy is selected based on FIG. 5 as the model differential update.
  • the data distribution information includes tag type information.
  • the data distribution information sent by any second device includes label type information, and before the first device selects the matching federated learning strategy according to the difference between the data distributions, the method further includes: determining the difference between the data distributions based on the label type information. .
  • the first gain information between different second devices in this embodiment is the same by default. Therefore, in the case that the label type information of different second devices is the same, the matching federated learning strategy is selected based on FIG. 5 as model average fusion. Correspondingly, in the case that the label type information of different second devices is different, the matching federated learning strategy is selected based on FIG. 5 as part of the model update.
  • the first device sends a parameter reporting policy corresponding to the federated learning policy to at least one second device among the plurality of second devices.
  • the first device After the first device selects and obtains the federated learning strategy, determines the parameter reporting strategy corresponding to each second device according to the determined federated learning strategy, and sends the parameter reporting strategy corresponding to the federated learning strategy corresponding to each second device to each second device respectively , so that the second device can obtain the second gain information according to the corresponding parameter reporting policy and the current training sample.
  • each second device in addition to sending the data distribution information to the first device, each second device also sends training sample feature information to the first device, where the training sample feature information is used to characterize the label distribution or the number of samples; the training sample feature information for the first device to determine hyperparameters.
  • the first device sends a parameter reporting policy corresponding to the federated learning policy to a plurality of second devices, and further includes: for any second device in the at least one second device that sends the parameter reporting policy, the first device according to the The training sample feature information sent by any second device determines the hyperparameters, and sends the hyperparameters to any second device, and the hyperparameters are used by the any second device to obtain the second gain information.
  • the training sample feature information includes label distribution information or the number of samples; the label distribution information includes at least one of label proportion information and the number of labels of each type, and the label proportion information is used to indicate that various types of labels are in The proportion of the labels of the current training sample; the sample number information is used to indicate the number of samples included in the current training sample. For example, if the current training sample includes 100 pieces of data with labels, the number of samples is 100.
  • the label proportion information is used to indicate the percentage of various types of labels in the labels of the current training sample. For example, out of 100 samples, there are 30 samples with A label, 50 samples with B label, and 20 samples with C label.
  • the number of tags in the A tag is 30, the number of tags in the B tag is 50, the number of tags in the C tag is 20, the tags in the A tag account for 30%, the tags in the B tag account for 50%, and the tags in the C tag account for 20%. ratio of 20%.
  • the hyperparameters are further determined.
  • the training sample feature information includes label distribution information
  • the label distribution information includes label proportion information
  • the first device determines the hyperparameters corresponding to various types of labels in the current training sample of any second device, and sends them to The second device transmits the determined hyperparameters.
  • the larger the tag proportion information of the tag the smaller the hyperparameter corresponding to the tag.
  • the labels of the current training sample include A label accounting for 80% and B label accounting for 20%
  • the hyperparameter corresponding to the A label is smaller than the hyperparameter corresponding to the B label.
  • the first device determines the hyperparameters for each second device according to the number of samples corresponding to different second devices. The larger the number of samples corresponding to any second device, the smaller the hyperparameter of the second device. For example, if the number of samples of device A is 100 and the number of samples of device B is 10,000, the hyperparameters of device A are greater than those of device B.
  • the label distribution information includes both the label proportion information and the number of labels of each type, refer to the description of the situation of the label proportion information, which will not be repeated here.
  • the samples with smaller size are configured with larger hyperparameters, so that the samples of different sizes in the current training samples of each second device can all contribute to the subsequent model training process. This ensures that the model trained through the federated learning process has better performance.
  • the second device receives the parameter reporting strategy corresponding to the federated learning strategy sent by the first device, obtains second gain information based on the received parameter reporting strategy and the current training sample, and the second gain information is used to obtain the second gain information of the second device. Model.
  • the execution time of 401 is between the last round of training process and the current training process, and 406 is the current training process.
  • the second device receives the federated learning strategy sent by the first device, it officially starts training based on the federated learning strategy.
  • the second device obtains second gain information based on the received parameter reporting strategy corresponding to the federated learning strategy and the current training sample of the second device.
  • the gain information includes gain information of at least one model parameter.
  • the federated learning strategy is model average fusion.
  • the second device receives the parameter reporting policy sent by the first device for the average fusion of the corresponding model, and the second device obtains the second gain information based on the parameter reporting policy and the current training sample. For example, for the federated learning strategy of model average fusion, the second device needs to report the gain information of all model parameters, so the first device sends a parameter reporting strategy for acquiring the gain information of all model parameters to the second device.
  • the federated learning strategy is model differential update.
  • the parameter reporting policy delivered by the first device is the same as that in case B1
  • the process of obtaining the second gain information by the second device is the same as that in case B1, and details are not repeated here.
  • the federated learning strategy is partially updated for the model.
  • the parameter reporting policy corresponding to the federated learning policy sent by the first device to the second device is used to instruct the second device to report the gain information of some model parameters.
  • the second gain information obtained by the second device may only include gain information of part of the model parameters.
  • the convolution layer and the sampling layer in the neural network model belong to the feature extraction layer, and the fully connected layer belongs to the classification layer.
  • the second device may only train the feature extraction layer without training the classification layer through the current training samples.
  • the second device may also perform training in the manner described in Case B1 to obtain gain information of all model parameters, and then select the gain information of some model parameters from the gain information of all model parameters as the second gain information.
  • the federated learning strategy is partially differentiated update of the model.
  • the parameter reporting policy delivered by the first device is the same as that in case B3, and the process of obtaining the second gain information by the second device is the same as that in case B3, and details are not repeated here.
  • the second device After the second device inputs each sample of the current training sample into the first model of the second device respectively, the output result corresponding to each sample will be obtained.
  • the second device receives the hyperparameter sent by the first device in addition to the parameter reporting policy corresponding to the federated learning policy, obtains second gain information based on the received parameter reporting policy and the current training sample of the second device, including : obtains the second gain information based on the received parameter reporting strategy, the current training sample and the hyperparameters.
  • the second device obtains the second gain information in different ways, for example, including but not limited to the following two cases.
  • Case 1 when the hyperparameter is determined by the first device based on the label distribution information, the second device determines the weight corresponding to each sample based on the hyperparameter, so as to perform a weighted summation of the output results corresponding to each sample to obtain a weighted summation. value.
  • the function value of the loss function is calculated according to the loss function and the weighted sum value, so as to obtain the second gain information.
  • the second device determines the weight corresponding to each sample based on the hyperparameter, including: for any sample, determining a label corresponding to the sample, and using the hyperparameter corresponding to the label as the weight of the sample.
  • the labels of the current training samples of the second device include A label accounting for 80% and B label accounting for 20%, and the hyperparameter M of the A label is smaller than the hyperparameter N of the B label. If the label of the sample is the A label, the weight corresponding to the sample is equal to the hyperparameter M of the A label.
  • the second device obtains the gain information of at least one model parameter by calculating. Afterwards, the gain information of at least one model parameter is updated based on the hyperparameter, for example, a multiplication calculation is performed, and the update result is used as the second gain information.
  • the method provided by this embodiment further includes the following process.
  • the second device sends the second gain information to the first device.
  • each second device participating in the federated learning reports the obtained second gain information to the first device.
  • the first device receives the second gain information sent by the multiple second devices, and performs federated fusion on the second gain information based on the federated learning strategy to obtain third gain information corresponding to each second device.
  • the second gain information is federated based on the federated learning strategy to obtain third gain information corresponding to each second device. If the federated learning strategy is different, the manner in which the first device obtains the third gain information corresponding to each second device through federated fusion is also different. In the following, the cases C1-C4 will be explained respectively.
  • the federated learning strategy is model average fusion.
  • the first device calculates the average value of the second gain information sent by each second device performing model average fusion, and obtains third gain information corresponding to each second device performing model average fusion.
  • the federated learning strategy is model differential update.
  • the first device performs a weighted summation of the second gain information sent by each second device that performs the model differential update, and the weights of different second devices are the same or different, so that the corresponding second devices performing the model differential update are obtained. the third gain information.
  • the first device performs incremental learning on the second gain information sent by each second device that performs model differential update.
  • the first device first updates the second gain information sent by a second device to obtain a first update result.
  • the first update result is then updated according to the second gain information sent by another second device to obtain a second update result.
  • the finally obtained update result is used as the third incremental information corresponding to each second device performing the model differential update.
  • the incremental learning method adopted in this embodiment includes updating using a Mondrian tree.
  • the federated learning strategy is partially updated for the model.
  • the first device can directly include the second gain information reported by the second device that updates the model part.
  • the gain information of part of the model parameters is averaged.
  • the first device is equivalent to federating the second model of each second device that performs model average fusion, while in case C3, the first device is the second device that performs partial model update. Part of the model is federated.
  • the federated learning strategy is partially differentiated update of the model.
  • the second gain information sent by the second device performing the differential update of the model part includes the gain information of part of the model parameters among all the model parameters.
  • the first device performs weighted summation or incremental learning on the gain information of part of the model parameters in the manner described in Case C2, thereby obtaining third gain information corresponding to the second device performing the partial differential update of the model.
  • the first device performs federated fusion on the second gain information based on the federated learning strategy, and obtains the third gain information corresponding to each second device
  • the second device includes device 1 , device 2 and device 3 . If device 1 and device 2 are compared and it is determined that the federated learning strategy is model average fusion, and device 1 and device 3 are compared and it is determined that the federated learning strategy is model partial differential update, the second gain information reported by device 1 can be compared with the second gain information reported by device 1. The second gain information reported by the device 2 is averaged, and the average value is then differentiated with the second gain information reported by the device 3 , and the obtained gain information is the third gain information corresponding to the device 1 .
  • the first device sends corresponding third gain information to a plurality of second devices respectively.
  • the first device directly sends the third gain information to the corresponding second device, or the first device obtains the second model based on the third gain information and the first model of the corresponding second device , and send the second model to the corresponding second device.
  • the process of obtaining the second model is performed by the first device, and the first device directly obtains the second model of each second device, and then sends the second model to each second device respectively.
  • the second model may only have a part of the model updated compared to the first model.
  • the first device sends only the updated model part to each second device, or sends the entire model to each second device.
  • the first model and the second model are both neural network models including five convolution layers, and the first model and the second model differ only in the first convolution layer. Then the first device sends the first convolutional layer in the second model to the second device, or sends the entire second model to the second device.
  • the second device receives corresponding third gain information sent by the first device, or a second model obtained based on the corresponding third gain information and the first model of the second device.
  • the second device In the case where the second device receives the corresponding third gain information, the second device adds the corresponding third gain information and each model parameter of the first model to obtain the second model.
  • each second device participating in federated learning in this embodiment of the present application sends its own data distribution information to the first device, so that the first device can judge the current training of different second devices according to each data distribution information
  • the distribution of the samples that is, the degree of non-IID of the current training samples of different second devices is grasped.
  • the first device selects the federated learning strategy according to the degree of non-IID, and sends the parameter reporting strategy corresponding to the selected federated learning strategy to each second device, and then each second device reports the parameters corresponding to the federated learning strategy respectively.
  • the strategy updates the model. Therefore, the non-IID phenomenon of training data between different second devices is avoided, which interferes with the federated learning process, so that the models obtained by each second device through federated learning have better performance, such as higher accuracy.
  • the embodiment of the present application also provides a federated learning apparatus.
  • the apparatus is configured to execute the federated learning method executed by the first device in the foregoing method embodiment through each module shown in FIG. 7 .
  • an embodiment of the present application provides a message transmission apparatus, which includes the following modules.
  • the receiving module 701 is used for the first device to receive data distribution information sent by multiple second devices participating in federated learning, and the data distribution information sent by any second device includes at least one of first gain information and tag type information,
  • the first gain information is used to indicate the degree of correction required for the first model obtained through the last round of training to adapt to the current training sample of any second device, and the label type information is used to indicate the type corresponding to the label of the current training sample.
  • the steps performed by the receiving module 701 refer to the descriptions in 403 and 408 above.
  • the selection module 702 is used for the first device to select a matching federated learning strategy according to the data distribution information sent by the plurality of second devices. For the steps performed by the selection module 702, see the description in 404 above.
  • the sending module 703 is used for the first device to send the parameter reporting policy corresponding to the federated learning policy to at least one second device in the plurality of second devices, and any second device in the at least one second device is used for reporting based on the received
  • the parameter reporting strategy and the second gain information obtained from the current training sample, the second gain information is used to obtain the second model of any second device.
  • the steps performed by the sending module 703 refer to the descriptions in 405 and 409 above.
  • the selection module 702 is used for the first device to select a matching federated learning strategy according to differences between data distributions, and the differences between data distributions are determined based on data distribution information sent by multiple second devices .
  • the data distribution information sent by any second device includes first gain information and tag type information
  • the apparatus further includes:
  • the first determination module is used for the first device to determine feature distribution information according to the first gain information of multiple second devices, and the feature distribution information is used to indicate whether the feature distributions of the current training samples of different second devices are the same;
  • the feature distribution information and the tag type information of the plurality of second devices determine the difference between the data distributions.
  • the selection module 702 is configured to indicate, based on the feature distribution information, that the feature distributions of the current training samples of different second devices are the same, and the label type information of different second devices is the same, then select the matching federated learning
  • the strategy is model average fusion, which is used for federated learning in a way of averaging the gain information.
  • the selection module 702 is configured to indicate, based on the feature distribution information, that the feature distributions of the current training samples of different second devices are different, and the label type information of different second devices is the same, then select the matching federated learning
  • the strategy is model differential update, and model differential update is used for federated learning by means of differential processing of gain information.
  • the selection module 702 is configured to indicate, based on the feature distribution information, that the feature distributions of the current training samples of different second devices are the same, and the label type information of different second devices is different, then select the matching federated learning
  • the strategy is the model part update, and the model part update is used for federated learning with partial gain information averaging.
  • the selection module 702 is configured to indicate, based on the feature distribution information, that the feature distributions of the current training samples of different second devices are different, and the label type information of different second devices is different, then select the matching federated learning
  • the strategy is model partial differential update, and model partial differential update is used for federated learning in a way of differential processing of partial gain information.
  • the data distribution information sent by any second device includes the first gain information
  • the apparatus further includes:
  • the second determination module is used for the first device to determine feature distribution information according to the first gain information of multiple second devices, and the feature distribution information is used to indicate whether the feature distributions of the current training samples of different second devices are the same; Feature distribution information determines differences between data distributions.
  • the selection module 702 is configured to indicate that the feature distributions of the current training samples of different second devices are the same based on the feature distribution information, and then select the matching federated learning strategy as model average fusion, and model average fusion is used for Federated learning is performed in a way that the gain information is averaged.
  • the selection module 702 is configured to indicate that the feature distributions of the current training samples of different second devices are different based on the feature distribution information, and then select the matching federated learning strategy as model differential update, model differential update It is used for federated learning in a way of differential processing of gain information.
  • the apparatus further includes: a third determination module, configured to determine the difference between the data distributions based on the tag type information.
  • the selection module 702 is configured to select the matching federated learning strategy based on the same label type information of different second devices as model average fusion, and the model average fusion is used to perform the gain information averaging method. Federated Learning.
  • the selection module 702 is configured to select the matching federated learning strategy as part of the model update based on different label type information of different second devices, and the part of the model update is used to average the partial gain information Do federated learning.
  • the receiving module 701 is further configured for the first device to receive second gain information sent by multiple second devices;
  • the device further includes: a fusion module for the first device to perform federated fusion of the second gain information based on the federated learning strategy to obtain third gain information corresponding to each second device;
  • the sending module 703 is further configured for the first device to send the corresponding third gain information to any second device in the at least one second device, or obtain the corresponding third gain information based on the corresponding third gain information and the first model of any second device the second model.
  • the receiving module 701 is further configured for the first device to receive training sample feature information sent by multiple second devices, and the training sample feature information is used to represent label distribution or sample quantity;
  • the sending module 703 is further configured to, for any second device in the at least one second device, the first device sends a hyperparameter to any second device, and the hyperparameter is determined based on the training sample feature information sent by any second device, The hyperparameters are used by any second device to obtain the second gain information.
  • the training sample feature information includes label distribution information or the number of samples; the label distribution information includes at least one of label proportion information and the number of labels of each type, and the label proportion information is used to indicate each The proportion of the type of labels in the labels of the current training sample; the sample number information is used to indicate the number of samples included in the current training sample.
  • the first model obtained in the last round of training includes the first model of any second device
  • the first gain information includes gain information corresponding to the first model of any second device
  • the first model of any second device The gain information corresponding to the first model of the second device is used to indicate the degree of correction required by the first model of any second device to adapt to the current training sample of any second device;
  • the first model obtained in the last round of training includes the first model of any second device and the first models of other second devices participating in federated learning
  • the first gain information includes the corresponding first model of any second device.
  • the gain information and the gain information corresponding to the first models of other second devices, and the gain information corresponding to the first models of other second devices is used to indicate that the first models of other second devices are adapted to the current training samples of any second device. degree of correction required.
  • the sending module 703 is further configured for the first device to send other second devices to any second device the first model.
  • the embodiment of the present application further provides another federated learning apparatus, which is configured to execute the federated learning method executed by the first device in the foregoing method embodiment through each module shown in FIG. 8 .
  • another federated learning apparatus which is configured to execute the federated learning method executed by the first device in the foregoing method embodiment through each module shown in FIG. 8 .
  • an embodiment of the present application provides a message transmission apparatus, which includes the following modules.
  • Obtaining module 801 is used for the second device to obtain data distribution information, where the data distribution information includes at least one of first gain information and label type information, and the first gain information is used to indicate that the first model obtained through the last round of training is adapted to The correction degree required for the current training sample of the second device, and the label type information is used to indicate the type corresponding to the label of the current training sample.
  • the steps performed by the obtaining module 801 refer to the description in 401 above.
  • the sending module 802 is used for the second device to send data distribution information to the first device, where the data distribution information is used for the first device to select a matching federated learning strategy.
  • the steps performed by the sending module 802 refer to the descriptions in 402 and 407 above.
  • the receiving module 803 is used for the second device to receive the parameter reporting strategy corresponding to the federated learning strategy sent by the first device, and obtain second gain information based on the received parameter reporting strategy and the current training sample, and the second gain information is used to obtain the second gain information.
  • Second model of the device The steps performed by the receiving module 803 refer to the descriptions in 406 and 410 above.
  • the sending module 802 is also used for the second device to send the second gain information to the first device;
  • the receiving module 803 is further configured for the second device to receive the corresponding third gain information sent by the first device based on the second gain information, and the second device to obtain the second model based on the third gain information and the first model of the second device, or , the second device receives the second model obtained based on the corresponding third gain information and the first model of the second device and sent by the first device.
  • the sending module 802 is further configured for the second device to send training sample feature information to the first device, and the training sample feature information is used for the first device to determine hyperparameters;
  • the receiving module 803 is further configured for the second device to receive the hyperparameter sent by the first device, and obtain second gain information based on the received parameter reporting policy, the current training sample and the hyperparameter.
  • the training sample feature information includes label distribution information or the number of samples; the label distribution information includes at least one of label proportion information and the number of labels of each type, and the label proportion information is used to indicate each The proportion of the type of labels in the labels of the current training sample; the sample number information is used to indicate the number of samples included in the current training sample.
  • the first model obtained from the last round of training includes the first model of the second device
  • the first gain information includes gain information corresponding to the first model of the second device
  • the first model of the second device The corresponding gain information is used to indicate the degree of correction required by the first model of the second device to adapt to the current training sample of the second device
  • the first model obtained from the last round of training includes the first model of the second device and the first models of other second devices participating in federated learning
  • the first gain information includes gain information corresponding to the first model of the second device and other
  • the gain information corresponding to the first model of the second device, and the gain information corresponding to the first models of other second devices is used to indicate the degree of correction required by the first models of other second devices to adapt to the current training samples of the second device.
  • the receiving module 803 is further configured for the second device to receive the first models of other second devices sent by the first device.
  • each second device participating in federated learning in this embodiment of the present application sends its own data distribution information to the first device, so that the first device can judge the current training of different second devices according to each data distribution information
  • the distribution of the samples that is, the degree of non-IID of the current training samples of different second devices is grasped.
  • the first device selects the federated learning strategy according to the degree of non-IID, and sends the selected federated learning strategy to each second device, and then each second device updates the model according to the federated learning strategy. Therefore, the non-IID phenomenon of training data between different second devices is avoided, which interferes with the federated learning process, so that the models obtained by each second device through federated learning have better performance, such as higher accuracy.
  • FIG. 9 shows a schematic structural diagram of a communication device 900 provided by an exemplary embodiment of the present application.
  • the communication device 900 shown in FIG. 9 is used to perform the operations involved in the federated learning method shown in the above-mentioned FIG. 4 or FIG. 6 .
  • the communication device 900 is, for example, a switch, a router, a controller, etc., and the communication device 900 can be implemented by a general bus architecture.
  • the communication device 900 includes at least one processor 901, memory 903, and at least one communication interface 904.
  • the processor 901 is, for example, a general-purpose central processing unit (central processing unit, CPU), a digital signal processor (digital signal processor, DSP), a network processor (network processor, NP), a graphics processor (Graphics Processing Unit, GPU), A neural-network processing unit (NPU), a data processing unit (DPU), a microprocessor or one or more integrated circuits for implementing the solution of the present application.
  • the processor 901 includes an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof.
  • the PLD is, for example, a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof. It may implement or execute the various logical blocks, modules and circuits described in connection with the disclosure of the embodiments of the present invention.
  • a processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.
  • the communication device 900 further includes a bus.
  • the bus is used to transfer information between the various components of the communication device 900 .
  • the bus may be a peripheral component interconnect (PCI for short) bus or an extended industry standard architecture (EISA for short) bus or the like.
  • PCI peripheral component interconnect
  • EISA extended industry standard architecture
  • the bus can be divided into address bus, data bus, control bus and so on. For ease of presentation, only one thick line is used in FIG. 9, but it does not mean that there is only one bus or one type of bus.
  • the memory 903 is, for example, a read-only memory (read-only memory, ROM) or other types of static storage devices that can store static information and instructions, or a random access memory (random access memory, RAM) or a memory device that can store information and instructions.
  • Other types of dynamic storage devices such as electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disk storage, optical disks storage (including compact discs, laser discs, compact discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, or other magnetic storage devices, or capable of carrying or storing desired program code in the form of instructions or data structures and capable of Any other medium accessed by a computer without limitation.
  • the memory 903 exists independently, for example, and is connected to the processor 901 through a bus.
  • the memory 903 may also be integrated with the processor 901 .
  • the communication interface 904 uses any transceiver-like device for communicating with other devices or a communication network, which may be Ethernet, a radio access network (RAN), or a wireless local area network (WLAN) )Wait.
  • Communication interface 904 may include a wired communication interface and may also include a wireless communication interface.
  • the communication interface 904 may be an Ethernet (Ethernet) interface, a Fast Ethernet (FE) interface, a Gigabit Ethernet (GE) interface, an Asynchronous Transfer Mode (ATM) interface, a wireless local area network ( wireless local area networks, WLAN) interfaces, cellular network communication interfaces, or a combination thereof.
  • the Ethernet interface can be an optical interface, an electrical interface or a combination thereof.
  • the communication interface 904 may be used for the communication device 900 to communicate with other devices.
  • the processor 901 may include one or more CPUs, such as CPU0 and CPU1 as shown in FIG. 9 .
  • Each of these processors can be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor.
  • a processor herein may refer to one or more devices, circuits, and/or processing cores for processing data (eg, computer program instructions).
  • the communication device 900 may include multiple processors, such as the processor 901 and the processor 905 shown in FIG. 9 .
  • processors can be a single-core processor (single-CPU) or a multi-core processor (multi-CPU).
  • a processor herein may refer to one or more devices, circuits, and/or processing cores for processing data (eg, computer program instructions).
  • the communication device 900 may further include an output device and an input device.
  • the output device communicates with the processor 901 and can display information in a variety of ways.
  • the output device may be a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, a projector, or the like.
  • the input device communicates with the processor 901 and can receive user input in a variety of ways.
  • the input device may be a mouse, a keyboard, a touch screen device, or a sensor device, or the like.
  • the memory 903 is used to store the program code 910 for executing the solutions of the present application, and the processor 901 can execute the program code 910 stored in the memory 903 . That is, the communication device 900 can implement the federated learning method provided by the method embodiment through the processor 901 and the program code 910 in the memory 903 . One or more software modules may be included in the program code 910 .
  • the processor 901 itself may also store program codes or instructions for executing the solutions of the present application.
  • the communication device 900 in this embodiment of the present application may correspond to the first device or the second device in the above method embodiments, and the processor 901 in the communication device 900 reads the instruction in the memory 903, so that FIG. 9
  • the communication device 900 shown can perform all or part of the operations performed by the first device or the second device in the method embodiment.
  • the communication device 900 may also correspond to the device shown in FIG. 7 above, and each functional module in the device shown in FIG. 7 is implemented by software of the communication device 900 .
  • the functional modules included in the apparatus shown in FIG. 7 are generated after the processor 901 of the communication device 900 reads the program code 910 stored in the memory 903 .
  • the communication device 900 may also correspond to the above-mentioned apparatus shown in FIG. 8 , and each functional module in the apparatus shown in FIG. 8 is implemented by software of the communication apparatus 900 .
  • the functional modules included in the apparatus shown in FIG. 8 are generated after the processor 901 of the communication device 900 reads the program code 910 stored in the memory 903 .
  • each step of the federated learning method shown in FIG. 4 and FIG. 6 is completed by an integrated logic circuit of hardware in the processor of the communication device 900 or instructions in the form of software.
  • the steps of the method disclosed in conjunction with the embodiments of the present application may be directly embodied as executed by a hardware processor, or executed by a combination of hardware and software modules in the processor.
  • the software modules may be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other storage media mature in the art.
  • the storage medium is located in the memory, and the processor reads the information in the memory, and completes the steps of the above method in combination with its hardware, which will not be described in detail here to avoid repetition.
  • the communication device described above may be implemented as a virtualized device.
  • the virtualization device may be a virtual machine (English: Virtual Machine, VM) running a program for sending a message, and the virtual machine is deployed on a hardware device (for example, a physical server).
  • a virtual machine refers to a complete computer system with complete hardware system functions simulated by software and running in a completely isolated environment.
  • the virtual machine can be configured as a first communication device or a second communication device.
  • a communication device may be implemented based on a general physical server combined with a Network Functions Virtualization (NFV) technology.
  • NFV Network Functions Virtualization
  • the communication device is a virtual host, a virtual router or a virtual switch.
  • a virtualization device may be a container, which is an entity used to provide an isolated virtualization environment, for example, a container may be a docker container.
  • a container can be configured as a communication device.
  • a communication device can be created through the corresponding image.
  • two container instances can be created for the proxy-container through the image of the proxy-container (a container that provides proxy services), namely the container instance proxy-container1 and the container instance proxy.
  • -container2 providing the container instance proxy-container1 as the first device in the above method embodiments, and providing the container instance proxy-container2 as the second device in the above method embodiments.
  • the communication device can use the kernel of the physical machine to run, and multiple communication devices can share the operating system of the physical machine. Different communication devices can be isolated through container technology.
  • the containerized communication device can run in a virtualized environment, for example, can run in a virtual machine, and the containerized communication device can also run directly in a physical machine.
  • a virtualized device can be a Pod, and a Pod is Kubernetes (Kubernetes is a container orchestration engine open sourced by Google, abbreviated as K10s in English), which is the basic unit for deploying, managing, and orchestrating containerized applications.
  • a Pod can contain one or more containers. Each container in the same Pod is usually deployed on the same host, so each container in the same Pod can communicate through the host and can share the host's storage resources and network resources. Pods can be configured as communication devices.
  • a container as a service can be instructed to create a Pod and provide the Pod as a communication device.
  • the communication device may also be other virtualized devices, which will not be listed here.
  • the above-mentioned communication device may also be implemented by a general-purpose processor.
  • the general purpose processor may be in the form of a chip.
  • a general-purpose processor that implements a communication device includes a processing circuit, an input interface and an output interface that are internally connected and communicated with the processing circuit, and the processing circuit is configured to perform the steps of generating messages in each of the above method embodiments through the input interface, The processing circuit is configured to perform the receiving step in the above method embodiments through the input interface, and the processing circuit is configured to perform the sending step in the above method embodiments through the output interface.
  • the general-purpose processor may further include a storage medium, and the processing circuit is configured to use the storage medium to perform the storage steps in each of the foregoing method embodiments.
  • the storage medium may store instructions executed by the processing circuit, where the processing circuit is configured to execute the instructions stored in the storage medium to perform the above-mentioned various method embodiments.
  • processor may be a central processing unit (Central Processing Unit, CPU), or other general-purpose processors, digital signal processing (digital signal processing, DSP), application specific integrated circuit (application specific integrated circuit, ASIC), field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • a general purpose processor may be a microprocessor or any conventional processor or the like. It should be noted that the processor may be a processor supporting an advanced RISC machine (ARM) architecture.
  • ARM advanced RISC machine
  • the above-mentioned memory may include read-only memory and random access memory, and provide instructions and data to the processor.
  • the memory may also include non-volatile random access memory.
  • the memory may also store device type information.
  • the memory may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory.
  • the non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically programmable Erase programmable read-only memory (electrically EPROM, EEPROM) or flash memory.
  • Volatile memory may be random access memory (RAM), which acts as an external cache. By way of example and not limitation, many forms of RAM are available.
  • SRAM static RAM
  • DRAM dynamic random access memory
  • SDRAM synchronous dynamic random access memory
  • double data rate synchronous dynamic random access Memory double data date SDRAM, DDR SDRAM
  • enhanced synchronous dynamic random access memory enhanced SDRAM, ESDRAM
  • synchronous link dynamic random access memory direct memory bus random access memory
  • direct rambus RAM direct rambus RAM
  • An embodiment of the present application provides a federated learning system, where the federated learning system includes: a first communication device and a plurality of second communication devices.
  • the first communication device is configured to execute the method executed by the first device in the foregoing method embodiment
  • each second communication device is configured to execute the method executed by the second device in the foregoing method embodiment.
  • the embodiments of the present application provide a computer program (product), where the computer program (product) includes: computer program code, when the computer program code is run by a computer, the computer program code enables the computer to execute the first device or the second device in the above method embodiment.
  • Implemented federated learning method when the computer program code is run by a computer, the computer program code enables the computer to execute the first device or the second device in the above method embodiment.
  • the embodiments of the present application provide a computer-readable storage medium, where the computer-readable storage medium stores programs or instructions, and when the programs or instructions are run on a computer, the federation executed by the first device or the second device in the foregoing method embodiments The learning method is executed.
  • An embodiment of the present application provides a chip, including a processor, configured to call and execute an instruction stored in the memory from a memory, so that a communication device installed with the chip executes the first device or the second device in the foregoing method embodiments. federated learning method.
  • An embodiment of the present application provides another chip, including: an input interface, an output interface, a processor, and a memory, the input interface, the output interface, the processor, and the memory are connected through an internal connection path, and the processor is used to execute code in the memory, When the code is executed, the processor is configured to execute the federated learning method executed by the first device or the second device in the above method embodiment.
  • the above-mentioned embodiments it may be implemented in whole or in part by software, hardware, firmware or any combination thereof.
  • software it can be implemented in whole or in part in the form of a computer program product.
  • the computer program product includes one or more computer instructions.
  • the computer program instructions when loaded and executed on a computer, result in whole or in part of the processes or functions described herein.
  • the computer may be a general purpose computer, special purpose computer, computer network, or other programmable device.
  • the computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be downloaded from a website site, computer, server, or data center Transmission to another website site, computer, server, or data center by wire (eg, coaxial cable, optical fiber, digital subscriber line) or wireless (eg, infrared, wireless, microwave, etc.).
  • the computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, a data center, or the like that includes an integration of one or more available media.
  • the usable media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes), optical media (eg, DVD), or semiconductor media (eg, Solid State Disk), and the like.
  • computer program code or related data may be carried by any suitable carrier to enable a device, apparatus or processor to perform the various processes and operations described above.
  • suitable carriers include signals, computer-readable media, and the like.
  • Examples of signals may include electrical, optical, radio, acoustic, or other forms of propagated signals, such as carrier waves, infrared signals, and the like.
  • a machine-readable medium can be any tangible medium that contains or stores a program for or in connection with an instruction execution system, apparatus, or device.
  • the machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium.
  • Machine-readable media may include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or devices, or any suitable combination thereof. More detailed examples of machine-readable storage media include electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read only memory (ROM), erasable programmable read only Memory (EPROM or flash memory), optical storage devices, magnetic storage devices, or any suitable combination thereof.
  • the disclosed systems, devices and methods may be implemented in other manners.
  • the device embodiments described above are only illustrative.
  • the division of the modules is only a logical function division. In actual implementation, there may be other division methods.
  • multiple modules or components may be combined or Integration into another system, or some features can be ignored, or not implemented.
  • the shown or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or modules, and may also be electrical, mechanical or other forms of connection.
  • modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, may be located in one place, or may be distributed to multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solutions of the embodiments of the present application.
  • each functional module in each embodiment of the present application may be integrated into one processing module, or each module may exist physically alone, or two or more modules may be integrated into one module.
  • the above-mentioned integrated modules can be implemented in the form of hardware, and can also be implemented in the form of software function modules.
  • the integrated modules are implemented in the form of software functional modules and sold or used as independent products, they may be stored in a computer-readable storage medium.
  • the technical solutions of the present application are essentially or part of contributions to the prior art, or all or part of the technical solutions can be embodied in the form of software products, and the computer software products are stored in a storage medium , including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in the various embodiments of the present application.
  • the aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk and other media that can store program codes .
  • first, second and other words are used to distinguish the same or similar items with basically the same function and function, and it should be understood that between “first”, “second” and “nth” There are no logical or timing dependencies, and no restrictions on the number and execution order. It will also be understood that, although the following description uses the terms first, second, etc. to describe various elements, these elements should not be limited by the terms. These terms are only used to distinguish one element from another. For example, a first image may be referred to as a second image, and, similarly, a second image may be referred to as a first image, without departing from the scope of various described examples. Both the first image and the second image may be images, and in some cases, may be separate and distinct images.
  • the size of the sequence number of each process does not mean the sequence of execution, and the execution sequence of each process should be determined by its function and internal logic, and should not be used in the embodiment of the present application. Implementation constitutes any limitation.
  • the meaning of the term “at least one” refers to one or more, and the meaning of the term “plurality” in this application refers to two or more.
  • a plurality of second messages refers to two or more more than one second message.
  • system and “network” are often used interchangeably herein.
  • determining B according to A does not mean that B is only determined according to A, and B may also be determined according to A and/or other information.
  • references throughout the specification to "one embodiment,” “an embodiment,” and “one possible implementation” mean that a particular feature, structure, or characteristic associated with the embodiment or implementation is included herein. in at least one embodiment of the application. Thus, appearances of "in one embodiment” or “in an embodiment” or “one possible implementation” in various places throughout this specification are not necessarily necessarily referring to the same embodiment. Furthermore, the particular features, structures or characteristics may be combined in any suitable manner in one or more embodiments.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Artificial Intelligence (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Medical Informatics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Image Analysis (AREA)

Abstract

本申请公开了一种联邦学习方法、装置、设备、系统及计算机可读存储介质,属于人工智能技术领域。该方法包括:首先,各个第二设备分别获得数据分布信息并向第一设备发送该数据分布信息。之后,第一设备接收参与联邦学习的多个第二设备发送的数据分布信息,从而根据多个第二设备发送的数据分布信息选择匹配的联邦学习策略。接着,第一设备向多个第二设备中的至少一个第二设备发送联邦学习对应的参数上报策略。其中,接收到参数上报策略的第二设备用于根据该参数上报策略以及当前训练样本获得第二增益信息,第二增益信息用于获得该第二设备的第二模型。本申请降低了数据的非独立同分布现象所造成的干扰,能够得到性能较好的第二模型。

Description

联邦学习方法、装置、设备、系统及计算机可读存储介质
本申请要求于2020年11月30日提交的申请号为202011385076.2、发明名称为“联邦学习方法、装置、设备、系统及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及人工智能技术领域,特别涉及一种联邦学习方法、装置、设备、系统及计算机可读存储介质。
背景技术
随着人工智能技术的不断发展,联邦学习作为一种新兴的人工智能技术,应用范围越来越广。联邦学习是指在进行机器学习的过程中,各参与方可借助其他方数据进行联合建模。各方无需共享数据资源,即数据不出本地的情况下,进行数据联合训练,建立共享的机器学习模型。
在联邦学习的应用场景中,各个设备上的数据是由设备/用户独立产生的,不同设备/用户的非同源数据具有不同的分布特征,而每一个设备在进行本地学习的时候,使用的训练数据是非独立同分布(non independently and identically distributed,Non-IID)的。因此,针对不同的数据分布情况,如何提升联邦学习的效率,对于联邦学习具有重要意义。
发明内容
本申请提供了一种联邦学习方法、装置、设备、系统及计算机可读存储介质,用于解决获得模型的灵活性较差,效率较低的问题。
第一方面,提供了一种联邦学习方法,方法包括:首先,第一设备接收参与联邦学习的多个第二设备发送的数据分布信息。对于任一第二设备而言,该任一第二设备发送的数据分布信息包括第一增益信息和标签类型信息中的至少一种。其中,第一增益信息用于指示通过上轮训练获得的第一模型为了适应任一第二设备的当前训练样本所需的修正程度,标签类型信息用于指示当前训练样本的标签对应的类型。
之后,第一设备根据多个第二设备发送的数据分布信息选择匹配的联邦学习策略。接着,第一设备向多个第二设备中的至少一个第二设备发送联邦学习策略对应的参数上报策略,至少一个第二设备中的任一第二设备用于上报基于接收到的参数上报策略以及当前训练样本获得的第二增益信息,第二增益信息用于获得任一第二设备的第二模型。
本申请中参与联邦学习的各个第二设备分别将各自的数据分布信息发送给第一设备,从而使得第一设备能够根据各个数据分布信息判断不同第二设备的当前训练样本的分布情况,也就是掌握了不同第二设备的当前训练样本的非独立同分布程度。之后,第一设备根据非独立同分布程度进行联邦学习策略的选择,基于选择的联邦学习策略向各个第二设备发送对应的参数上报策略,使得各个第二设备分别根据联邦学习策略进行模型的更新。因此,避免了 不同第二设备之间的训练数据存在非独立同分布现象而对联邦学习过程造成干扰,使得各个第二设备通过联邦学习得到的模型具有较好的性能,例如准确度较高。
在一种可能的实现方式中,第一设备根据多个第二设备发送的数据分布信息选择匹配的联邦学习策略,包括:第一设备根据数据分布之间的差异选择匹配的联邦学习策略,数据分布之间的差异基于多个第二设备发送的数据分布信息确定。
在一种可能的实现方式中,任一第二设备发送的数据分布信息包括第一增益信息和标签类型信息,第一设备根据数据分布之间的差异选择匹配的联邦学习策略之前,还包括:第一设备根据多个第二设备的第一增益信息确定特征分布信息,特征分布信息用于指示不同第二设备的当前训练样本的特征分布是否相同;第一设备根据特征分布信息以及多个第二设备的标签类型信息确定数据分布之间的差异。
在一种可能的实现方式中,第一设备根据数据分布之间的差异选择匹配的联邦学习策略,包括:基于特征分布信息指示不同第二设备的当前训练样本的特征分布相同,且不同第二设备的标签类型信息相同,则选择匹配的联邦学习策略为模型平均融合,模型平均融合用于以增益信息平均的方式进行联邦学习。
在一种可能的实现方式中,第一设备根据数据分布之间的差异选择匹配的联邦学习策略,包括:基于特征分布信息指示不同第二设备的当前训练样本的特征分布不同,且不同第二设备的标签类型信息相同,则选择匹配的联邦学习策略为模型差异化更新,模型差异化更新用于以增益信息差异化处理的方式进行联邦学习。
在一种可能的实现方式中,第一设备根据数据分布之间的差异选择匹配的联邦学习策略,包括:基于特征分布信息指示不同第二设备的当前训练样本的特征分布相同,且不同第二设备的标签类型信息不同,则选择匹配的联邦学习策略为模型部分更新,模型部分更新用于以部分增益信息平均的方式进行联邦学习。
在一种可能的实现方式中,第一设备根据数据分布之间的差异选择匹配的联邦学习策略,包括:基于特征分布信息指示不同第二设备的当前训练样本的特征分布不同,且不同第二设备的标签类型信息不同,则选择匹配的联邦学习策略为模型部分差异化更新,模型部分差异化更新用于以部分增益信息差异化处理的方式进行联邦学习。
在一种可能的实现方式中,任一第二设备发送的数据分布信息包括第一增益信息,第一设备根据数据分布之间的差异选择匹配的联邦学习策略之前,还包括:第一设备根据多个第二设备的第一增益信息确定特征分布信息,特征分布信息用于指示不同第二设备的当前训练样本的特征分布是否相同;第一设备根据特征分布信息确定数据分布之间的差异。
在一种可能的实现方式中,第一设备根据数据分布之间的差异选择匹配的联邦学习策略,包括:基于特征分布信息指示不同第二设备的当前训练样本的特征分布相同,则选择匹配的联邦学习策略为模型平均融合,模型平均融合用于以增益信息平均的方式进行联邦学习。
在一种可能的实现方式中,第一设备根据数据分布之间的差异选择匹配的联邦学习策略,包括:基于特征分布信息指示不同第二设备的当前训练样本的特征分布不同,则选择匹配的联邦学习策略为模型差异化更新,模型差异化更新用于以增益信息差异化处理的方式进行联邦学习。
在一种可能的实现方式中,任一第二设备发送的数据分布信息包括标签类型信息,第一设备根据数据分布之间的差异选择匹配的联邦学习策略之前,还包括:基于标签类型信息确 定数据分布之间的差异。
在一种可能的实现方式中,第一设备根据数据分布之间的差异选择匹配的联邦学习策略,包括:基于不同第二设备的标签类型信息相同,则选择匹配的联邦学习策略为模型平均融合,模型平均融合用于以增益信息平均的方式进行联邦学习。
在一种可能的实现方式中,第一设备根据数据分布之间的差异选择匹配的联邦学习策略,包括:基于不同第二设备的标签类型信息不同,则选择匹配的联邦学习策略为模型部分更新,模型部分更新用于以部分增益信息平均的方式进行联邦学习。
在一种可能的实现方式中,第一设备向多个第二设备中的至少一个第二设备发送联邦学习策略对应的参数上报策略之后,方法还包括:第一设备接收多个第二设备发送的第二增益信息;第一设备基于联邦学习策略对第二增益信息进行联邦融合,得到各个第二设备对应的第三增益信息;第一设备向至少一个第二设备中的任一第二设备发送对应的第三增益信息,或者基于对应的第三增益信息以及任一第二设备的第一模型获得的第二模型。
在一种可能的实现方式中,第一设备向多个第二设备中的至少一个第二设备发送联邦学习策略对应的参数上报策略之前,方法还包括:第一设备接收多个第二设备发送的训练样本特征信息,训练样本特征信息用于表征标签分布或样本数量;第一设备向多个第二设备中的至少一个第二设备发送联邦学习策略对应的参数上报策略,还包括:对于至少一个第二设备中的任一第二设备,第一设备向任一第二设备发送超参数,超参数基于任一第二设备发送的训练样本特征信息确定,超参数用于任一第二设备获取第二增益信息。
在一种可能的实现方式中,训练样本特征信息包括标签分布信息或样本数量;标签分布信息包括标签占比信息和每种类型的标签数量中的至少一种,标签占比信息用于指示各种类型的标签在当前训练样本的标签中的占比;样本数量信息用于指示当前训练样本中包括的样本的条数。
在一种可能的实现方式中,上轮训练获得的第一模型包括任一第二设备的第一模型,第一增益信息包括任一第二设备的第一模型对应的增益信息,任一第二设备的第一模型对应的增益信息用于指示任一第二设备的第一模型为了适应任一第二设备的当前训练样本所需的修正程度;或者,上轮训练获得的第一模型包括任一第二设备的第一模型及参与联邦学习的其他第二设备的第一模型,第一增益信息包括任一第二设备的第一模型对应的增益信息以及其他第二设备的第一模型对应的增益信息,其他第二设备的第一模型对应的增益信息用于指示其他第二设备的第一模型为了适应任一第二设备的当前训练样本所需的修正程度。
在一种可能的实现方式中,第一设备接收参与联邦学习的多个第二设备发送的数据分布信息之前,方法还包括:第一设备向任一第二设备发送其他第二设备的第一模型。
第二方面,提供了一种联邦学习方法,方法包括:第二设备获得数据分布信息,数据分布信息包括第一增益信息和标签类型信息中的至少一种,第一增益信息用于指示通过上轮训练获得的第一模型为了适应第二设备的当前训练样本所需的修正程度,标签类型信息用于指示当前训练样本的标签对应的类型;第二设备向第一设备发送数据分布信息,数据分布信息用于第一设备选择匹配的联邦学习策略;第二设备接收第一设备发送的联邦学习策略对应的参数上报策略,基于接收到的参数上报策略以及当前训练样本获得第二增益信息,第二增益信息用于获得第二设备的第二模型。
本申请中参与联邦学习的第二设备将各自的数据分布信息发送给第一设备,从而使得第 一设备能够根据各个数据分布信息判断不同第二设备的当前训练样本的分布情况,也就是掌握了不同第二设备的当前训练样本的非独立同分布程度。之后,第二设备接收第一设备基于选择的联邦学习策略向各个第二设备发送的对应的参数上报策略,使得第二设备能够根据参数上报策略上报对应的第二增益信息,以实现模型更新。因此,避免了不同第二设备之间的训练数据存在非独立同分布现象而对联邦学习过程造成干扰,使得各个第二设备通过联邦学习得到的模型具有较好的性能,例如准确度较高。
在一种可能的实现方式中,基于接收到的参数上报策略以及当前训练样本获得第二增益信息之后,方法还包括:第二设备向第一设备发送第二增益信息;第二设备接收第一设备基于第二增益信息发送的对应的第三增益信息,第二设备基于第三增益信息以及第二设备的第一模型获得第二模型,或者,第二设备接收第一设备发送的基于对应的第三增益信息以及第二设备的第一模型获得的第二模型。
在一种可能的实现方式中,方法还包括:第二设备向第一设备发送训练样本特征信息,训练样本特征信息用于第一设备确定超参数;第二设备接收第一设备发送的超参数;
基于接收到的参数上报策略以及当前训练样本获得第二增益信息,包括:第二设备基于接收到的参数上报策略、当前训练样本以及超参数获得第二增益信息。
在一种可能的实现方式中,训练样本特征信息包括标签分布信息或样本数量;标签分布信息包括标签占比信息和每种类型的标签数量中的至少一种,标签占比信息用于指示各种类型的标签在当前训练样本的标签中的占比;样本数量信息用于指示当前训练样本中包括的样本的条数。
在一种可能的实现方式中,上轮训练获得的第一模型包括第二设备的第一模型,第一增益信息包括第二设备的第一模型对应的增益信息,第二设备的第一模型对应的增益信息用于指示第二设备的第一模型为了适应第二设备的当前训练样本所需的修正程度;或者,上轮训练获得的第一模型包括第二设备的第一模型及参与联邦学习的其他第二设备的第一模型,第一增益信息包括第二设备的第一模型对应的增益信息以及其他第二设备的第一模型对应的增益信息,其他第二设备的第一模型对应的增益信息用于指示其他第二设备的第一模型为了适应第二设备的当前训练样本所需的修正程度。
在一种可能的实现方式中,第二设备获得数据分布信息之前,方法还包括:第二设备接收第一设备发送的其他第二设备的第一模型。
第三方面,提供了一种联邦学习装置,装置包括:
接收模块,用于第一设备接收参与联邦学习的多个第二设备发送的数据分布信息,任一第二设备发送的数据分布信息包括第一增益信息和标签类型信息中的至少一种,第一增益信息用于指示通过上轮训练获得的第一模型为了适应任一第二设备的当前训练样本所需的修正程度,标签类型信息用于指示当前训练样本的标签对应的类型;
选择模块,用于第一设备根据多个第二设备发送的数据分布信息选择匹配的联邦学习策略;
发送模块,用于第一设备向多个第二设备中的至少一个第二设备发送联邦学习策略对应的参数上报策略,至少一个第二设备中的任一第二设备用于上报基于接收到的参数上报策略以及当前训练样本获得的第二增益信息,第二增益信息用于获得任一第二设备的第二模型。
在一种可能的实现方式中,选择模块,用于第一设备根据数据分布之间的差异选择匹配 的联邦学习策略,数据分布之间的差异基于多个第二设备发送的数据分布信息确定。
在一种可能的实现方式中,任一第二设备发送的数据分布信息包括第一增益信息和标签类型信息,装置还包括:
第一确定模块,用于第一设备根据多个第二设备的第一增益信息确定特征分布信息,特征分布信息用于指示不同第二设备的当前训练样本的特征分布是否相同;第一设备根据特征分布信息以及多个第二设备的标签类型信息确定数据分布之间的差异。
在一种可能的实现方式中,选择模块,用于基于特征分布信息指示不同第二设备的当前训练样本的特征分布相同,且不同第二设备的标签类型信息相同,则选择匹配的联邦学习策略为模型平均融合,模型平均融合用于以增益信息平均的方式进行联邦学习。
在一种可能的实现方式中,选择模块,用于基于特征分布信息指示不同第二设备的当前训练样本的特征分布不同,且不同第二设备的标签类型信息相同,则选择匹配的联邦学习策略为模型差异化更新,模型差异化更新用于以增益信息差异化处理的方式进行联邦学习。
在一种可能的实现方式中,选择模块,用于基于特征分布信息指示不同第二设备的当前训练样本的特征分布相同,且不同第二设备的标签类型信息不同,则选择匹配的联邦学习策略为模型部分更新,模型部分更新用于以部分增益信息平均的方式进行联邦学习。
在一种可能的实现方式中,选择模块,用于基于特征分布信息指示不同第二设备的当前训练样本的特征分布不同,且不同第二设备的标签类型信息不同,则选择匹配的联邦学习策略为模型部分差异化更新,模型部分差异化更新用于以部分增益信息差异化处理的方式进行联邦学习。
在一种可能的实现方式中,任一第二设备发送的数据分布信息包括第一增益信息,装置还包括:
第二确定模块,用于第一设备根据多个第二设备的第一增益信息确定特征分布信息,特征分布信息用于指示不同第二设备的当前训练样本的特征分布是否相同;第一设备根据特征分布信息确定数据分布之间的差异。
在一种可能的实现方式中,选择模块,用于基于特征分布信息指示不同第二设备的当前训练样本的特征分布相同,则选择匹配的联邦学习策略为模型平均融合,模型平均融合用于以增益信息平均的方式进行联邦学习。
在一种可能的实现方式中,选择模块,用于基于特征分布信息指示不同第二设备的当前训练样本的特征分布不同,则选择匹配的联邦学习策略为模型差异化更新,模型差异化更新用于以增益信息差异化处理的方式进行联邦学习。
在一种可能的实现方式中,装置还包括:第三确定模块,用于基于标签类型信息确定数据分布之间的差异。
在一种可能的实现方式中,选择模块,用于基于不同第二设备的标签类型信息相同,则选择匹配的联邦学习策略为模型平均融合,模型平均融合用于以增益信息平均的方式进行联邦学习。
在一种可能的实现方式中,选择模块,用于基于不同第二设备的标签类型信息不同,则选择匹配的联邦学习策略为模型部分更新,模型部分更新用于以部分增益信息平均的方式进行联邦学习。
在一种可能的实现方式中,接收模块,还用于第一设备接收多个第二设备发送的第二增 益信息;
装置还包括:融合模块,用于第一设备基于联邦学习策略对第二增益信息进行联邦融合,得到各个第二设备对应的第三增益信息;
发送模块,还用于第一设备向至少一个第二设备中的任一第二设备发送对应的第三增益信息,或者基于对应的第三增益信息以及任一第二设备的第一模型获得的第二模型。
在一种可能的实现方式中,接收模块,还用于第一设备接收多个第二设备发送的训练样本特征信息,训练样本特征信息用于表征标签分布或样本数量;
发送模块,还用于对于至少一个第二设备中的任一第二设备,第一设备向任一第二设备发送超参数,超参数基于任一第二设备发送的训练样本特征信息确定,超参数用于任一第二设备获取第二增益信息。
在一种可能的实现方式中,训练样本特征信息包括标签分布信息或样本数量;标签分布信息包括标签占比信息和每种类型的标签数量中的至少一种,标签占比信息用于指示各种类型的标签在当前训练样本的标签中的占比;样本数量信息用于指示当前训练样本中包括的样本的条数。
在一种可能的实现方式中,上轮训练获得的第一模型包括任一第二设备的第一模型,第一增益信息包括任一第二设备的第一模型对应的增益信息,任一第二设备的第一模型对应的增益信息用于指示任一第二设备的第一模型为了适应任一第二设备的当前训练样本所需的修正程度;
或者,上轮训练获得的第一模型包括任一第二设备的第一模型及参与联邦学习的其他第二设备的第一模型,第一增益信息包括任一第二设备的第一模型对应的增益信息以及其他第二设备的第一模型对应的增益信息,其他第二设备的第一模型对应的增益信息用于指示其他第二设备的第一模型为了适应任一第二设备的当前训练样本所需的修正程度。
在一种可能的实现方式中,第一设备接收参与联邦学习的多个第二设备发送的数据分布信息之前,发送模块,还用于第一设备向任一第二设备发送其他第二设备的第一模型。
第四方面,提供了一种联邦学习装置,装置包括:
获得模块,用于第二设备获得数据分布信息,数据分布信息包括第一增益信息和标签类型信息中的至少一种,第一增益信息用于指示通过上轮训练获得的第一模型为了适应第二设备的当前训练样本所需的修正程度,标签类型信息用于指示当前训练样本的标签对应的类型;
发送模块,用于第二设备向第一设备发送数据分布信息,数据分布信息用于第一设备选择匹配的联邦学习策略;
接收模块,用于第二设备接收第一设备发送的联邦学习策略对应的参数上报策略,基于接收到的参数上报策略以及当前训练样本获得第二增益信息,第二增益信息用于获得第二设备的第二模型。
在一种可能的实现方式中,发送模块,还用于第二设备向第一设备发送第二增益信息;
接收模块,还用于第二设备接收第一设备基于第二增益信息发送的对应的第三增益信息,第二设备基于第三增益信息以及第二设备的第一模型获得第二模型,或者,第二设备接收第一设备发送的基于对应的第三增益信息以及第二设备的第一模型获得的第二模型。
在一种可能的实现方式中,发送模块,还用于第二设备向第一设备发送训练样本特征信息,训练样本特征信息用于第一设备确定超参数;
接收模块,还用于第二设备接收第一设备发送的超参数,基于接收到的参数上报策略、当前训练样本以及超参数获得第二增益信息。
在一种可能的实现方式中,训练样本特征信息包括标签分布信息或样本数量;标签分布信息包括标签占比信息和每种类型的标签数量中的至少一种,标签占比信息用于指示各种类型的标签在当前训练样本的标签中的占比;样本数量信息用于指示当前训练样本中包括的样本的条数。
在一种可能的实现方式中,上轮训练获得的第一模型包括第二设备的第一模型,第一增益信息包括第二设备的第一模型对应的增益信息,第二设备的第一模型对应的增益信息用于指示第二设备的第一模型为了适应第二设备的当前训练样本所需的修正程度;
或者,上轮训练获得的第一模型包括第二设备的第一模型及参与联邦学习的其他第二设备的第一模型,第一增益信息包括第二设备的第一模型对应的增益信息以及其他第二设备的第一模型对应的增益信息,其他第二设备的第一模型对应的增益信息用于指示其他第二设备的第一模型为了适应第二设备的当前训练样本所需的修正程度。
在一种可能的实现方式中,接收模块,还用于第二设备接收第一设备发送的其他第二设备的第一模型。
第五方面,提供了一种通信设备,该设备包括:通信接口和处理器。可选地,该通信设备还包括存储器。其中,该通信接口、该存储器和该处理器通过内部连接通路互相通信,该存储器用于存储指令,该处理器用于执行该存储器存储的指令,以控制通信接口接收信号,并控制通信接口发送信号,并且当该处理器执行该存储器存储的指令时,使得该处理器执行第一方面或第一方面的任一种可能的实现方式中的方法。
第六方面,提供了一种通信设备,该设备包括:通信接口和处理器。可选地,该通信设备还包括存储器。其中,该通信接口、该存储器和该处理器通过内部连接通路互相通信,该存储器用于存储指令,该处理器用于执行该存储器存储的指令,以控制通信接口接收信号,并控制通信接口发送信号,并且当该处理器执行该存储器存储的指令时,使得该处理器执行第二方面或第二方面的任一种可能的实现方式中的方法。
可选地,处理器为一个或多个,存储器为一个或多个。
可选地,存储器可以与处理器集成在一起,或者存储器与处理器分离设置。
在具体实现过程中,存储器可以为非瞬时性(non-transitory)存储器,例如只读存储器(read only memory,ROM),其可以与处理器集成在同一块芯片上,也可以分别设置在不同的芯片上,本申请对存储器的类型以及存储器与处理器的设置方式不做限定。
第七方面,提供了一种通信系统,该系统包括第一通信设备和第二通信设备,第一通信设备用于执行上述第一方面或第一方面的任一种可能的实现方式所提供的联邦学习方法,第二通信设备用于执行上述第二方面或第二方面的任一种可能的实现方式所提供的联邦学习方法。
第八方面,提供了一种计算机程序(产品),计算机程序(产品)包括:计算机程序代码,当计算机程序代码被计算机运行时,使得计算机执行上述各方面中的方法。
第九方面,提供了一种计算机可读存储介质,计算机可读存储介质存储程序或指令,当程序或指令在计算机上运行时,上述各方面中的方法被执行。
第十方面,提供了一种芯片,包括处理器,用于从存储器中调用并运行存储器中存储的 指令,使得安装有芯片的通信设备执行上述各方面中的方法。
第十一方面,提供另一种芯片,包括:输入接口、输出接口、处理器和存储器,输入接口、输出接口、处理器以及存储器之间通过内部连接通路相连,处理器用于执行存储器中的代码,当代码被执行时,处理器用于执行上述各方面中的方法。
附图说明
图1是本申请实施例提供的一种联邦学习示意图;
图2是本申请实施例提供的一种相关技术中的联邦学习示意图;
图3是本申请实施例提供的一种联邦学习系统的架构示意图;
图4是本申请实施例提供的一种联邦学习的方法流程图;
图5是本申请实施例提供的一种选择联邦学习策略的流程示意图;
图6是本申请实施例提供的一种联邦学习的流程示意图;
图7是本申请实施例提供的一种联邦学习装置的结构示意图;
图8是本申请实施例提供的一种联邦学习装置的结构示意图;
图9是本发明实施例提供的通信设备的结构示意图。
具体实施方式
本申请的实施方式部分使用的术语仅用于对本申请的实施例进行解释,而非旨在限定本申请。下面结合附图,对本发明的实施例进行描述。
本申请的实施方式部分使用的术语仅用于对本申请的实施例进行解释,而非旨在限定本申请。下面结合附图,对本发明的实施例进行描述。
随着人工智能(artificial intelligence,AI)技术的发展及完善,AI技术逐渐引起各领域的广泛关注。其中,AI技术依赖于对大量标签数据的学习过程。而在实际应用中,持有数据源的对象往往面临着数据源中标签数据体量不足的问题。并且,由于数据源的类型限制以及隐私保护等原因,不同对象之间难以共享数据源。从而,导致AI技术在实际应用中面临“数据孤岛”问题。
为解决这一问题,联邦学习应运而生。在联邦学习过程中,多个持有数据源的对象分别作为参与方,从而在保证数据不出域的前提下联合多个参与方的数据源来训练机器学习模型,多个参与方能够共享该机器学习模型。参见图1,图1示出了一种联邦学习架构,包括N个客户端以及服务端,各个客户端分别与服务端通信连接。其中,客户端与联邦学习的参与方一一对应,客户端通过参与方提供的数据源在域内进行模型训练。之后,将模型训练结果上传至服务端,服务端综合各个客户端上传的模型训练结果获得共享的机器学习模型,将共享的机器学习模型下发至各个客户端以供使用。
在理想状态下,用于训练机器学习模型的训练数据遵循独立同分布(independently identically distribution,IID)。而在实际应用中,各个数据源中的标签数据往往是非独立的,与其他因素之间具有较强的相关性(inter-dependent),不同数据源之间的标签数据也往往具有不同的概率分布,从而使得联邦学习过程中的训练数据遵循非独立同分布(non-IID)。如何在训练数据遵循non-IID时保证机器学习模型的准确度,避免机器学习模型无法收敛等负面情况的发生,对于联邦学习过程具有重要意义。
相关技术提供了一种数据共享(data-sharing)的联邦学习方法。参见图2,该方法中服务端管理具有统一概率分布的标签数据集,服务端从该标签数据集中获得数据子集,基于该数据子集训练模型。服务端训练的模型用于确定各个客户端的权重,服务端基于所确定的权重向各个客户端分别下发数据子集。例如,在图2中,客户端1的权重为α 1,客户端2的权重为α 2。之后,各个客户端基于具有权重的数据子集以及域内数据源进行模型训练,将模型训练结果上传至服务端。服务端综合各个客户端上传的模型训练结果获得共享的机器学习模型。
然而,实际应用中往往难以获得到具有统一概率分布的标签数据集,从而导致相关技术所提供的方法仅存在于理论层面,很难落地应用。
本申请实施例提供了一种联邦学习方法,该方法能够应用于如图3所示的联邦学习系统中。图3中,包括第一设备以及N个第二设备(N≥2),各个第二设备分别与第一设备通信连接。第一设备用于作为联邦学习过程中的服务端(也称为中心节点),第二设备用于作为联邦学习过程中的客户端(也称为边缘节点)。其中,第一设备包括数据分布偏移模块、联合学习策略模块以及模型更新模块,各个第二设备分别包括增益信息计算模块以及模型更新模块。对图3示出的各模块进行说明如下:
增益信息计算模块:用于基于当前训练样本计算得到第一增益信息,该第一增益信息用于第一设备选择联邦学习策略。还用于基于联邦学习策略对应的参数上报策略以及对应的训练样本计算得到第二增益信息,该第二增益信息用于第一设备进行联邦融合。
模型更新模块:用于基于增益信息计算模块获得的第一增益信息或者第二增益信息对自身在上轮训练过程中获得的模型进行更新。
可选地,该第二设备还包括数据预处理模块,用于对当前训练样本所包括的样本进行预处理,得到预处理后的样本。示例性地,预处理包括但不限于数据补值以及特征提取。则增益信息计算模块用于基于预处理后的样本计算得到第一增益信息。还用于基于联邦学习策略对应的参数上报策略以及预处理后的样本计算得到第二增益信息。
数据分布偏移模块:用于根据各个第二设备的第一增益信息确定不同第二设备的当前训练样本的特征分布。
联合学习策略模块:用于根据不同第二设备的当前训练样本的特征分布选择匹配的联邦学习策略。
模型融合模块:用于基于联邦学习策略以及不同第二设备的第二增益信息进行联邦融合,得到第二设备对应的第三增益信息。将第三增益信息发送给对应的第二设备,用于第二设备基于该第三增益信息获取第二设备的第二模型。或者,基于第三增益信息及对应的第二设备的第一模型获得第二模型,将第二模型发送给对应的第二设备。
基于上述说明中各模块所具有的功能,参见图3,第二设备A依次通过A-1、A-2、A-3、A-4以及A-5完成联邦学习过程。另外,其他第二设备完成联邦学习的过程与第二设备A完成联邦学习的过程相同。例如,图3中示出的第二设备B依次通过图3所示的B-1、B-2、B-3、B-4以及B-5完成联邦学习过程,此处不再进行赘述。
基于上述图3所示的实施环境,本申请实施例提供了一种联邦学习方法。以通过第一设 备与第二设备之间的交互实现该联邦学习方法为例,参见图4,该方法包括如下的过程。
401,第二设备获得数据分布信息,数据分布信息包括第一增益信息和标签类型信息中的至少一种,第一增益信息用于指示通过上轮训练获得的第一模型为了适应第二设备的当前训练样本所需的修正程度,标签类型信息用于指示当前训练样本的标签对应的类型。
其中,联邦学习由第一设备以及多个第二设备共同参与,联邦学习往往包括多轮训练过程。401的执行时间位于多轮训练过程中任意两轮相邻的训练过程之间。为便于说明,文中将在执行401时已结束的一轮训练过程称为上轮训练过程,将在执行401时还未开始的一轮训练过程称为当前训练过程。
对于任一第二设备而言,在本轮训练之前,该第二设备会接收到第一设备下发的模型,第二设备由此得到第二设备的第一模型,该第一模型作为上轮训练获得的第一模型。此外,该第二设备在本轮训练过程中具有对应的训练样本,也即当前训练样本。本申请实施例不对第二设备当前训练样本的获取方式进行限定。示例性地,在上轮训练结束之后,该第二设备对应的上轮训练样本可能发生变化,从而使得该第二设备对应的训练样本由上轮训练样本更新为当前训练样本。例如,在上轮训练样本的基础上再加新的样本,构成当前训练样本。例如,针对本轮训练获取新的训练样本作为当前训练样本。应当理解的是,无论是上轮训练样本还是当前训练样本,均包括多个对应有标签的样本,也即样本包括标签。相应地,在当前训练过程中,该第二设备需要基于当前训练样本重新对该第二设备对应的第一模型进行训练。在重新训练之前,该第二设备执行401以获得数据分布信息。其中,该数据分布信息用于第一设备获得联邦学习策略,以便于该第二设备能够在当前训练过程中根据联邦学习策略进行重新训练。
示例性地,数据分布信息包括第一增益信息和标签类型信息中的至少一种。以下对第一增益信息和标签类型信息分别进行说明。
第一增益信息:第二设备发送的第一增益信息用于指示通过上轮训练获得的第一模型为了适应第二设备的当前训练样本所需的修正程度。
该第二设备为参与联邦学习的任一第二设备,示例性地,上轮训练获得的第一模型包括该第二设备的第一模型,第一增益信息包括该第二设备的第一模型对应的增益信息,该第二设备的第一模型对应的增益信息用于指示该第二设备的第一模型为了适应该第二设备的当前训练样本所需的修正程度;
或者,上轮训练获得的第一模型包括该第二设备的第一模型及参与联邦学习的其他第二设备的第一模型,第一增益信息包括该第二设备的第一模型对应的增益信息以及其他第二设备的第一模型对应的增益信息,其他第二设备的第一模型对应的增益信息用于指示其他第二设备的第一模型为了适应该第二设备的当前训练样本所需的修正程度。
其中,第一增益信息是在第一模型上运行当前训练样本所得到的运行结果。在实际应用中,以第二设备的第一模型对应的增益信息的计算过程为例:将当前训练样本所包括的多个样本分别输入第二设备的第一模型,得到多个输出结果。根据第一模型对应的损失函数以及多个输出结果计算损失函数的函数值,基于该函数值确定第二设备的第一模型所包括的各个模型参数的增益信息,将各个模型参数的增益信息确定为该第二设备的第一模型对应的增益信息。其他第二设备的第一模型对应的增益信息的获取方式可参考上述第二设备的第一模型对应的增益信息的计算方式,此处不再赘述。
示例性地,无论是第二设备的第一模型,还是其他第二设备的第一模型,基于第一模型为神经网络模型,则上述第一增益信息为梯度信息,且本实施例能够在根据损失函数的函数值确定第一增益信息时采用误差反向传播算法。或者,基于第一模型为决策树模型,则上述第一增益信息为分裂信息。其中,决策树模型包括多个节点,除底层节点以外的各个节点分别对应有决策条件以及两个分支,各个分支中分别包括至少一个样本。例如,决策树模型中的一个节点的决策条件为0.8,则当前训练样本包括的各个样本中小于0.8的样本属于该节点对应的其中一个分支,不小于0.8的样本属于该节点对应的另一个分支。相应地,上述分裂信息是指:各个节点对应的决策条件以及各个节点对应的分支所包括的样本的数量。
需要说明的是,对于第二设备所使用的第一模型包括上轮训练过程中其他第二设备的第一模型的情况,本实施例所提供的方法还包括:对于任一第二设备,第一设备向该多个第二设备中除任一第二设备以外的其他第二设备发送任一第二设备的第一模型。相应地,第二设备接收第一设备发送的参与联邦学习的其他第二设备的第一模型。
以参与联邦学习的第二设备包括A设备、B设备以及C设备为例,则:第一设备向A设备发送B设备的第一模型以及C设备的第一模型,第一设备向B设备发送A设备的第一模型以及C设备的第一模型,第一设备向C设备发送A设备的第一模型以及B设备的第一模型。
示例性地,对于第一设备存储有各个第二设备对应的第一模型的情况,则第一设备可直接根据各个第二设备的需求进行第一模型的发送。或者,对于第一设备不存储有各个第二设备对应的第一模型的情况,则各个第二设备分别向第一设备上传各自的第一模型,再由第一设备根据各个第二设备的需求进行第一模型的发送。其中,出于安全性的考虑,第一设备在将一个第二设备对应的第一模型发送给另一个第二设备之前,首先向待发送的第一模型对应的第二设备申请权限,在获得授权之后再进行第一模型的发送。例如,第一设备要向A设备发送B设备的第一模型,则第一设备向B设备申请B设备的第一模型的下发权限,在得到B设备的授权之后,再向A设备发送B设备的第一模型。
应当理解的是,各个第二设备的第一模型可能相同,也可能不同。基于各个第二设备的第一模型相同,则第一设备向各个第二设备分别发送其他第二设备的第一模型显然会造成资源的浪费。因此。本实施例在不同第二设备的第一模型不同的情况下,再由第一设备进行第一模型的发送。
标签类型信息:标签类型信息用于指示当前训练样本的标签对应的类型。其中,当前训练样本所包括的多个样本均具有标签,当前训练样本的标签即为当前训练样本包括的样本的标签。当前训练样本的标签对应的类型是指当前训练样本中各个样本的标签是何种类型。示例性地,标签类型信息用于指示当前训练样本的标签对应A、B、C三种类型,也即当前训练样本的标签包括A、B、C三种类型的标签,则指示第二设备的当前训练样本所包括的样本具有A、B、C三种类型的标签,而各种类型的标签的数量则不进行限定。
其中,以当前训练样本的标签用于指示识别结果是否为异常为例,该当前训练样本的标签对应的类型包括两种,一种类型的标签指示识别结果为异常,另一种类型的标签指示识别结果为非异常。
402,第二设备向第一设备发送数据分布信息。
在各个第二设备分别获得数据分布信息之后,各个第二设备分别将数据分布信息发送给第一设备,以便于第一设备基于第二设备发送的数据分布信息选择匹配的联邦学习策略。
403,第一设备接收参与联邦学习的多个第二设备发送的数据分布信息。
由于参与联邦学习的各个第二设备均向第一设备发送了数据分布信息,因而第一设备能够接收到参与联邦学习的多个第二设备发送的数据分布信息。
404,第一设备根据多个第二设备发送的数据分布信息选择匹配的联邦学习策略。
在示例性实施例中,第一设备根据多个第二设备发送的数据分布信息选择匹配的联邦学习策略,包括:第一设备根据数据分布之间的差异选择匹配的联邦学习策略,该数据分布之间的差异基于多个第二设备发送的数据分布信息确定。根据401中的说明可知,数据分布信息包括第一增益信息和标签类型信息中的至少一种。在数据分布信息所包括的信息不同的情况下,选择联邦学习策略的方式也不同,以下对选择过程中涉及的各种方式分别进行说明。
方式A1,数据分布信息包括增益信息以及标签类型信息。相应地,第一设备根据数据分布之间的差异选择匹配的联邦学习策略之前,还包括:第一设备根据多个第二设备的第一增益信息确定特征分布信息,特征分布信息用于指示不同第二设备的当前训练样本的特征分布是否相同;第一设备根据特征分布信息以及多个第二设备的标签类型信息确定数据分布之间的差异。根据401中的说明可知,对于任一第二设备而言,该第二设备获得第一增益信息的过程中所使用的第一模型可能是该第二设备自身的第一模型,也可能还包括其他第二设备的第一模型。
在第一增益信息包括第二设备的第一模型对应的增益信息的情况中,若两个第二设备的第一增益信息之间的距离小于阈值,则说明这两个第二设备的当前训练样本的特征分布相同。例如,设备A在设备A的第一模型A上运行得到的第一增益信息为d1A,设备B在设备B的第一模型B上运行得到的第一增益信息为d2B。若d1A和d2B之间的距离(d1A,d2B)小于阈值,则说明设备A和设备B的当前训练样本的特征分布相同。
在第一增益信息包括第二设备的第一模型对应的增益信息以及其他第二设备的第一模型对应的增益信息的情况中,若两个第二设备在对方对应的第一模型上运行得到的第一增益信息之间的距离小于阈值,则说明这两个第二设备的当前训练样本的特征分布相同。例如,设备A在设备B的第一模型B上运行得到的第一增益信息为d2A,设备B在设备A的第一模型A上运行得到的第一增益信息为d1B。若d2A和d1B之间的距离(d2A,d1B)小于阈值,则说明设备A和设备B的当前训练样本的特征分布相同。
应当理解的是,在第二设备为三个以上的情况下,对于当前训练样本的特征分布相同的两个第二设备,不仅需要在对方的第一模型上运行得到的第一增益信息之间的距离小于阈值,还需要在除对方以外的其他相同的第一模型上运行得到的第一增益信息之间的距离小于阈值。例如,参与联邦学习的第二设备还包括设备C,设备A在设备C的第一模型C上运行得到的第一增益信息为d3A,设备B在设备C的第一模型上运行得到的第一增益信息为d3B。则在上述(d2A,d1B)以及和之间的距离(d3A,d3B)均小于阈值的情况下,认为设备A和设备B的当前训练样本的特征分布相同。
若两个第二设备在相同的第二设备的第一模型上运行得到的第一增益信息之间的距离小于阈值,则说明这两个第二设备的当前训练样本的特征分布相同。例如,设备A的第一模型为A,设备B的第一模型为B。设备A在第一模型A和第一模型B上运行得到的第一增益信息分别为d1A和d2A,设备B在第一模型A和第一模型B上运行得到的第一增益信息分别为d1B和d2B。若设备A和设备B在相同的第一模型A上运行得到的第一增益信息d1A和d1B之间的距离 (d1A,d1B)小于阈值,且设备A和设备B在相同的第一模型B上运行得到的第一增益信息d2A和d2B之间的距离(d2A,d2B)小于阈值,则说明设备A和设备B的当前训练样本的特征分布相同。
需要说明的是,确定特征分布是否相同的过程在不同第二设备之间是具有传递性的。例如,根据上述说明中的方式确定设备A和设备B的当前训练样本的特征分布相同,并确定设备B和设备C的当前训练样本的特征分布相同,则说明设备A、设备B以及设备C三者的当前训练样本的特征分布均相同。在参与联邦学习的第二设备的数量较多的情况下,所有第二设备的当前训练样本的特征分布均相同的概率往往较小。不过,所有第二设备中能够包括至少一组具有相同特征部分的当前训练样本的第二设备。例如,参与联邦学习的第二设备的数量为十个,则可能设备1-5的当前训练样本的特征分布相同,设备6-10的当前训练样本的特征分布相同,而设备1-5与设备6-10的当前训练样本的特征分布则不同。
上述确定特征分布的过程中,均需要确定不同第一增益信息之间的距离。根据401中对第一增益信息的说明可知,第一增益信息中包括有第一模型中各个模型参数的增益信息。示例性地,对于两个第二设备的第一增益信息,首先获得第一增益信息中相对应的模型参数的增益信息之间的子距离,得到多个子距离。之后,对多个子距离进行加权求和,将所得到的加权求和值确定为这两个第二设备的第一增益信息之间的距离。
在第一增益信息为梯度信息、第一模型为神经网络模型的情况下,第一模型包括卷积层、采样层以及全连接层等等。示例性地,同一类型层的模型参数相对应。例如,设备A和设备B的第一增益信息中属于卷积层的模型参数是相对应的模型参数,属于采样层的模型参数是相对应的模型参数。另外,不同类型层根据实际需要对应相同或不同的权重。示例性地,对于任一类型层,通过该类型层的模型参数的增益信息计算得到的子距离的权重等于该任一类型层对应的权重。
在第一增益信息为分裂信息、第一模型为决策树模型的情况下,决策树模型中的节点包括根节点以及多个叶子节点,叶子节点位于不同层级。其中,根节点或者同一层级的叶子节点相对应。根节点以及各个叶子节点对应的权重相同或不同,示例性地,本实施例中根节点对应的权重最大,越底层的叶子节点对应的权重越小。
在确定特征分布信息后,第一设备根据数据分布之间的差异选择匹配的联邦学习策略,示例性地,本实施例按照图5所示的流程选择联邦学习策略,选择过程包括但不限于如下四种情况。
情况一,基于特征分布信息指示不同第二设备的当前训练样本的特征分布相同,且不同第二设备的标签类型信息相同,则选择匹配的联邦学习策略为模型平均融合,模型平均融合用于以增益信息平均的方式进行联邦学习。其中,增益信息是第二设备根据该模型平均融合对应的参数上报策略上报至第一设备的第二增益信息,该第二增益信息可参见后文情况B1中的说明。也就是说,第一设备用于在接收到第二设备上传的第二增益信息之后,基于该模型平均融合的联邦学习策略计算接收到的第二增益信息的平均值。
情况二,基于特征分布信息指示不同第二设备的当前训练样本的特征分布不同,且不同第二设备的标签类型信息相同,则选择匹配的联邦学习策略为模型差异化更新,模型差异化更新用于以增益信息差异化处理的方式进行联邦学习。其中,增益信息可参见上文情况一中的说明。第一设备用于在接收到第二设备上传的增益信息之后,基于该模型差异化更新的联 邦学习策略对增益信息进行差异化处理,差异化处理的过程可参见后文情况C2中的说明。
情况三,基于特征分布信息指示不同第二设备的当前训练样本的特征分布相同,且不同第二设备的标签类型信息不同,则选择匹配的联邦学习策略为模型部分更新,模型部分更新用于以部分增益信息平均的方式进行联邦学习。其中,部分增益信息是第二设备根据模型部分更新对应的参数上报策略上报至第一设备的第二增益信息,该第二增益信息可参见后文情况B3中的说明。第一设备用于在接收到该第二增益信息之后,基于模型部分更新的联邦学习策略对接收到的部分增益信息进行平均计算。
情况四,基于特征分布信息指示不同第二设备的当前训练样本的特征分布不同,且不同第二设备的标签类型信息不同,则选择匹配的联邦学习策略为模型部分差异化更新,模型部分差异化更新用于以部分增益信息差异化处理的方式进行联邦学习。部分增益信息可参见情况三中的说明,差异化处理的过程可参见后文情况C4中的说明,此处不再进行赘述。
其中,所选择的联邦学习策略用于第一设备向第二设备下发对应的参数上报策略,若选择的联邦学习策略不同,则第一设备向第二设备发送的参数上报策略也有所不同,详见后文406中的说明。应当理解的是,图5示出的四种联邦学习策略仅为举例,并不用于对联邦学习策略进行限制。
另外,根据图5可知,基于不同第二设备的标签类型信息不同,则本实施例在确定不同第二设备的当前训练样本的特征分布是否相同之前,先根据实际需求或者经验确定不同第二设备的当前训练样本的标签之间是否需要联合。如果不需要联合,则进一步确定不同第二设备的当前训练样本的特征分布是否相同。如果需要联合,则直接选择匹配的联邦学习策略为模型差异化更新。
方式A2:数据分布信息包括第一增益信息。相应地,第一设备根据数据分布之间的差异选择匹配的联邦学习策略之前,还包括:第一设备根据多个第二设备的第一增益信息确定特征分布信息,特征分布信息用于指示不同第二设备的当前训练样本的特征分布是否相同;第一设备根据特征分布信息确定数据分布之间的差异。第一设备根据数据分布之间的差异选择匹配的联邦学习策略,包括但不限于如下两种情况。
情况一,基于特征分布信息指示不同第二设备的当前训练样本的特征分布相同,则选择匹配的联邦学习策略为模型平均融合。
情况二,基于特征分布信息指示不同第二设备的当前训练样本的特征分布不同,则选择匹配的联邦学习策略为模型差异化更新。
第一设备确定特征分布信息的过程参见上文方式A1中的说明,此处不再进行赘述。在数据分布信息仅包括第一增益信息而不包括标签类型信息的情况下,本实施例等同默认不同第二设备之间的标签类型信息相同。从而,在不同第二设备的当前训练样本的特征分布相同的情况下,基于图5选择匹配的联邦学习策略为模型平均融合。相应地,在特征分布信息指示不同第二设备的当前训练样本的特征分布不同的情况下,则基于图5选择匹配的联邦学习策略为模型差异化更新。
方式A3,数据分布信息包括标签类型信息。相应地,任一第二设备发送的数据分布信息包括标签类型信息,第一设备根据数据分布之间的差异选择匹配的联邦学习策略之前,还包括:基于标签类型信息确定数据分布之间的差异。
在数据分布信息仅包括标签类型信息而不包括第一增益信息的情况下,本实施例默认不 同第二设备之间的第一增益信息相同。因而,在不同第二设备的标签类型信息相同的情况下,基于图5选择匹配的联邦学习策略为模型平均融合。相应地,在不同第二设备的标签类型信息不同的情况下,基于图5选择匹配的联邦学习策略为模型部分更新。
405,第一设备向多个第二设备中的至少一个第二设备发送联邦学习策略对应的参数上报策略。
在第一设备选择得到联邦学习策略之后,根据确定的联邦学习策略确定各个第二设备对应的参数上报策略,将各个第二设备对应的联邦学习策略对应的参数上报策略分别发送给各个第二设备,以使第二设备能够根据对应的参数上报策略以及当前训练样本获得第二增益信息。
在示例性实施例中,各个第二设备除了向第一设备发送数据分布信息以外,还向第一设备发送训练样本特征信息,训练样本特征信息用于表征标签分布或样本数量;训练样本特征信息用于第一设备确定超参数。相应地,第一设备向多个第二设备发送联邦学习策略对应的参数上报策略,还包括:对于上述发送参数上报策略的至少一个第二设备中的任一第二设备,第一设备根据该任一第二设备发送的训练样本特征信息确定超参数,向任一第二设备发送超参数,超参数用于该任一第二设备获取第二增益信息。其中,第二设备应用该超参数的过程参见后文406,此处暂不赘述。
示例性地,训练样本特征信息包括标签分布信息或样本数量;标签分布信息包括标签占比信息和每种类型的标签数量中的至少一种,标签占比信息用于指示各种类型的标签在当前训练样本的标签中的占比;样本数量信息用于指示当前训练样本中包括的样本的条数。例如,当前训练样本共包括100条具有标签的数据,则样本数量即为100。而标签占比信息则用于指示各种类型的标签在当前训练样本的标签中所占的百分比。例如,在100条样本中,具有A标签的样本为30条,具有B标签的样本为50条,具有C标签的样本为20条。则A标签的标签数量为30,B标签的标签数量为50,C标签的标签数量为20,A标签的标签占比为30%,B标签的标签占比为50%,C标签的标签占比为20%。
在第一设备获得训练样本特征信息之后,进一步对超参数进行确定。其中,在训练样本特征信息包括标签分布信息,该标签分布信息包括标签占比信息的情况下,第一设备确定任一第二设备的当前训练样本中各种类型的标签对应的超参数,向该第二设备发送确定出的各个超参数。对于任一种类型的标签而言,该标签的标签占比信息越大,则该标签对应的超参数越小。例如,当前训练样本的标签包括占比80%的A标签以及占比20%的B标签,则A标签对应的超参数小于B标签对应的超参数。
或者,在训练样本特征信息包括样本数量的情况下,第一设备根据不同第二设备对应的样本数量为各个第二设备分别确定超参数。任一第二设备对应的样本数量越大,则该第二设备的超参数越小。例如,设备A的样本数量为100条,设备B的样本数量为10000条,则设备A的超参数大于设备B的超参数。另外,在标签分布信息既包括标签占比信息又包括每种类型的标签数量的情况下,参见标签占比信息情况的说明,此处不再进行赘述。
若不采用上述确定超参数的方式,则在后续的模型训练过程中,相比基于体量较大(标签占比信息较大、数据量信息较大)的样本所得到的训练结果,基于体量较小(标签占比信息较小、数据量信息较小)的样本所得到的训练结果会被当作噪声消除,则体量较小的样本难以在后续的模型训练过程中产生贡献。而本实施例通过采用为体量较小的样本配置较大的 超参数,使得各个第二设备的当前训练样本中不同体量的样本均能够对后续的模型训练过程产生贡献。由此,保证了通过联邦学习过程训练得到的模型的性能较好。
406,第二设备接收第一设备发送的联邦学习策略对应的参数上报策略,基于接收到的参数上报策略以及当前训练样本获得第二增益信息,第二增益信息用于获得第二设备的第二模型。
根据401中的说明可知,401的执行时间在上轮训练过程与当前训练过程之间,而406即为当前训练过程。换言之,在第二设备接收第一设备发送的联邦学习策略之后,便基于该联邦学习策略正式开始进行训练。在当前训练过程中,对于任一第二设备而言,该第二设备基于接收到的联邦学习策略对应的参数上报策略以及该第二设备的当前训练样本,获得第二增益信息,该第二增益信息中包括至少一个模型参数的增益信息。
404中举例说明了四种不同的联邦学习策略。联邦学习策略不同,则第二设备获得第二增益信息的过程也不同,以下通过情况B1-B4对四种获得第二增益信息的情况分别进行说明。
情况B1,联邦学习策略为模型平均融合。此种情况下,第二设备接收第一设备发送的对应模型平均融合对应的参数上报策略,第二设备基于该参数上报策略以及当前训练样本获得第二增益信息。例如,针对模型平均融合的联邦学习策略,第二设备需要上报所有模型参数的增益信息,因而第一设备向第二设备下发用于获取所有模型参数的增益信息的参数上报策略。
情况B2,联邦学习策略为模型差异化更新。此种情况下第一设备下发的参数上报策略与情况B1相同,则第二设备获得第二增益信息的过程与情况B1中的相同,不再进行赘述。
情况B3,联邦学习策略为模型部分更新。在情况B3中,第一设备向第二设备发送的与联邦学习策略对应的参数上报策略用于指示第二设备上报部分模型参数的增益信息。则第二设备获得的第二增益信息可仅包括部分模型参数的增益信息。以神经网络模型为例,神经网络模型中的卷积层、采样层等属于特征提取层,全连接层属于分类层。第二设备可通过当前训练样本仅对特征提取层进行训练,而不对分类层进行训练。另外,第二设备也可按照情况B1中说明的方式进行训练,得到所有模型参数的增益信息,再从所有模型参数的增益信息中选择部分模型参数的增益信息作为第二增益信息。
情况B4,联邦学习策略为模型部分差异化更新。此种情况下第一设备下发的参数上报策略与情况B3相同,则第二设备获得第二增益信息的过程与情况B3中的相同,不再进行赘述。
根据401中对第一增益信息的计算过程的说明可知,第二设备将当前训练样本的各个样本分别输入第二设备的第一模型之后,会得到各个样本对应的输出结果。在第二设备除了联邦学习策略对应的参数上报策略还接收到第一设备发送的超参数的情况下,基于接收到的参数上报策略以及该第二设备的当前训练样本获得第二增益信息,包括:基于接收到的参数上报策略、当前训练样本以及超参数获得第二增益信息。其中,针对超参数的确定方式不同,第二设备获取第二增益信息的方式不同,例如,包括但不限于如下两种情况。
情况一,该超参数是第一设备基于标签分布信息所确定的情况下,第二设备基于超参数确定各个样本对应的权重,从而对各个样本对应的输出结果进行加权求和,得到加权求和值。接着,根据损失函数以及该加权求和值计算损失函数的函数值,从而得到第二增益信息。
示例性地,第二设备基于超参数确定各个样本对应的权重,包括:对于任一个样本,确定该样本对应的标签,将该标签对应的超参数作为该样本的权重。例如,第二设备的当前训 练样本的标签包括占比80%的A标签以及占比20%的B标签,A标签的超参数M小于B标签的超参数N。若样本的标签为A标签,则该样本对应的权重等于A标签的超参数M。
情况二,在超参数是第一设备基于样本数量确定的情况下,由于不同的第二设备的超参数随着样本数量的不同而不同,因而第二设备在计算得到至少一个模型参数的增益信息之后,基于该超参数对至少一个模型参数的增益信息进行更新,例如进行乘积等计算,将更新结果作为第二增益信息。
在示例性实施例中,参见图6,在第二设备得到第二增益信息之后,本实施例所提供的方法还包括如下的过程。
407,第二设备向第一设备发送第二增益信息。
示例性地,参与联邦学习的各个第二设备均将获得的第二增益信息上报给第一设备。
408,第一设备接收多个第二设备发送的第二增益信息,基于联邦学习策略对第二增益信息进行联邦融合,得到各个第二设备对应的第三增益信息。
其中,在第一设备获得第二增益信息之后,基于联邦学习策略对第二增益信息进行联邦融合,得到各个第二设备对应的第三增益信息。联邦学习策略不同,则第一设备通过联邦融合得到各个第二设备对应的第三增益信息的方式也不同。以下通过情况C1-C4分别进行说明。
情况C1,联邦学习策略为模型平均融合。此种情况下,第一设备计算进行模型平均融合的各个第二设备发送的第二增益信息的平均值,得到进行模型平均融合的各个第二设备对应的第三增益信息。
情况C2,联邦学习策略为模型差异化更新。其中,第一设备对进行模型差异化更新的各个第二设备发送的第二增益信息进行加权求和,不同第二设备的权重相同或不同,从而得到进行模型差异化更新的各个第二设备对应的第三增益信息。或者,第一设备对进行模型差异化更新的各个第二设备发送的第二增益信息进行增量学习。在增量学习过程中,第一设备首先对一个第二设备发送的第二增益信息进行更新,得到第一更新结果。再根据另一个第二设备发送的第二增益信息对该第一更新结果进行更新,得到第二更新结果。以此类型,将最终得到的更新结果作为进行模型差异化更新的各个第二设备对应的第三增量信息。示例性地,本实施例采用的增量学习方式包括使用蒙德里安(Mondrian)树进行更新。
情况C3,联邦学习策略为模型部分更新。在情况C3中,由于第二设备发送的第二增益信息是所有模型参数中部分模型参数的增益信息,因而第一设备可直接对进行模型部分更新的第二设备上报的第二增益信息所包括的部分模型参数的增益信息计算平均值。其中,情况C1中第一设备相当于对进行模型平均融合的各个第二设备的第二模型整体进行了联邦,而情况C3则是第一设备对进行模型部分更新的各个第二设备的第二模型中的一部分进行了联邦。
情况C4,联邦学习策略为模型部分差异化更新。在此种情况中,进行模型部分差异化更新的第二设备所发送的第二增益信息中包括所有模型参数中部分模型参数的增益信息。第一设备按照情况C2中说明的方式对部分模型参数的增益信息进行加权求和或者进行增量学习,从而得到进行模型部分差异化更新的第二设备对应的第三增益信息。
需要说明的是,第一设备基于联邦学习策略对第二增益信息进行联邦融合,得到各个第二设备对应的第三增益信息时,如果一个第二设备对应不用的联邦学习策略,则可以针对不同的联邦学习策略进行对应的第二增益信息进行联邦融合。例如,第二设备包括设备1、设备2和设备3。如果设备1与设备2比对确定联邦学习策略为模型平均融合,而设备1与设备3比对 之后确定联邦学习策略为模型部分差异化更新,则可先将设备1上报的第二增益信息与设备2上报的第二增益信息进行平均,再将平均值与设备3上报的第二增益信息进行差异化处理,得到的增益信息为设备1对应的第三增益信息。
409,第一设备向多个第二设备分别发送对应的第三增益信息。
其中,对于任一第二设备,第一设备直接将第三增益信息发送至对应的第二设备,或者第一设备基于第三增益信息以及对应的第二设备的第一模型获得第二模型后,将该第二模型发送给对应的第二设备。对于后一种情况,获取第二模型的过程由第一设备执行,第一设备直接获得各个第二设备的第二模型,再向各个第二设备分别发送该第二模型。
示例性地,第二模型与第一模型相比,可能仅有模型中的一部分发生了更新。此种情况下,第一设备仅将更新的模型部分发送给各个第二设备,或者将全部模型发送给各个第二设备。例如,第一模型与第二模型均为包括五个卷积层的神经网络模型,且第一模型与第二模型仅在第一个卷积层上存在不同。则第一设备将第二模型中的第一个卷积层发送给第二设备,或者将第二模型全部发送给第二设备。
410,第二设备接收第一设备发送的对应的第三增益信息,或者基于对应的第三增益信息以及第二设备的第一模型获得的第二模型。
针对第二设备接收对应的第三增益信息的情况,第二设备将对应的第三增益信息与第一模型的各个模型参数进行作和,从而得到第二模型。
综上所述,本申请实施例中参与联邦学习的各个第二设备分别将各自的数据分布信息发送给第一设备,从而使得第一设备能够根据各个数据分布信息判断不同第二设备的当前训练样本的分布情况,也就是掌握了不同第二设备的当前训练样本的非独立同分布程度。之后,第一设备根据非独立同分布程度进行联邦学习策略的选择,将选择的联邦学习策略对应的参数上报策略发送给各个第二设备,则各个第二设备分别根据联邦学习策略对应的参数上报策略进行模型的更新。因此,避免了不同第二设备之间的训练数据存在非独立同分布现象而对联邦学习过程造成干扰,使得各个第二设备通过联邦学习得到的模型具有较好的性能,例如准确度较高。
以上介绍了本申请实施例的联邦学习方法,与上述方法对应,本申请实施例还提供联邦学习装置。该装置用于通过图7所示的各个模块执行上述方法实施例中第一设备所执行的联邦学习方法。如图7所示,本申请实施例提供报文传输装置,包括如下几个模块。
接收模块701,用于第一设备接收参与联邦学习的多个第二设备发送的数据分布信息,任一第二设备发送的数据分布信息包括第一增益信息和标签类型信息中的至少一种,第一增益信息用于指示通过上轮训练获得的第一模型为了适应任一第二设备的当前训练样本所需的修正程度,标签类型信息用于指示当前训练样本的标签对应的类型。接收模块701所执行的步骤参见上文403及408中的说明。
选择模块702,用于第一设备根据多个第二设备发送的数据分布信息选择匹配的联邦学习策略。选择模块702所执行的步骤参见上文404中的说明。
发送模块703,用于第一设备向多个第二设备中的至少一个第二设备发送联邦学习策略对应的参数上报策略,至少一个第二设备中的任一第二设备用于上报基于接收到的参数上报策略以及当前训练样本获得的第二增益信息,第二增益信息用于获得任一第二设备的第二模 型。发送模块703所执行的步骤参见上文405及409中的说明。
在一种可能的实现方式中,选择模块702,用于第一设备根据数据分布之间的差异选择匹配的联邦学习策略,数据分布之间的差异基于多个第二设备发送的数据分布信息确定。
在一种可能的实现方式中,任一第二设备发送的数据分布信息包括第一增益信息和标签类型信息,装置还包括:
第一确定模块,用于第一设备根据多个第二设备的第一增益信息确定特征分布信息,特征分布信息用于指示不同第二设备的当前训练样本的特征分布是否相同;第一设备根据特征分布信息以及多个第二设备的标签类型信息确定数据分布之间的差异。
在一种可能的实现方式中,选择模块702,用于基于特征分布信息指示不同第二设备的当前训练样本的特征分布相同,且不同第二设备的标签类型信息相同,则选择匹配的联邦学习策略为模型平均融合,模型平均融合用于以增益信息平均的方式进行联邦学习。
在一种可能的实现方式中,选择模块702,用于基于特征分布信息指示不同第二设备的当前训练样本的特征分布不同,且不同第二设备的标签类型信息相同,则选择匹配的联邦学习策略为模型差异化更新,模型差异化更新用于以增益信息差异化处理的方式进行联邦学习。
在一种可能的实现方式中,选择模块702,用于基于特征分布信息指示不同第二设备的当前训练样本的特征分布相同,且不同第二设备的标签类型信息不同,则选择匹配的联邦学习策略为模型部分更新,模型部分更新用于以部分增益信息平均的方式进行联邦学习。
在一种可能的实现方式中,选择模块702,用于基于特征分布信息指示不同第二设备的当前训练样本的特征分布不同,且不同第二设备的标签类型信息不同,则选择匹配的联邦学习策略为模型部分差异化更新,模型部分差异化更新用于以部分增益信息差异化处理的方式进行联邦学习。
在一种可能的实现方式中,任一第二设备发送的数据分布信息包括第一增益信息,装置还包括:
第二确定模块,用于第一设备根据多个第二设备的第一增益信息确定特征分布信息,特征分布信息用于指示不同第二设备的当前训练样本的特征分布是否相同;第一设备根据特征分布信息确定数据分布之间的差异。
在一种可能的实现方式中,选择模块702,用于基于特征分布信息指示不同第二设备的当前训练样本的特征分布相同,则选择匹配的联邦学习策略为模型平均融合,模型平均融合用于以增益信息平均的方式进行联邦学习。
在一种可能的实现方式中,选择模块702,用于基于特征分布信息指示不同第二设备的当前训练样本的特征分布不同,则选择匹配的联邦学习策略为模型差异化更新,模型差异化更新用于以增益信息差异化处理的方式进行联邦学习。
在一种可能的实现方式中,装置还包括:第三确定模块,用于基于标签类型信息确定数据分布之间的差异。
在一种可能的实现方式中,选择模块702,用于基于不同第二设备的标签类型信息相同,则选择匹配的联邦学习策略为模型平均融合,模型平均融合用于以增益信息平均的方式进行联邦学习。
在一种可能的实现方式中,选择模块702,用于基于不同第二设备的标签类型信息不同,则选择匹配的联邦学习策略为模型部分更新,模型部分更新用于以部分增益信息平均的方式 进行联邦学习。
在一种可能的实现方式中,接收模块701,还用于第一设备接收多个第二设备发送的第二增益信息;
装置还包括:融合模块,用于第一设备基于联邦学习策略对第二增益信息进行联邦融合,得到各个第二设备对应的第三增益信息;
发送模块703,还用于第一设备向至少一个第二设备中的任一第二设备发送对应的第三增益信息,或者基于对应的第三增益信息以及任一第二设备的第一模型获得的第二模型。
在一种可能的实现方式中,接收模块701,还用于第一设备接收多个第二设备发送的训练样本特征信息,训练样本特征信息用于表征标签分布或样本数量;
发送模块703,还用于对于至少一个第二设备中的任一第二设备,第一设备向任一第二设备发送超参数,超参数基于任一第二设备发送的训练样本特征信息确定,超参数用于任一第二设备获取第二增益信息。
在一种可能的实现方式中,训练样本特征信息包括标签分布信息或样本数量;标签分布信息包括标签占比信息和每种类型的标签数量中的至少一种,标签占比信息用于指示各种类型的标签在当前训练样本的标签中的占比;样本数量信息用于指示当前训练样本中包括的样本的条数。
在一种可能的实现方式中,上轮训练获得的第一模型包括任一第二设备的第一模型,第一增益信息包括任一第二设备的第一模型对应的增益信息,任一第二设备的第一模型对应的增益信息用于指示任一第二设备的第一模型为了适应任一第二设备的当前训练样本所需的修正程度;
或者,上轮训练获得的第一模型包括任一第二设备的第一模型及参与联邦学习的其他第二设备的第一模型,第一增益信息包括任一第二设备的第一模型对应的增益信息以及其他第二设备的第一模型对应的增益信息,其他第二设备的第一模型对应的增益信息用于指示其他第二设备的第一模型为了适应任一第二设备的当前训练样本所需的修正程度。
在一种可能的实现方式中,第一设备接收参与联邦学习的多个第二设备发送的数据分布信息之前,发送模块703,还用于第一设备向任一第二设备发送其他第二设备的第一模型。
本申请实施例还提供了另一种联邦学习装置,该装置用于通过图8所示的各个模块执行上述方法实施例中第一设备所执行的联邦学习方法。如图8所示,本申请实施例提供报文传输装置,包括如下几个模块。
获得模块801,用于第二设备获得数据分布信息,数据分布信息包括第一增益信息和标签类型信息中的至少一种,第一增益信息用于指示通过上轮训练获得的第一模型为了适应第二设备的当前训练样本所需的修正程度,标签类型信息用于指示当前训练样本的标签对应的类型。获得模块801所执行的步骤参见上文401中的说明。
发送模块802,用于第二设备向第一设备发送数据分布信息,数据分布信息用于第一设备选择匹配的联邦学习策略。发送模块802执行的步骤参见上文402及407中的说明。
接收模块803,用于第二设备接收第一设备发送的联邦学习策略对应的参数上报策略,基于接收到的参数上报策略以及当前训练样本获得第二增益信息,第二增益信息用于获得第二设备的第二模型。接收模块803所执行的步骤参见上文406及410中的说明。
在一种可能的实现方式中,发送模块802,还用于第二设备向第一设备发送第二增益信 息;
接收模块803,还用于第二设备接收第一设备基于第二增益信息发送的对应的第三增益信息,第二设备基于第三增益信息以及第二设备的第一模型获得第二模型,或者,第二设备接收第一设备发送的基于对应的第三增益信息以及第二设备的第一模型获得的第二模型。
在一种可能的实现方式中,发送模块802,还用于第二设备向第一设备发送训练样本特征信息,训练样本特征信息用于第一设备确定超参数;
接收模块803,还用于第二设备接收第一设备发送的超参数,基于接收到的参数上报策略、当前训练样本以及超参数获得第二增益信息。
在一种可能的实现方式中,训练样本特征信息包括标签分布信息或样本数量;标签分布信息包括标签占比信息和每种类型的标签数量中的至少一种,标签占比信息用于指示各种类型的标签在当前训练样本的标签中的占比;样本数量信息用于指示当前训练样本中包括的样本的条数。
在一种可能的实现方式中,上轮训练获得的第一模型包括第二设备的第一模型,第一增益信息包括第二设备的第一模型对应的增益信息,第二设备的第一模型对应的增益信息用于指示第二设备的第一模型为了适应第二设备的当前训练样本所需的修正程度;
或者,上轮训练获得的第一模型包括第二设备的第一模型及参与联邦学习的其他第二设备的第一模型,第一增益信息包括第二设备的第一模型对应的增益信息以及其他第二设备的第一模型对应的增益信息,其他第二设备的第一模型对应的增益信息用于指示其他第二设备的第一模型为了适应第二设备的当前训练样本所需的修正程度。
在一种可能的实现方式中,接收模块803,还用于第二设备接收第一设备发送的其他第二设备的第一模型。
综上所述,本申请实施例中参与联邦学习的各个第二设备分别将各自的数据分布信息发送给第一设备,从而使得第一设备能够根据各个数据分布信息判断不同第二设备的当前训练样本的分布情况,也就是掌握了不同第二设备的当前训练样本的非独立同分布程度。之后,第一设备根据非独立同分布程度进行联邦学习策略的选择,将选择的联邦学习策略发送给各个第二设备,则各个第二设备分别根据联邦学习策略进行模型的更新。因此,避免了不同第二设备之间的训练数据存在非独立同分布现象而对联邦学习过程造成干扰,使得各个第二设备通过联邦学习得到的模型具有较好的性能,例如准确度较高。
应理解的是,上述图7以及图8的报文传输装置在实现其功能时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将设备的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的装置与方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。
参见图9,图9示出了本申请一个示例性实施例提供的通信设备900的结构示意图。图9所示的通信设备900用于执行上述图4或者图6所示的联邦学习方法所涉及的操作。该通信设备900例如是交换机、路由器、控制器等,该通信设备900可以由一般性的总线体系结构来实现。
如图9所示,通信设备900包括至少一个处理器901、存储器903以及至少一个通信接 口904。
处理器901例如是通用中央处理器(central processing unit,CPU)、数字信号处理器(digital signal processor,DSP)、网络处理器(network processer,NP)、图形处理器(Graphics Processing Unit,GPU)、神经网络处理器(neural-network processing units,NPU)、数据处理单元(Data Processing Unit,DPU)、微处理器或者一个或多个用于实现本申请方案的集成电路。例如,处理器901包括专用集成电路(application-specific integrated circuit,ASIC),可编程逻辑器件(programmable logic device,PLD)或者其他可编程逻辑器件、晶体管逻辑器件、硬件部件或者其任意组合。PLD例如是复杂可编程逻辑器件(complex programmable logic device,CPLD)、现场可编程逻辑门阵列(field-programmable gate array,FPGA)、通用阵列逻辑(generic array logic,GAL)或其任意组合。其可以实现或执行结合本发明实施例公开内容所描述的各种逻辑方框、模块和电路。处理器也可以是实现计算功能的组合,例如包括一个或多个微处理器组合,DSP和微处理器的组合等等。
可选的,通信设备900还包括总线。总线用于在通信设备900的各组件之间传送信息。总线可以是外设部件互连标准(peripheral component interconnect,简称PCI)总线或扩展工业标准结构(extended industry standard architecture,简称EISA)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,图9中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
存储器903例如是只读存储器(read-only memory,ROM)或可存储静态信息和指令的其它类型的静态存储设备,又如是随机存取存储器(random access memory,RAM)或者可存储信息和指令的其它类型的动态存储设备,又如是电可擦可编程只读存储器(electrically erasable programmable read-only Memory,EEPROM)、只读光盘(compact disc read-only memory,CD-ROM)或其它光盘存储、光碟存储(包括压缩光碟、激光碟、光碟、数字通用光碟、蓝光光碟等)、磁盘存储介质或者其它磁存储设备,或者是能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其它介质,但不限于此。存储器903例如是独立存在,并通过总线与处理器901相连接。存储器903也可以和处理器901集成在一起。
通信接口904使用任何收发器一类的装置,用于与其它设备或通信网络通信,通信网络可以为以太网、无线接入网(radio access network,RAN)或无线局域网(wireless local area networks,WLAN)等。通信接口904可以包括有线通信接口,还可以包括无线通信接口。具体的,通信接口904可以为以太(Ethernet)接口、快速以太(Fast Ethernet,FE)接口、千兆以太(Gigabit Ethernet,GE)接口,异步传输模式(Asynchronous Transfer Mode,ATM)接口,无线局域网(wireless local area networks,WLAN)接口,蜂窝网络通信接口或其组合。以太网接口可以是光接口,电接口或其组合。在本申请实施例中,通信接口904可以用于通信设备900与其他设备进行通信。
在具体实现中,作为一种实施例,处理器901可以包括一个或多个CPU,如图9中所示的CPU0和CPU1。这些处理器中的每一个可以是一个单核(single-CPU)处理器,也可以是一个多核(multi-CPU)处理器。这里的处理器可以指一个或多个设备、电路、和/或用于处理数据(例如计算机程序指令)的处理核。
在具体实现中,作为一种实施例,通信设备900可以包括多个处理器,如图9中所示的 处理器901和处理器905。这些处理器中的每一个可以是一个单核处理器(single-CPU),也可以是一个多核处理器(multi-CPU)。这里的处理器可以指一个或多个设备、电路、和/或用于处理数据(如计算机程序指令)的处理核。
在具体实现中,作为一种实施例,通信设备900还可以包括输出设备和输入设备。输出设备和处理器901通信,可以以多种方式来显示信息。例如,输出设备可以是液晶显示器(liquid crystal display,LCD)、发光二级管(light emitting diode,LED)显示设备、阴极射线管(cathode ray tube,CRT)显示设备或投影仪(projector)等。输入设备和处理器901通信,可以以多种方式接收用户的输入。例如,输入设备可以是鼠标、键盘、触摸屏设备或传感设备等。
在一些实施例中,存储器903用于存储执行本申请方案的程序代码910,处理器901可以执行存储器903中存储的程序代码910。也即是,通信设备900可以通过处理器901以及存储器903中的程序代码910,来实现方法实施例提供的联邦学习方法。程序代码910中可以包括一个或多个软件模块。可选地,处理器901自身也可以存储执行本申请方案的程序代码或指令。
在具体实施例中,本申请实施例的通信设备900可对应于上述方法实施例中的第一设备或者第二设备,通信设备900中的处理器901读取存储器903中的指令,使图9所示的通信设备900能够执行方法实施例中第一设备或者第二设备所执行的全部或部分操作。
通信设备900还可以对应于上述图7所示的装置,图7所示的装置中的每个功能模块采用通信设备900的软件实现。换句话说,图7所示的装置包括的功能模块为通信设备900的处理器901读取存储器903中存储的程序代码910后生成的。
通信设备900还可以对应于上述图8所示的装置,图8所示的装置中的每个功能模块采用通信设备900的软件实现。换句话说,图8所示的装置包括的功能模块为通信设备900的处理器901读取存储器903中存储的程序代码910后生成的。
其中,图4以及图6所示的联邦学习方法的各步骤通过通信设备900的处理器中的硬件的集成逻辑电路或者软件形式的指令完成。结合本申请实施例所公开的方法的步骤可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器,处理器读取存储器中的信息,结合其硬件完成上述方法的步骤,为避免重复,这里不再详细描述。
在一些可能的实施例中,上述通信设备可以实现为虚拟化设备。
例如,虚拟化设备可以是运行有用于发送报文功能的程序的虚拟机(英文:Virtual Machine,VM),虚拟机部署在硬件设备上(例如,物理服务器)。虚拟机指通过软件模拟的具有完整硬件系统功能的、运行在一个完全隔离环境中的完整计算机系统。可以将虚拟机配置为第一通信设备或第二通信设备。例如,可以基于通用的物理服务器结合网络功能虚拟化(Network Functions Virtualization,NFV)技术来实现通信设备。通信设备为虚拟主机、虚拟路由器或虚拟交换机。本领域技术人员通过阅读本申请即可结合NFV技术在通用物理服务器上虚拟出具有上述功能的通信设备。此处不再赘述。
例如,虚拟化设备可以是容器,容器是一种用于提供隔离的虚拟化环境的实体,例如,容器可以是docker容器。可以将容器配置为通信设备。例如,可以通过对应的镜像来创建出 通信设备,例如可以通过proxy-container(提供代理服务的容器)的镜像,为proxy-container创建2个容器实例,分别是容器实例proxy-container1、容器实例proxy-container2,将容器实例proxy-container1提供为上述方法实施例中的第一设备,将容器实例proxy-container2提供为上述方法实施例中的第二设备。采用容器技术实现时,通信设备可以利用物理机的内核运行,多个通信设备可以共享物理机的操作系统。通过容器技术可以将不同的通信设备隔离开来。容器化的通信设备可以在虚拟化的环境中运行,例如可以在虚拟机中运行,容器化的通信设备可也可以直接在物理机中运行。
例如,虚拟化设备可以是Pod,Pod是Kubernetes(Kubernetes是谷歌开源的一种容器编排引擎,英文简称为K10s)为部署、管理、编排容器化应用的基本单位。Pod可以包括一个或多个容器。同一个Pod中的每个容器通常部署在同一主机上,因此同一个Pod中的每个容器可以通过该主机进行通信,并且可以共享该主机的存储资源和网络资源。可以将Pod配置为通信设备。例如,具体地,可以指令容器即服务(英文全称:container as a service,英文简称:CaaS,是一种基于容器的PaaS服务)来创建Pod,将Pod提供为通信设备。
当然,通信设备还可以是其他虚拟化设备,在此不做一一列举。
在一些可能的实施例中,上述通信设备也可以由通用处理器来实现。
例如,该通用处理器的形态可以是一种芯片。具体地,实现通信设备的通用处理器包括处理电路和与该处理电路内部连接通信的输入接口以及输出接口,该处理电路用于通过输入接口执行上述各个方法实施例中的报文的生成步骤,该处理电路用于通过输入接口执行上述各个方法实施例中的接收步骤,该处理电路用于通过输出接口执行上述各个方法实施例中的发送步骤。可选地,该通用处理器还可以包括存储介质,该处理电路用于通过存储介质执行上述各个方法实施例中的存储步骤。存储介质可以存储处理电路执行的指令,该处理电路用于执行存储介质存储的指令以执行上述各个方法实施例。
应理解的是,上述处理器可以是中央处理器(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(digital signal processing,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现场可编程门阵列(field-programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者是任何常规的处理器等。值得说明的是,处理器可以是支持进阶精简指令集机器(advanced RISC machines,ARM)架构的处理器。
进一步地,在一种可选的实施例中,上述存储器可以包括只读存储器和随机存取存储器,并向处理器提供指令和数据。存储器还可以包括非易失性随机存取存储器。例如,存储器还可以存储设备类型的信息。
该存储器可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(read-only memory,ROM)、可编程只读存储器(programmable ROM,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(random access memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用。例如,静态随机存取存储器(static RAM,SRAM)、动态随机存取存储器(dynamic random access memory,DRAM)、同步动态随机存取存储器 (synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(double data date SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(direct rambus RAM,DR RAM)。
本申请实施例提供了一种联邦学习系统,该联邦学习系统包括:第一通信设备以及多个第二通信设备。可选地,第一通信设备用于执行上述方法实施例中第一设备所执行的方法,各个第二通信设备分别用于执行上述方法实施例中第二设备所执行的方法。
本申请实施例提供了一种计算机程序(产品),计算机程序(产品)包括:计算机程序代码,当计算机程序代码被计算机运行时,使得计算机执行上述方法实施例中第一设备或者第二设备所执行的联邦学习方法。
本申请实施例提供了一种计算机可读存储介质,计算机可读存储介质存储程序或指令,当程序或指令在计算机上运行时,上述方法实施例中第一设备或者第二设备所执行的联邦学习方法被执行。
本申请实施例提供了一种芯片,包括处理器,用于从存储器中调用并运行存储器中存储的指令,使得安装有芯片的通信设备执行上述方法实施例中第一设备或者第二设备所执行的联邦学习方法。
本申请实施例提供另一种芯片,包括:输入接口、输出接口、处理器和存储器,输入接口、输出接口、处理器以及存储器之间通过内部连接通路相连,处理器用于执行存储器中的代码,当代码被执行时,处理器用于执行上述方法实施例中第一设备或者第二设备所执行的联邦学习方法。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线)或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk)等。
在本申请实施例的上下文中,计算机程序代码或者相关数据可以由任意适当载体承载,以使得设备、装置或者处理器能够执行上文描述的各种处理和操作。载体的示例包括信号、计算机可读介质等等。
信号的示例可以包括电、光、无线电、声音或其它形式的传播信号,诸如载波、红外信号等。
机器可读介质可以是包含或存储用于或有关于指令执行系统、装置或设备的程序的任何 有形介质。机器可读介质可以是机器可读信号介质或机器可读存储介质。机器可读介质可以包括但不限于电子的、磁的、光学的、电磁的、红外的或半导体系统、装置或设备,或其任意合适的组合。机器可读存储介质的更详细示例包括带有一根或多根导线的电气连接、便携式计算机磁盘、硬盘、随机存储存取器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或闪存)、光存储设备、磁存储设备,或其任意合适的组合。
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的系统、设备和模块的具体工作过程,可以参见前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、设备和方法,可以通过其它的方式实现。例如,以上所描述的设备实施例仅仅是示意性的,例如,该模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个模块或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另外,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口、设备或模块的间接耦合或通信连接,也可以是电的,机械的或其它的形式连接。
该作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理模块,即可以位于一个地方,或者也可以分布到多个网络模块上。可以根据实际的需要选择其中的部分或者全部模块来实现本申请实施例方案的目的。
另外,在本申请各个实施例中的各功能模块可以集成在一个处理模块中,也可以是各个模块单独物理存在,也可以是两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。
该集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分,或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例中方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
本申请中术语“第一”“第二”等字样用于对作用和功能基本相同的相同项或相似项进行区分,应理解,“第一”、“第二”、“第n”之间不具有逻辑或时序上的依赖关系,也不对数量和执行顺序进行限定。还应理解,尽管以下描述使用术语第一、第二等来描述各种元素,但这些元素不应受术语的限制。这些术语只是用于将一元素与另一元素区别分开。例如,在不脱离各种所述示例的范围的情况下,第一图像可以被称为第二图像,并且类似地,第二图像可以被称为第一图像。第一图像和第二图像都可以是图像,并且在某些情况下,可以是单独且不同的图像。
还应理解,在本申请的各个实施例中,各个过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
本申请中术语“至少一个”的含义是指一个或多个,本申请中术语“多个”的含义是指两个或两个以上,例如,多个第二报文是指两个或两个以上的第二报文。本文中术语“系统”和“网络”经常可互换使用。
应理解,在本文中对各种所述示例的描述中所使用的术语只是为了描述特定示例,而并非旨在进行限制。如在对各种所述示例的描述和所附权利要求书中所使用的那样,单数形式“一个(“a”,“an”)”和“该”旨在也包括复数形式,除非上下文另外明确地指示。
还应理解,术语“包括”(也称“includes”、“including”、“comprises”和/或“comprising”)当在本说明书中使用时指定存在所陈述的特征、整数、步骤、操作、元素、和/或部件,但是并不排除存在或添加一个或多个其他特征、整数、步骤、操作、元素、部件、和/或其分组。
还应理解,术语“若”和“如果”可被解释为意指“当...时”(“when”或“upon”)或“响应于确定”或“响应于检测到”。类似地,根据上下文,短语“若确定...”或“若检测到[所陈述的条件或事件]”可被解释为意指“在确定...时”或“响应于确定...”或“在检测到[所陈述的条件或事件]时”或“响应于检测到[所陈述的条件或事件]”。
应理解,根据A确定B并不意味着仅仅根据A确定B,还可以根据A和/或其它信息确定B。
还应理解,说明书通篇中提到的“一个实施例”、“一实施例”、“一种可能的实现方式”意味着与实施例或实现方式有关的特定特征、结构或特性包括在本申请的至少一个实施例中。因此,在整个说明书各处出现的“在一个实施例中”或“在一实施例中”、“一种可能的实现方式”未必一定指相同的实施例。此外,这些特定的特征、结构或特性可以任意适合的方式结合在一个或多个实施例中。
以上所述仅为本申请的实施例,并不用以限制本申请,凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。

Claims (39)

  1. 一种联邦学习方法,其特征在于,所述方法包括:
    第一设备接收参与联邦学习的多个第二设备发送的数据分布信息,任一第二设备发送的数据分布信息包括第一增益信息和标签类型信息中的至少一种,所述第一增益信息用于指示通过上轮训练获得的第一模型为了适应所述任一第二设备的当前训练样本所需的修正程度,所述标签类型信息用于指示所述当前训练样本的标签对应的类型;
    所述第一设备根据所述多个第二设备发送的数据分布信息选择匹配的联邦学习策略;
    所述第一设备向所述多个第二设备中的至少一个第二设备发送所述联邦学习策略对应的参数上报策略,所述至少一个第二设备中的任一第二设备用于上报基于接收到的参数上报策略以及所述当前训练样本获得的第二增益信息,所述第二增益信息用于获得所述任一第二设备的第二模型。
  2. 根据权利要求1所述的方法,其特征在于,所述第一设备根据所述多个第二设备发送的数据分布信息选择匹配的联邦学习策略,包括:
    所述第一设备根据数据分布之间的差异选择匹配的联邦学习策略,所述数据分布之间的差异基于所述多个第二设备发送的数据分布信息确定。
  3. 根据权利要求2所述的方法,其特征在于,所述任一第二设备发送的数据分布信息包括第一增益信息和标签类型信息,所述第一设备根据数据分布之间的差异选择匹配的联邦学习策略之前,还包括:
    所述第一设备根据所述多个第二设备的第一增益信息确定特征分布信息,所述特征分布信息用于指示不同第二设备的当前训练样本的特征分布是否相同;
    所述第一设备根据所述特征分布信息以及所述多个第二设备的标签类型信息确定所述数据分布之间的差异。
  4. 根据权利要求3所述的方法,其特征在于,所述第一设备根据数据分布之间的差异选择匹配的联邦学习策略,包括:
    基于所述特征分布信息指示不同第二设备的当前训练样本的特征分布相同,且所述不同第二设备的标签类型信息相同,则选择匹配的联邦学习策略为模型平均融合,所述模型平均融合用于以增益信息平均的方式进行联邦学习。
  5. 根据权利要求3所述的方法,其特征在于,所述第一设备根据数据分布之间的差异选择匹配的联邦学习策略,包括:
    基于所述特征分布信息指示不同第二设备的当前训练样本的特征分布不同,且所述不同第二设备的标签类型信息相同,则选择匹配的联邦学习策略为模型差异化更新,所述模型差异化更新用于以增益信息差异化处理的方式进行联邦学习。
  6. 根据权利要求3所述的方法,其特征在于,所述第一设备根据数据分布之间的差异选择匹配的联邦学习策略,包括:
    基于所述特征分布信息指示不同第二设备的当前训练样本的特征分布相同,且所述不同第二设备的标签类型信息不同,则选择匹配的联邦学习策略为模型部分更新,所述模型部分更新用于以部分增益信息平均的方式进行联邦学习。
  7. 根据权利要求3所述的方法,其特征在于,所述第一设备根据数据分布之间的差异选择匹配的联邦学习策略,包括:
    基于所述特征分布信息指示不同第二设备的当前训练样本的特征分布不同,且所述不同第二设备的标签类型信息不同,则选择匹配的联邦学习策略为模型部分差异化更新,所述模型部分差异化更新用于以部分增益信息差异化处理的方式进行联邦学习。
  8. 根据权利要求2所述的方法,其特征在于,所述任一第二设备发送的数据分布信息包括第一增益信息,所述第一设备根据数据分布之间的差异选择匹配的联邦学习策略之前,还包括:
    所述第一设备根据所述多个第二设备的第一增益信息确定特征分布信息,所述特征分布信息用于指示不同第二设备的当前训练样本的特征分布是否相同;
    所述第一设备根据所述特征分布信息确定所述数据分布之间的差异。
  9. 根据权利要求8所述的方法,其特征在于,所述第一设备根据数据分布之间的差异选择匹配的联邦学习策略,包括:
    基于所述特征分布信息指示不同第二设备的当前训练样本的特征分布相同,则选择匹配的联邦学习策略为模型平均融合,所述模型平均融合用于以增益信息平均的方式进行联邦学习。
  10. 根据权利要求8所述的方法,其特征在于,所述第一设备根据数据分布之间的差异选择匹配的联邦学习策略,包括:
    基于所述特征分布信息指示不同第二设备的当前训练样本的特征分布不同,则选择匹配的联邦学习策略为模型差异化更新,所述模型差异化更新用于以增益信息差异化处理的方式进行联邦学习。
  11. 根据权利要求2所述的方法,其特征在于,所述任一第二设备发送的数据分布信息包括标签类型信息,所述第一设备根据数据分布之间的差异选择匹配的联邦学习策略之前,还包括:基于所述标签类型信息确定所述数据分布之间的差异。
  12. 根据权利要求11所述的方法,其特征在于,所述第一设备根据数据分布之间的差异选择匹配的联邦学习策略,包括:
    基于不同第二设备的标签类型信息相同,则选择匹配的联邦学习策略为模型平均融合,所述模型平均融合用于以增益信息平均的方式进行联邦学习。
  13. 根据权利要求11所述的方法,其特征在于,所述第一设备根据数据分布之间的差异选择匹配的联邦学习策略,包括:
    基于不同第二设备的标签类型信息不同,则选择匹配的联邦学习策略为模型部分更新,所述模型部分更新用于以部分增益信息平均的方式进行联邦学习。
  14. 根据权利要求1-13任一所述的方法,其特征在于,所述第一设备向所述多个第二设备中的至少一个第二设备发送所述联邦学习策略对应的参数上报策略之后,所述方法还包括:
    所述第一设备接收所述多个第二设备发送的所述第二增益信息;
    所述第一设备基于所述联邦学习策略对所述第二增益信息进行联邦融合,得到各个第二设备对应的第三增益信息;
    所述第一设备向所述至少一个第二设备中的任一第二设备发送对应的第三增益信息,或者基于对应的第三增益信息以及所述任一第二设备的第一模型获得的第二模型。
  15. 根据权利要求1-14任一所述的方法,其特征在于,所述第一设备向所述多个第二设备中的至少一个第二设备发送所述联邦学习策略对应的参数上报策略之前,所述方法还包括:
    所述第一设备接收所述多个第二设备发送的训练样本特征信息,所述训练样本特征信息用于表征标签分布或样本数量;
    所述第一设备向所述多个第二设备中的至少一个第二设备发送所述联邦学习策略对应的参数上报策略,还包括:
    对于所述至少一个第二设备中的任一第二设备,所述第一设备向所述任一第二设备发送超参数,所述超参数基于所述任一第二设备发送的训练样本特征信息确定,所述超参数用于所述任一第二设备获取第二增益信息。
  16. 根据权利要求15所述的方法,其特征在于,所述训练样本特征信息包括标签分布信息或样本数量;所述标签分布信息包括标签占比信息和每种类型的标签数量中的至少一种,所述标签占比信息用于指示各种类型的标签在所述当前训练样本的标签中的占比;
    所述样本数量信息用于指示所述当前训练样本中包括的样本的条数。
  17. 根据权利要求1-13任一所述的方法,其特征在于,所述上轮训练获得的第一模型包括所述任一第二设备的第一模型,所述第一增益信息包括所述任一第二设备的第一模型对应的增益信息,所述任一第二设备的第一模型对应的增益信息用于指示所述任一第二设备的第一模型为了适应所述任一第二设备的当前训练样本所需的修正程度;
    或者,所述上轮训练获得的第一模型包括所述任一第二设备的第一模型及参与联邦学习的其他第二设备的第一模型,所述第一增益信息包括所述任一第二设备的第一模型对应的增益信息以及所述其他第二设备的第一模型对应的增益信息,所述其他第二设备的第一模型对应的增益信息用于指示所述其他第二设备的第一模型为了适应所述任一第二设备的当前训练样本所需的修正程度。
  18. 根据权利要求17所述的方法,其特征在于,所述第一设备接收参与联邦学习的多个第二设备发送的数据分布信息之前,所述方法还包括:
    所述第一设备向所述任一第二设备发送所述其他第二设备的第一模型。
  19. 一种联邦学习方法,其特征在于,所述方法包括:
    第二设备获得数据分布信息,所述数据分布信息包括第一增益信息和标签类型信息中的至少一种,所述第一增益信息用于指示通过上轮训练获得的第一模型为了适应所述第二设备的当前训练样本所需的修正程度,所述标签类型信息用于指示所述当前训练样本的标签对应的类型;
    所述第二设备向所述第一设备发送所述数据分布信息,所述数据分布信息用于所述第一设备选择匹配的联邦学习策略;
    所述第二设备接收所述第一设备发送的所述联邦学习策略对应的参数上报策略,基于接收到的参数上报策略以及所述当前训练样本获得第二增益信息,所述第二增益信息用于获得所述第二设备的第二模型。
  20. 根据权利要求19所述的方法,其特征在于,所述基于接收到的参数上报策略以及所述当前训练样本获得第二增益信息之后,所述方法还包括:
    所述第二设备向所述第一设备发送所述第二增益信息;
    所述第二设备接收所述第一设备基于所述第二增益信息发送的对应的第三增益信息,所述第二设备基于所述第三增益信息以及所述第二设备的第一模型获得第二模型,或者,所述第二设备接收所述第一设备发送的基于所述对应的第三增益信息以及所述第二设备的第一模型获得的第二模型。
  21. 根据权利要求19或20所述的方法,其特征在于,所述方法还包括:
    所述第二设备向所述第一设备发送训练样本特征信息,所述训练样本特征信息用于所述第一设备确定超参数;
    所述第二设备接收所述第一设备发送的超参数;
    所述基于接收到的参数上报策略以及所述当前训练样本获得第二增益信息,包括:
    所述第二设备基于所述接收到的参数上报策略、所述当前训练样本以及所述超参数获得第二增益信息。
  22. 根据权利要求21所述的方法,其特征在于,所述训练样本特征信息包括标签分布信息或样本数量;所述标签分布信息包括标签占比信息和每种类型的标签数量中的至少一种,所述标签占比信息用于指示各种类型的标签在所述当前训练样本的标签中的占比;
    所述样本数量信息用于指示所述当前训练样本中包括的样本的条数。
  23. 根据权利要求19-22任一所述的方法,其特征在于,所述上轮训练获得的第一模型包括所述第二设备的第一模型,所述第一增益信息包括所述第二设备的第一模型对应的增益信息,所述第二设备的第一模型对应的增益信息用于指示所述第二设备的第一模型为了适应所述第 二设备的当前训练样本所需的修正程度;
    或者,所述上轮训练获得的第一模型包括所述第二设备的第一模型及参与联邦学习的其他第二设备的第一模型,所述第一增益信息包括所述第二设备的第一模型对应的增益信息以及所述其他第二设备的第一模型对应的增益信息,所述其他第二设备的第一模型对应的增益信息用于指示所述其他第二设备的第一模型为了适应所述第二设备的当前训练样本所需的修正程度。
  24. 根据权利要求23所述的方法,其特征在于,所述第二设备获得数据分布信息之前,所述方法还包括:
    所述第二设备接收所述第一设备发送的所述其他第二设备的第一模型。
  25. 一种联邦学习装置,其特征在于,所述装置包括:
    接收模块,用于第一设备接收参与联邦学习的多个第二设备发送的数据分布信息,任一第二设备发送的数据分布信息包括第一增益信息和标签类型信息中的至少一种,所述第一增益信息用于指示通过上轮训练获得的第一模型为了适应所述任一第二设备的当前训练样本所需的修正程度,所述标签类型信息用于指示所述当前训练样本的标签对应的类型;
    选择模块,用于所述第一设备根据所述多个第二设备发送的数据分布信息选择匹配的联邦学习策略;
    发送模块,用于所述第一设备向所述多个第二设备中的至少一个第二设备发送所述联邦学习策略对应的参数上报策略,所述至少一个第二设备中的任一第二设备用于上报基于接收到的参数上报策略以及所述当前训练样本获得的第二增益信息,所述第二增益信息用于获得所述任一第二设备的第二模型。
  26. 根据权利要求25所述的装置,其特征在于,所述选择模块,用于所述第一设备根据数据分布之间的差异选择匹配的联邦学习策略,所述数据分布之间的差异基于所述多个第二设备发送的数据分布信息确定。
  27. 根据权利要求26所述的装置,其特征在于,所述任一第二设备发送的数据分布信息包括第一增益信息和标签类型信息,所述装置还包括:
    第一确定模块,用于所述第一设备根据所述多个第二设备的第一增益信息确定特征分布信息,所述特征分布信息用于指示不同第二设备的当前训练样本的特征分布是否相同;所述第一设备根据所述特征分布信息以及所述多个第二设备的标签类型信息确定所述数据分布之间的差异。
  28. 根据权利要求27所述的装置,其特征在于,所述选择模块,用于基于所述特征分布信息指示不同第二设备的当前训练样本的特征分布相同,且所述不同第二设备的标签类型信息相同,则选择匹配的联邦学习策略为模型平均融合,所述模型平均融合用于以增益信息平均的方式进行联邦学习。
  29. 根据权利要求27所述的装置,其特征在于,所述选择模块,用于基于所述特征分布信息指示不同第二设备的当前训练样本的特征分布不同,且所述不同第二设备的标签类型信息相同,则选择匹配的联邦学习策略为模型差异化更新,所述模型差异化更新用于以增益信息差异化处理的方式进行联邦学习。
  30. 根据权利要求27所述的装置,其特征在于,所述选择模块,用于基于所述特征分布信息指示不同第二设备的当前训练样本的特征分布相同,且所述不同第二设备的标签类型信息不同,则选择匹配的联邦学习策略为模型部分更新,所述模型部分更新用于以部分增益信息平均的方式进行联邦学习。
  31. 根据权利要求27所述的装置,其特征在于,所述选择模块,用于基于所述特征分布信息指示不同第二设备的当前训练样本的特征分布不同,且所述不同第二设备的标签类型信息不同,则选择匹配的联邦学习策略为模型部分差异化更新,所述模型部分差异化更新用于以部分增益信息差异化处理的方式进行联邦学习。
  32. 根据权利要求25-31任一所述的装置,其特征在于,所述接收模块,还用于所述第一设备接收所述多个第二设备发送的所述第二增益信息;
    所述装置还包括:融合模块,用于所述第一设备基于所述联邦学习策略对所述第二增益信息进行联邦融合,得到各个第二设备对应的第三增益信息;
    所述发送模块,还用于所述第一设备向所述至少一个第二设备中的任一第二设备发送对应的第三增益信息,或者基于对应的第三增益信息以及所述任一第二设备的第一模型获得的第二模型。
  33. 根据权利要求25-32任一所述的装置,其特征在于,所述接收模块,还用于所述第一设备接收所述多个第二设备发送的训练样本特征信息,所述训练样本特征信息用于表征标签分布或样本数量;
    所述发送模块,还用于对于所述至少一个第二设备中的任一第二设备,所述第一设备向所述任一第二设备发送超参数,所述超参数基于所述任一第二设备发送的训练样本特征信息确定,所述超参数用于所述任一第二设备获取第二增益信息。
  34. 一种联邦学习装置,其特征在于,所述装置包括:
    获得模块,用于第二设备获得数据分布信息,所述数据分布信息包括第一增益信息和标签类型信息中的至少一种,所述第一增益信息用于指示通过上轮训练获得的第一模型为了适应所述第二设备的当前训练样本所需的修正程度,所述标签类型信息用于指示所述当前训练样本的标签对应的类型;
    发送模块,用于所述第二设备向所述第一设备发送所述数据分布信息,所述数据分布信息用于所述第一设备选择匹配的联邦学习策略;
    接收模块,用于所述第二设备接收所述第一设备发送的所述联邦学习策略对应的参数上报策略,基于接收到的参数上报策略以及所述当前训练样本获得第二增益信息,所述第二增 益信息用于获得所述第二设备的第二模型。
  35. 根据权利要求34所述的装置,其特征在于,所述发送模块,还用于所述第二设备向所述第一设备发送所述第二增益信息;
    所述接收模块,还用于所述第二设备接收所述第一设备基于所述第二增益信息发送的对应的第三增益信息,所述第二设备基于所述第三增益信息以及所述第二设备的第一模型获得第二模型,或者,所述第二设备接收所述第一设备发送的基于所述对应的第三增益信息以及所述第二设备的第一模型获得的第二模型。
  36. 根据权利要求34或35所述的装置,其特征在于,所述发送模块,还用于所述第二设备向所述第一设备发送训练样本特征信息,所述训练样本特征信息用于所述第一设备确定超参数;所述接收模块,还用于所述第二设备接收所述第一设备发送的超参数,基于所述接收到的参数上报策略、所述当前训练样本以及所述超参数获得第二增益信息。
  37. 一种通信设备,其特征在于,所述通信设备包括:处理器,所述处理器与存储器耦合,所述存储器中存储有至少一条程序指令或代码,所述至少一条程序指令或代码由所述处理器加载并执行,以使所述通信设备实现权利要求1-24中任一所述的联邦学习方法。
  38. 一种联邦学习系统,其特征在于,所述系统包括第一通信设备和第二通信设备,所述第一通信设备用于执行所述权利要求1-18中任一所述的联邦学习方法,所述第二通信设备用于执行所述权利要求19-24中任一所述的联邦学习方法。
  39. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有至少一条程序指令或代码,所述程序指令或代码由处理器加载并执行时以使计算机实现如权利要求1-24中任一所述的联邦学习方法。
PCT/CN2021/133579 2020-11-30 2021-11-26 联邦学习方法、装置、设备、系统及计算机可读存储介质 WO2022111639A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP21897139.8A EP4235522A4 (en) 2020-11-30 2021-11-26 FEDERATED LEARNING METHOD AND APPARATUS, DEVICE, SYSTEM, AND COMPUTER-READABLE STORAGE MEDIUM
US18/325,533 US20230306311A1 (en) 2020-11-30 2023-05-30 Federated Learning Method and Apparatus, Device, System, and Computer-Readable Storage Medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011385076.2 2020-11-30
CN202011385076.2A CN114580651A (zh) 2020-11-30 2020-11-30 联邦学习方法、装置、设备、系统及计算机可读存储介质

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US18/325,533 Continuation US20230306311A1 (en) 2020-11-30 2023-05-30 Federated Learning Method and Apparatus, Device, System, and Computer-Readable Storage Medium

Publications (1)

Publication Number Publication Date
WO2022111639A1 true WO2022111639A1 (zh) 2022-06-02

Family

ID=81753757

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/133579 WO2022111639A1 (zh) 2020-11-30 2021-11-26 联邦学习方法、装置、设备、系统及计算机可读存储介质

Country Status (4)

Country Link
US (1) US20230306311A1 (zh)
EP (1) EP4235522A4 (zh)
CN (1) CN114580651A (zh)
WO (1) WO2022111639A1 (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115587257A (zh) * 2022-12-13 2023-01-10 阿里巴巴(中国)有限公司 模型超参数优化方法、存储介质和电子设备
CN116055335A (zh) * 2022-12-21 2023-05-02 深圳信息职业技术学院 基于联邦学习的车联网入侵检测模型训练方法、入侵检测方法及设备
CN117077817A (zh) * 2023-10-13 2023-11-17 之江实验室 一种基于标签分布的个性化联邦学习模型训练方法及装置
WO2024008154A1 (zh) * 2022-07-08 2024-01-11 维沃移动通信有限公司 联邦学习方法、装置、通信设备及可读存储介质

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115481752B (zh) * 2022-09-23 2024-03-19 中国电信股份有限公司 模型训练方法、装置、电子设备以及存储介质
WO2024103271A1 (zh) * 2022-11-16 2024-05-23 华为技术有限公司 一种通信方法以及相关装置
CN116541712B (zh) * 2023-06-26 2023-12-26 杭州金智塔科技有限公司 基于非独立同分布数据的联邦建模方法及系统

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110443063A (zh) * 2019-06-26 2019-11-12 电子科技大学 自适性保护隐私的联邦深度学习的方法
CN111008709A (zh) * 2020-03-10 2020-04-14 支付宝(杭州)信息技术有限公司 联邦学习、资料风险评估方法、装置和系统
CN111291897A (zh) * 2020-02-10 2020-06-16 深圳前海微众银行股份有限公司 基于半监督的横向联邦学习优化方法、设备及存储介质
CN111915023A (zh) * 2020-08-28 2020-11-10 支付宝(杭州)信息技术有限公司 一种基于联邦学习的超参数确定方法及装置
WO2020235631A1 (ja) * 2019-05-22 2020-11-26 日本電気株式会社 モデル生成装置、システム、パラメータ算出装置、モデル生成方法、パラメータ算出方法および記録媒体

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020235631A1 (ja) * 2019-05-22 2020-11-26 日本電気株式会社 モデル生成装置、システム、パラメータ算出装置、モデル生成方法、パラメータ算出方法および記録媒体
CN110443063A (zh) * 2019-06-26 2019-11-12 电子科技大学 自适性保护隐私的联邦深度学习的方法
CN111291897A (zh) * 2020-02-10 2020-06-16 深圳前海微众银行股份有限公司 基于半监督的横向联邦学习优化方法、设备及存储介质
CN111008709A (zh) * 2020-03-10 2020-04-14 支付宝(杭州)信息技术有限公司 联邦学习、资料风险评估方法、装置和系统
CN111915023A (zh) * 2020-08-28 2020-11-10 支付宝(杭州)信息技术有限公司 一种基于联邦学习的超参数确定方法及装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4235522A4

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024008154A1 (zh) * 2022-07-08 2024-01-11 维沃移动通信有限公司 联邦学习方法、装置、通信设备及可读存储介质
CN115587257A (zh) * 2022-12-13 2023-01-10 阿里巴巴(中国)有限公司 模型超参数优化方法、存储介质和电子设备
CN115587257B (zh) * 2022-12-13 2023-04-07 阿里巴巴(中国)有限公司 模型超参数优化方法、存储介质和电子设备
CN116055335A (zh) * 2022-12-21 2023-05-02 深圳信息职业技术学院 基于联邦学习的车联网入侵检测模型训练方法、入侵检测方法及设备
CN116055335B (zh) * 2022-12-21 2023-12-19 深圳信息职业技术学院 基于联邦学习的车联网入侵检测模型训练方法、入侵检测方法及设备
CN117077817A (zh) * 2023-10-13 2023-11-17 之江实验室 一种基于标签分布的个性化联邦学习模型训练方法及装置
CN117077817B (zh) * 2023-10-13 2024-01-30 之江实验室 一种基于标签分布的个性化联邦学习模型训练方法及装置

Also Published As

Publication number Publication date
CN114580651A (zh) 2022-06-03
EP4235522A4 (en) 2024-04-24
US20230306311A1 (en) 2023-09-28
EP4235522A1 (en) 2023-08-30

Similar Documents

Publication Publication Date Title
WO2022111639A1 (zh) 联邦学习方法、装置、设备、系统及计算机可读存储介质
US20230031889A1 (en) Machine learning pipeline for predictions regarding a network
CN112153650B (zh) 一种无线网络中基于终端信誉的可靠联邦学习方法及系统
US20230162047A1 (en) Massively Scalable, Resilient, and Adaptive Federated Learning System
US11580458B2 (en) Method and system for performance tuning and performance tuning device
US11706289B1 (en) System and method for distributed management of hardware using intermediate representations of systems to satisfy user intent
US20230208915A1 (en) Data processing method, apparatus, device, and medium
WO2023137858A1 (zh) 混合专家模型训练的性能优化方法和装置
WO2021050905A1 (en) Global table management operations for multi-region replicated tables
CN113438681A (zh) 网络切片的可行性评估方法、装置及计算设备
Imani et al. iSample: Intelligent client sampling in federated learning
WO2024037629A1 (zh) 区块链的数据整合方法、装置、计算机设备及存储介质
US11985171B2 (en) Aggregated networking subsystem station move control system
Kanwal et al. Head node selection algorithm in cloud computing data center
US11595471B1 (en) Method and system for electing a master in a cloud based distributed system using a serverless framework
US11886928B2 (en) Automated service tiering between edge computing sites and a core data center
Wang et al. Virtual network embedding with pre‐transformation and incentive convergence mechanism
US11108663B1 (en) Ring control data exchange system
Yi et al. PPDRL: A Pretraining‐and‐Policy‐Based Deep Reinforcement Learning Approach for QoS‐Aware Service Composition
Berkennou et al. A replication and migration strategy on the hierarchical architecture in the fog computing environment
TW202201284A (zh) 自動機器學習系統效能調優方法、裝置、設備及介質
CN110457280A (zh) 一种hdfs副本再复制改进策略
Bogacka et al. Introducing Federated Learning into Internet of Things ecosystems–preliminary considerations
US11005746B1 (en) Stack group merging system
US11601305B2 (en) Physical infrastructure/virtual infrastructure integration system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21897139

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2021897139

Country of ref document: EP

Effective date: 20230522

NENP Non-entry into the national phase

Ref country code: DE