Convolutional neural network training method and system

By constructing a batch data set in a convolutional neural network and splitting the model into a feature extractor and classifier, using comparison loss to protect the model gradient, the problems of high training accuracy loss and high computational complexity in the existing technology are solved, and efficient gradient privacy protection is achieved.

CN118798302BActive Publication Date: 2025-04-29HANGZHOU SHIPING INFORMATION & TECH +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411263294.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-10
Publication Date
2025-04-29
Estimated Expiration
2044-09-10

AI Technical Summary

Technical Problem

The existing model gradient protection method protects the gradient information by adding random noise in training, resulting in significant loss of training accuracy and reduced model performance; at the same time, homomorphic encryption is used to protect the gradient information, which has high computational complexity and low training efficiency.

Method used

By constructing a batch dataset, the convolutional neural network is split into two parts: feature extractor and classifier, using contrast loss as noise to provide privacy protection for model gradients, avoiding the negative impact of random noise on training, and reducing the overhead of encryption and decryption.

Benefits of technology

While ensuring the privacy of gradient information, it reduces the impact on training accuracy, improves training efficiency, and avoids the problem of high computational complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118798302B_ABST
    Figure CN118798302B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of neural networks and discloses a convolutional neural network training method and system. The method includes: obtaining a data set and randomly selecting b samples; for X m uniformly and randomly sampling in the data set to obtain samples N m with different labels from X m and samples P m with the same label as X m ; taking X m , N m , P m as a sample set {X m , N m , P m}, denoted as data group B m ; b data groups form a batch data set B, and randomly shuffle the order of samples in the batch data set B, denoted as B S ; receive the set {X, X f}; where X f is a feature map obtained by feature extraction for each sample X in B S ; obtain the gradient G according to the received set {X, X f}; update the convolutional neural network parameters according to the gradient G. The present invention adds a contrastive loss to the objective function to provide privacy protection for the model gradient during training on the premise of having a small impact on accuracy with noise.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of neural networks, and in particular to a convolutional neural network training method and system. Background Art

[0002] Model gradient protection is an important concept in the training of convolutional neural networks (CNNs), especially in applications involving sensitive data, such as medical image processing, personal data analysis, etc. The purpose of this technology is to protect data privacy and model integrity during model training, and prevent malicious attackers from inferring details of training data by analyzing gradient information. Currently, there are roughly the following methods for model gradient protection:

[0003] 1. Differential Privacy:

[0004] Differential privacy technology protects the privacy of personal data by adding noise to the gradient, ensuring that the output of the model does not change significantly after deleting or adding a single data point. This method can effectively reduce the risk of leaking sensitive information through gradients. In practice, differential privacy usually requires a trade-off between the strength of privacy protection and model performance, because the added random noise may affect the training effect.

[0005] 2. Homomorphic Encryption:

[0006] Homomorphic encryption is a technology that allows calculations to be performed directly on encrypted data, and the calculation results remain valid after decryption. In CNN training, homomorphic encryption can be used to protect gradients, so that the calculation and transmission of gradients are performed in an encrypted state, ensuring data security.

[0007] 3. Secure Multi-Party Computation (MPC):

[0008] Secure multi-party computation is a technology that allows multiple parties to jointly complete computing tasks while preserving the privacy of their input data. In CNN training, MPC can be used to securely calculate gradients and update model parameters without any party exposing their private data.

[0009] 4. Federated Learning:

[0010] Federated learning allows multiple devices or data centers to collaboratively train a shared model without centralizing the data to a single location. In this setting, gradients or model updates can be aggregated after being computed locally, reducing the information that any single update might leak by aggregating multiple updates.

[0011] The paper Privacy-preserving deep learning uses a differential privacy method to protect gradient information by adding random noise during training. Although this ensures the privacy of gradient information, it also causes a significant loss in training accuracy and reduces model performance after training.

