Pruning, training method, class recognition method and related device of neural network

By pruning the global neural network and removing ineffective neurons, the problems of low efficiency and poor accuracy caused by uneven training sets are solved, achieving efficient training and flexible adaptation of neural networks.

CN113962356BActive Publication Date: 2025-11-04HUAWEI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010700975.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-20
Publication Date
2025-11-04
Estimated Expiration
2040-07-20

AI Technical Summary

Technical Problem

The existing neural network training process suffers from low training efficiency and poor model accuracy due to uneven training sets, and it is difficult to adjust it according to user needs.

Method used

By acquiring target class features, the global neural network is pruned to obtain a local neural network, removing ineffective neurons to adapt to user needs and training set characteristics.

Benefits of technology

It improves training efficiency and model accuracy, enabling flexible adaptation and efficient training of neural networks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113962356B_ABST
    Figure CN113962356B_ABST
Patent Text Reader

Abstract

A pruning method, a training method, a class recognition method and related devices of a neural network are applied to the field of artificial intelligence and relate to federated learning. The pruning method comprises: obtaining a target class feature, the target class feature being used to represent characteristics of data belonging to a target class; and pruning a global neural network according to the target class feature to obtain a local neural network, wherein the global neural network is used to recognize a plurality of classes, the local neural network is used to recognize the target class, and the plurality of classes include the target class. The training method comprises: training the local neural network obtained by pruning the global neural network by using a training set to obtain a trained neural network, and the trained neural network is used to update the global neural network, wherein the target class includes a class to which a sample in the training set belongs.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of artificial intelligence, and in particular to a neural network pruning method, a neural network training method, a class identification method and related devices. BACKGROUND

[0002] With the development of science and technology, artificial intelligence is applied more and more widely. The key to applying artificial intelligence is to train a machine learning model with high accuracy. Neural network model is the most widely used model in the field of machine learning.

[0003] The neural network model is usually trained by using multiple training sets during training. Due to the uneven samples in the training set used for each training, for example, if the neural network model is a 5-classification model, and the training set used for training is missing some class samples, for example, only contains 2-class samples, the parameters of the neurons that affect the missing class will be updated arbitrarily during the training process. This mismatch between the training set and the neural network to be trained not only leads to low training efficiency, but also reduces the accuracy of the model. In addition, during the application of the neural network, it is difficult to adjust the neural network according to the user's needs to obtain the neural network required by the user.

[0004] Therefore, the neural network cannot be adapted to the training set or the user, which is a technical problem to be solved at present. SUMMARY

[0005] The embodiments of the present application provide a neural network pruning method, a neural network training method, a class identification method and related devices, which obtain a local neural network suitable for a user or a training set by pruning a global neural network.

[0006] In a first aspect, the embodiments of the present application provide a neural network pruning method, comprising:

[0007] obtaining a target class feature, the target class feature being used to represent the characteristics of data belonging to a target class;

[0008] pruning a global neural network according to the target class feature to obtain a local neural network, wherein the global neural network is used to identify multiple classes, the local neural network is used to identify the target class, and the multiple classes include the target class.

[0009] The above method, on the one hand, prunes the global neural network based on the target class feature, avoiding the arbitrary update of some invalid neurons in the global neural network during the training of the training set on the global neural network, thereby improving the training efficiency. On the other hand, during the application of the global neural network, the global neural network can be pruned to flexibly meet the requirements of each user.

[0010] In a possible implementation, the local neural network includes neurons in the global neural network for identifying the target class; the first class and the second class are two classes in the plurality of classes; the more similar the class feature of the first class is to the class feature of the second class, the more neurons for identifying the first class in the global neural network are the same as neurons for identifying the second class.

[0011] In a possible implementation, the target class feature includes n-dimensional data, n being a positive integer, and the pruning of the global neural network according to the target class feature to obtain the local neural network includes:

[0012] For each dimension of the n-dimensional data, a probability distribution corresponding to each dimension is generated with the dimension as a mean value, to obtain n probability distributions, the n probability distributions corresponding to the n-dimensional data one by one;

[0013] The global neural network is pruned according to the n probability distributions to obtain the local neural network.

[0014] Optionally, the pruning of the global neural network according to the n probability distributions to obtain the local neural network includes:

[0015] Each layer structure in the global neural network is encoded respectively;

[0016] The distribution value of each neuron in each layer structure in the global neural network is determined as a value corresponding to the encoding of the neuron in the probability distribution corresponding to the layer structure, the n dimensions have a corresponding relationship with the layer structures in the global neural network, and the probability distribution corresponding to each layer structure is a probability distribution corresponding to a dimension corresponding to the layer structure in the n probability distributions;

[0017] Neurons with a distribution value less than a first threshold value in the global neural network are removed to obtain the local neural network.

[0018] Optionally, the pruning of the global neural network according to the n probability distributions to obtain the local neural network includes:

[0019] All neurons in the global neural network are encoded;

[0020] Each probability distribution of the n probability distributions is added after being increased by a bias value;

[0021] The distribution value of each neuron in the global neural network is determined as a value corresponding to the encoding of the neuron in the added probability distribution;

[0022] remove neurons in the global neural network with a distribution value less than a second threshold value to obtain the local neural network.

[0023] Optionally, the target classes include at least two classes, and the obtaining of the target class feature includes:

[0024] Optionally, the target classes include at least two classes, and the obtaining of the target class feature includes:

[0025] In a possible implementation, the target classes include at least two classes, and the target class feature includes a class feature of each of the at least two classes. The pruning of the global neural network according to the target class feature to obtain the local neural network includes:

[0026] For each of the target classes, a probability distribution of the each of the target classes is generated according to the class feature of the each of the target classes, and neurons in the global neural network that act on the each of the target classes are determined according to the probability distribution of the each of the target classes.

[0027] The neurons in the global neural network that act on the target classes are determined as a union set of neurons in the global neural network that respectively act on all classes in the target classes.

[0028] The neurons in the global neural network except the neurons that act on the target classes are removed to obtain the local neural network.

[0029] Optionally, the class feature of the each of the target classes includes n-dimensional data, where n is a positive integer. The generating of the probability distribution of the each of the target classes according to the class feature of the each of the target classes includes:

[0030] For each of the n-dimensional data, a probability distribution corresponding to the each of the n-dimensional data is generated with the each of the n-dimensional data as a mean value, to obtain n probability distributions. The n probability distributions correspond to the n-dimensional data one by one, and the probability distribution of the each of the target classes includes the n probability distributions.

[0031] Further, the determining of the neurons in the global neural network that act on the each of the target classes according to the probability distribution of the each of the target classes includes:

[0032] Each layer structure in the global neural network is encoded respectively.

[0033] A distribution value of each neuron in each layer structure in the global neural network is determined as a value corresponding to the encoding of the each neuron in a probability distribution corresponding to the each layer structure. The n dimensions have a corresponding relationship with the layer structures in the global neural network, and the probability distribution corresponding to the each layer structure is a probability distribution corresponding to a dimension corresponding to the each layer structure in the n probability distributions.

[0034] remove neurons in the global neural network with a distribution value less than a third threshold value, to obtain neurons in the global neural network that act on each class.

[0035] Optionally, the determining the neurons in the global neural network that act on each class according to the probability distribution of each class comprises:

[0036] encoding all neurons in the global neural network;

[0037] adding a bias to each probability distribution of the n probability distributions and superimposing the n probability distributions;

[0038] determining the distribution value of each neuron in the global neural network as a value corresponding to the encoding of the neuron in the superimposed probability distribution;

[0039] remove neurons in the global neural network with a distribution value less than a third threshold value, to obtain neurons in the global neural network that act on each class.

[0040] In a second aspect, the embodiments of the present application further provide a neural network training method, comprising:

[0041] obtaining a target class feature; the target class feature is used to represent the characteristics of samples belonging to a target class, and the target class includes a class to which samples in a training set belong;

[0042] pruning a global neural network according to the target class feature to obtain a first local neural network;

[0043] training the first local neural network through the training set to obtain a second local neural network;

[0044] wherein, the second local neural network is used to update the global neural network; the global neural network is used to identify a plurality of classes, and the second local neural network is used to identify the target class, and the plurality of classes include the target class.

[0045] The above method prunes the global neural network based on the target class feature, avoids arbitrary updating of part of invalid neurons in the global neural network by the training set during the training of the global neural network, and improves the training efficiency.

[0046] Optionally, the first local neural network includes neurons in the global neural network used to identify the target class; the first class and the second class are two classes in the plurality of classes; the class feature of the first class is similar to the class feature of the second class, and the more the same neurons in the neurons used to identify the first class and the neurons used to identify the second class in the global neural network are, the more the same neurons in the neurons used to identify the first class and the neurons used to identify the second class in the global neural network are.

[0047] In a possible implementation, the target class feature includes n-dimensional data, where n is a positive integer, and the pruning the global neural network according to the target class feature to obtain the first local neural network includes:

[0048] For each piece of data in the n-dimensional data, a probability distribution corresponding to each piece of data is generated with the each piece of data as a mean value, to obtain n probability distributions, which correspond to the n-dimensional data one by one;

[0049] The global neural network is pruned according to the n probability distributions to obtain the first local neural network.

[0050] Optionally, the pruning the global neural network according to the n probability distributions to obtain the first local neural network includes:

[0051] Each layer structure in the global neural network is encoded respectively;

[0052] A distribution value of each neuron in each layer structure in the global neural network is determined as a value corresponding to the encoding of the each neuron in the probability distribution corresponding to the each layer structure, the n dimensions have a corresponding relationship with the layer structures in the global neural network, and the probability distribution corresponding to the each layer structure is a probability distribution corresponding to a dimension corresponding to the each layer structure in the n probability distributions;

[0053] Neurons with a distribution value less than a first threshold value in the global neural network are removed to obtain the first local neural network.

[0054] Optionally, the pruning the global neural network according to the n probability distributions to obtain the first local neural network includes:

[0055] All neurons in the global neural network are encoded;

[0056] Each probability distribution of the n probability distributions is added after being increased by a bias value, and then superimposed;

[0057] A distribution value of each neuron in the global neural network is determined as a value corresponding to the encoding of the each neuron in the superimposed probability distribution;

[0058] Neurons with a distribution value less than a second threshold value in the global neural network are removed to obtain the first local neural network.

[0059] Optionally, the target class includes at least two classes, and the obtaining the target class feature includes:

[0060] The class features of each class in the target class are weighted and summed to obtain the target class feature.

[0061] In a possible implementation, the target classes include at least two classes, the target class features include class features of each of the at least two classes, and the pruning of the global neural network according to the target class features to obtain the first local neural network includes:

[0062] generating, for each of the target classes, a probability distribution of the each of the target classes according to the class feature of the each of the target classes, and determining, according to the probability distribution of the each of the target classes, neurons in the global neural network that act on the each of the target classes;

[0063] determining the neurons in the global neural network that act on the target classes as a union of the neurons in the global neural network that act on all of the target classes respectively;

[0064] removing, from the global neural network, neurons other than the neurons that act on the target classes to obtain the first local neural network.

[0065] Optionally, the class feature of the each of the target classes includes n-dimensional data, n is a positive integer, and the generating of the probability distribution of the each of the target classes according to the class feature of the each of the target classes includes:

[0066] generating, for each of the n-dimensional data, a probability distribution corresponding to the each of the n-dimensional data with the each of the n-dimensional data as a mean value, to obtain n probability distributions, the n probability distributions correspond to the n-dimensional data one by one, and the probability distribution of the each of the target classes includes the n probability distributions.

[0067] Further, the determining of the neurons in the global neural network that act on the each of the target classes according to the probability distribution of the each of the target classes includes:

[0068] encoding each layer structure in the global neural network respectively;

[0069] determining a distribution value of each neuron in the each layer structure in the global neural network as a value corresponding to the encoding of the each neuron in the probability distribution corresponding to the each layer structure, the n dimensions have a corresponding relationship with the layer structures in the global neural network, and the probability distribution corresponding to the each layer structure is a probability distribution corresponding to a dimension corresponding to the each layer structure in the n probability distributions;

[0070] removing, from the global neural network, neurons with a distribution value less than a third threshold value to obtain the neurons in the global neural network that act on the each of the target classes.

[0071] Optionally, the determining of the neurons in the global neural network that act on the each of the target classes according to the probability distribution of the each of the target classes includes:

[0072] encoding all neurons in the global neural network;

[0073] superimposing each probability distribution of the n probability distributions after adding a bias to the each probability distribution;

[0074] determining a distribution value of each neuron in the global neural network as a value corresponding to the encoding of the each neuron in the superimposed probability distribution;

[0075] removing neurons in the global neural network with a distribution value less than a fourth threshold value, to obtain neurons in the global neural network that act on the each class.

[0076] In a possible implementation, the method further includes:

[0077] sending the second local neural network to a server, the server being configured to update the global neural network according to the second local neural network.

[0078] In a possible implementation, before the target class feature is acquired, the method further includes:

[0079] extracting a feature of the target class from each sample in the training set, to obtain a feature corresponding to the each sample;

[0080] performing weighted average on the features corresponding to all samples in the training set, to obtain a class center of the target class;

[0081] sending the class center of the target class to the server, the class center of the target class being used by the server to determine the target class feature.

[0082] In a possible implementation, the target class includes at least two classes, and the target class feature includes class features of the at least two classes, before the target class feature is acquired, the method further includes:

[0083] for each class in the target class, extracting a feature of the each class from samples belonging to the each class in the training set, and performing weighted average on the features corresponding to the samples belonging to the each class, to obtain a class center of the each class;

[0084] sending the class centers of all classes in the target class to the server, the class center of the each class being used by the server to determine the class feature of the each class.

[0085] In a third aspect, an embodiment of the present application further provides a neural network training method, including:

[0086] sending a global neural network to a plurality of user terminals; the global neural network being configured to identify a plurality of classes;

[0087] receive second local neural networks respectively sent by the plurality of user terminals, the second local neural networks being used for identifying a target class, the plurality of classes including the target class, the second local neural networks being obtained by the user terminals by training a first local neural network, the first local neural network being obtained by the user terminals by pruning the global neural network according to target class features, the target class features being used for characterizing characteristics of samples belonging to the target class in the training set;

[0088] update the global neural network according to the received second local neural networks.

[0089] The method described above prunes the global neural network based on target class features, avoids arbitrary update of part of invalid neurons in the global neural network by the training set during training of the global neural network, and improves training efficiency.

[0090] Optionally, the updating the global neural network according to the received second local neural networks comprises:

[0091] for each neuron in the global neural network, determining that a network parameter of the each neuron in the updated global neural network is a weighted average of a network parameter of the each neuron in the received second local neural network.

[0092] Optionally, the method further comprises:

[0093] receive class centers of the target class respectively sent by the at least one user terminal, the class center of the target class sent by a first user terminal being obtained by performing weighted average on features extracted from samples belonging to the target class in a training set of the first user terminal;

[0094] determine the target class features according to the received class centers of the target class.

[0095] In a fourth aspect, the embodiments of the present application further provide a neural network training method, comprising:

[0096] receive target class features sent by a user terminal, the target class features being used for characterizing characteristics of samples belonging to the target class in a training set;

[0097] prune a global neural network according to the target class features to obtain a local neural network, the global neural network being used for identifying a plurality of classes, the local neural network being used for identifying the target class, the plurality of classes including the target class;

[0098] send the local neural network to the user terminal, so that the user terminal trains the local neural network by using the training set;

[0099] updating the global neural network according to the trained local neural network.

[0100] The method prunes the global neural network based on the target class feature, avoids arbitrary updating of part of invalid neurons in the global neural network by the training set during training of the global neural network, and improves training efficiency.

[0101] In a fifth aspect, an embodiment of the present application further provides a neural network training method, which comprises:

[0102] obtaining a target class feature, wherein the target class feature is used to represent characteristics of samples belonging to a target class, and the target class comprises a class to which samples in a training set belong;

[0103] determining neurons in a global neural network that affect the target class according to the target class feature;

[0104] training the global neural network by using the training set to obtain a trained global neural network, wherein the global neural network is used to identify multiple classes, the multiple classes comprise the target class, and the training restricts an updating or changing amount of neurons in the global neural network other than the neurons that affect the target class.

[0105] The method determines the neurons that affect the target class when training the global neural network, and then trains the global neural network, thereby avoiding arbitrary updating of part of invalid neurons in the global neural network by the training set during training of the global neural network, and improving training efficiency and model accuracy.

[0106] Optionally, the training restriction can include two implementation manners: ①, during training of the global neural network by using the training set, parameters of the neurons that affect the target class are updated, and parameters of the neurons that do not affect the target class are not updated; ②, during training of the global neural network by using the training set, a large penalty term is applied to parameters of the neurons that do not affect the target class to reduce the variable of the parameters of the neurons that do not affect the target class, and parameters of the neurons that affect the target class can be unconstrained or subjected to smaller constraint, which can be realized by setting of an algorithm function.

[0107] In a sixth aspect, an embodiment of the present application further provides a class identification method, which comprises:

[0108] obtaining a target class feature, wherein the target class feature is used to represent characteristics of data belonging to a target class;

[0109] The global neural network is pruned according to the target class feature, to obtain a local neural network, wherein the global neural network is used for identifying a plurality of classes, and the local neural network is used for identifying the target class, and the plurality of classes includes the target class.

[0110] The data to be identified is input into the local neural network, to obtain an identification result.

[0111] Optionally, the target class includes at least two classes, and the obtaining of the target class feature includes:

[0112] The class features of each class in the target class are weighted and summed, to obtain the target class feature.

[0113] Optionally, the specific implementation of pruning the global neural network according to the target class feature to obtain a local neural network can refer to the related description in the first aspect, which will not be repeated here.

[0114] The above method prunes a global neural network according to a target class feature, to obtain a local neural network required by the global neural network, and then the local neural network can be run to perform class identification, so that the fast identification of a class can be realized in a terminal with less computing resources. Further, different users can prune a neural network required by themselves according to a class to be identified, and the flexibility is high.

[0115] In a seventh aspect, the embodiments of the present application further provide a neural network pruning apparatus, which includes: functional units for implementing the method in any possible implementation of the first aspect, which can refer to the related description in the first aspect, and will not be repeated here.

[0116] In an eighth aspect, the embodiments of the present application further provide a neural network pruning apparatus, which includes: one or more processors, one or more memories, and a communication interface; the one or more memories are coupled with the one or more processors, and are used for storing computer program codes; the computer program codes include computer instructions, and when the one or more processors execute the computer instructions, the terminal executes the method in any implementation of the first aspect.

[0117] In a ninth aspect, the embodiments of the present application further provide a neural network training apparatus, which includes: functional units for implementing the method in any possible implementation of the second aspect, which can refer to the related description in the second aspect, and will not be repeated here.

[0118] In a tenth aspect, the embodiments of the present application further provide a neural network training apparatus, comprising: one or more processors, one or more memories, a communication interface; the one or more memories are coupled to the one or more processors, and are configured to store computer program codes, the computer program codes comprising computer instructions, when the one or more processors execute the computer instructions, the terminal executes the method according to any implementation of the second aspect.

