Method and system for predicting pig growth traits based on federal learning and pig genome
By adopting federated learning technology in pig genome prediction, it is divided into feature extraction layer, hidden feature layer and prediction layer, and sharing hidden feature layer, it solves the problem of non-independent same distribution and data privacy of pig gene data, and improves pig growth The accuracy of trait prediction and the security of data sharing overcome data silos and privacy leakage problems.
Patent Information
- Application Number
- CN202410965096.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-11-15
Smart Images

Figure CN118969095A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of biotechnology, and specifically relates to a method and system for predicting pig growth traits based on federated learning and pig genome. Background Art
[0002] Currently, in the field of genomic prediction of growth traits, most technologies are based on deep learning. However, deep learning requires a large amount of data to achieve good accuracy, while most organizations in the field of pig genomics have only a small amount of data. This results in these organizations often not being able to achieve good results when using deep learning methods. At the same time, due to privacy issues, each organization is reluctant to share its own data, which results in very little data available to a single organization, making it difficult to fully utilize deep learning methods.
[0003] In addition, the classic federated learning method is to share all parameters, which often performs poorly under the condition that the data is not independent and identically distributed, and the data owned by different biological companies is often not independent and identically distributed. The current method to solve the non-independent and identically distributed problem is often to solve the non-independent and identically distributed problem on the label, but for pig genes, not only the label is not independent and identically distributed, but also the features are not independent and identically distributed. Therefore, the current method cannot solve the non-independent and identically distributed problem of federated learning on pig genes.
[0004] Therefore, the problems in the existing technology are mainly: there are data islands in the prediction of pig growth traits based on the pig genome, and each company has a certain amount of data but is unwilling to disclose it; and the non-independent and identically distributed problems in both labels and features of pig gene data lead to poor results in the application of federated learning in the prediction of pig growth traits based on the pig genome. Summary of the invention
[0005] In order to solve the problems in the prior art, the present invention proposes a method and system for predicting pig growth traits based on federated learning and pig genome.
[0006] The technical solution adopted by the present invention is as follows:
[0007] In a first aspect, the present invention discloses a method for predicting pig growth traits based on federated learning and pig genome, comprising the following steps:
[0008] Collecting a number of pig genomes and storing them locally, inputting the local pig genomes into a locally trained pig growth trait prediction model to obtain prediction results of the pig genomes, wherein the prediction results include the age of the pig when the weight reaches 100 kg or the thickness of the pig's back fat;
[0009] The pig growth trait prediction model comprises a feature extraction layer, a hidden feature layer and a prediction layer; the pig growth trait prediction model is obtained by training the hidden feature layer based on federated learning.
[0010] Furthermore, the hidden feature layer is trained based on federated learning, specifically:
[0011] 1) Build a pig growth trait prediction model for each client and use it as a local model; the hidden feature layer of each client is consistent, and the output dimension of the feature extraction layer and the input dimension of the prediction layer of each client are consistent;
[0012] 2) Each client initializes the parameters of its own feature extraction layer and prediction layer, and the server initializes the parameters of the hidden feature layer and distributes them to each client;
[0013] 3) The client receives the parameters of the hidden feature layer from the server, and initializes the parameters of the hidden feature layer of the local model with the parameters of the hidden feature layer;
[0014] 4) The client uses local data to train the local model, and all clients send the parameters of the trained hidden feature layer to the server;
[0015] 5) The server aggregates the parameters of the received hidden feature layer and distributes the aggregated results to each client;
[0016] 6) Repeat steps 3)-5) until all local models converge; at this point, the local model of each client is a trained pig growth trait prediction model;
[0017] The local pig genome of the client is input into the trained pig growth trait prediction model of the client to obtain the prediction result of the pig genome.
[0018] Furthermore, each client can select the feature extraction layer and prediction layer suitable for its own local dataset.
[0019] Furthermore, the local pig genome is input into the local trained pig growth trait prediction model to obtain the prediction result of the pig genome, specifically:
[0020] The local pig genome composed of multiple 0s, 1s, and 2s is input into the feature extraction layer. The feature extraction layer extracts the feature representation of the local pig genome and inputs the feature representation into the hidden feature layer. The hidden feature layer converts the feature representation of the local pig genome into hidden features and inputs the hidden features into the final prediction layer. The prediction layer predicts the final result based on the extracted hidden features.
[0021] In a second aspect, the present invention discloses a prediction system for pig growth traits based on federated learning and pig genome, including a client and a server;
[0022] The client builds a pig growth trait prediction model as a local model, trains the local model through local data, and receives the aggregated results sent by the server; finally obtains a trained pig growth trait prediction model; and predicts the local pig genome through the trained pig growth trait prediction model;
[0023] The server initializes the parameters of the hidden feature layer and distributes them to each client, receives the trained parameters of the hidden feature layer sent by all clients, aggregates them, and distributes the aggregated results to each client.
[0024] Compared with the prior art, the present invention has the following beneficial effects:
[0025] 1) It can solve the problem that the features and labels in pig genes are not independent and identically distributed. The present invention solves the problem that the features and labels in pig genes in federated learning are not independent and identically distributed by inventing a federated learning technology, personalizing the feature extraction layer and the prediction layer, and sharing the intermediate feature hidden layer.
[0026] 2) It can solve the problem of insufficient data for deep learning applications in pig genes and avoid the leakage of corporate data privacy. The present invention applies federated learning technology to solve the problem of insufficient data for deep learning in pig gene breeding. In addition, since the data of federated learning does not leave the local area, the privacy of the data is protected, so that multiple institutions are willing to participate in federated learning, thus solving the problem of isolated pig gene data islands. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 This is a framework diagram of the pig growth trait prediction model;
[0028] Figure 2 A flowchart for training a pig growth trait prediction model based on federated learning;
[0029] Figure 3 This is a specific framework diagram of the pig growth trait prediction model. DETAILED DESCRIPTION
[0030] The present invention is further described and illustrated below in conjunction with specific embodiments. The embodiments are merely exemplary of the present disclosure and do not define the scope of limitation. The technical features of each embodiment of the present invention may be combined accordingly without conflicting with each other.
[0031] In order to overcome the above defects, this scheme provides a prediction method for pig growth traits based on federated learning and pig genome, which solves the problems of insufficient data and data privacy in the existing technology, and the poor effect of federated learning in the prediction of pig growth traits due to the fact that pig gene data are not independent and identically distributed in both feature distribution and label distribution.
[0032] This scheme proposes to regard the model as three parts: feature extraction layer, hidden feature layer and prediction layer. Its framework diagram is as follows Figure 1 As shown in the figure. For each client, a unique feature extraction layer and prediction layer are learned, and only the hidden feature layer between the feature extraction layer and the prediction layer is shared. This is because for pig gene data, not only are non-independent and identically distributed in labels, but also in features.
[0033] The existing scheme mainly learns the classifier part separately, which can only solve the problem of non-IID of labels, but not the problem of non-IID of features. Therefore, this scheme proposes to learn a unique feature extraction layer and prediction layer, so that each client can learn the distribution of local features and the distribution of local labels at the same time. In addition, since the hidden feature layer is shared (that is, the hidden feature layer is consistent, and the consistency of the hidden feature layer means that the network structure and parameters of the hidden feature layer are consistent.), the effect of the model can also be enhanced with the help of pig genetic data from other farms.
[0034] The steps of this program are as follows: Figure 2 As shown, including:
[0035] S1: Build a pig growth trait prediction model, and determine the feature extraction layer, hidden feature layer, and prediction layer in the model. Pig genome data can be collected based on existing technologies, and the pig genome data used for training the pig growth trait prediction model is annotated with target labels, such as age at 100kg (the age of the pig when the weight reaches 100kg), back fat thickness (the thickness of the pig's back fat), etc. Since the pig genetic data of different companies are not independent and identically distributed in terms of feature distribution and label distribution, the method of only sharing the feature extraction layer and learning the prediction layer separately cannot achieve good results. Therefore, this plan proposes to regard a model as three parts, such as Figure 1 As shown, it includes: feature extraction layer, hidden feature layer and prediction layer.
[0036] First, the local pig gene data composed of multiple genes consisting of 0, 1, and 2 are input into the feature extraction layer. The feature extraction layer extracts the local pig gene feature representation and inputs it into the hidden feature layer. Since the hidden feature layer is trained with more data, it will further convert the local pig gene features into better hidden features and input them into the final prediction layer. The prediction layer will predict the final value based on the extracted features, such as the age of the pig when the weight reaches 100kg (the age of the pig when the weight reaches 100kg), the back fat thickness (the thickness of the pig's back fat), etc.
[0037] For each client, it is necessary to learn its own unique feature extraction layer and prediction layer so that it can adapt to the distribution of local data. At the same time, in order to use data from other clients to enhance the effect of the local model, this solution proposes to share a hidden feature layer between the feature extraction layer and the prediction layer to enhance the effect of the model. The shared hidden feature layer can further use the data of all clients to learn their common features based on the features learned by each client, so that the features extracted by the model have stronger expression capabilities. In addition, this solution can be applicable to any deep learning model, including Transformer, MLP (Multi-Layer Perception) or CNN (Convolutional Neural Networks). For example, the feature extraction layer can be a model such as CNN, Transformer, ResNet (residual neural network), the hidden feature layer can be a model such as CNN, Transformer or MLP, and the prediction layer can be a model such as MLP;
[0038] For example, one of the model structures is Figure 3 As shown in the figure, it consists of CNN, ResNet, and MLP. CNN is the feature extraction layer, ResNet is the hidden feature layer, and MLP is the prediction layer. CNN and MLP do not share and only use local data for training, while ResNet uses data from multiple clients for federated learning.
[0039] S2: The client determines the optimizer, learning rate, batch size, etc. used for training, and initializes the parameters of the feature extraction layer and prediction layer; the server initializes the hidden feature layer parameters and sends them to all clients. For each client, you can choose to use the feature extraction layer and prediction layer that are suitable for your local data set. You only need to keep the dimensions of the feature extraction layer output and the classifier input consistent with other clients. When transmitting model parameters, you can also choose to use privacy encryption algorithms, such as differential privacy algorithms, to further enhance privacy protection;
[0040] S3: The client receives the hidden feature layer parameters from the server and uses them to initialize the parameters of the hidden feature layer of the local model;
[0041] S4: The client trains the local model with its own private data and can repeat the training for multiple rounds. All clients send the trained hidden feature layer parameters to the server.
[0042] S5: The server aggregates the received hidden feature layer parameters and sends them to the client. Here, any model aggregation algorithm in federated learning can be used, including FedAVG, FedSAM, etc.
[0043] S6: Repeat S3-S5 until the model converges.
[0044] In this embodiment, a prediction system for pig growth traits based on federated learning and pig genome is also provided, including a client and a server;
[0045] The client builds a pig growth trait prediction model as a local model, trains the local model through local data, and receives the aggregated results sent by the server; finally obtains a trained pig growth trait prediction model; and predicts the local pig genome through the trained pig growth trait prediction model;
[0046] The server initializes the parameters of the hidden feature layer and distributes them to each client, receives the trained parameters of the hidden feature layer sent by all clients, aggregates them, and distributes the aggregated results to each client.
[0047] For the system embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment, and the implementation methods of the remaining modules will not be repeated here. The system embodiment described above is only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of the present invention. Ordinary technicians in this field can understand and implement it without paying creative work.
[0048] The above-mentioned embodiments only express several implementation modes of the present invention, and the description is relatively specific and detailed, but it cannot be understood as limiting the scope of the present invention. For those of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention.
Claims
1. A method for predicting pig growth traits based on federated learning and pig genome, characterized in that: The following steps are involved: Collecting a number of pig genomes and storing them locally, inputting the local pig genomes into a locally trained pig growth trait prediction model to obtain prediction results of the pig genomes, wherein the prediction results include the age of the pig when the weight reaches 100 kg or the thickness of the pig's back fat; The pig growth trait prediction model comprises a feature extraction layer, a hidden feature layer and a prediction layer; the pig growth trait prediction model is obtained by training the hidden feature layer based on federated learning.
2. The method according to claim 1, characterized in that The training of the hidden feature layer based on federated learning is specifically as follows: 1) Build a pig growth trait prediction model for each client and use it as a local model; the hidden feature layer of each client is consistent, and the output dimension of the feature extraction layer and the input dimension of the prediction layer of each client are consistent; 2) Each client initializes the parameters of its own feature extraction layer and prediction layer, and the server initializes the parameters of the hidden feature layer and distributes them to each client; 3) The client receives the parameters of the hidden feature layer from the server, and initializes the parameters of the hidden feature layer of the local model with the parameters of the hidden feature layer; 4) The client uses local data to train the local model, and all clients send the parameters of the trained hidden feature layer to the server; 5) The server aggregates the parameters of the received hidden feature layer and distributes the aggregated results to each client; 6) Repeat steps 3)-5) until all local models converge; at this point, the local model of each client is a trained pig growth trait prediction model; The local pig genome of the client is input into the trained pig growth trait prediction model of the client to obtain the prediction result of the pig genome.
3. The method according to claim 2, characterized in that The feature extraction layer is CNN, Transformer or ResNet, the hidden feature layer is CNN, Transformer or MLP, and the prediction layer is MLP.
4. The method according to claim 3, characterized in that Each client can select the feature extraction layer and prediction layer that are suitable for its own local dataset.
5. The method according to claim 2, characterized in that: The feature extraction layer is CNN, the hidden feature layer is ResNet, and the prediction layer is MLP.
6. The method according to claim 2, characterized in that In step 4), each time the client trains the local model using local data, multiple rounds of training need to be repeated.
7. The method according to claim 2, characterized in that: In the step 5), the server side aggregates the parameters of the hidden feature layer using the FedAVG or FedSAM method.
8. The method according to claim 2, characterized in that: When parameters are transmitted between the server and the client, a differential privacy algorithm is used to encrypt the transmission parameters.
9. The method according to claim 1, characterized in that: The local pig genome is input into the local trained pig growth trait prediction model to obtain the prediction result of the pig genome, specifically: The local pig genome composed of multiple 0s, 1s, and 2s is input into the feature extraction layer. The feature extraction layer extracts the feature representation of the local pig genome and inputs the feature representation into the hidden feature layer. The hidden feature layer converts the feature representation of the local pig genome into hidden features and inputs the hidden features into the final prediction layer. The prediction layer predicts the final result based on the extracted hidden features.
10. A prediction system for pig growth traits based on federated learning and pig genome, characterized in that: Including client and server; The client builds a pig growth trait prediction model as a local model, trains the local model through local data, and receives the aggregated results sent by the server; finally obtains a trained pig growth trait prediction model; and predicts the local pig genome through the trained pig growth trait prediction model; The server initializes the parameters of the hidden feature layer and distributes them to each client, receives the trained parameters of the hidden feature layer sent by all clients, aggregates them, and distributes the aggregated results to each client.