[0012] A Chinese patent application with publication number CN113037460A discloses a privacy protection method for federated learning based on homomorphic encryption and secret sharing. The method includes two parts: a gradient protection method based on homomorphic encryption and a random number protection method based on secret sharing. By adopting the gradient protection method based on homomorphic encryption, the protection of the gradient is achieved, and the aggregation of the gradient ciphertext can be completed at the same time, which can effectively prevent the leakage of gradient privacy information and achieve secure aggregation of the gradient; by using the random number protection method based on secret sharing, the gradient ciphertext is protected, and the random number protected by the gradient ciphertext is protected, which can effectively prevent collusion attacks between the aggregation server, the key generation server and the participating parties, and further ensure the security of the gradient information during the interaction between the three.

[0013] The shortcomings of the prior art mainly include the following two points:

[0014] 1. The existing model gradient protection scheme based on differential privacy protects gradient information by adding random noise during training. Although it ensures the privacy of gradient information, it also causes a significant loss in training accuracy and reduces model performance after training.

[0015] 2. The existing model gradient protection scheme uses homomorphic encryption to protect gradient information, which has high computational complexity and low training efficiency. Summary of the invention

[0016] The purpose of the present invention is to provide a convolutional neural network training method and system to solve at least one of the technical problems existing in the existing model gradient protection, namely, obvious loss of training accuracy, reduced model performance after training, high computational complexity, and low training efficiency.

[0017] In a first aspect, the present invention provides a convolutional neural network training method, comprising:

[0018] Obtain a data set for training a convolutional neural network; the first participant randomly selects b samples X1, X2, ..., X m , ...... , X b ; For each sample X m Uniformly randomly sample from the data set with m A sample N with different labels m and has the same mA sample P with the same label m ; For each sample X m and its corresponding sample N m , sample P m As a sample set {X m , N m , P m}, recorded as data group B m , 1≤m≤b; b data sets form a batch data set B={ B 1 , B 2 , B 3 ,……,B m ,……, B b}; Randomly shuffle the order of the data group samples in the batch data set B, denoted as B S ; The first party will B S Send the second party;

[0019] The second party to B S Extract features from each sample X to obtain feature map X f , and the set {X, X f}Send to the first party;

[0020] The first participant receives the set {X, X f};

[0021] The first participant receives the set {X, X f}Get the gradient G and update the output layer parameters through the gradient descent algorithm;

[0022] The second participant updates the convolutional neural network parameters according to the gradient G.

[0023] The present invention is further improved in that: the first participant stores a classifier of the convolutional neural network; the second participant stores a feature extractor of the convolutional neural network;

[0024] Among them, the last fully connected layer in the convolutional neural network is split as a classifier, and the remaining layers are used as feature extractors.

[0025] The present invention is further improved in that: the first participant receives the set {X, X f} Obtaining the gradient G; The second participant updates the convolutional neural network parameters according to the gradient G, specifically including:

[0026] The first party will receive the set {X, X f} in the feature map X f Pass in the classifier and get the predicted category c;

[0027] Calculating cross entropy loss ;

[0028] For the collected feature map X f According to the data set B saved locally m To classify;

[0029] Compute contrast loss based on classification ;

[0030] by As the loss function, the partial derivative of the convolutional neural network output y is calculated to obtain the gradient G relative to the output y, G = , sent to the second participant; then, using the chain rule, find the gradient of the output layer weight W, that is, , and the gradient about the output layer bias b, that is, ; Update the output layer weight W and output layer bias b through the gradient descent algorithm;

[0031] The second participant calculates the gradient G of L relative to the current layer output G'= W T , where W T The convolutional neural network parameters are updated by the gradient descent algorithm, and the back propagation continues to repeat the update process.

[0032] The present invention is further improved in that: the calculation of cross entropy loss In the steps, the calculation formula is:

[0033]

[0034] Among them, 3b is the total number of samples, C is the total number of possible categories, is a one-hot encoding vector, indicating that the predicted category c of the i-th sample is the same as the true category, then ,otherwise ; is the probability that the convolutional neural network predicts that the i-th sample belongs to category c.