[0119] In an eleventh aspect, the embodiments of the present application further provide a neural network training apparatus, comprising: functional units for implementing the method according to any possible implementation of the third aspect, which can be specifically referred to the related description of the third aspect above, and will not be repeated here.

[0120] In a twelfth aspect, the embodiments of the present application further provide a neural network training apparatus, comprising: one or more processors, one or more memories, a communication interface; the one or more memories are coupled to the one or more processors, and are configured to store computer program codes, the computer program codes comprising computer instructions, when the one or more processors execute the computer instructions, the terminal executes the method according to any implementation of the third aspect.

[0121] In a thirteenth aspect, the embodiments of the present application further provide a neural network training apparatus, comprising: functional units for implementing the method according to any possible implementation of the fourth aspect, which can be specifically referred to the related description of the fourth aspect above, and will not be repeated here.

[0122] In a fourteenth aspect, the embodiments of the present application further provide a neural network training apparatus, comprising: one or more processors, one or more memories, a communication interface; the one or more memories are coupled to the one or more processors, and are configured to store computer program codes, the computer program codes comprising computer instructions, when the one or more processors execute the computer instructions, the terminal executes the method according to any implementation of the fourth aspect.

[0123] In a fifteenth aspect, the embodiments of the present application further provide a neural network training apparatus, comprising: functional units for implementing the method according to any possible implementation of the fifth aspect, which can be specifically referred to the related description of the fifth aspect above, and will not be repeated here.

[0124] In a sixteenth aspect, an embodiment of the present application further provides a neural network training apparatus, comprising: one or more processors, one or more memories, and a communication interface; the one or more memories are coupled to the one or more processors, and are configured to store computer program codes, the computer program codes comprising computer instructions, when the one or more processors execute the computer instructions, the terminal executes the method according to any possible implementation of the fifth aspect.

[0125] In a seventeenth aspect, an embodiment of the present application further provides a class identification apparatus, comprising: functional units for implementing the method according to any possible implementation of the sixth aspect, which can be referred to the related description of the sixth aspect.

[0126] In an eighteenth aspect, an embodiment of the present application further provides a class identification apparatus, comprising: one or more processors, one or more memories, and a communication interface; the one or more memories are coupled to the one or more processors, and are configured to store computer program codes, the computer program codes comprising computer instructions, when the one or more processors execute the computer instructions, the terminal executes the method according to any possible implementation of the sixth aspect.

[0127] In a nineteenth aspect, an embodiment of the present application further provides a computer program product comprising instructions, when the computer program product is executed on an electronic device, the electronic device executes the method according to any possible implementation of any one of the first to sixth aspects.

[0128] In a twentieth aspect, an embodiment of the present application further provides a computer readable storage medium, the computer readable medium is configured to store program codes, the program codes comprising instructions for executing the method according to any possible implementation of any one of the first to sixth aspects.

[0129] In a twenty-first aspect, an embodiment of the present application further provides a chip, the chip comprising a processor and a data interface, the processor reading instructions stored on a memory through the data interface, and executing the method according to any possible implementation of any one of the first to sixth aspects.

[0130] Optionally, as an implementation manner, the chip can further comprise a memory, the memory storing instructions, and the processor is configured to execute the instructions stored on the memory, when the instructions are executed, the processor is configured to execute the method according to any possible implementation of any one of the first to sixth aspects. BRIEF DESCRIPTION OF DRAWINGS

[0131] FIG. 1A is a schematic diagram of an architecture of a system provided by an embodiment of the present application;

[0132] FIG. 1B-1F is an architecture schematic diagram of five federated learning systems provided by an embodiment of the present application;

[0133] FIG. 2A is a schematic diagram of a class feature calculation method provided by an embodiment of the present application;

[0134] FIG. 2B is a flow schematic diagram of a class feature calculation method provided by an embodiment of the present application;

[0135] FIG. 3 is a flow schematic diagram of a method for determining neurons in a global neural network that affect a target class provided by an embodiment of the present application;

[0136] FIG. 4A is an example diagram of a correspondence relationship between n-dimensional data of a target class and a layer structure in a global neural network provided by an embodiment of the present application;

[0137] FIG. 4B is a schematic diagram of a principle for determining neurons in a first layer structure that affect a target class based on a first probability distribution provided by an embodiment of the present application;

[0138] FIG. 4C is a flow schematic diagram of a method for determining neurons in a first layer structure that affect a target class based on a first probability distribution provided by an embodiment of the present application;

[0139] FIG. 5A is a flow schematic diagram of a method for determining neurons in a global neural network that affect a target class provided by an embodiment of the present application;

[0140] FIG. 5B is a schematic diagram of an encoding method of a global neural network provided by an embodiment of the present application;

[0141] FIG. 5C is a schematic diagram of a method for determining neurons in a global neural network that affect a target class provided by an embodiment of the present application;

[0142] FIG. 6A is a schematic diagram of a method for determining a template of a first layer structure in a pruning template provided by an embodiment of the present application;

[0143] FIG. 6B is a schematic diagram of a pruning template provided by an embodiment of the present application;

[0144] FIG. 6C is a schematic diagram of a method for determining a pruning template of a target class provided by an embodiment of the present application;

[0145] FIG. 7Ais a flowchart of a pruning method of a neural network provided by an embodiment of the present application;

[0146] FIG. 7B is a flowchart of another pruning method of a neural network provided by an embodiment of the present application;

[0147] FIG. 7C is a schematic explanatory diagram of a pruning method of a neural network provided by an embodiment of the present application;

[0148] FIG. 8 is a flowchart of a training method of a neural network provided by an embodiment of the present application;

[0149] FIG. 9 is a flowchart of another training method of a neural network provided by an embodiment of the present application;

[0150] FIG. 10 is a flowchart of another training method of a neural network provided by an embodiment of the present application;

[0151] FIG. 11 is a flowchart of another training method of a neural network provided by an embodiment of the present application;

[0152] FIG. 12 is a flowchart of another training method of a neural network provided by an embodiment of the present application;

[0153] FIG. 13 is a flowchart of another training method of a neural network provided by an embodiment of the present application;

[0154] FIG. 14 is a flowchart of a classification method provided by an embodiment of the present application;

[0155] FIG. 15A-15B is a structural schematic diagram of a pruning device of two neural networks provided by an embodiment of the present application;

[0156] FIG. 16 is a structural schematic diagram of a pruning device of a neural network provided by an embodiment of the present application;

[0157] FIG. 17 is a structural schematic diagram of a training device of a neural network provided by an embodiment of the present application;

[0158] FIG. 18 is a structural schematic diagram of another training device of a neural network provided by an embodiment of the present application;

[0159] FIG. 19 is a structural schematic diagram of another training device of a neural network provided by an embodiment of the present application;

[0160] FIG. 20 is a structural schematic diagram of another training device of a neural network provided by an embodiment of the present application;

[0161] FIG. 21 is a structural schematic diagram of another training device of a neural network provided by an embodiment of the present application;

[0162] FIG. 22 is a structural schematic diagram of another training device of a neural network provided by an embodiment of the present application;

[0163] FIG. 23 is a structural schematic diagram of a class identification device provided by an embodiment of the present application;

[0164] FIG. 24 is a structural schematic diagram of a class identification device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0165] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments and are not intended to be limiting of the present application. As used in the specification and the appended claims of the present application, the singular forms “a,” “an” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms “comprises” and / or “comprising,” as used in the specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0166] Generally, when training a neural network (also referred to as a model), multiple training is required, and the samples in the training set used in each training can be unevenly distributed, for example, some classes of samples are missing in the training set. In the training process, the samples of one class only affect the parameter update of a part of neurons in the neural network, however, when some classes of samples are missing in the training set used, the training process will arbitrarily update the parameters of the neurons affected by the missing classes, on the one hand, the update of these neurons itself is invalid, not only increasing the calculation cost of data, on the other hand, the arbitrarily updated values have a bad effect on the neurons affected by the missing classes, resulting in poor accuracy of the model obtained by training.

[0167] In addition, through the study of the existing training method of federated learning, it can be found that in the process of user-side training, the samples of one class only affect the parameter update of a part of neurons in the neural network, since each user only includes some classes of samples, each user only affects the parameter update of a part of neurons in the neural network, and similar users will affect the same part of the neural network. Here, similar users refer to users whose class and class distribution in the training set are similar.

[0168] However, the current federated learning does not consider the objective fact that the training data at the user end is different, and the neural network structure trained by all user ends is still the same, although each user end only updates the parameters of part of the neurons in the neural network, each user end still needs to repeatedly train the complete structure of the neural network, thereby causing the problem of low training efficiency.

[0169] In addition, when the user does not have corresponding training data, some neurons in the model also need to be updated, and the update of these neurons is invalid itself, which not only increases the calculation cost and transmission cost of data, but also interferes with the training of the entire model. Because, if a neuron has no effect on the inference side along the forward propagation process, updating the parameters of the neuron to any value will not have a bad effect on the local training result; however, this value may have a great influence on other neurons, so the local update of the neuron that does not work will have a bad effect. In summary, in addition to the transmission and calculation cost, limiting the arbitrary update of the local training to the invalid neurons may not show a bad effect on the local side, but it brings very bad problems to other neurons, resulting in a poor accuracy of the model obtained by training.

[0170] Based on the above analysis, the embodiments of the present application provide the following methods:

[0171] The embodiments of the present application provide a pruning method of a neural network. In the process of training a complete structure of a neural network (also referred to as a global neural network in the present application), the global neural network is pruned according to a class (also referred to as a target class) contained in a training set, so as to remove neurons in the global neural network that do not work for the target class, and obtain a local neural network that can recognize the target class. The global neural network is used to recognize a plurality of classes, the local neural network is used to recognize the target class, and the plurality of classes include the target class. The present application takes the global neural network used to recognize M classes as an example for illustration, and M is a positive integer greater than 1.

[0172] Further, based on the local neural network collected above, the present application provides a training method of a neural network. Before training by a training set, the global neural network is pruned by the class of the training set to obtain a local neural network suitable for the user end, and then the local neural network is trained by the training set, which can improve the training efficiency and the accuracy of the model. Further, the global neural network can be updated according to the local neural networks pruned and trained by different training sets respectively.

[0173] The embodiment of the present application provides a neural network training method. In the training process, according to a class in a training set, a neuron of the neural network which is used for the class in the training set in a complete structure (also referred to as a global neural network in the present application) is determined, then when the global neural network is updated by the training set, only the neuron which is used for the class in the training set is updated or the updating amount of the neuron which is not used for the class in the training set is reduced, and then the training efficiency and the accuracy of the model are improved.

[0174] For example, in the training process of the global neural network by the training set, only the neuron which is used for the class in the training set in the global neural network is updated, and the updating of the neuron which is not used for the class in the training set is avoided, so that the training efficiency and the accuracy of the model are improved.

[0175] For example, in the training process of the global neural network by the training set, the updating of the neuron which is not used for the class in the training set is constrained, so that the updating amount of the neuron which is not used for the class in the training set is reduced, and the accuracy of the model is improved.

[0176] The above method will be described in detail in the following embodiment.

[0177] The terms and concepts related to the embodiment of the present application are described below.

[0178] (1) Neural network

[0179] The neural network can be composed of neural units (also referred to as neurons). The neural unit can refer to an operation unit with x s and an intercept 1 as inputs. The output of the operation unit can be:

[0180]

[0181] Wherein, s=1, 2, …n, n is a natural number greater than 1, W s is the weight of x s , and b is the bias of the neural unit. f is an activation function of the neural unit, which is used to introduce a nonlinear characteristic into the neural network to convert the input signal in the neural unit into an output signal. The output signal of the activation function can be used as the input of the next convolution layer. The activation function can be a sigmoid function. The neural network is a network formed by connecting many single neural units described above, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected with the local receptive field of the previous layer to extract the features of the local receptive field, and the local receptive field can be a region composed of several neural units.

[0182] (2) Deep neural network

[0183] Deep neural network (DNN), also known as multi-layer neural network, can be understood as a neural network with many hidden layers, where "many" has no special measurement. From the position of different layers of DNN, the neural network inside DNN can be divided into three categories: input layer, hidden layer, and output layer. Generally, the first layer is the input layer, the last layer is the output layer, and the number of layers in between is the hidden layer. The layers are fully connected, that is, any neuron in the ith layer is connected to any neuron in the (i+1)th layer. Although DNN looks very complex, in terms of the work of each layer, it is actually not complex, which is simply expressed as the following linear relationship expression: wherein, is an input vector, is an output vector, b is a bias vector, W is a weight matrix (also called a coefficient), and a() is an activation function. Each layer only obtains the output vector from the input vector by such a simple operation. Since DNN has many layers, the number of coefficients W and bias vectors b is also large. These parameters are defined in DNN as follows: taking the coefficient W as an example: assuming in a three-layer DNN, the linear coefficient from the 4th neuron of the second layer to the 2nd neuron of the third layer is defined as The superscript 3 represents the layer number of the coefficient W, and the subscript corresponds to the output third layer index 2 and the input second layer index 4. In summary, the coefficient from the kth neuron of the (L-1)th layer to the jth neuron of the Lth layer is defined as It should be noted that the input layer has no W parameter. In a deep neural network, more hidden layers allow the network to better describe complex situations in the real world. In theory, the more parameters a model has, the higher its complexity and "capacity", which means it can complete more complex learning tasks. Training a deep neural network is a process of learning the weight matrix, and the ultimate goal is to obtain the weight matrix of all layers of the trained deep neural network (the weight matrix formed by many layers of vectors W).

[0184] (3) Convolutional neural network (CNN)

[0185] A convolutional neural network (CNN) is a deep neural network with a convolutional structure. A CNN contains a feature extractor composed of convolutional layers and sub-sampling layers. The feature extractor can be regarded as a filter, and the convolution process can be regarded as using a trainable filter to convolve with an input image or a convolutional feature map. A convolutional layer refers to a layer of neurons in a CNN that performs convolutional processing on an input signal. In a convolutional layer of a CNN, a neuron can be connected to only a portion of the neurons in the adjacent layer. A convolutional layer typically contains several feature maps, each of which can be composed of a number of rectangularly arranged neurons. The neurons in the same feature map share weights, where the shared weights are convolutional kernels. The shared weights can be understood as being independent of the way and position of extracting image information. The underlying principle is that the statistical information of a portion of an image is the same as that of another portion, which means that the image information learned in one portion can also be used in another portion. Therefore, the same learned image information can be used for all positions on the image. In the same convolutional layer, multiple convolutional kernels can be used to extract different image information. Generally, the more the number of convolutional kernels, the more the image information reflected by the convolutional operation.

[0186] The convolutional kernels can be initialized in the form of a matrix of random size, and the convolutional kernels can obtain reasonable weights through learning in the training process of the CNN. In addition, the direct benefit of shared weights is to reduce the connections between the layers of the CNN and to reduce the risk of overfitting.

[0187] (4) Recurrent neural networks (RNNs)

[0188] The purpose of RNNs is to process sequential data. In a traditional neural network model, the connection between layers is full connection, and the nodes between layers are not connected. However, such a general neural network is powerless for many problems. For example, to predict the next word of a sentence, the previous words need to be used because the words in a sentence are not independent. RNNs are called recurrent neural networks because the current output of a sequence is related to the previous output. Specifically, the network can memorize the previous information and apply it to the calculation of the current output, that is, the nodes between the hidden layers are connected, and the input of the hidden layer includes not only the output of the input layer but also the output of the hidden layer at the previous time. In theory, RNNs can process sequential data of any length.

[0189] Training RNNs is similar to training traditional ANNs (Artificial Neural Networks). It also uses the backpropagation (BP) algorithm, but with a key difference. In RNNs, the parameters W, U, and V are shared when the network is unfolded, unlike in traditional neural networks. Furthermore, in gradient descent, the output at each step depends not only on the current step's network state but also on the states of the network from several previous steps. For example, at t=4, it needs to propagate three more steps, adding various gradients to each of those three steps. This learning algorithm is called Backpropagation Through Time (BPTT).

[0190] Since we already have artificial neural networks and convolutional neural networks, why do we need recurrent neural networks? The reason is simple: both convolutional neural networks and artificial neural networks are based on the premise that elements are independent of each other, and input and output are also independent, like cats and dogs. However, in the real world, many elements are interconnected, such as stock prices changing over time. Someone might say, "I love traveling, and my favorite place is Yunnan. I definitely want to go there someday." To fill in the blank, most people would know to fill in "Yunnan" because we infer from the context. But achieving that level of accuracy is quite difficult. Therefore, recurrent neural networks were developed. Their essence is to possess the ability to remember, just like humans. Therefore, their output depends on the current input and the memories they hold.

[0191] An RNN can consist of multiple unit structures, and each unit structure performs the same function. In short, an RNN is a reusable unit structure. Multiple unit structures can share network parameters.

[0192] An RNN is a sequence-to-sequence model, assuming x t-1 ,x t ,x t+1 If the input is "I am China", then o t-1 ,o t The corresponding words should be "is" and "China". What is the most likely next word? It's "o". t+1 It's more likely to be a "human".

[0193] Therefore, we can define it as follows:

[0194] X t : Represents the input at time t, o t : represents the output at time t, S t: represents the memory at time t. Because the output at the current time is determined by the memory and the output at the current time, just like you are now in your senior year, your knowledge is a combination of the knowledge learned in the senior year (current input) and the things learned before the third year (memory), RNNs are similar in this regard, and neural networks are best at integrating a lot of content through a series of parameters, and then learning the parameters, thus defining the basis of RNNs:

[0195] S t = f(U*X t +W*S t -1) The f() function is the activation function in the neural network, but why is it added? For example, if you have learned very good problem-solving methods in college, do you still use the problem-solving methods in junior high school? Obviously not. The idea of RNN is the same, since you can remember, of course, only important information is remembered, and other unimportant information is forgotten. But what is the best way to filter information in a neural network? It must be an activation function, so an activation function is used here to do a nonlinear mapping to filter information, which may be tanh or other.

[0196] Suppose you are about to graduate in your senior year and take the exam, do you remember the content you have learned before taking the exam, or do you take the exam directly with a few books? Obviously, the idea of RNN is to predict with the current memory S t to predict. If you want to predict the probability of the next word appearing in "I am Chinese", it is obvious that softmax is used to predict the probability of each word appearing, but the prediction cannot be directly predicted with a matrix, so a weight matrix V is used to predict, which is expressed as: o t = softmax(VS t ) where o t represents the output at time t.

[0197] It should be understood that W, U, and V are equal at each time (weight sharing). RNNs can include long short-term memory (LSTM) networks, stacked recurrent neural networks (SRNN), etc.

[0198] (5) Loss function