[0035] The present invention is further improved in that: the collected feature graph X f According to the data set B saved locally m The steps for classification include:

[0036] From sample X m The extracted feature map is denoted as X f , from sample X m The corresponding sample N m , sample P m The extracted feature maps are denoted as N f , Pf , for the sample set {X m , N m , P m}, get the feature map set {X f , N f , P f}.

[0037] The present invention is further improved in that: the calculation of contrast loss In the steps, the calculation formula is:

[0038]

[0039] in, For X f and P f The distance between ;

[0040] For X f and N f The distance between ;

[0041] in, k Preserve security parameters for gradient privacy.

[0042] In a second aspect, the present invention provides a convolutional neural network training method, which iteratively executes the above-mentioned convolutional neural network training method until a preset number of iterations is reached, or the loss function of the convolutional neural network converges, thereby completing the training of the convolutional neural network and obtaining a trained convolutional neural network.

[0043] In a third aspect, the present invention provides a convolutional neural network training system, comprising:

[0044] The first participant is used to obtain a data set for training a convolutional neural network; randomly select b samples X1, X2, ..., X in the data set m , ...... , X b ; For each sample X m Uniformly randomly sample from the data set with m A sample N with different labels m and has the same m A sample P with the same label m ; For each sample X m and its corresponding sample N m , sample P m As a sample set {X m , N m , P m}, recorded as data group B m, 1≤m≤b; b data sets form a batch data set B={ B 1 , B 2 , B 3 ,……,B m ,……, B b}; Randomly shuffle the order of samples in batch data set B, denoted as B S ; B S Send the second participant; receive the set {X, X f}, according to the received set {X, X f}Get the gradient G relative to the output;

[0045] The second party, for S Extract features from each sample X to obtain feature map X f , and the set {X, X f}Send to the first participant; Calculate the gradient G' about the output of each layer layer by layer according to the gradient G relative to the output, and update the convolutional neural network parameters.

[0046] The present invention is further improved in that: the first participant stores a classifier of the convolutional neural network; the second participant stores a feature extractor of the convolutional neural network;

[0047] Among them, the last fully connected layer in the convolutional neural network is split as a classifier, and the remaining layers are used as feature extractors.

[0048] The present invention is further improved in that: the first participant receives the set {X, X f The steps to obtain the gradient G include:

[0049] The first party will receive the set {X, X f} in the feature map X f Pass in the classifier and get the predicted category c;

[0050] Calculating cross entropy loss ;

[0051] For the collected feature map X f According to the data set B saved locally m To classify;

[0052] Compute contrast loss based on classification ;

[0053] by As the loss function, the partial derivative of the convolutional neural network output y is calculated to obtain the gradient G relative to the output y, G = , sent to the second participant; then, using the chain rule, find the gradient of the output layer weight W, that is, , and the gradient about the output layer bias b, that is, ; Update the output layer weight W and output layer bias b through the gradient descent algorithm;

[0054] The second participant calculates the gradient G of L relative to the current layer output G'= W T , where W T The convolutional neural network parameters are updated by the gradient descent algorithm, and the back propagation continues to repeat the update process.

[0055] The present invention is further improved in that: the cross entropy loss The calculation formula is:

[0056]

[0057] Among them, 3b is the total number of samples, C is the total number of possible categories, is a one-hot encoding vector, indicating that the predicted category c of the i-th sample is the same as the true category, then ,otherwise ; is the probability that the convolutional neural network predicts that the i-th sample belongs to category c.

[0058] The present invention is further improved in that: the collected feature graph X f According to the data set B saved locally m The steps for classification include:

[0059] From sample X m The extracted feature map is denoted as X f , from sample X m The corresponding sample N m , sample P m The extracted feature maps are denoted as N f , P f , for the sample set {X m , N m , P m}, get the feature map set {X f , N f , P f}.

[0060] The present invention is further improved in that: the contrast loss The calculation formula is:

[0061]

[0062] in, For X fand P f The distance between ;

[0063] For X f and N f The distance between ;

[0064] in, k Preserve security parameters for gradient privacy.

[0065] Compared with the prior art, the present invention has the following beneficial effects:

[0066] The present invention provides a convolutional neural network training method and related system, wherein the last fully connected layer in the convolutional neural network is saved as a classifier to a client, and the rest is saved as a feature extraction part to a server, so that the network is more efficient and flexible in processing various image classification tasks. By constructing a batch data set, the present invention can retain more training data information locally, so that triplet loss can be calculated.

[0067] The present invention provides privacy protection for the model gradient during training by adding contrast loss as noise in the objective function with little impact on accuracy. Compared with random noise, which has a positive supervisory effect on training, it has little impact on training accuracy while ensuring the privacy of gradient information.

[0068] The present invention does not require encryption and decryption, greatly reduces privacy protection overhead, and has higher training efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0069] The accompanying drawings constituting a part of the present invention are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the accompanying drawings:

[0070] Figure 1 A flow chart of a convolutional neural network training method for inventing model gradient protection based on contrast noise;

[0071] Figure 2 This is an iterative flow chart of a convolutional neural network training method based on model gradient protection of contrast noise according to the present invention;

[0072] Figure 3 A structural schematic diagram of a convolutional neural network training system according to an embodiment of the present invention. DETAILED DESCRIPTION

[0073] The present invention will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present invention can be combined with each other without conflict.

[0074] The following detailed description is an exemplary description, which is intended to provide further detailed description of the present invention. Unless otherwise specified, all technical terms used in the present invention have the same meaning as those generally understood by those skilled in the art to which the present invention belongs. The terms used in the present invention are only for describing specific embodiments, and are not intended to limit the exemplary embodiments according to the present invention.

[0075] Privacy protection of model gradients during training is not only an effective way to protect training data from being leaked, but also helps build secure and compliant AI systems. Gradients play an important role in neural network training, directly guiding the parameter update process, helping the model learn to extract features from input data and reduce the probability of incorrect predictions. Although the gradient itself is not raw data, in some cases, by analyzing the gradient value, attackers can infer information about the input data or even reconstruct the original data. In distributed learning or federated learning scenarios, the gradient of the model needs to be shared among participants to update the global model. If the gradient is not encrypted or privacy-protected, it may be exploited by malicious participants, endangering data privacy and model security. In addition, with the tightening of data protection regulations, such as the EU's GDPR, higher requirements are placed on the privacy protection of machine learning models processing personal data. Gradient privacy protection helps make model training comply with these laws and regulations.

[0076] See also Figure 1 and Figure 2 As shown, in order to solve the problem of gradient privacy protection, the embodiment of the present invention proposes a convolutional neural network training method based on model gradient protection of contrast noise, which provides privacy protection for model gradient by adding contrast loss as contrast noise in the objective function. Compared with the prior art, the present invention has less impact on training accuracy, and the specific steps are as follows:

[0077] S10. Preparation before training:

[0078] S101, convolutional neural network splitting:

[0079] The convolutional neural network to be trained is split into two parts: a feature extractor and a classifier. The specific splitting method is as follows: the last fully connected layer in the original convolutional neural network is split and saved as a classifier to the client, and the remaining layers of the original convolutional neural network are saved as feature extractors to the server.

[0080] S102, parameter setting:

[0081] The user sets the gradient privacy protection security parameters k and g.

[0082] In a specific implementation, the gradient privacy protection security parameters k and g are both numbers greater than 0.

[0083] When training a convolutional neural network, the specific steps for each iteration are as follows.

[0084] S1. Obtain a data set for training a convolutional neural network; the client splits the data set and constructs a batch data set B.

[0085] In a specific implementation, the client splits the data set to construct the batch data set B, specifically including:

[0086] S11. The client randomly selects b samples X1, X2, ..., X in the data set m , ...... , X b For each sample X m , uniformly randomly sample from the data set with m A sample N with different labels m and has the same m A sample P with the same label m ; Wherein, b is a positive integer greater than 0.