[0199] In the process of training a deep neural network, because the output of the deep neural network is expected to be as close as possible to the value that is actually intended to be predicted, the weight vector of each layer of the neural network can be updated according to the difference between the predicted value of the current network and the target value that is actually intended to be predicted (of course, before the first update, a process of pre-configuring parameters for each layer of the deep neural network is usually performed), for example, if the predicted value of the network is too high, the weight vector is adjusted to make it predict a lower value, and the adjustment is continuously performed until the deep neural network can predict the target value that is actually intended to be predicted or a value very close to the target value. Therefore, it is necessary to define in advance "how to compare the difference between the predicted value and the target value", which is a loss function or an objective function, which is an important equation for measuring the difference between the predicted value and the target value. Taking the loss function as an example, the higher the output value (loss) of the loss function, the greater the difference, and then the training of the deep neural network becomes a process of trying to minimize the loss.

[0200] (6) Back propagation algorithm

[0201] The convolutional neural network can use a back propagation (BP) algorithm to correct the size of the parameters in the convolutional neural network during the training process, so that the reconstruction error loss of the convolutional neural network becomes smaller and smaller. Specifically, the forward propagation of the input signal until the output generates an error loss, and the error loss information is propagated backward to update the parameters in the convolutional neural network, so that the error loss converges. The back propagation algorithm is a back propagation movement dominated by error loss, aiming to obtain optimal parameters of the convolutional neural network, such as a weight matrix.

[0202] (7) Training data, training set, sample, class

[0203] In this application, the training data includes one or more training sets; a training set includes a large number of samples, and a sample is composed of input data and a label, and the label in this application is a class (referred to as "class" for short). For example, in the field of image recognition, the label of a sample can be an object to be recognized or a type of object, such as a cat, a dog, a chicken, a duck, a peony, a Chinese rose, a willow tree, etc. For another example, in the field of natural language processing, the label of a sample can be an intent, such as turning on a TV, turning off a light, opening a door, booking a ticket, querying a hotel, etc. Different training sets are used in multiple training processes, which can be reflected in different input data and labels of the samples. Among them, a training set can include samples of at least one class, also known as samples belonging to a target class, and class features of the class can be extracted from the samples belonging to the class, and the class features can be composed of multidimensional data. The more similar two training sets are, the more similar the class features extracted therefrom are, and the more neurons in the neural network that are affected by both training sets.

[0204] The training set includes one or more samples. A sample can include input data and a label. Wherein, in a round of training process, the set of samples used for training the neural network, it is understood that the training of the neural network by the training data can include performing multiple rounds of training process, in each round of training process, the neural network obtained by the last training is trained by the training set. It is also understood that the training sets used in each round of training process are different.

[0205] (8) Class feature

[0206] The class feature is used to represent the characteristics / characteristics of the samples or data belonging to a class, which is usually described by one or more dimensions. The class features of the samples belonging to the same class are the same. The class features of different classes are different. In the embodiments of the present application, the more similar the classes, the more similar the class features. For example, in the field of image recognition, the classes can include cats, dogs, chickens, etc. The similarity of the class features of cats and dogs is greater than the similarity of the class features of cats and chickens.

[0207] The class feature of the user (also referred to as the class feature of the user end) is used to represent the characteristics of the class to which the training set or data included in the user end belongs, which can include the class features of each class in the class (target class) to which the training set or data belongs, or can be obtained by weighted sum of the class features of all classes of the class to which the training set or data belongs. Here, the class to which the training set belongs is the set of classes to which the samples belong, that is, the set of labels of the samples.

[0208] For example, the training set / data of the first user includes samples of cats, dogs, and chickens, the training set / data of the second user includes samples of cats, dogs, and rabbits, and the training set / data of the third user includes samples of pigs, sheep, and cattle. The similarity of the class features of the first user and the second user is greater than the similarity of the class features of the first user and the third user, that is, the similarity of the first user and the second user is greater than the similarity of the first user and the third user.

[0209] The target class feature is used to represent the characteristics of the samples / data belonging to the target class, and in some embodiments, can include the class features of each class in the target class; in other embodiments, the target class feature is the weighted sum of the class features of all classes in the target class.

[0210] The following FIG. 1A A system provided by the embodiments of the present application is introduced, which can include a clipping device 10, a training device 11, and an execution device 12, wherein:

[0211] In one scenario, the pruning device 10 is configured to prune the global neural network 101 according to target class features to obtain a local neural network 102 for identifying target classes. The target class features include class features of each class in the target classes, which can be classes included in the training set D1. The pruning device 10 can send the pruned local neural network 102 to the training device 11. The training device 11 can train the local neural network 102 (also referred to as the first local neural network in this application) through the training set D1, and further obtain a trained local neural network 102 (also referred to as the second local neural network in this application). Further, the training device 11 can update the global neural network based on a plurality of trained local neural networks 103, and through multiple rounds of training, obtain a trained global neural network, also referred to as a class identification model 104 in this application. The training device 11 can send the class identification model 104 to the execution device 12, and the execution device 12 can implement the function of class identification. Specifically, the execution device 12 can input the to-be-identified data into the class identification model 104 to obtain the identification result. Optionally, the pruning device 10 and the training device 11 can be the same device.

[0212] For example, the class identification model 104 is an image identification model, which is a global neural network trained by the training device 11 using a large number of images as training inputs, and can identify a plurality of classes. Inputting a to-be-identified image into the image identification model can obtain the identification result of the to-be-identified image, i.e., the class to which the to-be-identified image belongs.

[0213] In another scenario, after the training device 11 trains the class identification model, the class identification model is a global neural network. The training device 11 can send the class identification model to the pruning device 10, which can prune the class identification model according to target class features to obtain a pruned class identification model, which is a local neural network for identifying target classes, and further send the pruned class identification model to the execution device 12. At this time, the class identification model 104 can be the pruned class identification model, and the execution device 12 can input the to-be-identified data into the pruned class identification model to obtain the identification result of the to-be-identified data. Optionally, the pruning device 10 and the execution device 12 can also be the same device.

[0214] For example, the class identification model 104 is an image identification model that can identify target classes, which is obtained by pruning a global neural network trained using a large number of images as training inputs, and is a local neural network that can identify target classes. Inputting a to-be-identified image into the image identification model can obtain the identification result of the to-be-identified image, i.e., the class to which the to-be-identified image belongs.

[0215] The above pruning device 10, training device 11 or execution device 12 can be a terminal such as a mobile phone, a tablet computer, a personal computer, a smart television, a smart watch, a VR / AR device, etc., and can also be a server, a cloud, etc.; and can be a device or a distributed computer system composed of multiple computing nodes.

[0216] It should be understood that the more similar the class features of two classes (such as the first class and the second class), that is, the more similar the first class and the second class, the more the same neurons in the neurons in the global neural network that act on the samples corresponding to the first class and the neurons in the global neural network that act on the samples corresponding to the second class. Therefore, during training, the neurons acting on each class can be set to satisfy the two classes with similar class features, and the more the same neurons in the neurons acting on each class. Based on this, the neurons in the global neural network acting on one or more classes can be determined based on the class features of the one or more classes.

[0217] The training device 11 can complete the training of the global neural network alone or together with the pruning device 10, or can train the global neural network through a federated learning system. After determining the neurons in the global neural network acting on the target class, the global neural network can be trained through the training set, and the global neural network can be pruned or not pruned during training. Only the neurons acting on it in the global neural network can be updated to reduce the amount of calculation, or the amount of change of the neurons not acting on it can be reduced to improve the accuracy of the model obtained by training. Among them, the following two methods can be used to achieve:

[0218] Method (I), also known as network pruning training method:

[0219] During the training of the global neural network through the training set, the global neural network can be pruned based on the class features of the target classes included in the training set to prune the neurons in the global neural network that do not act on the training set, retain the neurons that act on the training set, and obtain a local neural network (also referred to as a first local neural network) suitable for the training set; the first local neural network is trained through the training set to obtain a trained local neural network (i.e., a second local neural network); and then, the global neural network is updated by collecting the second local neural networks trained by multiple training sets. Through multiple rounds of training processes, the final global neural network can be obtained.

[0220] Method (II), also known as network constraint training method:

[0221] During the training of the global neural network by the training set, the neurons in the global neural network that do not work on the training set can be determined based on the class features of the target classes included in the training set; the neurons are constrained during the training, that is, the amount of change of the network parameters of the neurons that do not work on the training set in the global neural network is reduced, or the update of the network parameters of the neurons that do not work on the training set in the global neural network is prohibited, and then the global neural network trained by the training set is obtained; and then the global neural network is updated by collecting the global neural networks trained by the multiple training sets. Through multiple rounds of training processes, the final global neural network can be obtained.

[0222] The following will be described in combination with FIG. 1B-1E A federated learning system is introduced in the present application, which can include at least one user terminal 100 and a server 200. In the training, each training set can come from a different user terminal 100, and each user terminal 100 has its own training set, which is only used to train the model locally.

[0223] The server 200 can also be referred to as a center device, a center server, or a platform, a cloud, etc. A neural network can be constructed, which is referred to as an initialized global neural network in the present application, that is, a neural network that needs to be trained. The server 200 does not contain training data and needs to rely on each user terminal 100 to realize the training of the global neural network. In the embodiments of the present application, the global neural network is taken as an example of a neural network for identifying m classes, and m is a positive integer greater than 1.

[0224] The user terminal 100, which can also be referred to as a node device, a user, or a user device, etc., has its own training set, which includes multiple samples, each of which is labeled with a class. The training sets owned by each user terminal 100 are different, which can be reflected in the difference in classes, class distribution, etc. For the same user terminal 100, the samples of each class in its training set can be unevenly distributed. Here, uneven class distribution means that in a user terminal 100, the proportions of samples of each class are inconsistent. For example, as shown in FIG. 1B-1F The training set of user terminal U1 mainly includes samples belonging to class 1, the training set of user terminal U2 mainly includes samples belonging to class 2, and the training set of user terminal U Q mainly includes samples belonging to class m. The distribution of samples in the training sets of the user terminals 100 shown in the above FIG. 1B-1F The distribution of samples in the training sets of the user terminals 100 shown in the above i is only an example for illustrative purposes, and other distributions can also be included, which are not limited. It should be understood that the user terminal U i is the i-th user terminal in the Q user terminals, and i is a positive integer not greater than Q.

[0225] The training set of each user terminal 100 cannot be externally transmitted due to user privacy and other factors, and becomes a "data island". However, the class characteristics of the user terminal 100 (which can also be referred to as the class characteristics of the user) are determined according to the classes of the user terminal or according to the classes, distribution of classes, etc. in the training set thereof, and vice versa, the class characteristics of the user terminal 100 can reflect the classes in the training set of the user terminal 100 or reflect the classes, distribution of classes, etc. in the training set to some extent. It should be understood that the closer the classes in the training set of the first user terminal are to the classes in the training set of the second user terminal, or the closer the classes and distribution are, the more similar the class characteristics of the first user terminal are to the class characteristics of the second user terminal, and the more the same neurons in the neurons of the first user terminal training set that affect the global neural network are than the neurons of the second user terminal training set that affect the global neural network.

[0226] Based on this, the user terminal 100 or the server 200 can prune the global neural network according to the class characteristics of the user terminal 100 to obtain a local neural network suitable for the user terminal 101. The Q user terminals 100 can obtain target class characteristics according to the local training set and send them to the server 200. For example, the Q user terminals can be represented as user terminals Ui, i = 1, 2,..., Q, and the user terminal Ui can obtain the target class characteristics according to the local training set and send them to the server 200. i The class characteristics of the user terminal Ui are obtained according to the local training set and sent to the server 200.

[0227] Based on this, the class characteristics of the user terminal 100 can be used to determine the neurons in the global neural network that are affected by the training set or the user terminal 100, and further, the user terminal 100 can remove the neurons in the global neural network that do not affect the training of the global neural network when training the global neural network using the training set, and obtain a local neural network, and only train the local neural network using the training set; or only update the neurons in the global neural network that affect the training, or limit the change amount of the neurons that do not affect the training.

[0228] Based on whether the local neural network needs to be pruned, the execution subject of the pruning, and whether the pruning is performed through a pruning template, the following can be obtained: FIG. 1B-1E The system architecture described above is introduced as follows:

[0229] Federal learning system (1): the user terminal does not prune through the pruning template.

[0230] As shown in the system of FIG. 1B After obtaining the class characteristics of the local training set, the user terminal 100 can not send the class characteristics to the server 100, thereby avoiding leakage of the information. At this time, the Q user terminals 100 and the server 200 jointly perform S training processes to obtain the global neural network obtained by the last training, i.e. the global neural network obtained by the Sth training process It should be understood that S is a positive integer, and S can be different for different model training. In some embodiments, S is the value that ensures the trained global neural network meets requirements, such as an accuracy higher than a preset threshold, such as 80%. Taking the k-th training process as an example, k is a positive integer not greater than S. In the k-th training process:

[0231] Server 200 will obtain the global neural network from the (k-1)th training process. The data is sent to Q user terminals (101 in total); among them, the global neural network obtained in the 0th training process... The global neural network initialized as described above.

[0232] Each user terminal 100 is configured with a global neural network based on its class characteristics. The resulting local neural network (also known as the first local neural network) is cropped and adapted for use. This local neural network is then trained using its local training set to obtain the trained local neural network (also known as the second local neural network), which is then sent to server 200. The following example uses user terminal U... i To illustrate, let's take the user-side U as an example. i Based on the classes contained in its local training set, the target class features are obtained, that is, the class features of the classes contained in the training set. Then, the global neural network is adjusted based on these target class features. Cut to size, suitable for user-side U i Local neural networks Further, this local neural network is trained using its local training set. Training is performed to obtain the trained local neural network. And send the network parameters to server 200.

[0233] Server 200 can aggregate local neural network signals sent from various user terminals 100. Furthermore, server 200, based on the above... Update the global neural network The global neural network is obtained by obtaining the k-th training process. In one specific implementation, the user terminal U i Send the trained local neural network to server 200 The network parameters and network information, which are used to instruct the local neural network. Or trained local neural networks The position of each neuron in the global neural network can be a pruning template. In another specific implementation, the user-side U... i Local neural networks can The network parameters are updated in the template of the global neural network to obtain the global neural network. At this time, the user terminal U i Global neural networks can The network parameters are sent to server 200 to realize the local neural network. The network parameters are sent to the server 200. Optionally, the client 100 may encrypt the above content before sending it to the server 200.

[0234] exist FIG. 1B In the system shown, during each round of training, the user terminal U i The training sets can be different for each client. In this case, due to the continuous changes in the training sets, the user terminal U... i The target class features are constantly changing, and the network structure of the local neural network pruned based on the target class features is also constantly changing. At this time, in each round of training, the user terminal 100 re-obtains the target class features based on the training set used in this training. Then, the user terminal 100 can prune the global neural network obtained in the previous training based on the class features of the user terminal 100 to obtain the local neural network suitable for the user terminal 100 in this training process.

[0235] Federated Learning System (2): The user end uses a trimming template for trimming.

[0236] like FIG. 1C The system shown is similar to the one described above. FIG. 1B The difference in the system shown is that the training set samples used by the same user terminal 100 in each training round are different, but the classes they contain or the distribution of the classes are the same, so that the target class features (class features of user terminal 100) obtained by the same user terminal 100 based on the training set are the same in each training round. In this case, to avoid each user terminal 100 needing to perform cropping based on the target class features in each training round and to reduce the computational load on each user terminal 100, each user terminal 100 generates a cropping template based on its target class features before or during the first training round. In subsequent training rounds, cropping only needs to be performed based on the cropping template. The following uses user terminal U... i To illustrate, let's take the user-side U as an example. i Based on its target class features and the initialized global neural network structure, a user-friendly U is generated. i The cropping template, and then, during the k-th training process, the user-side U i The global neural network obtained from the (k-1)th training process is received. Then, according to the user terminal U i Pruning templates for global neural networks Cut to size, suitable for user-side U i Local neural networks Further, the local neural network is trained by its local training set to obtain a trained local neural network and the network parameters of the trained local neural network are sent to the server 200. The sending of the network parameters of the local neural network to the server 200 is the same as the sending of the network parameters of the local neural network to the server 200 in the federated learning system (1) described above, and can refer to the relevant description in the federated learning system (1) described above.

[0237] It should be understood that the global neural network obtained by the 0th training process is the initialized global neural network. The system diagram described above FIG. 1C In the system diagram described above, each user terminal 100 generates a pruning template according to the class features of each class before or during the first training process, and only needs to prune according to the pruning template in the subsequent training process, which can reduce the calculation amount of the user terminal 100 and improve the training efficiency.

[0238] In one implementation, as shown in the system FIG. 1D , the server 200 obtains the class features of each class of the m classes, determines the neurons in the global neural network that act on each class according to the class features of each class, and the neurons can form a class template. It can be understood that the neurons acting on each class of the m classes can form a class template, and there are m class templates. Further, the server can send the m class templates to each user terminal 100. After receiving the m class templates, the user terminal 100 can determine a pruning template suitable for the user terminal 100 according to the class (i.e., the target class) contained in its local training set, wherein the pruning template can be the union of the class templates of all classes in the target class. Further, the user terminal 100 can prune based on the determined pruning template.

[0239] In the federated learning systems (1) and (2) described above, the user terminal 100 can also apply constraints to the neurons in the local neural network during the training of the local neural network by the local training set. For example, stronger constraints are applied to neurons owned by fewer class templates or neurons acting on fewer classes to reduce the amount of change of the parameters of the neurons during the training process; while stronger constraints are applied to neurons owned by more class templates or neurons acting on more classes or weaker constraints are applied or no constraints are applied to increase the amount of change of the parameters of the neurons during the training process, which can be achieved by setting the loss function. The details are described in other parts of the present application.

[0240] Alternatively, the training process can be constrained based on the number of samples in each class in the training set. For example, for classes with fewer samples, stronger constraints are imposed on the neurons in their class templates to reduce the amount of change in the parameters of those neurons during training; while for classes with fewer samples, weaker constraints or no constraints are imposed on the neurons in their class templates to increase the amount of change in the parameters of those neurons during training.

[0241] Federated Learning System (3): The server uses a trimming template for trimming.

[0242] like FIG. 1E The system shown is similar to the one described above. FIG. 1B or FIG. 1C The difference in the system shown is that after acquiring the target class features, user terminal 100 can send its target class features to server 200, which then performs pruning on the global neural network, thereby avoiding pruning by user terminal 100 and reducing the computational load on user terminal 100. In this embodiment, server 200 can collect the target class features sent by each user terminal 100, and then prune the current global neural network according to the target class features of each user terminal 100 to obtain local neural networks suitable for each user terminal. The pruned local neural networks are then sent to user terminal 100. Server 200 can perform pruning based on target class features or based on a pruning template; this is not limited here.

[0243] In this embodiment, Q user terminals 100 and server 200 can jointly perform multiple training processes on the global neural network. When the trained global neural network model meets the requirements, such as an accuracy higher than a preset threshold (e.g., 80%), the final global neural network is obtained. The k-th training process is used as an example. In the k-th training process:

[0244] Q user terminals 100 each send the target class features obtained from their local training sets to server 200. Server 200 then modifies the global neural network obtained in the (k-1)th training process based on the target class features sent by the Q user terminals 100. After pruning, local neural networks suitable for each user terminal 100 are obtained. Furthermore, server 200 will use the local neural network obtained from the (k-1)th training process... The data is sent to the corresponding user terminal 100. Each user terminal 100 trains the received local neural network using its local training set and then sends the trained local neural network to the server. For example, user terminal U... i The received local neural network is trained using the local training set. Training is performed to obtain the trained local neural network. Furthermore, the user-side U i Local neural networks Send to server 200. Among them, the global neural network obtained in the 0th training process... This is the initialized global neural network. Furthermore, server 200 aggregates the local neural networks {after training} sent by each user terminal 100. The system comprises Q local neural networks. Server 200 updates the global neural network based on these Q local neural networks. The network parameters. For example, for a global neural network. For any neuron in the network, its network parameters can be the average of the parameters of that neuron in Q local neural networks.

[0245] In one implementation, the above FIG. 1D In this context, for each user terminal 100, the target class features of each user terminal 100 are different due to the different training sets used in each round of training.

[0246] In another implementation, similar to the federated learning system (2) described above, the target class features of the user terminal 100 remain unchanged throughout each training round. In this case, the user terminal 100 does not need to send the target class features in each training round, but only needs to send the target class features once during the first training round or before the first training round. Optionally, the server 200 also does not need to prune the global neural network obtained from the previous training round based on the target class features each time, but can prune based on a pruning template applicable to each user terminal 100. The specific implementation is the same as the specific implementation of pruning of the user terminal 100 in the federated learning system (2) described above, and will not be repeated here.

[0247] Federated learning system (4): No cuts or cuts on the client or server.

[0248] like FIG. 1F The system shown involves Q user terminals 100 and server 200 jointly performing multiple training processes to obtain a global neural network that meets the requirements. Taking the k-th training process as an example, where k is a positive integer not greater than S, in the k-th training process:

[0249] Server 200 will obtain the global neural network from the (k-1)th training process. The data is sent to each user terminal 100. Each user terminal 100 obtains target class features based on its local training set, and then determines the received global neural network based on these target class features. The neurons that function in their target class are then used to train the global neural network through this local training set. Perform constrained training to obtain the trained global neural network, and then send it to server 200. For example, user terminal U i Using local training sets to train global neural networks Training is performed to obtain the trained global neural network. Furthermore, the user-side U i Global Neural Network Send to server 200. Server 200 is based on a global neural network trained on Q user terminals 100 respectively. Update the global neural network Obtain the global neural network This refers to the global neural network obtained during the local training process.

[0250] Constraint training includes the following two implementation methods:

[0251] Implementation Method 1: During the local training of the global neural network using the training set, the user terminal 100 only updates the parameters of neurons that have an effect on the network, and does not update the parameters of neurons that do not have an effect. Optionally, the parameters of neurons that do not have an effect can also be set to 0.

[0252] Implementation Method 2: During the local training of the global neural network using the training set, the user terminal 100 applies a large penalty term to the parameters of inactive neurons to reduce the variable affecting the parameters of inactive neurons, while the parameters of active neurons remain unconstrained. This is achieved through the setting of the loss function, which will be described in detail in other sections of this application.

[0253] It should be noted that a global neural network can be a deep neural network such as a convolutional neural network or a recurrent neural network. For more information on neural networks, deep neural networks, convolutional neural networks, and recurrent neural networks, please refer to the relevant descriptions in the terminology and concepts section above; they will not be repeated here.

[0254] The following describes the method embodiments involved in this application.

[0255] Example 1:

[0256] The following describes a method for calculating class features provided by an embodiment of this application, such as... FIG. 2A The schematic diagrams shown and FIG. 2B The flowchart shown above illustrates the method, which can be derived from the above. FIG. 1B-1F This can be implemented using any federated learning system, and the method may include, but is not limited to, the following steps:

[0257] S21: For each of the Q user terminals, the user terminal can extract the features of the target class from its training set to obtain the class center of each class.

[0258] All classes included in the training set of the user end are target classes, and the target classes of different user ends can be different due to different training sets.

[0259] The following describes a method for obtaining a class center of each class by a user end U i . The user end U i is the i-th user end in Q user ends, and i is a positive integer not greater than Q. The training set of the user end U i includes at least one class, and the class center extracted by the user end U i includes a class center of the at least one class. The first class is one of the at least one class. The following describes a method for obtaining a class center of each class in the at least one class. The class center of the first class is obtained based on features extracted from samples belonging to the first class in the local training set of the user end U i , and is used to indicate features of samples belonging to the first class in the local training set of the user end U i . The specific implementation can include, but is not limited to, the following two implementation manners:

[0260] Implementation manner (1): The user end U i may locally calculate the mean of the samples belonging to the first class to obtain the class center of the first class. For example, the training set of the user end U i includes z samples belonging to the first class, and the mean of the data of the z samples is calculated, that is, the data of the corresponding elements in the input data of the z samples is added and then averaged.

[0261] Implementation manner (2): The user end U i may extract features of the samples belonging to the first class through a self-encoder, and then average the features extracted from the samples belonging to the first class to obtain the class center of the first class. The self-encoder can be a self-encoder trained by the server based on training data. The self-encoder includes an encoder and a decoder. The training process of the self-encoder is as follows: a sample belonging to the first class is input into the encoder to obtain features of the first class; the features of the first class are input into the decoder, and the training process is a process of making the difference between the data output by the decoder and the sample input into the encoder smaller and smaller. The self-encoder after training can be used to extract features of samples. Specifically, the user end can input the samples belonging to the first class into the self-encoder respectively, and the output result of the encoder is the features of the first class extracted from the sample. Further, the features of the first class extracted from the samples belonging to the first class can be averaged to obtain an average value, which is the class center of the first class obtained by the user end U i .

[0262] It should be understood that the training data of the autoencoder can include samples belonging to each of the m classes, which can be used to extract features of each of the m classes. The autoencoder is trained with the training data or pseudo-training data, which is machine-generated data that can replace the training data, and the training method of the autoencoder is prior art, which will not be described here.

[0263] S22: The Q user terminals respectively send the class centers of the target classes extracted by the Q user terminals to the server.

[0264] S23: The server processes the received class centers to obtain class features of the m classes. The class feature of each class is a common feature possessed by the samples belonging to the class.

[0265] In some embodiments, the class T j is the jth class in the m classes, j is a positive integer not greater than m, the server collects the class centers sent by the Q user terminals, and the server processes the received class centers of the class T j to obtain the class feature of the class T j . The embodiments of the present application take the class feature of the class T j as an example to illustrate the acquisition method of the class feature of each class. For example, the server receives a total of H class features of the class T j , H is a positive integer not greater than Q, that is, only H user terminals contain samples belonging to the class T j and have extracted the class feature of the class T j ; and some user terminals do not have samples belonging to the class T j , so these user terminals have not extracted the class center of the class T j from their training sets. The following are three implementations for determining the class feature of the class T j :

[0266] Implementation (1): The class feature of the class T j is the average of the class centers of the H classes T j . That is, where X i is the class feature of the class T j , x i,j is the class center of the class T j extracted by the user terminal U i , the user terminal U i is one of the Q user terminals, i = 1, 2, …, Q, and when the user terminal U i does not obtain the class center of the class T j , x i,j is a matrix or vector of all 0.

[0267] Implementation (2): Class T j The class characteristics are the H classes T j The weighted sum of the class centers is, Among them, regarding x i,j The meaning can be referred to in the relevant description in the above implementation (1), w i For user-side U i Extracted class T j The weight of the class center, when the user U i Unobtained class T j When the class center is w i =0. Where, w i It can be obtained in the following three ways:

[0268] In w i In the first implementation, the user-side U i Extracted class T j The weight w of the class center i For user-side U i The percentage of the included sample size to the total sample size of H user terminals (or to the total sample size of Q user terminals).

[0269] In w i In the second implementation, the user-side U i Extracted class T j The weight w of the class center i For user-side U i The training set belongs to this type of T j The sample size and the number of Q user terminals in the training set belonging to this class T j The ratio of the total sample size to the total sample size. It is evident that the method for determining this type of feature allows for a greater contribution of user clients with a larger sample size to the class features of that class.

[0270] In w i In the third implementation, the client sends not only the class center of each class to the server, but also the confidence level of that class center. (Client U) i Extracted class T j The weight w of the class center i For this type of T j The confidence level of the features. It should be understood that class T j The confidence of the class center is related to the class T. j The two matrices are of the same size as the class centers, and the two elements at the same position correspond to each other. That is, the elements in the confidence score represent the confidence score of the element corresponding to that class center. It should also be understood that the user-side U i For those belonging to class T in the training set j Features were extracted from each sample, and the user-side Ui Extracted class T j The class center is the class T that belongs to its local training set. j The average value of the features extracted from each sample, for class T j The confidence of the class center can be that it belongs to class T j The variance is the reciprocal of the variance of the features extracted from each sample, or a value determined based on that variance. It should be understood that the smaller the variance, the more likely the sample contains features of class T. j The more clustered and similar the features are, the greater their credibility. Therefore, the class T extracted from the user terminal is assigned... j The class centers are given greater weight to make the obtained class features more accurate.

[0271] In w h In the third implementation method, the user-side U i Extracted class T j The weights of the features w i The above can be in w i The product of the ratio obtained by the first implementation method and the confidence level obtained by the third implementation method, or the product of the ratio obtained by the second implementation method and the confidence level obtained by the third implementation method, can take into account both sample size and confidence level.

[0272] It should also be understood that the above implementation (1) is a special case of the above implementation (2). In the above implementation (1), class T j The class characteristics are the H classes T j When the average value of the features is reached, the class T extracted by each user terminal is then... j The weights of the class centers are the same.

[0273] Implementation (3): To reduce the dimensionality of class features, avoid the curse of dimensionality, and compress data to improve computational efficiency. In this implementation (3), step S23 may include, but is not limited to, the following steps:

[0274] S231: The server receives class T from the class center. j The class center is processed to obtain class T. j The general characteristics.

[0275] Among them, class T j The calculation method of the general features is the same as that of class T in the above implementation (1) or implementation (2). j The calculation method for class characteristics is the same, and for details, please refer to the relevant descriptions in implementation (1) or implementation (2) above. It should be understood that class T... j The class center and class T j The dimensions of the general features are the same. In implementation (3), class T j Class center / class Tj dimension of the general feature of the class T j dimension n of the class feature of the class T j dimension of the general feature of the class T

[0276] S232: The server determines the similarity between each two classes in the m classes according to the general features of the m classes, to obtain a similarity matrix.

[0277] The similarity between two classes can be obtained by calculating the cosine similarity of the general features of the two classes, or by calculating the Euclidean distance of the general features of the two classes. Alternatively, after obtaining the similarity between each two classes in the m classes, normalization operation can be performed. Alternatively, the similarity between two classes can be calculated in other ways, which are not limited here.

[0278] S233: The server performs dimension reduction on the general feature of each class according to the similarity matrix, to obtain the class feature of each class, wherein the similarity between any two classes remains unchanged before and after dimension reduction. That is, the similarity between each two classes in the m classes obtained in the above step S232 is consistent with the similarity between each two classes in the m classes determined according to the class features of the m classes.

[0279] The dimension reduction method can include but is not limited to principal component analysis (PCA), matrix decomposition, singular value decomposition (SVD), etc. The following takes SVD as an example to illustrate:

[0280] The similarity matrix of the m classes is an m x m matrix, and the value of the element in the fth row and the gth column of the matrix is used to indicate the similarity between the class T f and the class T g The similarity between the class T T and the class T j is obtained by the dot product of the m x u matrix composed of the general features of the m classes and the transpose matrix of the m x u matrix. The m x m similarity matrix can be decomposed to obtain an m x n matrix A and an n x m matrix A j At this time, each row of the matrix A is a class feature of a class.

[0281] It should be noted that this method can also be implemented by the clipping device or the training device or other devices shown in FIG. 1A The device can include multiple training sets, and further, the class features of the m classes can be determined by the above method, or the samples belonging to the class T j in all training sets can be averaged to obtain the class feature of the class T jdimension reduction, to obtain class features of the class T j .

[0282] Further, after obtaining the class features of the m classes, the target class feature can be determined based on the class features. The method of determining the target class feature is further described below, such as FIG. 2B After S23, the target class feature can be determined based on the class features of the m classes, which can be implemented by the server or the user side, FIG. 2B For example only, the method can include but is not limited to the following steps:

[0283] S24: The server sends the class features of the m classes to the user side.

[0284] Wherein, the method of obtaining the class features of the m classes can refer to the related description in the above FIG. 2A embodiments, which will not be repeated here.

[0285] S25: The user side generates the target class feature according to the local training set and the class features of the m classes.

[0286] The embodiments of the present application take the class feature of the user side U i as an example to illustrate the generation method of the target class feature of each user side, and the following are two implementation ways of generating the target class feature provided by the embodiments of the present application:

[0287] Method one: the user side U i can weight sum the class features of the m classes to obtain the target class feature of the user side U i , which can be expressed by the formula: Wherein, for the user side U i , the weight W j of the class feature X j of the class T i,j is the ratio of the sample amount belonging to the class T i in the training set of the user side U j to the total sample amount in the training set of the user side U i .

[0288] Method two: different from the method one, for the user side U i , the weight W j of the class feature X j of the class T i,j is the ratio of the sample amount belonging to the class T i in the training set of the user side U j to the total sample amount belonging to the class T j in the training sets of the Q user sides.

[0289] The target class feature of the user terminal obtained by the above method can represent the characteristics of the training set of the user terminal, and the similar user terminals have similar class features.

[0290] It should be understood that the user terminal can also send the class included in the local training set, i.e., the target class, to the server, and the server performs S25 to send the obtained target class feature of the user terminal to the server.

[0291] It should also be understood that in other embodiments, the target class feature can also be determined in other ways.

[0292] Embodiment two:

[0293] After obtaining the m class features, the neurons in the global neural network that affect the target class can be determined. The target class can be one class or multiple classes, and can be a class included in the local training set of the user terminal or a specified class or classes. For example, FIG. 3 As shown in the method for determining the neurons in the global neural network that affect the target class provided by the embodiments of the present application, the method can be implemented by the clipping device, the training device, or the execution device alone or in combination in the system shown in FIG. 1A As shown in the system shown in FIG. 1B-1F The method can include but is not limited to the following steps:

[0294] S30: generating a probability distribution according to the class feature of the target class.

[0295] The class feature of the target class is also referred to as the target class feature. When the target class includes multiple classes, the class feature of the target class includes the class feature of each class in the target class. The class features, such as the class feature of the target class and the class feature of the user terminal, include n dimensions in the embodiments of the present application, i.e., include n-dimensional data, for example, can be a column vector or a row vector including n-dimensional data.

[0296] In one implementation (1) of S30, the target class includes one class, the class feature of the target class is also referred to as the target class feature, and the target class feature includes n-dimensional data. For each dimension of the n-dimensional data, a probability distribution corresponding to the data can be generated with the data as the mean value, and n probability distributions can be obtained. The n probability distributions correspond one-to-one to the n-dimensional data of the target class feature, and each probability distribution is used to indicate the probability that the neuron corresponding to the probability distribution in the global neural network is not clipped.

[0297] wherein the probability distribution can be a Gaussian distribution generated with the dimension data as the center (or mean) and the first value as the variance, wherein the variance is a hyper-parameter and is a constant. It should be understood that the value of the variance can be the same or different for different dimensions, which is not limited here. In some embodiments, the data of the target class feature can also be calculated according to the class center of the target class.

[0298] Optionally, the probability distribution corresponding to the one-dimensional data can also be a parabola or the like, for example, y = a (x-b) 2 +c, wherein b is the dimension data, and a and c are hyper-parameters and are constants. The values of a or c can be the same or different for different dimensions, which is not limited here.

[0299] In another implementation (2) of S30, the target class includes multiple classes, and the target class feature is a weighted sum of the class features of all classes in the target class, and at this time, the target class feature includes n-dimensional data. As in implementation (1) of S30, for each dimension data in the n-dimensional data, a probability distribution corresponding to the data can be generated with the data as the mean, and n probability distributions are obtained.

[0300] S32: determining the neurons in the global neural network that affect the target class according to the obtained probability distribution.

[0301] wherein the global neural network here can be an initialized global neural network or a global neural network in a training process. The global neural network can include multiple layer structures, and each layer structure includes multiple neurons. Different layer structures can have different functions in the global neural network, and the global neural network can include at least one convolutional layer, at least one pooling layer, at least one excitation layer, at least one fully connected layer, an output layer, etc., a total of E layer structures, and E is a positive integer greater than 1.

[0302] In the above implementation (1) and implementation (2) of S30, the target class feature includes n-dimensional data, and the following are two implementation manners provided by the embodiments of the present application for determining the neurons in the global neural network that affect the target class based on the probability distribution obtained based on the target class feature:

[0303] Implementation manner one:

[0304] Referring to FIG. 8, FIG. 4A different probability distributions act on different layer structures. For example, FIG. 4A wherein the target class feature includes n-dimensional data, and n probability distributions are generated, FIG. 4AThe middle probability distribution 1 is used to determine the neurons in the layer structure 1 that affect the target class, the probability distribution 2 is used to determine the neurons in the layer structure 2 that affect the target class, the probability distribution 2 is used to determine the neurons in the layer structure 2 that affect the target class, and the probability distribution n is used to determine the neurons in the layer structure E that affect the target class. It should be understood that the above-mentioned FIG. 4A The correspondence between the probability distribution and the layer structure is only exemplary, and other correspondences can also be used in the embodiments of the present application. For example, each probability distribution can be used to determine the neurons in at least two consecutive layer structures in the global neural network that affect the target class. For example, the probability distribution 1 is used to determine the neurons in the layer structure 1 and the layer structure 2 that affect the target class. It should be understood that the correspondence between the probability distribution and the layer structure can be determined in advance, and then when generating each probability distribution, the hyperparameters for generating the corresponding probability distribution can be set by considering the functions, positions, and other factors of the layer structures.

[0305] Referring to FIG. 4B , FIG. 4B An implementation method of S32 is shown in the flowchart. The implementation method first determines the neurons in each layer structure that affect the target class, and then determines the neurons in the global neural network that affect the target class based on the neurons in each layer structure that affect the target class. FIG. 4C For example, the first probability distribution in the n probability distributions is used to determine the neurons in the first layer structure that affect the target class. As shown in the flowchart, the method includes but is not limited to the following steps: FIG. 4B

[0306] S41: Encode the neurons in the first layer structure.

[0307] In some embodiments, the neurons can be encoded in a fixed order of the neurons in the first layer structure. Alternatively, the fixed order can be the arrangement order of the positions of the neurons in the first layer structure. At this time, the positions of the two neurons adjacent in the order are also adjacent in the first layer structure. The increment between the codes of any two adjacent neurons in the order can be set to be the same during the encoding process, that is, the neurons in the layer structure are arranged equidistantly in the interval such as [0, 1]. It should be understood that the fixed order can also not be arranged according to the positions, which is not limited here.

[0308] For example, when the first layer structure includes 11 neurons, the codes of the neurons in the first layer structure are 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, and 1 in turn.