[0087] S12, each sample X m and its corresponding sample N m , sample P m As a sample set {X m , N m , P m}, recorded as data group B m , 1≤m≤b; b data sets form a batch data set B={ B 1 , B 2 , B 3 ,……,B m ,……, B b}Save on the client.

[0088] S13, randomly shuffle the order of the data group samples in the batch data set B, denoted as B S . Client Record B S The original position of each sample in B S Send to the server.

[0089] S2, the server receives the B S Each sample X is subjected to feature extraction to obtain a feature map X f ; Send the set {X, X f} to the client.

[0090] S3, the client receives the set {X, X f}Update the convolutional neural network parameters;

[0091] In a specific implementation manner, the client receives the set {X, X f} Update the convolutional neural network parameters, including:

[0092] S31. The client receives the set {X, X f} in the feature map X f Pass into the classifier and get the predicted category c.

[0093] S32. Calculate the cross entropy loss:

[0094]

[0095] Among them, 3b is the total number of samples, C is the total number of possible categories, is a one-hot encoding vector, indicating that the predicted category c of the i-th sample is the same as the true category, then ,otherwise . is the probability that the convolutional neural network predicts that the i-th sample belongs to category c.

[0096] S33, the collected feature map X f According to the data set B saved locally m To classify;

[0097] In a specific implementation, the collected feature graph X f According to the data set B saved locally m Classification, including:

[0098] From sample X m The extracted feature map is denoted as X f , from sample X m The corresponding sample N m , sample P m The extracted feature maps are denoted as N f , P f , for the sample set {X m , N m , P m}, get the feature map set {X f , N f , P f}.

[0099] S34. Calculate contrast loss :

[0100]

[0101] in, For X f and P fThe distance between ;

[0102] For X f and N f The distance between .

[0103] S35, As the loss function, the partial derivative of the convolutional neural network output y is calculated to obtain the gradient G relative to the output y, G = , sent to the server; then, using the chain rule, find the gradient of the output layer weight W, that is, , and the gradient about the output layer bias b, that is, ; Update the output layer weight W and output layer bias b through the gradient descent algorithm.

[0104] S4, the server calculates the gradient G of L relative to the current layer output G'= W T , where W T The convolutional neural network parameters are updated by the gradient descent algorithm, and the back propagation continues to repeat the update process.

[0105] Iterate steps S1-S4 until the maximum number of training times is reached or the loss function of the convolutional neural network converges, completing the training of the convolutional neural network and obtaining a trained convolutional neural network.

[0106] An embodiment of the present invention provides a convolutional neural network training method, comprising:

[0107] Obtain a data set for training a convolutional neural network; the first participant randomly selects b samples X1, X2, ..., X m , ...... , X b ; For each sample X m Uniformly randomly sample from the data set with m A sample N with different labels m and has the same m A sample P with the same label m ; For each sample X m and its corresponding sample N m , sample P m As a sample set {X m , N m , P m}, recorded as data group B m , 1≤m≤b; b data sets form a batch data set B={ B 1 , B2 , B 3 ,……,B m ,……, B b}; Randomly shuffle the order of the data group samples in the batch data set B, denoted as B S ; The first party will B S Send the second party;

[0108] The second party to B S Extract features from each sample X to obtain feature map X f , and the set {X, X f}Send to the first party;

[0109] The first participant receives the set {X, X f};

[0110] The first participant receives the set {X, X f}Get the gradient G and update the output layer parameters through the gradient descent algorithm;

[0111] The second participant updates the convolutional neural network parameters according to the gradient G.

[0112] A further improvement of the present invention is that: the first participant stores a classifier of the convolutional neural network; the second participant stores a feature extractor of the convolutional neural network;

[0113] Among them, the last fully connected layer in the convolutional neural network is split as a classifier, and the remaining layers are used as feature extractors.

[0114] A further improvement of the present invention is that: the first participant receives the set {X, X f} Obtaining the gradient G; The second participant updates the convolutional neural network parameters according to the gradient G, specifically including:

[0115] The first party will receive the set {X, X f} in the feature map X f Pass in the classifier and get the predicted category c;

[0116] Calculating cross entropy loss ;

[0117] For the collected feature map X f According to the data set B saved locally m To classify;

[0118] Compute contrast loss based on classification ;

[0119] by As the loss function, the partial derivative of the convolutional neural network output y is calculated to obtain the gradient G relative to the output y, G = , sent to the second participant; then, using the chain rule, find the gradient of the output layer weight W, that is, , and the gradient about the output layer bias b, that is, ; Update the output layer weight W and output layer bias b through the gradient descent algorithm;

[0120] The second participant calculates the gradient G of L relative to the current layer output G'= W T , where W T The convolutional neural network parameters are updated by the gradient descent algorithm, and the back propagation continues to repeat the update process.

[0121] A further improvement of the present invention is that: the cross entropy loss is calculated In the steps, the calculation formula is:

[0122]

[0123] Among them, 3b is the total number of samples, C is the total number of possible categories, is a one-hot encoding vector, indicating that the predicted category c of the i-th sample is the same as the true category, then ,otherwise . is the probability that the convolutional neural network predicts that the i-th sample belongs to category c.

[0124] A further improvement of the present invention is that: the collected feature graph X f According to the batch data set B saved locally T The steps for classification include:

[0125] From sample X m The extracted feature map is denoted as X f , from sample X m The corresponding sample N m , sample P m The extracted feature maps are denoted as N f , P f , for the sample set {X m , N m , P m}, get the feature map set {X f , N f , P f}.

[0126] A further improvement of the present invention is that: the calculation of contrast loss In the steps, the calculation formula is:

[0127]

[0128] in, For X f and P f The distance between ;

[0129] For X f and N f The distance between ;

[0130] in, k Preserve security parameters for gradient privacy.

[0131] The convolutional neural network training method is iteratively executed until a preset number of iterations is reached or the loss function of the convolutional neural network converges, the training of the convolutional neural network is completed, and a trained convolutional neural network is obtained.

[0132] See also Figure 3 As shown, an embodiment of the present invention provides a convolutional neural network training system, including:

[0133] The first participant is used to obtain a data set for training a convolutional neural network; randomly select b samples X1, X2, ..., X in the data set m , ...... , X b ; For each sample X m Uniformly randomly sample from the data set with m A sample N with different labels m and has the same m A sample P with the same label m ;

[0134] For each sample X m and its corresponding sample N m , sample P m As a sample set {X m , N m , P m}, recorded as data group B m , 1≤m≤b; b data sets form a batch data set B={ B 1 , B 2 , B 3 ,……,B m ,……, B b}; Randomly shuffle the order of samples in batch data set B, denoted as B S ; B SSend the second participant; receive the set {X, X f}, according to the received set {X, X f}Get the gradient G relative to the output and update the output layer parameters through the gradient descent algorithm;

[0135] The second party, for S Extract features from each sample X to obtain feature map X f , and the set {X, X f}Send to the first participant; Calculate the gradient G' about the output of each layer layer by layer according to the gradient G relative to the output, and update the convolutional neural network parameters.

[0136] A further improvement of the present invention is that: the first participant stores a classifier of the convolutional neural network; the second participant stores a feature extractor of the convolutional neural network;

[0137] Among them, the last fully connected layer in the convolutional neural network is split as a classifier, and the remaining layers are used as feature extractors.