[0309] ​S42: Determine the distribution value corresponding to the encoding of each neuron in the first layer structure in the first probability distribution.

[0310] It should be understood that the first probability distribution is a Gaussian distribution or a parabolic distribution in an interval such as [0, 1], and the encoding of the neurons in the first layer structure is in the interval.

[0311] S43: Determine the neurons with distribution values not less than the first threshold value as the neurons in the first layer structure that affect the target class.

[0312] It should be understood that for different layer structures, the first threshold value used by the corresponding probability distribution can be the same or different, as shown in FIG. 4A , probability distribution 1 uses threshold value v1, probability distribution 2 uses threshold value v2, probability distribution 3 uses threshold value v3, …, and probability distribution n uses threshold value vn. Wherein, each threshold value can be the same or different.

[0313] S44: Determine the neurons in the global neural network that affect the target class as the union of the neurons in all layer structures of the global neural network that affect the target class.

[0314] The determination method of the neurons in other layer structures of the global neural network that affect the target class can refer to the determination method of the neurons in the first layer structure that affect the target class, and further, the neurons in the global neural network that affect the target class are determined as the union of the neurons in all layer structures of the global neural network that affect the target class.

[0315] Implementation mode two:

[0316] Referring to FIG. 5A , FIG. 5A is a flowchart of an implementation method of S32, which can be implemented by the method, and the method includes but is not limited to the following steps:

[0317] S51: Encode all neurons in the global neural network.

[0318] As shown in FIG. 5B , each layer in the global neural network is unfolded, and all neurons are encoded.

[0319] S52: Superimpose each probability distribution in the n probability distributions after adding a bias to obtain a superimposed probability distribution.

[0320] As shown in FIG. 5C , the n probability distributions are superimposed after adding a bias, wherein the bias of each probability distribution is a hyperparameter, which is a preset value, and the bias of each probability distribution can be the same or different, which is not limited here.

[0321] S53: Determine the distribution value corresponding to the encoding of each neuron in the global neural network in the superimposed probability distribution.

[0322] S54: Determine the neurons with distribution values not less than the second threshold as the neurons in the global neural network that act on the target class.

[0323] As shown in FIG. 5C neurons with distribution values less than the second threshold are determined as the neurons in the global neural network that do not act on the target class.

[0324] In another embodiment of the present application, the target class includes multiple classes, the target class feature includes the class feature of each class in the target class, and the class feature of each class includes n-dimensional data. As in the implementation (1) of S30, for each dimension of data in the class feature of each class, a probability distribution corresponding to the data is generated with the data as the mean value, and n probability distributions are obtained. At this time, n probability distributions can be obtained for each class in the target class. Further, based on the same principles as the implementation mode one or the implementation mode two of the above S32, the neurons in the global neural network that act on each class can be determined, and in this embodiment, the first threshold is also referred to as a third threshold, and the second threshold is also referred to as a fourth threshold. Furthermore, the neurons in the global neural network that act on the target class are determined as the union of the neurons in the global neural network that act on all classes in the target class.

[0325] Embodiment three:

[0326] Based on the determined neurons in the global neural network that act on the target class, the class template, the pruning template, etc. can also be determined. The following will be introduced respectively:

[0327] In some embodiments of the present application, the neurons in the global neural network that act on a class can be determined based on the class feature of the class by the method described in the above embodiment two, and further, the class template of the class can be obtained based on the neurons in the global neural network that act on the class. The class template of the class can be due to the pruning of the global neural network, or indicate the neurons in the global neural network that act on the class.

[0328] In some embodiments of the present application, the neurons in the global neural network that act on the target class can be determined based on the class feature of the target class by the method described in the above embodiment two, and further, the pruning template of the target class can be obtained based on the neurons in the global neural network that act on the target class. Similarly, the pruning template of the target class can be due to the pruning of the global neural network, or indicate the neurons in the global neural network that act on the target class.

[0329] Please refer to FIG. 6AAfter S44, neurons in the first layer that affect the target class can be marked as "1", while neurons that do not affect the target class can be marked as "0", generating row or column vectors. The elements of this vector correspond one-to-one with the neurons in the first layer. Each element indicates whether the target class affects the neuron at the corresponding position in the first layer. This vector can serve as the template for the first layer in the target class's pruning template. Each layer in the global neural network can be generated using the above method. FIG. 6A The method shown yields a corresponding template. The data array obtained by combining the templates corresponding to the above layer structures is the clipping template for the target class, such as... FIG. 6B The diagram illustrates a target class cropping template. The cropping template can be a dataset or a vector. FIG. 6B This example uses a pruning template as a vector. The number of elements in this dataset or vector is the same as the number of neurons in the global neural network. Each element in the dataset or vector corresponds one-to-one with a neuron in the global neural network. An element with a value of "1" indicates that the neuron corresponding to that element is retained; that is, the neuron corresponding to the element with a value of "1" is active for the target class. An element with a value of "0" indicates that the neuron corresponding to that element is pruned; that is, the neuron corresponding to the element with a value of "0" is inactive for the target class. Similarly, a class template is also a dataset or vector, with the same number of elements as the number of neurons in the global neural network, also in a one-to-one correspondence. An element with a value of "1" indicates that the neuron corresponding to that element is active for that class; an element with a value of "0" indicates that the neuron corresponding to that element is inactive for that class. It should be understood that when all elements in the dataset or vector are "1", it represents the template of the global neural network.

[0330] Please see FIG. 6C After S44, neurons in the global neural network that affect the target class can be marked as "1", and neurons in the global neural network that do not affect the target class can be marked as "0", generating a data array. The elements in this data array correspond one-to-one with the neurons in the global neural network. Each element is used to indicate whether the target class is affected by the neuron at the position corresponding to that element in the global neural network. This data array can be used as a pruning template to prune the global neural network to obtain a local neural network suitable for the target class.

[0331] In some embodiments of the present application, the target class includes a plurality of classes, the target class feature includes a class feature of each class in the target class, the neurons in the global neural network that respectively act on each class in the target class can be determined according to the method described in Embodiment Two, and then the class template corresponding to each class is obtained, and then the pruning template of the target class is determined according to the class template of each class in the target class, wherein the pruning template of the target class is a combination of the class templates of each class in the target class. Specifically, the class templates of each class in the target class can be added, and the elements greater than 1 in the matrix obtained by addition are set to 1, and then the pruning template of the target class is obtained.

[0332] Embodiment Four

[0333] Based on the neurons in the neural network that act on the target class determined in Embodiment Two or the pruning template of the target class or the pruning template of each class determined in Embodiment Three, the neural network can be pruned. The following introduces a method for pruning a neural network provided by an embodiment of the present application, as shown in FIG. 7, which can be implemented by the pruning device in the system shown in FIG. 6, or by the server or the user end in the federated learning system shown in FIG. 5, alone or in combination. The method can include but is not limited to the following steps: FIG. 7A FIG. 1A FIG. 1B-1F

[0334] S71: Obtain a target class feature, which is used to represent the characteristics of data belonging to a target class.

[0335] S72: Prune the global neural network according to the target class feature to obtain a local neural network, wherein the global neural network is used to identify m classes, the local neural network is used to identify the target class, and the m classes include the target class.

[0336] Wherein, the local neural network includes neurons in the global neural network that are used to identify the target class, the first class and the second class are two classes in the m classes; the more similar the class feature of the first class is to the class feature of the second class, the more neurons that are used to identify the first class in the global neural network are the same as the neurons that are used to identify the second class, that is, the more neurons that act on the first class in the global neural network are the same as the neurons that act on the second class.

[0337] Specifically, the neurons in the global neural network that act on the target class can be determined by the method described in Embodiment Two, and then when the global neural network is pruned according to the target class feature, the neurons in the global neural network that act on the target class are retained, and the neurons outside the neurons in the global neural network that act on the target class (i.e., the neurons in the global neural network that do not act on the target class) are pruned to obtain the local neural network. ​​​

[0338] In one scenario, the target class is one or more specified classes, and the device performing the method can obtain class features of the m classes, and then determine the target class features based on the target class and the class features of the m classes.

[0339] In one scenario, the target class is a set of classes to which the samples in the training set belong, and the training device, server, or user end can obtain class features of the m classes, and then determine the target class features based on the target class and the class features of the m classes.

[0340] For the target class features, please refer to the relevant description in Embodiment Two above, which will not be repeated here.

[0341] In some embodiments, the pruning can also be implemented through class templates and / or pruning templates. Specifically, the pruning template of the target class can be obtained through the method described in Embodiment Three above, and the pruning template indicates the neurons in the global neural network that affect the target class. Then, based on the pruning template, the neurons in the global neural network that affect the target class are retained, and the neurons in the global neural network that do not affect the target class are pruned, to obtain the local neural network.

[0342] For example, please refer to the flowchart of another neural network pruning method shown in FIG. 7B and the pruning schematic diagram shown in FIG. 7C The method can be implemented by the federated learning system shown in FIG. 1D The method includes but is not limited to the following steps:

[0343] S701: The server generates class templates of the m classes based on the class features of the m classes.

[0344] Here, the class features of the m classes include the class features of each of the m classes, and the class templates of the m classes include the class templates of each of the m classes. Specifically, the class templates of each of the m classes can be obtained through the method described in Embodiment Three above.

[0345] S702: The server sends the class templates of the m classes to the Q user ends respectively.

[0346] S703: The user end can obtain the pruning template of the target class according to the class templates of the m classes and the target class. The pruning template of the target class is obtained by merging the class templates of all classes in the target class.

[0347] S704: The user end prunes the global neural network based on the pruning template to obtain the local neural network.

[0348] It can be understood that when multiple pruning is needed, the pruning method based on the pruning template can speed up the pruning process and improve the calculation efficiency.

[0349] Embodiment five:

[0350] Based on the neurons in the global neural network that affect the target class determined in Embodiment Two or the pruning template of the target class determined in Embodiment Two, the global neural network can be pruned to obtain a local neural network. When training is performed through the training set, the local neural network can be trained to avoid invalid updates of the neurons in the global neural network that do not affect the target class. Another method for training a neural network provided by an embodiment of the present application is introduced below, as shown in FIG. 8, which can be implemented based on the federated learning system shown in FIG. 7. The method can include, but is not limited to, the following steps: FIG. 9 FIG. 1B-1E

[0351] S81: The server sends a global neural network to Q user terminals, where the global neural network is used to identify m classes. The global neural network can be an initialized neural network or a global neural network trained through a previous round of training.

[0352] S82: The user terminal U i obtains a target class feature X t,i based on the local training set of the user terminal U i . local,i The user terminal U i is the i-th user terminal in the Q user terminals, i = 1, 2, …, Q, and the target class feature X t,i is obtained based on the local training set of the user terminal U i and is used to represent the characteristics of samples belonging to the target class T t,i . t,i The target class T i is a set of classes to which the samples in the local training set of the user terminal U local,i belong.

[0353] It should be understood that the target class features and the first local neural network corresponding to different user terminals are different.

[0354] It should also be understood that the first local neural network is a local neural network obtained by pruning the global neural network according to the target class feature, and is used to identify the target class. For specific implementation of the pruning method of the global neural network, please refer to the related description in Embodiment Four described above, which will not be described here.

[0355] S82 can also be performed by the server, and in this case, the method can further include that the server sends the first local neural network NN local,i to the user terminal U i .

[0356] S83: The user terminal Ui The first local neural network NN is trained using the local training set. local,i The second local neural network is obtained. Among them, the second local neural network This is the trained local neural network.

[0357] S84: User-side U i The second local neural network Send to the server.

[0358] S85: The server updates the global neural network based on the received second local neural network.

[0359] Specifically, the server aggregates the second local neural network sent from Q user clients. The server can update the global neural network based on the local neural network it receives. The following example illustrates how to update any neuron in the global neural network (also called the first neuron). Specific update methods may include, but are not limited to, the following two:

[0360] Update method (1):

[0361] In update method (1), the second local neural network sent by Q user terminals A neural network set is formed. The parameters of the first neuron in the updated global neural network are obtained by weighted summing of the network parameters of the first neurons in all the second local neural networks in this set. Where a second local neural network does not contain a first neuron, the parameters of the first neuron in that second local neural network are 0. In some embodiments, the second local neural network... The weights of the parameters of the first neuron in the process can be the user-side U i The ratio of the sample size of the local training set to the total sample size of Q user terminals; in other embodiments, the neural network set has P second local neural networks containing first neurons, and the weights of each second local neural network in the neural network set are the same, all being 1 / P. The above only considers user terminal U. i The corresponding second local neural network Taking the weights of the first neuron as an example, it should be understood that the weights of the first neuron in other user-side second local neural networks can be referenced to the above-described second local neural network. The method for determining the weights of the parameters of the first neuron is not elaborated here.

[0362] Update method (2):

[0363] In update method (2), the user terminal U iIn the second local neural network Before being sent to the server, or after the server receives the second local neural network. Then, the second local neural network can be... By feeding it into a global neural network, we obtain a global neural network.

[0364] In one implementation, a global neural network Except for the second local neural network The parameters of neurons outside of this network are 0, and the server can aggregate into Q global neural networks, i.e. At this point, the global neural network can be updated based on the aforementioned Q global neural networks. The parameters of the first neuron in the updated global neural network can be the weighted sum of the network parameters of the first neuron in all the Q global neural networks. Global Neural Network The weights of the first neuron are updated in the same way as in the second local neural network in the above update method (1). The weights of the parameters of the first neuron can be referred to the relevant description in the update method (1) above.

[0365] In another implementation, a global neural network Except for the second local neural network The parameters of the neurons outside the neural network remain unchanged. At this point, the server can obtain the first local neural network NN obtained by the pruning process. local,i Cutting template M i Furthermore, Q second local neural networks and Q cropping templates {M i The global neural network is updated according to the sequence i = 1, 2, ..., Q. The parameters of neuron v in the updated global neural network are then determined. global (v) can be:

[0366]

[0367] Among them, M i (v) indicates the trimming template M i The value corresponding to neuron v in the first local neural network NN local,i When containing neuron v, M i (v) = 1; when the first local neural network NN local,i Without neuron v, M i (v) = 0. For details on generating the trimming template, please refer to the relevant description in Example 3 above; it will not be repeated here. i It can be the user-side U i The ratio of the sample size to the total sample size of the Q user terminals.

[0368] It should be understood that S81-S85 above constitutes a single training process jointly executed by Q user terminals and the server. The Q user terminals and the server can jointly execute multiple training processes until the accuracy of the global neural network meets the requirements. The same user terminal may use different training sets in different training processes. However, in some embodiments, the target class features may be the same. This is because the training sets used in different training processes contain samples of the same class and with the same class distribution. Consequently, the structure of the first local neural network obtained based on the target class features is the same. In this case, pruning can be achieved through a pruning template to accelerate the training process. In other embodiments, the target class features may be different, and consequently, the structure of the first local neural network obtained based on the target class features is also different.

[0369] It should also be understood that the structure of the global neural network remains unchanged throughout the training process, but its parameters are constantly updated as training progresses, that is, the parameters of its neurons change continuously as training progresses.

[0370] The following section combines the above. FIG. 1B-1E The federated learning system shown introduces four neural network training methods provided in the embodiments of this application.

[0371] like FIG. 9 The training method for the neural network shown can be derived from the above. FIG. 1B The federated learning system shown is used to implement this method, which may include, but is not limited to, some or all of the following steps:

[0372] S90: Server builds initial global neural network

[0373] S91: User-side U i The target class feature is obtained based on the local training set. This target class feature is a characteristic used to indicate that the sample belongs to the target class, which is the user-side U. i The set of classes to which the samples in the local training set belong.

[0374] Optionally, the target class features may include the class features of each class in the target class, or they may be a weighted sum of the class features of all classes in the target class. See the relevant descriptions in S24 and S25 of Embodiment 1.

[0375] S92: Q client machines and the server jointly execute S training processes to obtain the global neural network obtained in the S-th training process. k and S are positive integers, k ≤ S. The k-th training process includes the following steps:

[0376] S921: The server will use the global neural network obtained from the (k-1)th training process. Send to user terminal Ui wherein the global neural network obtained in the 0th training process for the initialized global neural network, the user end U i is the i-th user end in the Q user ends, i = 1, 2, …, Q.

[0377] S922: the user end U i cutting the global neural network according to the target class feature obtaining the local neural network For specific implementation of the cutting, please refer to the relevant description in the above embodiment four, which will not be repeated here.

[0378] S923: the user end U i training the local neural network by using the local training set .

[0379] In a specific implementation, the user end U i may divide its local training data into S training sets, and different training sets are used in different rounds of training. Optionally, the classes to which the samples in the K training sets belong and the distribution of the classes can be uniform or non-uniform, which is not limited by the embodiments of the present application.

[0380] S924: the user end U i sending the trained local neural network to the server The specific implementation can include, but is not limited to, the following three specific implementations:

[0381] In the first specific implementation of S924: the user end U i sends the local neural network , the identifier of each neuron and the network parameters to the server. It should be understood that the identifier is used to uniquely identify the neuron in the global neural network.

[0382] In the second specific implementation of S924: the user end U i sends the network parameters of each neuron in the local neural network and the cutting template of the local neural network to the server, wherein the element marked with "1" in the cutting template corresponds to the neuron in the global neural network that is not a neuron in the local neural network , and the element marked with "0" corresponds to the neuron in the global neural network that is not a neuron in the local neural network . The network parameters of the local neural network correspond one-to-one to the elements marked with "1" in the cutting template, so that the server can identify the positions of the neurons in the local neural network based on the cutting template.

[0383] In a third implementation of S924, the user terminal U i The local neural network The network parameters of each neuron are updated to the global neural network The global neural network Further, the global neural network At this time, the network parameters of the other neurons in the global neural network except the local neural network may be 0. In another implementation, the network parameters of the other neurons in the global neural network except the local neural network may be not 0, at this time, the user terminal U i needs to send the pruning template of the local neural network or other indication information for indicating whether the network parameters of the neurons in the global neural network are valid.

[0384] S925: The server updates the network parameters of the global neural network according to the received local neural network, and obtains the global neural network

[0385] It can be understood that the server converges the local neural networks sent by the Q user terminals, i.e. The implementation of updating the global neural network can refer to the two updating modes shown in the above FIG. 8 embodiments.

[0386] Through performing multiple training processes, until the network parameters of the global neural network updated by the local neural network obtained by the training process meet the requirements, such as convergence or accuracy greater than a target threshold (e.g., 80%), the training is stopped, the network parameters of the global neural network updated by the local neural network obtained by the last training process are used to obtain the trained global neural network. It should be understood that S is a positive integer that meets the above requirements.

[0387] As FIG. 10 shown is another method for training a neural network provided by an embodiment of the present application, which can be implemented by the system shown in the above FIG. 1C , such as the method can include but is not limited to the following part or all steps:

[0388] S100: Construct an initialized global neural network.

[0389] S101: The user terminal U i obtains target class features according to the local training set. The target class features are features of samples belonging to the target class, and the target class is the class of the sample to be classified by the user terminal Ui The set of classes to which the samples in the local training set belong. For information on obtaining target class features, please refer to the above. FIG. 9 The relevant description in S91 of the illustrated embodiment.

[0390] S102: User terminal U i A pruning template is generated based on the target class features and the initialized global neural network. The specific implementation of generating the pruning template can be found in the relevant description in Example 3 above, and will not be repeated here.

[0391] S103: Q client terminals and the server jointly execute S training processes to obtain the global neural network obtained in the S-th training process, where k and S are positive integers, and k ≤ S; wherein, the k-th training process may include the following steps:

[0392] S1031: The server will use the global neural network obtained from the (k-1)th training process. Send to user terminal i, where the global neural network obtained in the 0th training process For the initialization of the global neural network, the user-side U i Let i be the i-th user terminal among Q user terminals, where i = 1, 2, ..., Q.

[0393] S1032: User terminal U i According to user terminal U i Pruning templates for global neural networks Get user-side U i Local neural networks That is, the median of the pruning template at user i corresponds one-to-one with the neurons of the global neural network. The pruning process based on the pruning template is to prune the global neural network. Neurons marked "1" are retained, while neurons marked "0" are removed.

[0394] S1033: User terminal U i Local neural networks are trained using local training sets. Training is performed to obtain the trained local neural network. For specific implementation details, please refer to the above. FIG. 9 The relevant descriptions in S923 of the illustrated embodiment will not be repeated here.

[0395] S1034: User terminal U i Send local neural network to server

[0396] S1035: The server updates the global neural network based on the received local neural network data. The network parameters are used to obtain the global neural network.

[0397] The specific implementation of S1033, S1034, and S1035 can be found in the above FIG. 9 The relevant description of S923, S934, and S935 in the embodiment shown in FIG. 9 will not be repeated here.

[0398] It should be understood that S102 can also be performed by the server, at which time the user end needs to send its target class features to the server, and the server sends the cutting template to the corresponding user end after obtaining the cutting template of each user end. In some other embodiments, S102 can also be performed by the server or the user end in the first training process.

[0399] In some embodiments, as shown in the federated learning system in FIG. 9, the server can also send m class templates to the user end, and the method for the user end to generate the collection template can be based on the local training set and the m class templates. For details, please refer to the relevant description in Embodiment 3 above. FIG. 1D

[0400] Similarly, by performing multiple training processes until the network parameters of the global neural network updated by the local neural network obtained in the training process meet the requirements, such as convergence or accuracy greater than a target threshold (for example, 80%), the training is stopped, and the network parameters of the global neural network updated by the local neural network obtained in the last training process are used to obtain the trained global neural network. It should be understood that K is a positive integer that meets the above requirements.

[0401] It should be understood that, unlike the embodiment shown in FIG. 9, in the embodiment shown in FIG. 10, the target class features of each user end do not change in S training processes, and the cutting template of each user end also remains unchanged. At this time, the structure of the local neural network of the user end in the training process remains unchanged. FIG. 10

[0402] As shown in FIG. 11, this is another method for training a neural network according to an embodiment of the present application. The method can be implemented by the system shown in FIG. 11, and can include but is not limited to the following steps or all of the steps: FIG. 11 FIG. 1E S110: The server constructs an initialized global neural network. For details, please refer to the relevant description of S90 in the embodiment shown in FIG. 9.

[0403] S111: Perform S training processes, update the network parameters of the global neural network according to the local neural network obtained in the Sth training process, and obtain the updated global neural network. K and S are positive integers, and k≤S. The kth training process includes the following steps: FIG. 9

[0404] S111: Perform S training processes, update the network parameters of the global neural network according to the local neural network obtained in the Sth training process, and obtain the updated global neural network. K and S are positive integers, and k≤S. The kth training process includes the following steps:

[0405] ​​​​S1111: The user client obtains the target class features based on the local training set. See above. FIG. 9 The relevant description in S91 of the illustrated embodiment.

[0406] S1112: Q user terminals each send their target class features to the server, where Q is a positive integer greater than 1.

[0407] S1113: For each of the Q user terminals, the server modifies the global neural network obtained in the (k-1)th training process based on its target class features. The local neural network is then cropped to be suitable for the user terminal.

[0408] and FIG. 9 The embodiment shown differs from the one described above in that... FIG. 11 In the illustrated embodiment, pruning of the global neural network is implemented through a server. The specific implementation is similar to pruning implemented by the user end; it can be pruning based on target class features or pruning templates. The specific implementation of pruning can be found in Embodiment 4 above.

[0409] S1114: The server will use a local neural network. Send to user terminal U i .

[0410] Among them, the user-side U obtained in the 0th training process i Local neural networks For the user terminal U i The initial local neural network.

[0411] S1115: User-side U i Local neural networks are trained using local training sets. Conduct training.

[0412] S1116: User-side U i The trained local neural network Send to the server. Its specific implementation may include, but is not limited to, the following three specific implementations:

[0413] In the first specific implementation of S1116: User terminal U i Send the trained local neural network to the server Each neuron in the network has an identifier and parameters. It should be understood that this identifier is used to uniquely identify neurons within the global neural network.

[0414] In the second specific implementation of S1116: User terminal U i Send the trained local neural network to the server The network parameters of each neuron and the local neural network The elements marked with "1" in the pruning template correspond to neurons in the global neural network that are neurons in the local neural network The elements marked with "0" in the pruning template correspond to neurons in the global neural network that are not neurons in the local neural network The network parameters of the trained local neural network correspond one-to-one to the elements marked with "1" in the pruning template, so that the server can identify the neurons in the local neural network based on the pruning template.

[0415] In the third implementation of S1116, the user terminal U i can put the network parameters of each neuron of the trained local neural network back into the global neural network, obtaining a global neural network Then, the server is sent the global neural network At this time, the network parameters of the neurons in the global neural network other than the neurons in the local neural network may be 0. In another implementation, the network parameters of the neurons in the global neural network other than the neurons in the local neural network may not be 0, in which case the user terminal U i needs to send the server the pruning template of the local neural network or other indication information indicating whether the network parameters of the neurons in the global neural network are valid.

[0416] S1117: The server updates the global neural network according to the trained local neural networks respectively sent by the Q user terminals, obtaining a global neural network

[0417] In some other embodiments, the target class features of the same user terminal do not change in each training process, in which case S1111 and S1112 can be performed only in the first training process or only before the S training processes. Further, in S1113, the server can also implement pruning of the global neural network based on the pruning template.

[0418] Further, the server can not perform S1117, but perform: the server updates the trained local neural network according to the trained local neural networks respectively sent by the Q user terminals, obtaining a local neural network At this point, S1113 does not need to be executed during each training process. Specifically, the server processes the trained local neural networks based on the trained local neural networks sent by the Q user terminals. Update the local neural network to obtain the local neural network. It can include the following two specific implementations:

[0419] In the first specific implementation, the first neuron is the user-side U. i Any neuron in a local neural network. A set of local neural networks consisting of the first neuron from Q user terminals obtained during the k-th training process is formed, such as the set of P user terminals' local neural networks obtained during the (k-1)-th training process. User terminal U i Local neural networks The parameters of the first neuron in the neural network are obtained by a weighted sum of the parameters of the first neurons in all local neural networks within the neural network ensemble. Optionally, the user terminal U... i Local neural networks The weights of the parameters of the first neuron in the middle are U on the user side. i The ratio of the number of samples in the training data to the total number of samples from Q user terminals (or to the total number of samples from P user terminals). In other embodiments, the local neural networks of each user terminal... The weights of the first neuron can all be the same, 1 / P. The above only applies to the user-side U. i Local neural networks Taking the weights of the first neuron as an example, it should be understood that the weights of the first neuron in the local neural network of any of the P user terminals can be referenced to the weights of the first neuron in the user terminal U mentioned above. i Local neural networks The method for determining the weights of the first neuron's parameters is described above and will not be elaborated here. It should also be understood that the update method for other user-side local neural networks can refer to the user-side U method described above. i This is achieved through a local neural network update method, which will not be elaborated here.

[0420] In the second specific implementation, the server updates the global neural network based on the trained local neural networks sent by Q user terminals, and then, based on the user terminal U pruned from the updated global neural network... i Local neural networks The specific implementation of the server updating the global neural network based on the trained local neural networks sent by Q users can be found in the above description. FIG. 9 The method in step S925 of the illustrated embodiment will not be described again here.

[0421] By performing multiple training processes until the network parameters of the global neural network updated by the local neural network obtained in the training process meet the requirements, such as convergence or accuracy greater than a target threshold (e.g., 80%), the training is stopped, and the network parameters of the global neural network updated by the local neural network obtained in the last training process are used to obtain the trained global neural network. It should be understood that S is a positive integer that meets the above requirements.

[0422] It should be understood that the structure of the local neural network of the user end does not change during the training process, and the network structure of the global neural network also remains unchanged, but as the training continues, the network parameters (also referred to as model parameters or weight matrices) of the global neural network and the local neural network change, i.e., the network parameters of each neuron change as the training progresses.

[0423] Embodiment six:

[0424] Based on the neurons in the global neural network that affect the target class determined in Embodiment Two, the global neural network can be trained, and a method for training a neural network provided in an embodiment of the present application is introduced below, as shown in FIG. 12 The method can be implemented by the training device in the system shown in FIG. 1A The method can be implemented by the user end in the federated learning system shown in FIG. 1F The method can include but is not limited to the following steps:

[0425] S121: Obtain target class features. The target class features are used to represent the characteristics of samples belonging to the target class, and the target class includes the classes to which the samples in the training set belong.

[0426] S122: Determine the neurons in the global neural network that affect the target class according to the target class features.

[0427] S123: Perform constraint training on the global neural network using the training set to obtain a trained global neural network.

[0428] The constraint training can include two implementation methods: ① During the training of the global neural network using the training set, the parameters of the neurons that affect the target class are updated, and the neurons that do not affect the target class are not updated; ② During the training of the global neural network using the training set, a large penalty term is applied to the parameters of the neurons that do not affect the target class to reduce the variable of the parameters of the neurons that do not affect the target class, while the parameters of the neurons that affect the target class can be unconstrained or subject to less constraint, which can be achieved by setting the function.

[0429] For implementation ①: the training process optimizes the network parameters of the global neural network by minimizing the loss, which can be calculated by a loss function. The form of the loss function can be as follows:

[0430] Loss1 = f1(W l ,D)

[0431] where Loss1 is the loss, W l is the parameter of the neuron in the global neural network that affects the target class, D is the input data of the global neural network, i.e., the sample in the training set; f1(W l ,D) is the cross-entropy, variance, etc. between the predicted class obtained by inputting all samples in the training set into the global neural network and the class (the true class) to which the all samples belong. During the training of the global neural network by the training set, the parameters of the neurons in the global neural network that do not affect the target class remain unchanged.

[0432] Further, the update of part of the neurons in the global neural network that affect the target class can be constrained during the training process. The part of the neurons can be the neurons that affect fewer classes, for example, the neurons that affect only one class are constrained. At this time, the loss function can add a penalty term, and the form of the loss function can be as follows:

[0433] Loss1 = f1(W l ,D) + g(W a )

[0434] where g(W a ) is the first penalty term, and Wa is the parameter of the part of the neurons. The first penalty term is used to constrain the change amount of the parameter of the part of the neurons. One implementation of g(W a ) can be:

[0435]

[0436] where W a is the value of the part of the neurons before the update, is the value of the part of the neurons after the update, and ‖ ‖ represents the norm, such as 0-norm, 1-norm, 2-norm, and infinite norm.

[0437] For implementation ②: the training process optimizes the network parameters of the global neural network by minimizing the loss, which can be calculated by a loss function. The form of the loss function can be as follows:

[0438]

[0439] where Loss2 is the loss, Here, W represents the updated parameters of the global neural network, the parameters of the neurons that affect the target class, and D represents the input data of the global neural network, i.e., the samples in the training set. g For the parameters of the global neural network; f2(W) g1 D) represents the cross-entropy, variance, etc., between the predicted class obtained by inputting all samples in the training set into the global neural network and the class to which all samples belong (the real class). This is the second penalty term, used to constrain the amount of parameter changes for neurons in the global neural network that do not function in the target class.

[0440] in, One possible implementation is:

[0441]

[0442] Where M is called the regularization template; M0 is the template of the global neural network, which is a dataset or vector of all 1s, where each element corresponds to a neuron in the global neural network; M j For class T j The class template is also a dataset or vector of the same size as the global neural network. An element of "1" indicates that the class template includes the neuron corresponding to that element, and an element of "0" indicates that the class template does not include the neuron corresponding to that element; λ is a constant, a preset value; r j For the training set belonging to class T j The ratio of the sample size in M ​​to the total sample size in the training set, ⊙ represents the element-wise product, also known as positional multiplication. It should be noted that when an element in M ​​is less than 0, it is set to 0.

[0443] As can be seen, by setting the second penalty term, the training imposes smaller constraints on neurons that function in classes with large sample sizes, while imposing larger constraints on neurons that function in classes with small sample sizes, thereby reducing the amount of parameter changes in neurons that function in classes with small sample sizes.

[0444] like FIG. 13 This is a flowchart illustrating another neural network training method provided in an embodiment of this application. The method may include the above-described... FIG. 1F The federated learning system shown is used to implement this; please refer to it as well. FIG. 1F The federated learning system shown includes, but is not limited to, some or all of the following steps:

[0445] S131: The server build initialization is a global neural network.

[0446] S132: The server and Q client terminals jointly execute S training processes, where k and S are positive integers, and k ≤ S. The k-th training process includes the following steps:

[0447] S1321: The server sends the global neural network obtained in the k-1th training process to Q user terminals.

[0448] S1322: Each of the Q user terminals determines the neurons in the global neural network that act on the target class according to the target class feature. It should be understood that the target class is a class included in the training set local to the user terminal, and the target class feature is a feature used to represent samples belonging to the target class. The training set in each user terminal is different, and the corresponding target class and target class feature can also be different.

[0449] S1323: Each of the Q user terminals performs constraint training on the global neural network by using the local training set to obtain a trained global neural network. Wherein, the user terminal U i performs training on the global neural network by using the local training set to obtain a trained global neural network For constraint training, please refer to the related description of constraint training in the embodiments described above, which will not be repeated here. FIG. 12

[0450] S1324: Each of the Q user terminals sends the trained global neural network to the server.

[0451] S1325: The server updates the global neural network obtained in the k-1th training process according to the received global neural network to obtain the global neural network obtained in the kth training process

[0452] The server collects the global neural networks trained by the Q user terminals and then updates the global neural network based on the received global neural networks The specific implementation of updating the global neural network can refer to the two updating methods in the embodiments described above. FIG. 12

[0453] Optionally, in another implementation, S1322 can also be performed by the server, that is, the server determines the neurons in the global neural network that act on the target class corresponding to the user terminal U i according to the target class feature corresponding to the user terminal U i .

[0454] ​​​It should be understood that the same user end adopts different training sets in different rounds of training process, but the target class features thereof can be the same or different. Among them, the target class and the target class features are unchanged when the user end adopts the training sets including the same classes or the same class distribution in different rounds.

[0455] Embodiment seven:

[0456] After the global neural network is trained, the global neural network can realize the identification of m classes, also known as a class identification model. The following introduces a class identification method provided by an embodiment of the present application, which can be executed by the execution device shown in the above FIG. 1A or the user end shown in the above FIG. 1B-1F or other user ends or devices not participating in the training of the global neural network. The present application takes the user end as an example to illustrate, and the class identification method is shown in the above FIG. 14 The method can include but is not limited to the following steps:

[0457] S141: Obtain a target class feature, which is used to represent the characteristics of data belonging to a target class.

[0458] The target class can also be at least one class specified or input by a user. The target class feature can be the class feature of the at least one class, or the weighted sum of the class features of the at least one class. The weight of each class in the at least one class can be a preset value. The class feature of each class can be obtained by the user end from the pruning device or the server.

[0459] S142: Prune the global neural network according to the target class feature to obtain a local neural network, wherein the global neural network is used to identify a plurality of classes, such as m classes, and the local neural network is used to identify a target class, and the m classes include the target class.

[0460] The global neural network is a global neural network obtained by the neural network training method shown in the above embodiment five or six, which is an m-classification model. The local neural network obtained by pruning can identify the target class, and the target class is a class in the m classes. The specific implementation of pruning the global neural network based on the target class feature can be referred to the related description in the above embodiment four, which will not be repeated here.

[0461] S143: Input the data to be identified into the local neural network to obtain an identification result.

[0462] The user end can apply the local neural network obtained by pruning to identify the target class.

[0463] The method can obtain a local neural network required by the target class by pruning the global neural network according to the target class feature, and then can run the local neural network to perform class recognition, so that the class can be quickly recognized in a terminal with less computing resources. Further, different users can prune the neural network required by the user according to the class to be recognized, and the flexibility is high.

[0464] In some other embodiments, the user end can also directly apply the global neural network, for example, input the to-be-recognized data into the global neural network to obtain the recognition result of the to-be-recognized data.

[0465] In an application scenario, the global neural network is an image recognition model, which is trained by a large number of image samples and is used to recognize various animals and plants. At this time, the to-be-recognized data is a to-be-recognized image.

[0466] In another application scenario, the global neural network is an intent recognition model, which is trained by a large number of text samples and is used to recognize intents. The to-be-recognized data is a to-be-recognized text. Further, the user end can also execute the recognized intent.

[0467] The device and the equipment related to the embodiments of the present application are introduced as follows.

[0468] Please refer to FIG. 15A and FIG. 15B , FIG. 15A and FIG. 15B are structural diagrams of two neural network pruning devices provided by the embodiments of the present application. The devices 150a and 150b can include but are not limited to the following functional units:

[0469] The obtaining unit 1501 is configured to obtain a target class feature, wherein the target class feature is used to represent the characteristics of data belonging to a target class.

[0470] The pruning unit 1502 is configured to prune a global neural network according to the target class feature to obtain a local neural network, wherein the global neural network is used to recognize a plurality of classes, the local neural network is used to recognize the target class, and the plurality of classes includes the target class.

[0471] In some embodiments, the target class feature includes n-dimensional data, n is a positive integer, and the pruning unit 1502 is specifically configured to:

[0472] For each dimension of data in the n-dimensional data, a probability distribution corresponding to each dimension of data is generated by taking each dimension of data as a mean value, to obtain n probability distributions, wherein the n probability distributions correspond to the n-dimensional data one by one.

[0473] The global neural network is pruned according to the n probability distributions to obtain the local neural network.

[0474] In some embodiments, as shown in the apparatus 150a, the pruning unit 1502 includes: FIG. 15A

[0475] The first encoding unit 15021 is configured to encode each layer structure in the global neural network respectively.

[0476] The first determining unit 15022 is configured to determine that the distribution value of each neuron in each layer structure in the global neural network is a value corresponding to the encoding of the neuron in the probability distribution corresponding to the layer structure, the n dimensions have a corresponding relationship with the layer structure in the global neural network, and the probability distribution corresponding to each layer structure is a probability distribution corresponding to the dimension corresponding to each layer structure in the n probability distributions.