[0138] A further improvement of the present invention is that: the first participant receives the set {X, X f The steps to obtain the gradient G include:

[0139] The first party will receive the set {X, X f} in the feature map X f Pass in the classifier and get the predicted category c;

[0140] Calculating cross entropy loss ;

[0141] For the collected feature map X f According to the data set B saved locally m To classify;

[0142] Compute contrast loss based on classification ;

[0143] by As the loss function, the partial derivative of the convolutional neural network output y is calculated to obtain the gradient G relative to the output y, G = , sent to the second participant; then, using the chain rule, find the gradient of the output layer weight W, that is, , and the gradient about the output layer bias b, that is, ; Update the output layer weight W and output layer bias b through the gradient descent algorithm;

[0144] The second participant calculates the gradient G of L relative to the current layer output G'= WT , where W T The convolutional neural network parameters are updated by the gradient descent algorithm, and the back propagation continues to repeat the update process.

[0145] A further improvement of the present invention is that: the cross entropy loss The calculation formula is:

[0146]

[0147] Among them, 3b is the total number of samples, C is the total number of possible categories, is a one-hot encoding vector, indicating that the predicted category c of the i-th sample is the same as the true category, then ,otherwise . is the probability that the convolutional neural network predicts that the i-th sample belongs to category c.

[0148] A further improvement of the present invention is that: the collected feature graph X f According to the batch data set B saved locally T The steps for classification include:

[0149] From sample X m The extracted feature map is denoted as X f , from sample X m The corresponding sample N m , sample P m The extracted feature maps are denoted as N f , P f , for the sample set {X m , N m , P m}, get the feature map set {X f , N f , P f}.

[0150] A further improvement of the present invention is that: the contrast loss The calculation formula is:

[0151]

[0152] in, For X f and P f The distance between ;

[0153] For X f and N f The distance between ;

[0154] in, k Preserve security parameters for gradient privacy.

[0155] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0156] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0157] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0158] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0159] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A convolutional neural network training method, characterized in that: include: Get a dataset for training a convolutional neural network; The client randomly selects b samples X1, X2,..., X in the data set m , ...... , X b ; For each sample X m Uniformly randomly sample from the data set with m A sample N with different labels m and has the same m A sample P with the same label m ; For each sample X m and its corresponding sample N m , sample P m As a sample set {X m , N m , P m }, recorded as data group B m , 1≤m≤b; b data sets form a batch data set B={B 1 , B 2 , B 3 ,……,B m ,……, B b }; Randomly shuffle the order of the data group samples in the batch data set B, denoted as B S ; The client will B S Sending server; Server B S Extract features from each sample X to obtain feature map X f , and the set {X, X f }Send to the client; The client receives the set {X, X f }; The client receives the set {X, X f }Get the gradient G and update the output layer parameters through the gradient descent algorithm; The server updates the convolutional neural network parameters according to the gradient G; The client stores the classifier of the convolutional neural network; the server stores the feature extractor of the convolutional neural network; Among them, the last fully connected layer in the convolutional neural network is split and used as a classifier for image classification; the remaining layers are used as feature extractors.

2. The convolutional neural network training method according to claim 1, characterized in that: The client receives the set {X, X f }Get gradient G; The server updates the convolutional neural network parameters according to the gradient G, specifically including: The client will receive the set {X, X f } in the feature map X f Pass in the classifier and get the predicted category c; Calculating cross entropy loss ; For the collected feature map X f According to the data set B saved locally m To classify; Compute contrast loss based on classification ; by As the loss function, the partial derivative of the convolutional neural network output y is calculated to obtain the gradient G relative to the output y, G = , sent to the server; then, using the chain rule, find the gradient of the output layer weight W, that is, , and the gradient about the output layer bias b, that is, ; Update the output layer weight W and output layer bias b through the gradient descent algorithm; The server calculates the gradient G of L relative to the current layer output G'= W T , where W T is the transpose of the current layer weights, and the convolutional neural network parameters are updated through the gradient descent algorithm, and the back propagation continues to repeat the update process.

3. The convolutional neural network training method according to claim 2, characterized in that: The cross entropy loss is calculated In the steps, the calculation formula is: Among them, 3b is the total number of samples, C is the total number of possible categories, is a one-hot encoding vector, indicating that the predicted category c of the i-th sample is the same as the true category, then ,otherwise ; is the probability that the convolutional neural network predicts that the i-th sample belongs to category c.

4. The convolutional neural network training method according to claim 2, characterized in that: The collected feature map X f According to the data set B saved locally m The steps for classification include: From sample X m The extracted feature map is denoted as X f , from sample X m The corresponding sample N m , sample P m The extracted feature maps are denoted as N f , P f , for the sample set {X m , N m , P m }, get the feature map set {X f , N f , P f }.