[0477] The first removing unit 15023 is configured to remove neurons with a distribution value less than a first threshold in the global neural network to obtain the local neural network.

[0478] In some embodiments, as shown in the apparatus 150b, the pruning unit 902 includes: FIG. 15B

[0479] The second encoding unit 15024 is configured to encode all neurons in the global neural network.

[0480] The superposition unit is configured to superimpose each probability distribution of the n probability distributions after adding a bias.

[0481] The second determining unit 15025 is configured to determine that the distribution value of each neuron in the global neural network is a value corresponding to the encoding of the neuron in the superimposed probability distribution.

[0482] The second removing unit 15026 is configured to remove neurons with a distribution value less than a second threshold in the global neural network to obtain the local neural network.

[0483] In some embodiments, the target class includes at least two classes, and the obtaining unit 901 is specifically configured to:

[0484] perform weighted summation on the class features of each class in the target class to obtain the target class feature.

[0485] It should be noted that the apparatus can also include other functional units for implementing the other functions described in Embodiment Four above, and the specific implementation of each unit can be referred to the related description in Embodiment Four above, which will not be described here.

[0486] Please refer to FIG. 16 , FIG. 16 ​​is a structural schematic diagram of a pruning device of a neural network provided by an embodiment of the application. The device 1600 can include, but is not limited to, a memory 1601, a processor 1602, a communication interface 1603, and a bus 1604. The memory 1601, the processor 1602, and the communication interface 1603 are communicatively connected to each other through the bus 1604.

[0487] The memory 1601 can be a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1601 can store a program, and when the program stored in the memory 1601 is executed by the processor 1602, the processor 1602 and the communication interface 1603 are used to execute the method or steps in the fourth embodiment of the method of the application.

[0488] The processor 1602 can adopt a general central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), a graphics processing unit (GPU), or one or more integrated circuits, to execute related programs to implement the functions required by the units in the device 150a or the device 150b of the embodiment of the application, or to execute the method or steps in the fourth embodiment of the method of the application.

[0489] The processor 1602 can also be an integrated circuit chip having a processing capability for signals. In implementation, each step in the method provided by the fourth embodiment of the present application can be completed by integrated logic circuitry of hardware in the processor 1602 or instructions in the form of software. The processor 1602 described above can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. The disclosed methods, steps and logic block diagrams in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register or other mature storage medium in the art. The storage medium is located in the memory 1601, and the processor 1602 reads the information in the memory 1601, and combines the hardware to complete the functions required by the units in the device 150a or the device 150b in the embodiments of the present application, or executes the method or steps described in the fourth embodiment of the method of the present application.

[0490] The communication interface 1603 uses a transceiver such as but not limited to a transceiver to realize the communication between the device 1600 and other devices or communication networks.

[0491] The bus 1604 can include a path for transmitting information between various components (for example, the memory 1601, the processor 1602, the communication interface 1603) of the device 1600.

[0492] It should be noted that the device 150a, the device 150b, the device 1600 described above can be a cutting device, an execution device in the FIG. 1A or FIG. 1B-1D user terminal shown in the FIG. 1E server shown in the

[0493] Please refer to FIG. 17 , FIG. 17 is a structural schematic diagram of a neural network training device provided by the embodiments of the present application. The device 1700 can include but not limited to the following functional units:

[0494] The acquisition unit 1701 is configured to acquire a target class feature; the target class feature is used to represent characteristics of samples belonging to a target class, and the target class includes a class to which samples in a training set belong;

[0495] The pruning unit 1702 is configured to prune a global neural network according to the target class feature, to obtain a first local neural network.

[0496] The training unit 1703 is configured to train the first local neural network by using the training set, to obtain a second local neural network.

[0497] The second local neural network is used to update the global neural network; the global neural network is used to identify a plurality of classes, the second local neural network is used to identify the target class, and the plurality of classes include the target class.

[0498] It should be noted that the apparatus can further include other functional units for implementing the method performed by the user end in the above-mentioned embodiment five, and the specific implementation of each unit can be referred to the related description in the above-mentioned embodiment four, which will not be described here.

[0499] Please refer to FIG. 18 , FIG. 18 is a structural schematic diagram of a neural network training apparatus provided by the embodiment of the application. The apparatus 1800 can include but is not limited to a memory 1801, a processor 1802, a communication interface 1803 and a bus 1804. The memory 1801, the processor 1802 and the communication interface 1803 are in communication connection with each other through the bus 1804.

[0500] The memory 1801 can be a read only memory (Read Only Memory, ROM), a static storage device, a dynamic storage device or a random access memory (Random Access Memory, RAM). The memory 1801 can store a program, and when the program stored in the memory 1801 is executed by the processor 1802, the processor 1802 and the communication interface 1803 are used to execute the method or steps performed by the user end in the method embodiment five.

[0501] The processor 1802 can be a general purpose Central Processing Unit (CPU), a microprocessor, an Application Specific Integrated Circuit (ASIC), a graphics processing unit (GPU) or one or more integrated circuits, for executing programs as needed to implement the functions of the units in the apparatus 1700 of the embodiments of the present application, or to perform the method or steps performed by the user end in the fifth embodiment of the method of the present application.

[0502] The processor 1802 can also be an integrated circuit chip having a processing capability for signals. In the implementation process, each step performed by the user end in the method of the fifth embodiment of the present application can be completed by the integrated logic circuit of hardware or the instruction in the form of software in the processor 1802. The processor 1802 described above can also be a general purpose processor, a Digital Signal Processing (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present application can be implemented or executed. The general purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in conjunction with the embodiments of the present application can be directly embodied as a hardware code processor for execution, or a combination of hardware and software modules in the code processor for execution. The software module can be located in a random access memory, a flash memory, a read only memory, a programmable read only memory or an electrically erasable programmable memory, a register or other mature storage medium in the art. The storage medium is located in the memory 1801, and the processor 1802 reads the information in the memory 1801, and combines the hardware to complete the functions required to be executed by the units in the apparatus 1700 of the embodiments of the present application, or to perform the method or steps performed by the user end in the fifth embodiment of the method of the present application.

[0503] The communication interface 1803 uses a transceiver such as but not limited to a transceiver to realize the communication between the apparatus 1800 and other devices or communication networks.

[0504] The bus 1804 can include a path for transmitting information between the various components (for example, the memory 1801, the processor 1802, the communication interface 1803) of the apparatus 1800.

[0505] It should be noted that the above apparatus can be a training device in the device, or FIG. 1A FIG. 1B-1E ​A user end in any federated learning system.

[0506] See FIG. 19 , FIG. 19 is a structural schematic diagram of a neural network training device provided by an embodiment of the application. The device 1900 can include but is not limited to the following functional units:

[0507] A sending unit 1901 is configured to send a global neural network to a plurality of user ends. The global neural network is used to identify a plurality of classes.

[0508] A receiving unit 1902 is configured to receive a second local neural network sent by the plurality of user ends respectively. The second local neural network is used to identify a target class. The plurality of classes includes the target class. The second local neural network is obtained by training a first local neural network by the user end using a training set. The first local neural network is obtained by cutting the global neural network according to a target class feature. The target class feature is used to represent characteristics of samples belonging to the target class in the training set.

[0509] An updating unit 1903 is configured to update the global neural network according to the received second local neural network.

[0510] It should be noted that the device 1900 can further include other functional units for implementing the method performed by the server in the above-mentioned embodiment five. The specific implementation of the above-mentioned units can be referred to the related description in the above-mentioned embodiment five, which will not be described here.

[0511] See FIG. 20 , FIG. 20 is a structural schematic diagram of a neural network training device provided by an embodiment of the application. The device 2000 can include but is not limited to a memory 2001, a processor 2002, a communication interface 2003 and a bus 2004. The memory 2001, the processor 2002 and the communication interface 2003 are in communication connection with each other through the bus 2004.

[0512] The memory 2001 can be a read only memory (ROM), a static storage device, a dynamic storage device or a random access memory (RAM). The memory 2001 can store a program. When the program stored in the memory 2001 is executed by the processor 2002, the processor 2002 and the communication interface 2003 are configured to execute the method or steps performed by the server in the method embodiment five.

[0513] The processor 2002 can be a general purpose Central Processing Unit (CPU), a microprocessor, an Application Specific Integrated Circuit (ASIC), a graphics processing unit (GPU) or one or more integrated circuits, for executing programs to implement the functions of the units in the apparatus 1900 of the embodiments of the present application, or to execute the methods or steps performed by the server in the method embodiment five of the present application.

[0514] The processor 2002 can also be an integrated circuit chip having a processing capability of signals. In the implementation process, each step of the method performed by the server in the method embodiment five of the present application can be completed by the integrated logic circuit of hardware in the processor 2002 or the instruction in the form of software. The processor 2002 described above can also be a general purpose processor, a Digital Signal Processing (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. The disclosed methods, steps and logic block diagrams in the embodiments of the present application can be implemented or executed. The general purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as a hardware code processor to execute, or executed by a combination of hardware and software modules in the code processor. The software module can be located in a random access memory, a flash memory, a read only memory, a programmable read only memory or an electrically erasable programmable memory, a register or other mature storage medium in the art. The storage medium is located in the storage 2001, and the processor 2002 reads the information in the storage 2001, and combines the hardware to complete the functions required to be executed by the units in the apparatus 1900 of the embodiments of the present application, or to execute the methods or steps performed by the server in the method embodiment five of the present application.

[0515] The communication interface 2003 uses a transceiver such as but not limited to a transceiver to realize the communication between the apparatus 2000 and other devices or communication networks.

[0516] The bus 2004 can include a path for transmitting information between the various components (for example, the storage 2001, the processor 2002, the communication interface 2003) of the apparatus 2000.

[0517] It should be noted that the above-mentioned apparatus 1900 and apparatus 2000 can be a training device in the method embodiment one of the present application, or FIG. 1A a server in the method embodiment two of the present application, orFIG. 1B-1E a server in any federated learning system.

[0518] See FIG. 21 , FIG. 21 is a structural schematic diagram of a neural network training device provided by an embodiment of the application. The device 2100 can include but is not limited to the following functional units:

[0519] An acquisition unit 2101 is configured to acquire target class features. The target class features are used to represent characteristics of samples belonging to a target class, and the target class includes a class to which samples in a training set belong.

[0520] A determination unit 2102 is configured to determine, according to the target class features, neurons in a global neural network that have an effect on the target class.

[0521] A training unit 2103 is configured to perform constrained training on the global neural network by using the training set, to obtain a trained global neural network.

[0522] The global neural network is used to identify a plurality of classes, and the plurality of classes includes the target class.

[0523] It should be noted that the device 2100 can also include other functional units for implementing the method performed by the training device in the above-described embodiment six. The specific implementation of the above-described units can be referred to the related description in the above-described embodiment six, and will not be described here.

[0524] See FIG. 22 , FIG. 22 is a structural schematic diagram of a neural network training device provided by an embodiment of the application. The device 2200 can include but is not limited to a memory 2201, a processor 2202, a communication interface 2203, and a bus 2204. The memory 2201, the processor 2202, and the communication interface 2203 are in communication connection with each other through the bus 2204.

[0525] The memory 2201 can be a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 2201 can store a program, and when the program stored in the memory 2201 is executed by the processor 2202, the processor 2202 and the communication interface 2203 are configured to execute the method or steps performed by the server in the method embodiment six of the application.

[0526] The processor 2202 can be a general purpose Central Processing Unit (CPU), a microprocessor, an Application Specific Integrated Circuit (ASIC), a graphics processing unit (GPU) or one or more integrated circuits, for executing programs to implement the functions of the units in the apparatus 2100 according to the embodiments of the present application, or to implement the method or steps performed by the training device in Embodiment Six of the present application.

[0527] The processor 2202 can also be an integrated circuit chip having a processing capability of signals. In the implementation process, each step in the method according to Embodiment Six of the present application can be completed by the integrated logic circuit of hardware in the processor 2202 or the instruction in the form of software. The processor 2202 described above can also be a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present application can be implemented or executed. The general purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as a hardware coding processor to execute, or be executed by a combination of hardware and software modules in the coding processor. The software module can be located in a random access memory, a flash memory, a read only memory, a programmable read only memory or an electrically erasable programmable memory, a register, or other mature storage medium in the art. The storage medium is located in the storage 2201, and the processor 2202 reads the information in the storage 2201, and combines the hardware to complete the functions required to be executed by the units in the apparatus 2100 according to the embodiments of the present application, or to implement the method or steps performed by the server in Embodiment Six of the present application.

[0528] The communication interface 2203 uses a transceiver such as but not limited to a transceiver to realize the communication between the apparatus 2200 and other devices or communication networks.

[0529] The bus 2204 can include a path for transmitting information between the various components (for example, the storage 2201, the processor 2202, the communication interface 2203) of the apparatus 2200.

[0530] It should be noted that the apparatus 2100 and the apparatus 2200 described above can be the training device or FIG. 1A the server in Embodiment Six of the present application.FIG. 1F User terminal in any system.

[0531] See FIG. 23 , FIG. 23 is a structural schematic diagram of a class identification device provided by an embodiment of the application. The device 2300 can include but is not limited to the following functional units:

[0532] An acquisition unit 2301 is configured to acquire a target class feature, where the target class feature is used to represent characteristics of data belonging to a target class.

[0533] A pruning unit 2302 is configured to prune a global neural network according to the target class feature to obtain a local neural network, where the global neural network is used to identify multiple classes, the local neural network is used to identify the target class, and the multiple classes include the target class.

[0534] An identification unit 2303 is configured to input to-be-identified data into the local neural network to obtain an identification result.

[0535] It should be noted that the device 2300 can further include other functional units for implementing the method executed by the execution device in the above-described embodiment seven, and the specific implementation of the above-described units can be referred to the related description in the above-described embodiment seven, which will not be described here again.

[0536] See FIG. 24 , FIG. 24 is a structural schematic diagram of a class identification device provided by an embodiment of the application. The device 2400 can include but is not limited to a memory 2401, a processor 2402, a communication interface 2403, and a bus 2404. The memory 2401, the processor 2402, and the communication interface 2403 are in communication connection with each other through the bus 2404.

[0537] The memory 2401 can be a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 2401 can store a program, and when the program stored in the memory 2401 is executed by the processor 2402, the processor 2402 and the communication interface 2403 are configured to execute the method or steps executed by the execution device in the method embodiment seven.

[0538] The processor 2402 can be a general purpose central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), a graphics processing unit (GPU) or one or more integrated circuits, for executing programs as needed to implement the functions of the units in the apparatus 2300 of the embodiments of the present application, or to perform the methods or steps performed by the execution device in Embodiment Seven of the methods of the present application.

[0539] The processor 2402 can also be an integrated circuit chip having a processing capability for signals. In the implementation process, each step in the method described in Embodiment Seven of the present application can be completed by the integrated logic circuit of hardware in the processor 2402 or by the instructions in the form of software. The processor 2402 described above can also be a general purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. The disclosed methods, steps and logic block diagrams in the embodiments of the present application can be implemented or executed. The general purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in conjunction with the embodiments of the present application can be directly embodied as a hardware code processor for execution, or a combination of hardware and software modules in the code processor for execution. The software module can be located in a random access memory, a flash memory, a read only memory, a programmable read only memory or an electrically erasable programmable memory, a register or other mature storage medium in the art. The storage medium is located in the storage 2401, and the processor 2402 reads the information in the storage 2401, and combines the hardware to complete the functions required to be executed by the units in the apparatus 2300 of the embodiments of the present application, or to perform the methods or steps performed by the execution device in Embodiment Seven of the methods of the present application.

[0540] The communication interface 2403 uses a transceiver such as but not limited to a transceiver to realize the communication between the apparatus 2400 and other devices or communication networks.

[0541] The bus 2404 can include a path for transmitting information between the various components (e.g., the storage 2401, the processor 2402, the communication interface 2403) of the apparatus 2400.

[0542] It should be noted that the above-mentioned apparatus 2300, apparatus 2400 can be an execution device in the apparatus 2300, apparatus 2400, or FIG. 1A the execution device in the apparatus 2300, apparatus 2400, orFIG. 1B-1F a user terminal in any of the systems, or other user terminals.

[0543] It should be noted that although FIG. 16 , FIG. 18 , FIG. 20 , FIG. 22 and FIG. 24 the devices shown only show the memory, processor, communication interface, but in the process of implementation, those skilled in the art should understand that FIG. 16 , FIG. 18 , FIG. 20 , FIG. 22 and FIG. 24 the devices shown can also include other devices necessary for normal operation. At the same time, according to the specific needs, those skilled in the art should understand that FIG. 16 , FIG. 18 , FIG. 20 , FIG. 22 and FIG. 24 the devices shown can also include hardware devices that implement other additional functions. In addition, those skilled in the art should understand that FIG. 16 , FIG. 18 , FIG. 20 , FIG. 22 and FIG. 24 the devices shown can also only include the devices necessary to implement the embodiments of the present application, and do not necessarily include FIG. 16 , FIG. 18 , FIG. 20 , FIG. 22 and FIG. 24 all the devices shown.

[0544] The method implemented by each of the above devices can refer to the related description in the above method embodiments, and the beneficial effects achieved by the above devices are also consistent with the above method embodiments, which will not be repeated here.

[0545] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto, any change or replacement within the technical scope disclosed in the present application should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A method for pruning a neural network, characterized in that, Applied to electronic devices, the method includes: Obtain target class features, which are used to characterize the features of data belonging to the target class; The global neural network is pruned based on the target class features to obtain a local neural network. The global neural network is an image recognition model for recognizing multiple classes, and the local neural network is an image recognition model for recognizing the target class. The multiple classes include the target class. The target class features include n-dimensional data, where n is a positive integer. The step of pruning the global neural network based on the target class features to obtain a local neural network includes: Based on each dimension of the n-dimensional data, a probability distribution corresponding to each dimension of the data is generated, resulting in n probability distributions, each of which corresponds one-to-one with the n-dimensional data; each probability distribution is used to indicate the probability that the neuron corresponding to each probability distribution in the global neural network will not be pruned. The global neural network is pruned according to the n probability distributions to obtain the local neural network.

2. The method according to claim 1, characterized in that, The local neural network includes neurons in the global neural network used to identify the target class; the first class and the second class are two classes among the plurality of classes; the more similar the class features of the first class and the class features of the second class are, the more identical neurons there are in the global neural network used to identify the first class and the neurons used to identify the second class.

3. The method according to claim 1 or 2, characterized in that, The step of generating a probability distribution corresponding to each dimension of the n-dimensional data, resulting in n probability distributions, includes: For each dimension of the n-dimensional data, a probability distribution corresponding to each dimension is generated using the mean of the data in each dimension, resulting in n probability distributions, each of which corresponds one-to-one with the n-dimensional data.

4. The method according to claim 3, characterized in that, The step of pruning the global neural network according to the n probability distributions to obtain the local neural network includes: Each layer of the global neural network is encoded separately; The distribution value of each neuron in each layer of the global neural network is determined to be the value corresponding to the encoding of each neuron in the probability distribution corresponding to each layer. The n probability distributions correspond to the layer structure in the global neural network, and the probability distribution corresponding to each layer is the probability distribution corresponding to the dimension of each layer in the n probability distributions. The local neural network is obtained by removing neurons in the global neural network whose distribution values ​​are less than a first threshold.

5. The method according to claim 3, characterized in that, The step of pruning the global neural network according to the n probability distributions to obtain the local neural network includes: Encode all neurons in the global neural network; Each of the n probability distributions is biased and then superimposed. The distribution value of each neuron in the global neural network is determined to be the value corresponding to the encoding of each neuron in the superimposed probability distribution; The local neural network is obtained by removing neurons in the global neural network whose distribution value is less than the second threshold.

6. The method according to claim 3, characterized in that, The target class includes at least two classes, and the acquisition of target class features includes: The target class features are obtained by weighted summation of the class features of each class in the target class.

7. A method for pruning a neural network, characterized in that, Applied to electronic devices, the method includes: Obtain target class features, which are used to characterize the features of data belonging to the target class; The global neural network is pruned based on the target class features to obtain a local neural network. The global neural network is an image recognition model for recognizing multiple classes, and the local neural network is an image recognition model for recognizing the target class. The multiple classes include the target class. The target class includes at least two classes, and the target class features include class features of each of the at least two classes. Each class feature includes n-dimensional data, where n is a positive integer. The step of pruning the global neural network based on the target class features to obtain a local neural network includes: For each class in the target class, a probability distribution corresponding to each dimension of the n-dimensional data is generated based on the data of each dimension, resulting in n probability distributions. The probability distribution of each class includes the n probability distributions. The neurons in the global neural network that affect each class are determined based on the probability distribution of each class. The n probability distributions correspond one-to-one with the n-dimensional data, and each probability distribution is used to indicate the probability that the neuron corresponding to each probability distribution in the global neural network will not be pruned. The neurons in the global neural network that act on the target class are determined to be the union of the neurons in the global neural network that act on all classes in the target class. The local neural network is obtained by removing all neurons from the global neural network except those that affect the target class.

8. The method according to claim 7, characterized in that, The step of generating a probability distribution corresponding to each dimension of the n-dimensional data based on each dimension of the data corresponding to each class, resulting in n probability distributions, includes: For each dimension of the n-dimensional data, a probability distribution corresponding to each dimension is generated using the mean of that dimension, resulting in n probability distributions.

9. The method according to claim 8, characterized in that, The step of determining the neurons in the global neural network that act on each class based on the probability distribution of each class includes: Each layer of the global neural network is encoded separately; The distribution value of each neuron in each layer of the global neural network is determined to be the value corresponding to the encoding of each neuron in the probability distribution corresponding to each layer. The n probability distributions correspond to the layer structure in the global neural network, and the probability distribution corresponding to each layer is the probability distribution corresponding to the dimension of each layer in the n probability distributions. Remove neurons in the global neural network whose distribution values ​​are less than a third threshold to obtain neurons in the global neural network that function for each class.

10. The method according to claim 8, characterized in that, The step of determining the neurons in the global neural network that act on each class based on the probability distribution of each class includes: Encode all neurons in the global neural network; Each of the n probability distributions is biased and then superimposed. The distribution value of each neuron in the global neural network is determined to be the value corresponding to the encoding of each neuron in the superimposed probability distribution; Remove neurons in the global neural network whose distribution values ​​are less than the fourth threshold to obtain neurons in the global neural network that function for each class.

11. A method for training a neural network, characterized in that, Applied to electronic devices, the method includes: Obtain target class features; the target class features are used to characterize the features of samples belonging to the target class, the target class including the class to which the samples in the training set belong; The global neural network is pruned based on the target class features to obtain a first local neural network; The first local neural network is trained using the training set to obtain the second local neural network; Wherein, the second local neural network is used to update the global neural network; the global neural network is an image recognition model for recognizing multiple classes, and the second local neural network is an image recognition model for recognizing the target class, wherein the multiple classes include the target class; The target class features include n-dimensional data, where n is a positive integer. The step of pruning the global neural network based on the target class features to obtain a first local neural network includes: Based on each dimension of the n-dimensional data, a probability distribution corresponding to each dimension of the data is generated, resulting in n probability distributions, each of which corresponds one-to-one with the n-dimensional data; each probability distribution is used to indicate the probability that the neuron corresponding to each probability distribution in the global neural network will not be pruned. The global neural network is pruned according to the n probability distributions to obtain the first local neural network.

12. The method according to claim 11, characterized in that, The first local neural network includes neurons in the global neural network used to identify the target class; the first class and the second class are two classes among the plurality of classes; if the class features of the first class are similar to the class features of the second class, then the more identical neurons in the global neural network used to identify the first class and the neurons used to identify the second class are.

13. The method according to claim 11, characterized in that, The step of generating a probability distribution corresponding to each dimension of the n-dimensional data, resulting in n probability distributions, includes: For each dimension of the n-dimensional data, a probability distribution corresponding to each dimension is generated using the mean of that dimension, resulting in n probability distributions.

14. The method according to claim 13, characterized in that, The step of pruning the global neural network according to the n probability distributions to obtain the first local neural network includes: Each layer of the global neural network is encoded separately; The distribution value of each neuron in each layer of the global neural network is determined to be the value corresponding to the encoding of each neuron in the probability distribution corresponding to each layer. The n probability distributions correspond to the layer structure in the global neural network, and the probability distribution corresponding to each layer is the probability distribution corresponding to the dimension of each layer in the n probability distributions. The first local neural network is obtained by removing neurons in the global neural network whose distribution value is less than a first threshold.

15. The method according to claim 13, characterized in that, The step of pruning the global neural network according to the n probability distributions to obtain the first local neural network includes: Encode all neurons in the global neural network; Each of the n probability distributions is biased and then superimposed. The distribution value of each neuron in the global neural network is determined to be the value corresponding to the encoding of each neuron in the superimposed probability distribution; The first local neural network is obtained by removing neurons in the global neural network whose distribution value is less than the second threshold.

16. The method according to claim 13, characterized in that, The target class includes at least two classes, and the acquisition of target class features includes: The target class features are obtained by weighted summation of the class features of each class in the target class.

17. The method according to any one of claims 11-16, characterized in that, The method further includes: The second local neural network is sent to the server, which is used to update the global neural network based on the second local neural network.

18. The method according to any one of claims 11-16, characterized in that, Before obtaining the target class features, the method further includes: Extract the features of the target class from each sample in the training set to obtain the features corresponding to each sample; The class center of the target class is obtained by taking a weighted average of the features corresponding to all samples in the training set. The class center of the target class is sent to the server, and the class center of the target class is used by the server to determine the characteristics of the target class.

19. The method according to any one of claims 11-16, characterized in that, The target class includes at least two classes, and the target class features include class features of at least two classes. Before obtaining the target class features, the method further includes: For each class in the target class, features of each class are extracted from the samples belonging to each class in the training set, and a weighted average is performed on the features corresponding to the samples belonging to each class to obtain the class center of each class. The class centers of all classes in the target class are sent to the server, and the class center of each class is used by the server to determine the class characteristics of each class.

20. A method for training a neural network, characterized in that, Applied to electronic devices, the method includes: Obtain target class features; the target class features are used to characterize the features of samples belonging to the target class, the target class including the class to which the samples in the training set belong; The global neural network is pruned based on the target class features to obtain a first local neural network; The first local neural network is trained using the training set to obtain the second local neural network; Wherein, the second local neural network is used to update the global neural network; the global neural network is an image recognition model for recognizing multiple classes, and the second local neural network is an image recognition model for recognizing the target class, wherein the multiple classes include the target class; The target class includes at least two classes, and the target class features include class features of each of the at least two classes. The step of pruning the global neural network based on the target class features to obtain a first local neural network includes: For each class in the target class, a probability distribution corresponding to each dimension of the n-dimensional data is generated based on the data of each dimension, resulting in n probability distributions. The probability distribution of each class includes the n probability distributions. The neurons in the global neural network that affect each class are determined based on the probability distribution of each class. The n probability distributions correspond one-to-one with the n-dimensional data, and each probability distribution is used to indicate the probability that the neuron corresponding to each probability distribution in the global neural network will not be pruned. The neurons in the global neural network that act on the target class are determined to be the union of the neurons in the global neural network that act on all classes in the target class. The first local neural network is obtained by removing all neurons from the global neural network except those that affect the target class.

21. The method according to claim 20, characterized in that, The step of generating the probability distribution corresponding to each dimension of the data based on each dimension of the n-dimensional data corresponding to each class includes: For each dimension of the n-dimensional data, a probability distribution corresponding to each dimension is generated using the mean of that dimension, resulting in n probability distributions.

22. The method according to claim 21, characterized in that, The step of determining the neurons in the global neural network that act on each class based on the probability distribution of each class includes: Each layer of the global neural network is encoded separately; The distribution value of each neuron in each layer of the global neural network is determined to be the value corresponding to the encoding of each neuron in the probability distribution corresponding to each layer. The n probability distributions correspond to the layer structure in the global neural network, and the probability distribution corresponding to each layer is the probability distribution corresponding to the dimension of each layer in the n probability distributions. Remove neurons in the global neural network whose distribution values ​​are less than a third threshold to obtain neurons in the global neural network that function for each class.

23. The method according to claim 21, characterized in that, The step of determining the neurons in the global neural network that act on each class based on the probability distribution of each class includes: Encode all neurons in the global neural network; Each of the n probability distributions is biased and then superimposed. The distribution value of each neuron in the global neural network is determined to be the value corresponding to the encoding of each neuron in the superimposed probability distribution; Remove neurons in the global neural network whose distribution values ​​are less than the fourth threshold to obtain neurons in the global neural network that function for each class.

24. The method according to any one of claims 20-23, characterized in that, The method further includes: The second local neural network is sent to the server, which is used to update the global neural network based on the second local neural network.

25. The method according to any one of claims 20-23, characterized in that, Before obtaining the target class features, the method further includes: Extract the features of the target class from each sample in the training set to obtain the features corresponding to each sample; The class center of the target class is obtained by taking a weighted average of the features corresponding to all samples in the training set. The class center of the target class is sent to the server, and the class center of the target class is used by the server to determine the characteristics of the target class.

26. The method according to any one of claims 20-23, characterized in that, The target class includes at least two classes, and the target class features include class features of at least two classes. Before obtaining the target class features, the method further includes: For each class in the target class, features of each class are extracted from the samples belonging to each class in the training set, and a weighted average is performed on the features corresponding to the samples belonging to each class to obtain the class center of each class. The class centers of all classes in the target class are sent to the server, and the class center of each class is used by the server to determine the class characteristics of each class.

27. A method for training a neural network, characterized in that, Applied to electronic devices, the method includes: A global neural network is sent to multiple user terminals; the global neural network is an image recognition model used to identify multiple classes. The system receives a second local neural network sent by the plurality of user terminals respectively. The second local neural network is an image recognition model for identifying target classes. The plurality of classes include the target class. The second local neural network is obtained by the user terminal training a first local neural network through a training set. The first local neural network is a local neural network obtained by the user terminal through the method described in any one of claims 1-10. The target class features are used to characterize the features of samples belonging to the target class in the training set. The global neural network is updated based on the received second local neural network.

28. The method according to claim 27, characterized in that, The step of updating the global neural network based on the received second local neural network includes: For each neuron in the global neural network, the network parameters of each neuron in the updated global neural network are determined to be the weighted average of the network parameters of each neuron in the received second local neural network.

29. The method according to claim 27 or 28, characterized in that, The method further includes: The system receives the class center of the target class sent by the at least one user terminal; the first user terminal is any one of the at least one user terminal, and the class center of the target class sent by the first user terminal is obtained by weighted averaging of features extracted from samples belonging to the target class in the training set of the first user terminal. The characteristics of the target class are determined based on the class center of the received target class.

30. A class recognition method, characterized in that, Applied to electronic devices, the method includes: Obtain target class features, which are used to characterize the features of data belonging to the target class; The global neural network is pruned based on the target class features to obtain a local neural network, wherein the global neural network is an image recognition model for recognizing multiple classes, and the local neural network is an image recognition model for recognizing the target class, wherein the multiple classes include the target class; the local neural network is obtained by the method described in any one of claims 1-10; The data to be identified is input into the local neural network to obtain the identification result.

31. A neural network pruning device, characterized in that, include: An acquisition unit is used to acquire target class features, wherein the target class features are used to characterize the features of data belonging to the target class; A cropping unit is used to crop the global neural network according to the target class features to obtain a local neural network, wherein the global neural network is an image recognition model for recognizing multiple classes, and the local neural network is an image recognition model for recognizing the target class, wherein the multiple classes include the target class; The target class feature includes n-dimensional data, where n is a positive integer, and the cropping unit is specifically used for: Based on each dimension of the n-dimensional data, a probability distribution corresponding to each dimension of the data is generated, resulting in n probability distributions, each of which corresponds one-to-one with the n-dimensional data; each probability distribution is used to indicate the probability that the neuron corresponding to each probability distribution in the global neural network will not be pruned. The global neural network is pruned according to the n probability distributions to obtain the local neural network.

32. The apparatus according to claim 31, characterized in that... The cutting unit is also specifically used for: For each dimension of the n-dimensional data, a probability distribution corresponding to each dimension is generated using the mean of that dimension.

33. The apparatus according to claim 32, characterized in that, The cutting unit includes: The first encoding unit is used to encode each layer of the global neural network separately; The first determining unit is used to determine that the distribution value of each neuron in each layer of the global neural network is the value corresponding to the encoding of each neuron in the probability distribution corresponding to each layer of the global neural network, wherein the n probability distributions correspond to the layer structure in the global neural network, and the probability distribution corresponding to each layer of the global neural network is the probability distribution corresponding to the dimension of each layer of the global neural network. The first removal unit is used to remove neurons in the global neural network whose distribution value is less than a first threshold, thereby obtaining the local neural network.

34. The apparatus according to claim 32, characterized in that, The cutting unit includes: The second encoding unit is used to encode all neurons in the global neural network; The superposition unit is used to superimpose each of the n probability distributions after adding a bias; The second determining unit is used to determine the distribution value of each neuron in the global neural network as the value corresponding to the encoding of each neuron in the superimposed probability distribution; The second removal unit is used to remove neurons in the global neural network whose distribution value is less than a second threshold, thereby obtaining the local neural network.

35. The apparatus according to any one of claims 32-34, characterized in that, The target class includes at least two classes, and the acquisition unit is specifically used for: The target class features are obtained by weighted summation of the class features of each class in the target class.

36. A training device for a neural network, characterized in that, include: The acquisition unit is used to acquire target class features; The target class feature is used to characterize the features of samples belonging to the target class, and the target class includes the class to which the samples in the training set belong; The pruning unit is used to prune the global neural network according to the target class features to obtain a first local neural network; The training unit is used to train the first local neural network using the training set to obtain the second local neural network; Wherein, the second local neural network is used to update the global neural network; the global neural network is an image recognition model for recognizing multiple classes, and the second local neural network is an image recognition model for recognizing the target class, wherein the multiple classes include the target class; The target class features include n-dimensional data, where n is a positive integer. The step of pruning the global neural network based on the target class features to obtain a first local neural network includes: Based on each dimension of the n-dimensional data, a probability distribution corresponding to each dimension of the data is generated, resulting in n probability distributions, each of which corresponds one-to-one with the n-dimensional data; each probability distribution is used to indicate the probability that the neuron corresponding to each probability distribution in the global neural network will not be pruned. The global neural network is pruned according to the n probability distributions to obtain the first local neural network.

37. The apparatus according to claim 36, characterized in that, The device further includes: A sending unit is configured to send the second local neural network to a server, wherein the server is configured to update the global neural network based on the second local neural network.

38. The apparatus according to claim 36, characterized in that, The device further includes: An extraction unit is used to extract features of the target class from each sample in the training set, thereby obtaining features corresponding to each sample. The calculation unit is used to perform a weighted average of the features corresponding to all samples in the training set to obtain the class center of the target class; The sending unit is used to send the class center of the target class to the server, and the class center of the target class is used by the server to determine the characteristics of the target class.

39. A training device for a neural network, characterized in that, include: The transmitting unit is used to send the global neural network to multiple user terminals; The global neural network is an image recognition model used to identify multiple classes; A receiving unit is configured to receive a second local neural network sent by the plurality of user terminals respectively. The second local neural network is an image recognition model for identifying target classes. The plurality of classes include the target class. The second local neural network is obtained by the user terminal through training a first local neural network using a training set. The first local neural network is a local neural network obtained by the user terminal through the method described in any one of claims 1-10. The target class features are used to characterize the features of samples belonging to the target class in the training set. An update unit is used to update the global neural network based on the received second local neural network.

40. The apparatus according to claim 39, characterized in that, The update unit is specifically used for: For each neuron in the global neural network, the network parameters of each neuron in the updated global neural network are determined to be the weighted average of the network parameters of each neuron in the received second local neural network.

41. The apparatus according to claim 39 or 40, characterized in that, The device further includes: A receiving unit is configured to receive the class center of the target class sent by the at least one user terminal respectively; the first user terminal is any one of the at least one user terminal, and the class center of the target class sent by the first user terminal is obtained by weighted averaging of features extracted from samples belonging to the target class in the training set of the first user terminal. A determining unit is used to determine the target class features based on the class center of the received target class.

42. A type identification device, characterized in that, include: An acquisition unit is used to acquire target class features, wherein the target class features are used to characterize the features of data belonging to the target class; A pruning unit is configured to prune the global neural network according to the target class features to obtain a local neural network, wherein the global neural network is an image recognition model for recognizing multiple classes, and the local neural network is an image recognition model for recognizing the target class, wherein the multiple classes include the target class; the local neural network is obtained by the method described in any one of claims 1-10; The recognition unit is used to input the data to be recognized into the local neural network to obtain the recognition result.

43. A neural network pruning device, characterized in that, The device includes a processor, a memory, and a communication interface, wherein the processor and the communication interface are connected to the processor, the memory is used to store a program, and the processor is used to execute the program stored in the memory, such that the device implements the neural network pruning method as described in any one of claims 1-10.

44. A training device for a neural network, characterized in that, The device includes a processor, a memory, and a communication interface, wherein the processor and the communication interface are connected to the processor, the memory is used to store a program, and the processor is used to execute the program stored in the memory, such that the device implements the neural network training method as described in any one of claims 11-26.

45. A training device for a neural network, characterized in that, The system includes a processor, a memory, and a communication interface. The processor and the communication interface are connected to the processor. The memory is used to store a program, and the processor is used to execute the program stored in the memory, so that the server implements the neural network training method as described in any one of claims 27-29.

46. ​​A type identification device, characterized in that, The system includes a processor, a memory, and a communication interface. The processor and the communication interface are connected to the processor. The memory is used to store a program, and the processor is used to execute the program stored in the memory, so that the user terminal implements the method as described in claim 30.

Citation Information

Patent Citations

  • Neural network system and vehicle identification method based on neural network system

    CN108052861A

  • Neural network parameter initialization method and device

    CN110909860A