5. The convolutional neural network training method according to claim 4, characterized in that: The contrast loss is calculated In the steps, the calculation formula is: in, For X f and P f The distance between ; For X f and N f The distance between ; in, k Preserve security parameters for gradient privacy.

6. A convolutional neural network training method, characterized in that: Iteratively execute the convolutional neural network training method described in any one of claims 1 to 5 until a preset number of iterations is reached, or the loss function of the convolutional neural network converges, thereby completing the training of the convolutional neural network and obtaining a trained convolutional neural network.

7. A convolutional neural network training system, characterized in that: include: The client is used to obtain the data set for training the convolutional neural network; randomly select b samples X1, X2, ..., X m , ...... , X b ; For each sample X m Uniformly randomly sample from the data set with m A sample N with different labels m and has the same m A sample P with the same label m ; For each sample X m and its corresponding sample N m , sample P m As a sample set {X m , N m , P m }, recorded as data group B m , 1≤m≤b; b data sets form a batch data set B={B 1 , B 2 , B 3 ,……,B m ,……, B b }; Randomly shuffle the order of samples in batch data set B, denoted as B S ; B S Sending server; receiving server sends a set {X, X f }, according to the received set {X, X f }Get the gradient G relative to the output and update the output layer parameters through the gradient descent algorithm; Server, used according to B S Extract features from each sample X to obtain feature map X f , and the set {X, X f }Send to the client; Calculate the gradient G' of each layer output layer by layer according to the gradient G relative to the output, and update the convolutional neural network parameters; The client stores the classifier of the convolutional neural network; the server stores the feature extractor of the convolutional neural network; Among them, the last fully connected layer in the convolutional neural network is split and used as a classifier for image classification; the remaining layers are used as feature extractors.

8. The convolutional neural network training system according to claim 7, characterized in that: The client receives the set {X, X f The steps to obtain the gradient G include: The client will receive the set {X, X f } in the feature map X f Pass in the classifier and get the predicted category c; Calculating cross entropy loss ; For the collected feature map X f According to the data set B saved locally m To classify; Compute contrast loss based on classification ; by As the loss function, the partial derivative of the convolutional neural network output y is calculated to obtain the gradient G relative to the output y, G = , sent to the server; then, using the chain rule, find the gradient of the output layer weight W, that is, , and the gradient about the output layer bias b, that is, ; Update the output layer weight W and output layer bias b through the gradient descent algorithm; The server calculates the gradient G of L relative to the current layer output G'= W T , where W T is the transpose of the current layer weights, and the convolutional neural network parameters are updated through the gradient descent algorithm, and the back propagation continues to repeat the update process.

9. The convolutional neural network training system according to claim 8, characterized in that: The cross entropy loss The calculation formula is: Among them, 3b is the total number of samples, C is the total number of possible categories, is a one-hot encoding vector, indicating that the predicted category c of the i-th sample is the same as the true category, then ,otherwise ; is the probability that the convolutional neural network predicts that the i-th sample belongs to category c.

10. The convolutional neural network training system according to claim 8, characterized in that: The collected feature map X f According to the data set B saved locally m The steps for classification include: From sample X m The extracted feature map is denoted as X f , from sample X m The corresponding sample N m , sample P m The extracted feature maps are denoted as N f , P f , for the sample set {X m , N m , P m }, get the feature map set {X f , N f , P f }.

11. The convolutional neural network training system according to claim 10, characterized in that: The contrast loss The calculation formula is: in, For X f and P f The distance between ; For X f and N f The distance between ; in, k Preserve security parameters for gradient privacy.

Citation Information

Patent Citations

  • Federal learning privacy protection method based on homomorphic encryption and secret sharing

    CN113037460A

  • Trace ratio criterion-based triple loss function design method

    CN108399428A

  • Classifier training method, data processing method, system and device

    CN111797895A