WO2019090954A1 - 一种预测方法及终端、服务器 - Google Patents

一种预测方法及终端、服务器 Download PDF

Info

Publication number
WO2019090954A1
WO2019090954A1 PCT/CN2017/120294 CN2017120294W WO2019090954A1 WO 2019090954 A1 WO2019090954 A1 WO 2019090954A1 CN 2017120294 W CN2017120294 W CN 2017120294W WO 2019090954 A1 WO2019090954 A1 WO 2019090954A1
Authority
WO
WIPO (PCT)
Prior art keywords
terminal
parameter
server
model
prediction
Prior art date
Application number
PCT/CN2017/120294
Other languages
English (en)
French (fr)
Inventor
陈飞
董振华
李震国
何秀强
钱莉
彭帅华
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP17931484.4A priority Critical patent/EP3693912A4/en
Priority to CN201780095993.7A priority patent/CN111226238B/zh
Publication of WO2019090954A1 publication Critical patent/WO2019090954A1/zh
Priority to US16/863,110 priority patent/US11580457B2/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/02Marketing; Price estimation or determination; Fundraising
    • G06Q30/0241Advertisements
    • G06Q30/0251Targeted advertisements
    • G06Q30/0255Targeted advertisements based on user history
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N5/00Computing arrangements using knowledge-based models
    • G06N5/02Knowledge representation; Symbolic representation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N99/00Subject matter not provided for in other groups of this subclass
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/02Marketing; Price estimation or determination; Fundraising
    • G06Q30/0241Advertisements
    • G06Q30/0251Targeted advertisements
    • G06Q30/0254Targeted advertisements based on statistics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/02Marketing; Price estimation or determination; Fundraising
    • G06Q30/0241Advertisements
    • G06Q30/0251Targeted advertisements
    • G06Q30/0267Wireless devices

Definitions

  • the present invention relates to the field of prediction models, and in particular, to a prediction method, a terminal, and a server.
  • Machine learning-based prediction systems are usually divided into two parts: model training and prediction.
  • Model training training a prediction model suitable for the task using training set data; wherein the training set usually contains a large amount of data
  • prediction Use the trained model to predict the test set data.
  • model training training a prediction model suitable for the task using training set data; wherein the training set usually contains a large amount of data
  • prediction Use the trained model to predict the test set data.
  • model training training a prediction model suitable for the task using training set data; wherein the training set usually contains a large amount of data
  • prediction Use the trained model to predict the test set data.
  • In traditional machine learning when solving terminal prediction tasks, one way is to perform model training separately in the terminal. Only a single terminal user's sample can be used, and other large users' information (such as similar mobile phone usage habits) cannot be utilized, resulting in prediction effect. Poor; another way is to train a unified predictive model on the cloud side server, but the larger size of the model also affects the prediction effect on a single user.
  • the embodiment of the invention provides a prediction method, a terminal and a server, which can realize a prediction model that reflects user differentiation by training with a large amount of user data.
  • an embodiment of the present invention provides a prediction method, including:
  • the server sends the first model parameter and the second model parameter to the plurality of terminals, where the first model parameter and the second model parameter are adapted to the prediction model of the terminal; and the first prediction loss sent by the at least one terminal of the plurality of terminals is received, at least one The first prediction loss sent by each terminal in the terminal is calculated by each terminal according to a prediction model that adopts the first model parameter and the second model parameter; and the first model parameter is updated according to the first prediction loss sent by the at least one terminal, Obtaining the updated first model parameter, and updating the second model parameter according to the first prediction loss sent by the at least one terminal to obtain the updated second model parameter.
  • the training of the prediction model can be performed at each terminal, so that the user's privacy of each terminal can be protected, and the terminal feeds back the calculated prediction loss to the server, so that the server can feed back data according to a large number of terminals.
  • the model parameters are updated again, so that the user's information can be used to accurately update the model parameters.
  • the server updates the first model parameter according to the first prediction loss sent by the at least one terminal to obtain the updated first model parameter, and the first prediction loss sent according to the at least one terminal.
  • Updating the second model parameter to obtain the updated second model parameter is: the server calculates a second prediction loss according to the first prediction loss sent by the at least one terminal; and the server according to the second prediction loss, according to the parameter update rule The first model parameter is updated to obtain the updated first model parameter, and the second model parameter is updated according to the parameter update rule to obtain the updated second model parameter.
  • the server may further send the updated first model parameter and the updated second model parameter to the multiple terminals, and any one of the multiple terminals adopts the updated first model according to The parameters and the predicted model of the updated second model parameters are predicted.
  • multiple terminals belong to the same group; terminals of the same group have common features.
  • the common feature comprises that at least two terminals are located in a preset geographical area. Since the end users belonging to the same group have more commonality, the corresponding meta learner can learn a more suitable mechanism for the group, so that training can be more suitable for the terminal in the group. Predictive models to achieve better predictive results.
  • an embodiment of the present invention provides a prediction method, including:
  • the terminal receives the first model parameter and the second model parameter sent by the server, the first model parameter and the second model parameter are adapted to the prediction model of the terminal; and the first model parameter is updated according to the training set and the prediction model to obtain the updated a first model parameter,
  • the training set includes a plurality of first sample data, the first sample data includes a first feature vector and a first sample tag corresponding to the first feature vector; acquiring a test set, and The first model parameter and the prediction model of the second model parameter calculate a first prediction loss of the test set, the test set includes a plurality of second sample data, the second sample data including a second feature vector and a second corresponding to the second feature vector a two sample tag; transmitting a first predicted loss to the server to cause the server to update the first model parameter and the second model parameter according to the first predicted loss.
  • the training of the prediction model can be performed at a plurality of terminals, so that the terminal does not need to upload its own data to the server, and can protect the privacy of the user of each terminal, and the terminal feeds back the calculated prediction loss to the terminal.
  • the server in order to enable the server to update the model parameters again according to the data fed back by a large number of terminals, so that the information of a large number of users can be used to accurately update the model parameters.
  • the terminal performs, in performing, updating the first model parameter according to the training set and the prediction model to obtain the updated first model parameter, specifically: performing the second calculation of the training set according to the prediction model.
  • the prediction model adopts a first model parameter and a second model parameter; according to the second prediction loss and the second model parameter, the first model parameter is updated according to the parameter update rule to obtain the updated first model parameter.
  • the terminal performs, in performing, calculating a second prediction loss of the training set according to the prediction model: calculating, according to the prediction model, a prediction loss corresponding to each first sample data of the plurality of first sample data; The predicted loss corresponding to the first sample data calculates a second predicted loss of the plurality of first sample data.
  • the terminal performs, in performing, calculating, according to the prediction model, a prediction loss corresponding to each of the first sample data of the plurality of first sample data: inputting the first feature vector of each first sample data to In the prediction model, the probability that the first feature vector of each first sample data corresponds to the first sample tag is obtained, wherein the prediction model adopts the first model parameter and the second model parameter; according to the first feature vector and The probability corresponding to the first sample tag calculates the predicted loss of each first sample data according to the loss calculation rule.
  • the terminal is configured to input a first feature vector of each first sample data into the prediction model to obtain a probability that the first feature vector of each first sample data corresponds to the first sample tag.
  • the aspect is specifically performed: acquiring a plurality of reference sample tags included in the prediction model, the plurality of reference sample tags including each first sample tag; inputting the first feature vector of each first sample data into the prediction model, to Obtaining a probability that the first feature vector corresponds to each of the reference sample tags; determining, by the reference sample tag, a probability corresponding to the first sample tag as a probability that the first feature vector corresponds to the first sample tag.
  • the terminal performs, in performing, calculating the first prediction loss of the test set according to the prediction model adopting the updated first model parameter and the second model parameter: the updated prediction according to the model parameter
  • the model calculates a prediction loss corresponding to each second sample data of the plurality of second sample data included in the test set, and the updated model model uses the updated first model parameter and the second model parameter; according to each second The predicted loss corresponding to the sample data is calculated, and the first predicted loss of the test set is calculated.
  • the terminal performs, in the execution of the prediction model that is updated according to the model parameter, the prediction loss corresponding to each second sample data included in the plurality of second sample data included in the test set is specifically performed: each second sample data is The second feature vector is input to the predicted model after the model parameter update to obtain a probability that the second feature vector of each second sample data corresponds to the second sample tag; and the second feature vector corresponds to the second sample tag The probability of calculating the predicted loss of each second sample data according to the loss calculation rule.
  • the terminal inputs a second feature vector of each second sample data into the prediction model after the model parameter update, to obtain a second feature vector of each second sample data corresponding to the second sample tag.
  • the probability aspect is specifically performed by: acquiring a plurality of reference sample tags included in the predicted model after updating the model parameters, the plurality of reference sample tags including each second sample tag; inputting the second feature vector of each second sample data to In the prediction model after the model parameter is updated, the probability that the second feature vector corresponds to each reference sample tag is obtained; and the probability that the reference sample tag is corresponding to the second sample tag is determined as the second feature vector corresponding to the second sample tag. The probability.
  • an embodiment of the present invention provides a prediction method, including:
  • the terminal receives the first model parameter and the second model parameter sent by the server, the first model parameter and the second model parameter are adapted to the prediction model of the terminal; and the first model parameter is updated according to the training set and the prediction model to obtain the updated a first model parameter, the training set includes a plurality of sample data, each sample data includes a feature vector and a sample tag corresponding to the feature vector; and the target feature vector to be predicted is input to the updated first model parameter and the second In the prediction model of the model parameter, the target sample tag corresponding to the target feature vector is obtained.
  • the terminal after the terminal receives the first model parameter and the second model parameter sent by the server, first updating the first model parameter according to the training set and the prediction model to obtain the updated first model parameter, where The target feature vector to be predicted is input to the prediction model adopting the updated first model parameter, and the target sample tag corresponding to the target feature vector is acquired.
  • the terminal can also reflect the difference between the terminal and other terminals in the prediction phase, and achieve a more accurate prediction effect.
  • the terminal performs the updating of the first model parameter according to the training set and the prediction model to obtain the updated first model parameter, and specifically performs: calculating the intermediate prediction of the training set according to the prediction model.
  • the loss model uses the first model parameter and the second model parameter; the terminal updates the first model parameter according to the parameter update rule according to the intermediate prediction loss and the second model parameter to obtain the updated first model parameter.
  • the intermediate prediction loss may reflect the deviation between the real result and the prediction result according to the first training set, and the first model parameter is updated by the deviation to improve the accuracy of the prediction model.
  • the terminal performs, in performing, calculating the intermediate prediction loss of the training set according to the prediction model: the terminal calculates a prediction loss corresponding to each sample data of the plurality of sample data according to the prediction model; and the terminal performs prediction according to each sample data. Loss, calculating the intermediate prediction loss of multiple sample data.
  • the terminal performs, in performing, calculating the prediction loss of each sample data in the multiple sample data according to the prediction model: the terminal inputs the feature vector of each sample data into the prediction model to obtain each sample data.
  • the probability that the feature vector corresponds to the sample tag; and the predicted loss of each sample data is calculated according to the loss calculation rule according to the probability that the feature vector corresponds to the sample tag.
  • the terminal performs performing the function of inputting the feature vector of each sample data into the prediction model to obtain a probability that the feature vector of each sample data corresponds to the sample tag: the terminal acquires the plurality of prediction models.
  • the plurality of reference sample tags include each sample tag; the terminal inputs the feature vector of each sample data into the prediction model to obtain a probability that the feature vector corresponds to each reference sample tag; the terminal will reference the sample tag as The probability corresponding to the sample tag is determined as the probability that the feature vector corresponds to the sample tag.
  • the terminal inputs the target feature vector to be predicted to the prediction model adopting the updated first model parameter and the second model parameter, and acquires the target sample tag corresponding to the target feature vector.
  • the aspect is specifically performed: the terminal acquires a plurality of reference sample labels included in the prediction model after the model parameter update, and the updated model model uses the updated first model parameter and the second model parameter; the target feature to be predicted by the terminal
  • the vector is input to the prediction model after the model parameter update to obtain the reference probability corresponding to each reference sample tag of the target feature vector to be predicted; the terminal determines the reference sample tag corresponding to the maximum value of the reference probabilities of the plurality of reference probabilities as Target sample label.
  • an embodiment of the present invention provides a server, including:
  • a sending module configured to send the first model parameter and the second model parameter to the multiple terminals, where the first model parameter and the second model parameter are adapted to the prediction model of the terminal;
  • a receiving module configured to receive a first prediction loss sent by at least one terminal of the multiple terminals, where the first prediction loss sent by each terminal in the at least one terminal is a prediction according to the first model parameter and the second model parameter used by each terminal Model calculation
  • a processing module configured to: update the first model parameter according to the first prediction loss sent by the at least one terminal, to obtain the updated first model parameter, and perform the second model parameter according to the first prediction loss sent by the at least one terminal Update to get the updated second model parameters.
  • the server may also implement some or all of the optional implementations of the first aspect.
  • an embodiment of the present invention provides a server.
  • the server includes a memory for storing computer executable program code, a transceiver, and a processor coupled to the memory and the transceiver.
  • the program code stored in the memory includes instructions that, when executed by the processor, cause the server to perform the method performed by the server in the first aspect above.
  • an embodiment of the present invention provides a terminal, including:
  • a receiving module configured to receive a first model parameter and a second model parameter sent by the server, where the first model parameter and the second model parameter are adapted to the prediction model of the terminal;
  • a processing module configured to update the first model parameter according to the training set and the prediction model, to obtain the updated first model parameter, where the training set includes a plurality of first sample data, where the first sample data includes the first feature vector And a first sample tag corresponding to the first feature vector;
  • a processing module configured to acquire a test set, and calculate a first prediction loss of the test set according to the prediction model that adopts the updated first model parameter, where the test set includes a plurality of second sample data, and the second sample data includes the second feature a vector and a second sample tag corresponding to the second feature vector;
  • a sending module configured to send a first prediction loss to the server, so that the server updates the first model parameter and the second model parameter according to the first prediction loss.
  • the terminal may also implement some or all of the optional implementations of the second aspect.
  • an embodiment of the present invention provides another terminal, including:
  • a receiving module configured to receive a first model parameter and a second model parameter sent by the server, where the first model parameter and the second model parameter are adapted to the prediction model of the terminal;
  • a processing module configured to update the first model parameter according to the training set and the prediction model to obtain an updated first model parameter, where the training set includes multiple sample data, each sample data includes a feature vector and a corresponding to the feature vector Sample label
  • the processing module is further configured to input the target feature vector to be predicted into the prediction model that adopts the updated first model parameter and the second model parameter, and acquire the target sample tag corresponding to the target feature vector.
  • the terminal may also implement some or all of the optional implementations of the third aspect.
  • an embodiment of the present invention provides a terminal.
  • the terminal includes a memory for storing computer executable program code, a transceiver, and a processor coupled to the memory and the transceiver.
  • the program code stored in the memory includes instructions which, when executed by the processor, cause the terminal to perform the method performed by the terminal in the second aspect or the third aspect above.
  • a computer program product comprising: computer program code, when the computer program code is run on a computer, causing the computer to perform the first to third aspects and any possible implementation thereof Methods.
  • a computer readable medium storing program code for causing a computer to perform the above first to third aspects and any possible implementation thereof when the computer program code is run on a computer The method in .
  • a method for training a machine learning model comprising: receiving, by a terminal, a first parameter and a second parameter of an algorithm model on the server sent by a server, where the first parameter is used as the terminal An initial parameter of the machine learning model, the second parameter is used to indicate a manner in which the terminal trains a machine learning model; the terminal trains the terminal according to the first parameter, the second parameter, and training set data a machine learning model, the training set data comprising a plurality of training samples, each training sample comprising a first feature vector and a corresponding first tag, the first feature vector being constructed according to user information in historical data of the terminal
  • the terminal obtains test results according to the test data and the machine learning model, and calculates a loss gradient according to the test result; the terminal uploads the loss gradient to the server, and the loss gradient is used for the server Updating the first parameter and the second parameter.
  • the calculating a loss gradient according to the test result comprising: the terminal calculating a prediction loss according to the test result and a label corresponding to the test data; The loss is calculated by predicting the loss.
  • test data includes a plurality of test sample data, each test sample data includes a second feature vector and a corresponding second tag, and each test sample data corresponds to one test result;
  • the terminal calculates the predicted loss according to the test result and the label corresponding to the test data, including: the terminal calculating the multiple according to the test result corresponding to the multiple test sample data and the second label. Test the predicted loss of each sample data;
  • the terminal Calculating the loss gradient according to the predicted loss, the terminal: calculating, by the terminal, a loss gradient of each of the plurality of test sample data according to a prediction loss of each of the plurality of test sample data; A plurality of loss gradients corresponding to the plurality of test sample data are averaged to obtain a target loss gradient;
  • the terminal uploading the loss gradient to the server includes: the terminal uploading the target loss gradient to the server.
  • test data includes a plurality of test sample data, each test sample data includes a second feature vector and a corresponding second tag, and each test sample data corresponds to one test result;
  • the terminal calculates the predicted loss according to the test result and the label corresponding to the test data, including: the terminal calculating the multiple according to the test result corresponding to the multiple test sample data and the second label. Testing respective prediction losses of the sample data; the terminal averaging the plurality of prediction losses corresponding to the plurality of test sample data to obtain an average prediction loss;
  • the calculating, by the terminal, the loss gradient according to the predicted loss comprising: the terminal calculating a target loss gradient according to the average predicted loss;
  • the terminal uploading the loss gradient to the server includes: the terminal uploading the target loss gradient to the server.
  • the terminal further includes: The terminal confirms that the predicted loss of each of the plurality of test sample data meets a preset condition, where the preset condition is used to indicate that the average predicted loss fluctuation value relative to the last calculation is less than a preset threshold, and the average predicted loss is The v. terminal averages a plurality of predicted losses corresponding to the plurality of test sample data.
  • the method further includes: if the terminal confirms that the predicted loss of the test sample data i does not satisfy the preset condition, the terminal does not calculate the loss gradient corresponding to the predicted loss of the test sample data i or does not The predicted loss of the test sample data i is calculated, and the test sample data i is any one of the plurality of test sample data.
  • the method before the terminal receives the first parameter and the second parameter of the algorithm model of the server sent by the server, the method includes: sending, by the terminal, the structural identifier of the machine learning model to the Referring to the server, the structure identifier is used by the server to determine the algorithm model corresponding to the machine learning model according to the structure identifier.
  • An eleventh aspect provides a prediction method, the method includes: acquiring, by a first terminal, user information of the first terminal, and generating a target feature vector according to the user information; the first terminal, the target feature Entering a target prediction model to obtain a target prediction result, where the target prediction model is a local machine learning model trained by the first terminal according to the first parameter, the second parameter, and historical data of the first terminal,
  • the first parameter and the second parameter are two parameters of an algorithm model of the server sent by the server, the first parameter is used as an initial parameter of a machine learning model of the first terminal, and the second parameter
  • the parameter is used to indicate a manner in which the first terminal trains a machine learning model, and the first parameter and the second parameter are obtained by the server according to multiple loss gradients fed back by multiple terminals, and any loss gradient is a corresponding terminal. Calculated based on local historical data.
  • the method before the first terminal inputs the target feature vector into the target prediction model to obtain the target prediction result, the method includes: the first terminal sending a parameter update request to the server The parameter update request is used to request the server to send the first updated first parameter and the second parameter of the algorithm model; the first terminal receives the first parameter of the last update sent by the server And the second parameter; the first terminal training the target prediction model according to the first updated first parameter and the second parameter and historical data of the first terminal;
  • the first terminal inputs the target feature vector into the target prediction model to obtain the target prediction result, and the first terminal inputs the target feature vector into the trained target prediction model to obtain a target prediction result.
  • the parameter update request includes: a structure identifier of a machine learning model corresponding to the target prediction model, where the structure identifier is used by the server to determine the algorithm corresponding to the target prediction model according to the structure identifier model.
  • the method further includes: the first terminal uploading the prediction result to the server a scoring, wherein the prediction result is scored into a score of the target prediction result by a user of the first terminal, the prediction result is scored for the server to determine a weighting coefficient, and the weighting coefficient is used by the server to process
  • the loss gradient uploaded by the plurality of terminals obtains a weighted loss gradient, the weighted loss gradient is used by the server to update the first parameter and the second parameter, and the plurality of terminals include the first terminal.
  • a method for training a machine learning model comprising: a server transmitting a first parameter and a second parameter of an algorithm model of the server to a plurality of terminals, the first parameter being used as a An initial parameter of a machine learning model of each of the plurality of terminals, the second parameter is used to indicate a manner of training a machine learning model of each of the plurality of terminals, and a machine learning model of the plurality of terminals Having the same structure, optionally, the multiple terminals belong to the same group, and the same group is used to indicate that the same or similar attribute features are selected.
  • the attribute features include a geographical area; Within the time window, the server receives a loss gradient uploaded by at least one of the plurality of terminals; the server updates the first parameter and the second parameter according to a loss gradient uploaded by the at least one terminal.
  • the method before the server sends the first parameter and the second parameter to the multiple terminals, the method includes: the server initializing the first parameter and the first part of the algorithm model Two parameters.
  • the method further includes: the server resetting the preset time window according to a probability that the plurality of terminals upload a loss gradient.
  • the method further includes: the server receiving a score of the prediction result uploaded by the at least one terminal, the prediction result being scored into a score of the prediction result of the machine learning model by the terminal user; The server scores according to the prediction result, and determines a weighting coefficient;
  • the server updates the first parameter and the second parameter according to the loss gradient uploaded by the at least one terminal, including: the server weights the loss gradient uploaded by the at least one terminal according to the weighting coefficient
  • the averaging process results in a weighted loss gradient; the server updates the first parameter and the second parameter according to the weighted loss gradient.
  • the method before the server sends the first parameter and the second parameter to the multiple terminals, the method further includes: receiving, by the server, a structural identifier of a respective machine learning model uploaded by the multiple terminals, The structure identifier is used by the server to determine the algorithm model corresponding to the structure of the machine learning model.
  • the method further includes: the server receiving a parameter update request sent by the first terminal, where the parameter update request is used to request the server to send the first parameter of the latest update And the second parameter, the first terminal is any one of the plurality of terminals; the server sends the first parameter and the second parameter that are updated last time to the first terminal.
  • a terminal device comprising: a processor, a storage medium; the storage medium is configured to store programmable instructions; and the processor is configured to invoke a programmable instruction executed on the storage medium to execute The method described in any of the possible implementations of the tenth or tenth aspect.
  • a terminal device comprising: a processor, a storage medium; the storage medium is configured to store programmable instructions; and the processor is configured to invoke a programmable instruction executed on the storage medium to execute The method described in any of the possible implementations of the eleventh or eleventh aspect.
  • a server includes: a processor, a storage medium; the storage medium is configured to store programmable instructions; and the processor is configured to invoke a programmable instruction executed on the storage medium to execute The method described in the twelve aspect or any of the possible implementations of the twelfth aspect.
  • a computer readable storage medium comprising instructions that, when executed on a computer, cause the computer to perform the method described in any one of the possible aspects of the tenth or tenth aspect.
  • a computer readable storage medium comprising instructions that, when executed on a computer, cause the computer to perform any of the possible implementations of the eleventh or eleventh aspect The method described by the way.
  • a computer readable storage medium comprising instructions that, when executed on a computer, cause the computer to perform any of the possible implementations of the twelfth or twelfth aspect The method described by the way.
  • the method and the device provided by the embodiments of the present invention can enable the terminal to train the local machine learning model by using a large amount of other terminal user data without uploading local privacy data to the server, and realize the performance and personalization of the machine learning model. .
  • FIG. 1 is a schematic structural diagram of a possible prediction system according to an embodiment of the present invention
  • FIG. 3 provides another prediction method according to an embodiment of the present invention.
  • Figure 4 provides an example diagram of a prediction system that recommends application software for a user
  • FIG. 5 is a schematic diagram of an example of a prediction method according to an embodiment of the present invention.
  • FIG. 6 is a schematic structural diagram of a terminal according to an embodiment of the present disclosure.
  • FIG. 7 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of a terminal according to an embodiment of the present disclosure.
  • FIG. 9 is a schematic structural diagram of a server according to an embodiment of the present disclosure.
  • FIG. 10 is a schematic structural diagram of a server according to an embodiment of the present invention.
  • FIG. 11 is a flowchart of a method for training a machine learning model according to an embodiment of the present invention.
  • FIG. 12 is a flowchart of a prediction method according to an embodiment of the present invention.
  • Embodiment 1 is a schematic diagram of a possible prediction system architecture according to an embodiment of the present invention.
  • the prediction system architecture diagram includes a server and a terminal. Data transfer between the server and the terminal is possible. It should be noted that only one terminal is shown in FIG. 1 , but this does not limit the embodiment of the present invention. The embodiment of the present invention does not limit the number of terminals.
  • the server and the terminal are combined to implement the training and use of the prediction model.
  • the terminal can use the respective data to perform training and prediction of the prediction model locally, so that the user's private data is not uploaded to the server, and the user's privacy is also protected.
  • the terminal can also feed back the prediction effect to the server, so that the server updates the model parameters according to the predicted loss fed back by the multiple terminals, so that the server also refers to the information of multiple terminals, and plays the role of updating the model parameters by using a large number of users' information. .
  • the terminal after the terminal receives the first model parameter and the second model parameter sent by the server, first updating the first model parameter according to the training set and the prediction model to obtain the updated first model parameter,
  • the target sample tag corresponding to the target feature vector is acquired in the prediction model in which the target feature vector to be predicted is input to the first model parameter and the second model parameter. This can reflect the difference between the terminal and other terminals, and achieve a more accurate prediction effect.
  • the server uses a meta-learner to maintain model parameters of the predictive model.
  • Meta-learning is a two-layer machine learning architecture that “re-learns” the learned results. Try to correct the wrong classification and consolidate the correct classification. Therefore, the accuracy of the meta learner is high, and the mode of the meta learner is used to implement the update of the model parameters in the embodiment of the present invention.
  • the server is configured to store and update model parameters adapted to the prediction model, and the terminal stores a prediction model corresponding to the model parameters, and the prediction model of the terminal may adopt a server.
  • the model parameters in the model are used to train and predict the prediction model.
  • the first training set or the second training set involved in the embodiment of the present invention is a tag data set used for training a prediction model
  • the test set is a tag data set used to test a model prediction capability.
  • the tag data is the data containing the correct tag.
  • the prediction loss of the sample data can be understood as: the deviation between the prediction result and the real result, where the prediction result refers to the prediction sample label obtained by the eigenvector through the prediction model, and the real result is the original eigenvector.
  • the sample label should correspond.
  • the terminal involved in the embodiment of the present invention may be a device having a communication function, such as a handheld terminal device, a notebook computer, a subscriber unit, a cellular phone, a smart phone, and wireless data.
  • a handheld terminal device such as a notebook computer, a subscriber unit, a cellular phone, a smart phone, and wireless data.
  • Card personal digital assistant (PDA) computer, tablet computer, wireless modem, handheld, laptop computer, cordless phone, or wireless local loop (wireless local loop, WLL) station, machine type communication (MTC) terminal, etc.
  • the terminal device may also be a portable, pocket, handheld, computer built-in or vehicle-mounted mobile device.
  • the server involved in the embodiment of the present invention may be a background service device having processing and communication functions. The embodiment of the present invention does not limit the terminal and the server.
  • Embodiment 2 Referring to FIG. 2, a prediction method is provided according to an embodiment of the present invention. The method is performed by the terminal. As shown in FIG. 2, the prediction method includes steps 201 to 203. Please refer to the following specific description.
  • the terminal receives the first model parameter and the second model parameter sent by the server.
  • the first model parameter and the second model parameter are adapted to the prediction model of the terminal.
  • the prediction model may include model parameters.
  • the server may send the model parameters to the terminal.
  • the model parameters may be updated in the model training phase or the model prediction phase, and the corresponding prediction model is also updated to adopt the updated model. Model parameters.
  • the server maintains a meta learner with ( ⁇ , ⁇ ) as a parameter, wherein ⁇ is a first model parameter and ⁇ is a second model parameter.
  • the first model parameter is denoted by ⁇ 1
  • the second model parameter is denoted by ⁇ 1 .
  • the server distributes the value of ( ⁇ 1 , ⁇ 1 ) as a model parameter of the prediction model to a plurality of terminals, where the execution subject of the received model parameters is any one of the plurality of terminals distributed.
  • the initialization meta-learner parameter in the server is ( ⁇ , ⁇ ), where ⁇ is the initial parameter of the prediction model, ⁇ is the vector, and each component included in ⁇ is represented by ⁇ j , and each term ⁇ j can be Randomly initialized as follows:
  • is a vector, and each component of ⁇ has a one-to-one correspondence with each component of ⁇ (because the update rule used in the subsequent examples needs to perform vector subtraction, so it is set here), each component included in ⁇ is ⁇ . j indicates that it is randomly initialized as follows:
  • first model parameter and the second model parameter are not limited in the embodiment of the present invention.
  • the terminal updates the first model parameter according to the training set and the prediction model to obtain an updated first model parameter.
  • the training set includes a plurality of sample data, each sample data including a feature vector and a sample tag corresponding to the feature vector.
  • each terminal can use its own data as sample data.
  • Step 202 can be specifically implemented by the following steps A11 and A12.
  • the terminal calculates an intermediate prediction loss of the training set according to a prediction model.
  • the training set herein includes a plurality of sample data, each of the plurality of sample data including a sample tag and a feature vector corresponding to the sample tag.
  • the model parameters used herein are the first model parameter and the second model parameter, namely ( ⁇ 1 , ⁇ 1 ).
  • the terminal first calculates the prediction loss of each sample data in the plurality of sample data, and then calculates an average of the multiple prediction losses to obtain an intermediate prediction loss, for example:
  • the training set is S train (m)
  • m represents the mth sample data of the training set
  • M the number of sample data in the training set
  • l m ( ⁇ 1 ) represents the first The predicted loss of m sample data.
  • the terminal first calculates a prediction loss of each sample data in the plurality of sample data, and then obtains a weight corresponding to each sample data, and calculates an average value of the multiple prediction losses to obtain an intermediate prediction. loss.
  • the training set is S train (m)
  • m represents the mth sample data of the training set
  • the number of sample data in the training set is M
  • l m ( ⁇ 1 ) represents the mth sample
  • the predicted loss of the data ⁇ m represents the weight corresponding to the mth sample data.
  • the weight corresponding to each sample data may be determined by the terminal according to the association information of the sample data, for example, according to the generation time of the sample data, and the prediction model is used to recommend the application software for the user as an example.
  • the training set is generated according to the history record of the user, and the sample tag of the sample data may be the name of the application software W, and the feature vector is formed according to the location, time, mobile phone power, and network signal strength of the application software W, Then, the terminal may sort according to the length of the current usage record from the longest time to the current time, and classify the duration and set the weight corresponding to each type of duration, for example, the weight value closer to the current time is larger.
  • the association information of the sample data is not limited.
  • the terminal updates the first model parameter according to the parameter update rule according to the intermediate prediction loss and the second model parameter to obtain the updated first model parameter.
  • the parameter update rule is preset, and the parameter update rule may also be changed.
  • the parameter update rule is not limited in the embodiment of the present invention.
  • the parameter update rule can be implemented according to the following formula:
  • ⁇ 2 represents the updated first model parameter
  • ⁇ 1 represents the first model parameter before the update
  • ⁇ 1 represents the second model parameter
  • Representing a gradient represents the component multiplication of a vector.
  • operations are: due to Contains the ⁇ 1 variable, passed The operation can be achieved Perform ⁇ 1 derivation to obtain for ⁇ 1 , Rate of change.
  • the updated first model parameter ⁇ 2 can be obtained according to the above update formula.
  • the second model parameter can be obtained by learning on the server side. After the second model parameter is more accurately learned, the accuracy of the updated first model parameter is further ensured.
  • the terminal may perform step 202 according to a preset number of iterations.
  • the number of iterations is 100, that is, step 202 needs to be executed 100 times according to steps A11 and A12, as follows:
  • ⁇ ' i ⁇ ⁇ 1 // denotes the first model parameter by ⁇ 1
  • ⁇ ′ i denotes the first model parameter before iteration
  • the number of prediction iterations is used to realize the multiple update of the first model parameter.
  • the difference between the previous intermediate prediction loss and the current intermediate prediction loss in the two adjacent iterations may be determined, if the difference is smaller than For the preset threshold, the iteration is no longer performed and the first model parameter calculated using the current intermediate intermediate prediction loss is used.
  • a gap between a previous update of the first model parameter and a current update of the first model parameter in the two previous iterations may be determined, and if the difference is less than a preset threshold, the iteration is no longer performed. And using the current update first model parameter to determine the updated first model parameter.
  • the example of the present invention is not limited to the number of iterations of the steps A11 and A12 and the conditions for the iteration to stop.
  • step B11 For how the prediction loss corresponding to each sample data in step A11 is calculated, refer to the detailed description of step B11 and step B12.
  • the terminal inputs the feature vector of each sample data into the prediction model to obtain a probability that the feature vector of each sample data corresponds to the sample tag.
  • step B11 since step B11 is before the first model parameter update, the prediction model here still adopts the first model parameter and the second model parameter.
  • the prediction model includes a plurality of reference sample tags, and the plurality of reference sample tags include sample tags corresponding to each sample data. That is to say, since the training set already includes the sample tag corresponding to the feature vector, the plurality of reference sample tags included in the prediction model should at least include the sample tags included in the training set, so that the prediction model can be accurately trained.
  • the probability that the feature vector corresponds to each reference sample label may be calculated; and the reference sample label is obtained as the corresponding sample label. Probability.
  • the prediction model is used to recommend an application software for a user.
  • the multiple reference sample labels include application names P1, P2, P8, P9, P10, P3, P4, P5, P6, and P7; Application names P1, P2, P3, P4, P5, P6; the corresponding feature vectors are x1, x2, x3, x4, x5, x6; the probability calculation rule using the first model parameter is According to this probability calculation rule, if the input value x is any one of the feature vectors, a probability value corresponding to a plurality of reference sample tags is obtained.
  • the result includes probability values corresponding to P1, P2, P8, P9, P10, P3, P4, P5, P6, and P7, respectively, since the feature vector x3 and the sample tag are P3, and The result of finding the reference sample label as P3 is found as the probability corresponding to the sample label P3.
  • the terminal calculates, according to a probability that the feature vector corresponds to the sample tag, a prediction loss of each sample data according to a loss calculation rule.
  • the loss calculation rule is Where x is a feature vector, and k is a k-th sample tag corresponding to the feature vector in the plurality of reference sample tags. Representing a probability that a feature vector corresponds to the sample tag; Indicates the predicted loss corresponding to the sample data.
  • the correlation between the probability calculation rules and the first model parameters is exemplified by a simple linear model (the linear model here is just an example, but also a more complex model such as a deep neural network).
  • the input feature vector is x ⁇ R m , where m is the feature vector dimension and the first model parameter of the prediction model is ⁇ 1 , then the output of the model defined as:
  • Model output Is a probability distribution, where the kth component Represents the probability that the sample tag is the kth APP.
  • K is the total number of APPs output.
  • the terminal inputs the target feature vector to be predicted into a prediction model that uses the updated first model parameter and the second model parameter, and acquires a target sample tag corresponding to the target feature vector.
  • the terminal when predicting a model including the updated first model parameter and the second model parameter, the terminal inputs the target feature vector to be predicted into the updated prediction model, and by using the above description, the prediction model A plurality of reference sample tags are included, so that a reference probability corresponding to each reference sample tag of the target feature vector is obtained; the terminal determines the reference sample tag corresponding to the maximum value of the reference probabilities of the plurality of reference probabilities as the target sample tag.
  • the prediction model is used to recommend the application software for the user.
  • FIG. 4 is an example diagram of a prediction model for recommending application software for a user according to an embodiment of the present invention, as shown in FIG. 4 .
  • the training set contains icons for 4 applications, and the prediction set represents the icon of the next recommended application to be predicted.
  • the icon of each application in the training set further includes a feature vector corresponding to each application, and the feature vector is formed according to characteristics such as the location, time, mobile phone power, and network signal strength of the application software W.
  • the prediction result of the target feature vector is corresponding to the 20 APPs.
  • the application name corresponding to the largest value.
  • the terminal after the terminal receives the first model parameter and the second model parameter sent by the server, first updating the first model parameter according to the training set and the prediction model to obtain the updated first model parameter,
  • the target sample tag corresponding to the target feature vector is acquired in the prediction model in which the target feature vector to be predicted is input to the first model parameter and the second model parameter. This can reflect the difference between the terminal and other terminals, and achieve a more accurate prediction effect.
  • Embodiment 3 based on the system architecture diagram shown in FIG. 1, please refer to FIG. 3, which is another prediction method according to an embodiment of the present invention.
  • the method is performed by two or more terminals and a server together. Only the interaction process between one terminal and the server is shown here. For the interaction process between other terminals and the server, a detailed description of the terminal may be referred to.
  • the prediction method includes steps 301 to 309, which are described in detail below.
  • the server sends the first model parameter and the second model parameter to the multiple terminals.
  • the first model parameter and the second model parameter are adapted to the prediction model of the terminal.
  • the prediction model may include model parameters.
  • the server may send the model parameters to the terminal.
  • the model parameters may be updated in the model training phase or the model prediction phase, and the corresponding prediction model is also updated to adopt the updated model. Model parameters.
  • the server maintains a meta learner with ( ⁇ , ⁇ ) as a parameter, wherein ⁇ is a first model parameter and ⁇ is a second model parameter.
  • the first model parameter is denoted by ⁇ 1
  • the second model parameter is denoted by ⁇ 1 .
  • the server distributes the value of ( ⁇ 1 , ⁇ 1 ) as a model parameter of the prediction model to a plurality of terminals, where the execution subject of the received model parameters is any one of the plurality of terminals distributed.
  • the initialization meta-learner parameter in the server is ( ⁇ , ⁇ ), where ⁇ is the initial parameter of the prediction model, ⁇ is the vector, and each component included in ⁇ is represented by ⁇ j , and each term ⁇ j can be Randomly initialized as follows:
  • is a vector, and each component of ⁇ has a one-to-one correspondence with each component of ⁇ (because the update rule used in the subsequent examples needs to perform vector subtraction, so it is set here), each component included in ⁇ is ⁇ . j indicates that it is randomly initialized as follows:
  • first model parameter and the second model parameter are not limited in the embodiment of the present invention.
  • each prediction model is a prediction model based on the same algorithm and is used to implement a prediction model using one prediction task.
  • the first model parameter and the second model parameter transmitted by the server corresponding to each terminal are adapted to the prediction model of each terminal.
  • the terminal updates the first model parameter according to the first training set and the prediction model to obtain the updated first model parameter.
  • the first training set herein includes a plurality of first sample data, the first sample data including a first feature vector and a first sample tag corresponding to the first feature vector.
  • the step 302 is specifically: calculating a second prediction loss of the training set according to the prediction model, where the prediction model adopts a first model parameter and a second model parameter, that is, ( ⁇ 1 , ⁇ 1 ); And predicting the loss and the second model parameter, and updating the first model parameter according to the parameter update rule to obtain the updated first model parameter.
  • step 202 in the embodiment shown in FIG. 2, where the difference between the two is that the second training set in step 302 corresponds to the training set in step 202, and the second prediction loss in step 302 corresponds to The intermediate prediction loss in step 202 is because the embodiment shown in FIG. 2 is in the stage of prediction using the prediction model, and the step 302 in the embodiment shown in FIG. 3 is to perform prediction model on each terminal through its own data.
  • the stage of training Although the stages are different, the implementation is the same and will not be described here.
  • the terminal acquires a test set, and calculates a first prediction loss of the test set according to the predicted model that uses the updated first model parameter and the second model parameter.
  • the test set includes a plurality of second sample data, and the second sample data includes a second feature vector and a second sample tag corresponding to the second feature vector.
  • the prediction model here has adopted the updated first model parameter, and the updated first model parameter is set to ⁇ 3 , and the model parameter used in the prediction model is ( ⁇ 3, ⁇ 1).
  • the test set includes a plurality of second sample data, and each of the plurality of second sample data includes a second sample tag and a second feature vector corresponding to the second sample tag.
  • the terminal first calculates a prediction loss of each second sample data of the plurality of second sample data, and then calculates an average of the multiple prediction losses to obtain a first prediction loss, for example:
  • ⁇ 3 represents the updated first model parameter; Representing the first prediction loss determined by the terminal i according to the updated first model parameter; the test set is S test (n), n represents the nth second sample data of the test set, and the number of the second sample data in the test set is N ;l n ( ⁇ 3 ) represents the predicted loss of the nth second sample data.
  • the terminal first calculates a prediction loss of each second sample data of the plurality of second sample data, and then obtains a weight corresponding to each second sample data, and calculates an average of the multiple prediction losses. Value to get the first predicted loss.
  • ⁇ 3 represents the updated first model parameter; Representing the first prediction loss determined by the terminal i according to the updated first model parameter; the test set is S test (n), n represents the nth second sample data of the test set, and the number of the second sample data in the test set is N ; l n ( ⁇ 3 ) represents the prediction loss of the nth second sample data, and ⁇ n represents the weight corresponding to the nth second sample data.
  • the weight corresponding to each second sample data may be determined by the terminal according to the association information of the second sample data, for example, according to a generation time of the second sample data, and the prediction model is used to recommend an application for the user.
  • the software is described as an example.
  • the second sample data is generated according to the history record of the user, that is, the second sample tag of the second sample data may be the name of the application software W, and the feature vector is based on the location of the application software W.
  • the time, the power of the mobile phone, the strength of the network signal, etc., the terminal can sort according to the duration of the historical use record from the longest to the shortest time, and classify the duration and set the weight corresponding to each type of duration, such as The weight value near the current time is large.
  • the association information of the second sample data is not limited.
  • step 303 For the calculation of the prediction loss corresponding to each second sample data in step 303, reference may be made to the detailed description of step B11 and step B12 in the embodiment shown in FIG. 2, and details are not described herein again.
  • the terminal sends the first predicted loss to the server.
  • the terminal After the determining, by the step 303, the first prediction loss, the terminal sends the first prediction loss to the server, so that the server performs the update of the prediction model according to the first prediction loss and the first prediction loss sent by other terminals to obtain an update. After the model parameters.
  • the server receives a first prediction loss sent by at least one of the multiple terminals.
  • the server receives a first prediction loss sent by at least one of the plurality of terminals.
  • the first prediction loss fed back by each terminal is numerically the same, because the first prediction loss sent by each terminal in the embodiment of the present invention is based on the first model parameter and the second model parameter of each terminal. computational.
  • the server updates the first model parameter according to the first prediction loss sent by the at least one terminal, to obtain the updated first model parameter, and according to the first prediction loss pair sent by the at least one terminal.
  • the second model parameter is updated to obtain the updated second model parameter.
  • the server updates the first model parameter and the second model parameter according to the first prediction loss that is fed back by the at least one terminal.
  • first prediction loss that is fed back by the at least one terminal.
  • the server calculates a second predicted loss according to the first predicted loss sent by the at least one terminal.
  • the server determines an average of the plurality of first predicted losses as the second predicted loss.
  • the server may obtain the weight corresponding to the first prediction loss of each terminal, and obtain a second prediction loss by using a weighted average operation manner.
  • the server calculates the second predicted loss as follows. It should be noted that the second prediction loss here is different from the second prediction loss involved in step 302, since the second prediction loss in step 302 is determined by the terminal, which is determined by the server. And the calculation of the two is different.
  • Q represents the number of at least one terminal
  • L 3 ( ⁇ 3 ) represents the second predicted loss
  • the server updates the first model parameter according to the parameter update rule according to the second prediction loss, to obtain the updated first model parameter, and the second model according to the parameter update rule.
  • the parameters are updated to obtain the updated second model parameters.
  • parameter update rule here is different from the parameter update rule involved in step 302.
  • the parameter update rule herein may be preset, and the parameter update rule is not limited in the embodiment of the present invention.
  • parameter update rules can be implemented as follows:
  • ⁇ 1 represents the first model parameter
  • ⁇ 2 represents the updated first model parameter
  • represents the first preset weight
  • L 3 ( ⁇ 3 ) can also be converted into a term containing the ⁇ 1 variable, ie L 3 ( ⁇ 1 )
  • Operation can be achieved L 3 ( ⁇ 1) for derivation ⁇ 1 to obtain the rate of change terms for ⁇ 1, L 3 ( ⁇ 1) of.
  • the updated first model parameter ⁇ 2 can be obtained according to the above update formula.
  • the second model parameters can be learned or updated in the following manner. Specifically, the server updates the second model parameter according to the parameter update rule according to the first predicted loss to obtain the updated second model parameter.
  • the parameter update rule is:
  • ⁇ 1 represents a second model parameter
  • ⁇ 2 represents an updated second model parameter
  • represents a second preset weight
  • L 3 ( ⁇ 1 , ⁇ 1 ) represents a first prediction transmitted by each terminal
  • the second predicted loss calculated by the loss, L 3 ( ⁇ 3 ) is calculated based on the received first predicted loss, ⁇ 3 is also updated according to ⁇ 1
  • the update process of ⁇ 3 also includes ⁇ 1
  • L 3 ( ⁇ 3 ) can also be converted into a term containing the ⁇ 1 variable and the ⁇ 1 variable, ie L 3 ( ⁇ 1 , ⁇ 1 ); Indicates the gradient. Since there is another variable added here.
  • the embodiment of the present invention does not limit ⁇ and ⁇ , and the two may be the same in value or different.
  • the server sends the updated first model parameter and the updated second model parameter to the multiple terminals.
  • step 306 it can be known that the updated first model parameter is ⁇ 2 and the updated second model parameter is ⁇ 2 ; therefore, in this case, the model parameter of the prediction model adapted by the server and transmitted by the terminal Is ( ⁇ 2 , ⁇ 2 ).
  • the terminal receives the updated first model parameter and the updated second model parameter sent by the server, so as to implement prediction according to the updated first model parameter and the updated second model parameter.
  • the terminal updates the first model parameter according to the second training set to obtain the updated first model parameter.
  • the terminal inputs a target feature vector to be predicted into a prediction model that uses the updated first model parameter and the second model parameter, and acquires a target sample tag corresponding to the target feature vector.
  • step 308 before the first model parameter is updated, the model parameter of the prediction model is ( ⁇ 2 , ⁇ 2 ); the updated first model parameter may be represented by ⁇ 4 , and the specific update process is no longer Narration.
  • the model parameters of the prediction model sent by the server to the at least two terminals in the embodiment of the present invention may be performed according to certain rules.
  • at least two terminals are E terminals, and the server may send to E The terminal is periodically distributed in a centralized manner; or, in the case of a meta-learner that needs to update the prediction model, the model parameters of the prediction model are transmitted to the E terminals; or, the E terminals are classified into the F-class, and the batch-type terminals are sent to the F-type terminal.
  • the embodiment of the present invention does not limit the rules according to the model parameters for the server to send the prediction model.
  • the prediction loss sent by the terminal to the server may also be performed according to a certain rule, for example, the time when the server sends feedback prediction loss to each of the at least two terminals, The time at which each terminal feeds back the predicted loss may be the same to achieve centralized acquisition; or the time at which each terminal feeds back the predicted loss may be different, and the batch acquisition is also implemented.
  • the terminal may feed back the predicted loss according to the training condition of the model. For example, after the terminal calculates the predicted loss, the terminal predicts the loss and the like to the server within a certain length of time.
  • the embodiment of the present invention does not limit the rules for the terminal to feedback the predicted loss.
  • the training of the predictive model can be performed at each terminal, so that the user privacy problem of each terminal can be protected, and the terminal feeds back the calculated prediction loss to the server, so that the server feeds back data according to a large number of terminals.
  • the model parameters are updated again, so that the information of the prediction model can be accurately updated by using a large amount of user information.
  • the server may send a model parameter adapted to the prediction model of the terminal to the terminal to enable the terminal to implement prediction, and after the terminal receives the model parameter sent by the server, first update the first model parameter according to the training set and the prediction model, Obtaining the updated first model parameter, and acquiring, in the prediction model updated to the updated first model parameter, the target feature tag to be predicted, and acquiring the target sample tag corresponding to the target feature vector.
  • This can reflect the difference between the terminal and other terminals, and achieve a more accurate prediction effect.
  • each group includes at least two terminals, for example, the group 1 includes the terminal 11, the terminal 12, and the like.
  • the server may group multiple terminals according to certain rules such that at least two terminals included in each group have common features. For example, a common feature between at least two terminals includes the location of the terminals within a certain geographic area, and the terminals have similar information related to the prediction model.
  • the information related to the prediction model may include the type of the application downloaded in the terminal, the duration of the user's use of the terminal, the user's usage habits, and the user's age range.
  • the grouping may be performed according to the identifier of the terminal, where the terminal identifier may include a hardware identifier, an Internet Protocol (IP), and the like. This embodiment of the present invention does not limit this.
  • the server may be separately managed for each group, that is, one group corresponds to one prediction model, for example, the terminal 11, the terminal 12, and the like in the group 1 are executed in the embodiment shown in FIG.
  • the steps, and in this process does not refer to the information fed back by the terminals of other groups. Since the end users belonging to the same group have more commonality, the corresponding meta learner can learn a more suitable mechanism for the group, so that training can be more suitable for the terminal in the group. Predictive models to achieve better predictive results.
  • FIG. 6 is a schematic structural diagram of a terminal according to an embodiment of the present application. Including the terminal 600 in FIG. 6 includes:
  • the receiving module 601 is configured to receive the first model parameter and the second model parameter sent by the server, where the first model parameter and the second model parameter are adapted to the prediction model of the terminal;
  • the processing module 602 is configured to update the first model parameter according to the training set and the prediction model to obtain an updated first model parameter, where the training set includes a plurality of first sample data, where a sample data includes a first feature vector and a first sample tag corresponding to the first feature vector;
  • the processing module 602 is specifically configured to acquire a test set, and calculate a first prediction loss of the test set according to a prediction model that uses the updated first model parameter, where the test set includes multiple second sample data.
  • the second sample data includes a second feature vector and a second sample tag corresponding to the second feature vector;
  • the sending module 603 is configured to send the first prediction loss to the server, so that the server updates the first model parameter and the second model parameter according to the first prediction loss;
  • the terminal includes a prediction model for prediction; the prediction model included in the terminal is the same type of prediction model as the prediction model of the server.
  • the processing module 602 performs the updating of the first model parameter according to the training set and the prediction model to obtain the updated first model parameter, specifically:
  • the processing module 602 performs, in performing, calculating a second prediction loss of the training set according to the prediction model, specifically:
  • the processing module 602 performs, in performing, calculating a prediction loss of each of the plurality of first sample data according to the prediction model, specifically:
  • the processing module 602 is configured to input a first feature vector of each of the first sample data into a prediction model to obtain the location of each of the first sample data.
  • the probability that the first feature vector corresponds to the first sample tag is specifically performed:
  • Determining a probability that the reference sample tag corresponds to the first sample tag is a probability that the first feature vector corresponds to the first sample tag.
  • the processing module 602 is configured to calculate a first prediction loss of the test set according to a prediction model that uses the updated first model parameter and the second model parameter, Is executed:
  • the processing module 602 calculates, in performing a prediction model updated according to the model parameter, a prediction loss corresponding to each second sample data of the plurality of second sample data included in the test set, Specifically, it is executed:
  • the processing module 602 is configured to input a second feature vector of each of the second sample data into the predicted model after the model parameter update to obtain the The probability that the second feature vector of the two sample data corresponds to the second sample tag is specifically performed:
  • the probability that the reference sample tag corresponds to the second sample tag is determined as a probability that the second feature vector corresponds to the second sample tag.
  • FIG. 7 is a schematic structural diagram of a terminal according to an embodiment of the present application.
  • the inclusion of terminal 700 in FIG. 7 includes:
  • the receiving module 701 is configured to receive a first model parameter and a second model parameter sent by the server, where the first model parameter and the second model parameter are adapted to the prediction model of the terminal;
  • the processing module 702 is configured to update the first model parameter according to the training set and the prediction model to obtain an updated first model parameter, where the training set includes multiple sample data, and each sample data includes a feature. a vector and a sample tag corresponding to the feature vector;
  • the processing module 702 is further configured to: input a target feature vector to be predicted into a prediction model that adopts the updated first model parameter and the second model parameter, and acquire a target corresponding to the target feature vector Sample label
  • the prediction model included in the terminal is the same type of prediction model as the prediction model of the server.
  • processing module 702 is configured to perform the updating of the first model parameter according to the training set and the prediction model to obtain the updated first model parameter, specifically:
  • the processing module 702 performs, in performing, calculating an intermediate prediction loss of the training set according to the prediction model, specifically:
  • the processing module 702 performs, in performing, calculating a prediction loss of each of the plurality of sample data according to the prediction model, specifically:
  • the processing module 702 inputs, in the execution terminal, a feature vector of each sample data into the prediction model to obtain the feature vector and the location of each sample data.
  • the probability aspect corresponding to the sample label is specifically executed:
  • determining, by the terminal, a probability that the reference sample label corresponds to the sample label is a probability that the feature vector corresponds to the sample label.
  • the processing module 702 performs the input of the target feature vector to be predicted into the prediction model adopting the updated first model parameter and the second model parameter, and acquires The target sample tag corresponding to the target feature vector is specifically executed:
  • a reference sample tag corresponding to the maximum value of the reference probabilities among the plurality of reference probabilities is determined as the target sample tag.
  • FIG. 8 is a schematic structural diagram of another terminal according to an embodiment of the present invention.
  • the terminal 800 shown in FIG. 8 includes: a processor 801 and a transceiver 802, where the transceiver 802 is configured to support the terminal 800 and the foregoing.
  • the information transmission between the servers involved in the embodiment for example, implements the functions of the receiving module 601 and the transmitting module 603 in the embodiment shown in FIG. 6, or, for example, implements the functions of the receiving module 701 in the embodiment shown in FIG.
  • the processor 801 and the transceiver 802 are communicatively coupled, such as by a bus.
  • the terminal 800 may further include a memory 803.
  • the memory 803 is used to store program code and data for execution by the terminal 800, and the processor 801 is configured to execute the application code stored in the memory 803 to implement the actions of the terminal provided by any of the embodiments shown in FIG. 2 or 5.
  • the terminal may include one or more processors, and the structure of the terminal 800 does not constitute a limitation on the embodiment of the present application.
  • the processor 801 can be a central processing unit (CPU), a network processor (NP), a hardware chip, or any combination thereof.
  • the hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof.
  • the PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a general array logic (GAL), or any combination thereof.
  • the memory 803 may include a volatile memory such as a random access memory (RAM); the memory 803 may also include a non-volatile memory such as a read-only memory (read- Only memory, ROM), flash memory, hard disk drive (HDD) or solid-state drive (SSD); the memory 803 may also include a combination of the above types of memories.
  • RAM random access memory
  • ROM read- Only memory
  • HDD hard disk drive
  • SSD solid-state drive
  • the memory 803 may also include a combination of the above types of memories.
  • a computer storage medium which can be used to store computer software instructions used by the terminal in the embodiment shown in FIG. 8, and includes a program for executing the terminal designed in the foregoing embodiment.
  • the storage medium includes, but is not limited to, a flash memory, a hard disk, a solid state disk.
  • a computer program product is also provided.
  • the prediction method designed for the terminal in the foregoing embodiment of FIG. 8 may be executed.
  • FIG. 9 is a schematic structural diagram of a server according to an embodiment of the present application.
  • the server 900 shown in FIG. 9 includes:
  • the sending module 901 is configured to send, to the multiple terminals, a first model parameter and a second model parameter, where the first model parameter and the second model parameter are adapted to the prediction model of the terminal;
  • the receiving module 902 is configured to receive a first prediction loss that is sent by at least one of the multiple terminals, where a first prediction loss sent by each terminal in the at least one terminal is used by each terminal according to the first Calculated by model parameters and prediction models of the second model parameters;
  • the processing module 903 is configured to update the first model parameter according to the first prediction loss sent by the at least one terminal to obtain the updated first model parameter, and according to the first prediction sent by the at least one terminal Losing the second model parameter to obtain an updated second model parameter;
  • the terminal includes a prediction model for prediction; the prediction model included in the terminal is the same type of prediction model as the prediction model of the server.
  • the processing module 903 performs an update on the first model parameter according to the first prediction loss sent by the at least one terminal to obtain the updated first model parameter, and according to The first prediction loss sent by the at least one terminal updates the second model parameter to obtain an updated second model parameter, specifically:
  • the server calculates a second predicted loss according to the first predicted loss sent by the at least one terminal
  • server updates the first model parameter according to the parameter update rule according to the second prediction loss to obtain the updated first model parameter, and the second model according to the parameter update rule The parameters are updated to obtain the updated second model parameters.
  • the sending module 901 is further configured to send, to the multiple terminals, the updated first model parameter and the updated second model parameter, so that the multiple Any one of the terminals performs prediction based on a prediction model that uses the updated first model parameter and the updated second model parameter.
  • the multiple terminals belong to the same group; the terminals of the same group have common features.
  • the common feature comprises the at least two terminals being located within a predetermined geographic area.
  • the server shown in FIG. 9 described above can be implemented by the server 1000 shown in FIG.
  • FIG. 10 is a schematic structural diagram of another server according to an embodiment of the present invention.
  • the server 1000 shown in FIG. 10 includes: a processor 1001 and a transceiver 1002.
  • the transceiver 1002 is configured to support the server 1000 and the foregoing.
  • the information transmission between the terminals involved in the embodiment for example, implements the functions of the transmitting module 901 and the receiving module 902 in the embodiment shown in FIG.
  • the processor 1001 and the transceiver 1002 are communicatively coupled, such as by a bus.
  • the server 1000 may also include a memory 1003.
  • the memory 1003 is configured to store program code and data for execution by the server 1000, and the processor 1001 is configured to execute the application code stored in the memory 1003 to implement the actions of the server provided by any of the embodiments shown in FIG. 3 to FIG.
  • the server may include one or more processors, and the structure of the server 1000 does not constitute a limitation on the embodiments of the present application.
  • the processor 1001 can be a CPU, an NP, a hardware chip, or any combination thereof.
  • the above hardware chip may be an ASIC, a PLD, or a combination thereof.
  • the above PLD may be a CPLD, an FPGA, a GAL, or any combination thereof.
  • the memory 1003 may include volatile memory such as RAM; the memory 1003 may also include non-volatile memory such as ROM, flash memory, hard disk or solid state hard disk; the memory 1003 may also include a combination of the above types of memory.
  • a computer storage medium which can be used to store computer software instructions used by the server in the embodiment shown in FIG. 9, and includes a program for executing the server designed in the above embodiment.
  • the storage medium includes, but is not limited to, a flash memory, a hard disk, a solid state disk.
  • a computer program product is also provided.
  • the prediction method designed for the server in the embodiment shown in FIG. 9 may be executed.
  • the third embodiment of the present invention is in the small sample joint learning framework.
  • the terminal uploads the prediction loss to the server in the third embodiment
  • the terminal in the embodiment of the present invention uploads the loss gradient to the server.
  • the steps of calculating the loss gradient from the predicted loss are performed at the terminal (Embodiment 6) and one at the server (Embodiment 3).
  • An embodiment of the present invention provides a method for training a machine learning model.
  • the interaction between the first terminal and the server is taken as an example, and the first terminal is any one of multiple terminals that establish a connection with the server, as shown in the figure.
  • the method includes:
  • the server sends the first parameter and the second parameter of the algorithm model maintained by the server to the multiple terminals including the first terminal, where the first parameter is used as an initial parameter of the machine learning model of each terminal of the multiple terminals.
  • the second parameter is used to indicate a manner of training the machine learning model of each of the plurality of terminals, and the machine learning models of the plurality of terminals have the same structure; optionally, the algorithm for sending the server to the plurality of terminals at the server Before the first parameter and the second parameter of the model, the server initializes the first parameter and the second parameter of the algorithm model.
  • the multiple terminals belong to the same group, and the same group is used to indicate the same or similar attribute features; optionally, the attribute features include a geographic area.
  • the server can maintain a common algorithm model for terminals in a geographic area.
  • the first terminal receives the first parameter and the second parameter of the algorithm model sent by the server, where the first terminal is one of multiple terminals in S1.
  • the first terminal trains the machine learning model to be trained according to the received first parameter, the second parameter, and the training set data, where the training set data includes multiple training samples, and each training sample includes a first feature vector and corresponding a first label, the first feature vector is constructed according to user information in historical data of the terminal;
  • the first terminal obtains test results according to test data and a machine learning model.
  • the first terminal calculates a loss gradient according to the test result.
  • the first terminal uploads the calculated loss gradient to the server, and the loss gradient is used by the server to update the first parameter and the second parameter of the algorithm model.
  • Steps S3-S6 in the embodiment of the present invention correspond to steps 302-304 in the third embodiment.
  • the main difference is that the embodiment of the present invention calculates the loss gradient and sends the loss gradient to the server, and the third embodiment calculates the predicted loss and predicts the loss. Sending to the server, the embodiment of the present invention replaces the predicted loss with a loss gradient, which can reduce the size of the uploaded data.
  • the server receives a loss gradient uploaded by the first terminal and at least one of the other terminals in the preset time window.
  • the server resets the preset time according to the probability that the multiple terminals upload the loss gradient. Window, where a plurality of terminals may include the first terminal or may not include the first terminal.
  • the number threshold can be calculated by the following method: suppose the terminal sent by the server is 1 , 2, ..., N, define p i as the ratio between the number of predicted feedbacks sent by the terminal i to the server and the number of requests sent by the server to the terminal i (i.e., p i is the predicted feedback sent to the terminal i) The estimation of the probability), the quantity threshold is defined as the expectation of the number of terminals transmitting the predicted feedback, ie
  • the server updates the first parameter and the second parameter according to all received loss gradients.
  • the server maintains a meta learner with ( ⁇ , ⁇ ) as a parameter.
  • the meta learner is a specific example of the algorithm model, and the terminal that predicts the loss prediction gradient is assumed. Is 1, 2, ..., N', where terminal i returns the predicted loss gradient Then update ( ⁇ , ⁇ ) as follows:
  • scalar ⁇ is a fixed hyperparameter representing the learning rate when updating the meta learner.
  • the first terminal of the S5 calculates a loss gradient according to the test result, and specifically includes:
  • the first terminal calculates the predicted loss according to the test result and the label corresponding to the test data
  • the first terminal calculates a loss gradient according to the predicted loss.
  • test data includes multiple test sample data, each test sample data includes a second feature vector and a corresponding second tag, and each test sample data corresponds to one test result;
  • the S5.1 first terminal calculates the predicted loss according to the test result and the label corresponding to the test data, and specifically includes: the first terminal calculates the multiple test samples according to the test result corresponding to the multiple test sample data and the second label. The respective predicted losses of the data;
  • the first terminal calculates the loss gradient according to the predicted loss, and the method includes: calculating, by the first terminal, a loss gradient of each of the plurality of test sample data according to respective prediction losses of the plurality of test sample data; Multiple loss gradients are averaged to obtain a target loss gradient;
  • the S6 first terminal uploads the loss gradient to the server, and specifically includes: the first terminal uploads the processed target loss gradient to the server.
  • test data includes multiple test sample data, each test sample data includes a second feature vector and a corresponding second tag, and each test sample data corresponds to one test result;
  • the S5.1 first terminal calculates the predicted loss according to the test result and the label corresponding to the test data, and specifically includes: the first terminal calculates the multiple test samples according to the test result corresponding to the multiple test sample data and the second label. The respective prediction loss of the data; the first terminal averages the plurality of prediction losses corresponding to the plurality of test sample data to obtain an average prediction loss;
  • the first terminal calculates a loss gradient according to the predicted loss, specifically: the first terminal calculates a target loss gradient according to the average predicted loss calculated above;
  • the S6 first terminal uploads the loss gradient to the server, and specifically includes: the terminal uploads the target loss gradient calculated according to the average prediction calculation to the server.
  • the embodiment of the present invention may calculate the gradient loss of each test sample and upload it to the server for the case where the test data includes multiple test sample data, or upload to the server; The predicted loss of each test sample is uploaded to the server.
  • the embodiment of the present invention may calculate the gradient loss of each test sample and upload it to the server for the case where the test data includes multiple test sample data, or upload to the server; The predicted loss of each test sample is uploaded to the server.
  • the first terminal calculates the predicted loss of each of the plurality of test sample data according to the test result and the second label corresponding to the plurality of test sample data, the first terminal further includes:
  • the first terminal confirms that the predicted loss of each of the plurality of test sample data meets a preset condition, and the preset condition is used to indicate that the average predicted loss fluctuation value relative to the last calculation is less than a preset threshold.
  • the determining whether the preset condition is met is: assuming that the predicted loss corresponding to the S i prediction feedback that the first terminal i has sent in history is respectively Calculate their mean And standard deviation If L i ⁇ [ ⁇ -3 ⁇ , ⁇ +3 ⁇ ], the prediction is normal; otherwise, the prediction is abnormal; [ ⁇ -3 ⁇ , ⁇ +3 ⁇ ] is equivalent to the preset condition.
  • the first terminal if the first terminal confirms that the predicted loss of the test sample data i does not satisfy the preset condition, the first terminal does not calculate the loss gradient corresponding to the prediction loss of the test sample data i or the prediction according to the test sample data i The loss calculates the average predicted loss, and the test sample data i is any one of the plurality of test sample data.
  • the method further includes:
  • the first terminal sends the structure identifier of the machine learning model to the server, and the structure identifier is used by the server to determine an algorithm model corresponding to the machine learning model according to the structure identifier.
  • the required algorithm model parameters can be determined by the identification.
  • the first terminal has a classification machine learning model and an application recommendation machine learning model. If the two models have different model structures, when the classification machine learning model needs to be trained, the identifier corresponding to the classification machine learning model can be uploaded, and the server is notified.
  • the parameters of the required algorithm model similarly, if the application recommends the machine learning model, when the application recommendation machine learning model needs to be trained, the identifier corresponding to the application recommended machine learning model can be uploaded to inform the server of the parameters of the required algorithm model; In a case where the computing power of the terminal is allowed, even if the first terminal needs to train both the classification machine learning model and the application recommendation machine learning model, the parameters of the algorithm model on the server can be obtained through the structure identification, and the multi-task is simultaneously performed.
  • the relationship between the structure identifier, the machine learning model, and the algorithm model may be pre-configured, or may be negotiated before the acquisition, and the specific correspondence portion imposes any restrictions.
  • the method further includes: S10, the server receiving the respective machine learning model uploaded by the multiple terminals A structure identifier for the server to determine the algorithm model corresponding to the structure of the machine learning model.
  • the method further includes: S11, the server receives the prediction result scored by the at least one terminal, and the prediction result is divided into the end user's scoring of the prediction result of the machine learning model; the S12 server scores the prediction result according to the prediction result, and determines the weighting coefficient; At least one terminal may include the first terminal or may not include the first terminal.
  • the S8 server updates the first parameter and the second parameter according to the loss gradient uploaded by the at least one terminal, specifically: the server performs weighted average processing on the loss gradient uploaded by the at least one terminal according to the weighting coefficient to obtain a weighted loss gradient;
  • the loss gradient updates the first parameter and the second parameter.
  • the server maintains a meta learner with ( ⁇ , ⁇ ) as a parameter, and the server receives the prediction loss gradient sent by the N′ terminals. Then calculate the average of all gradients The meta learner parameters are updated with this average.
  • the method further includes: S13, the server receives a parameter update request sent by the first terminal, where the parameter update request is used to request the server to send the first parameter and the second parameter that are updated recently, where the first terminal is Any one of the terminals;
  • the server sends the first parameter and the second parameter of the last update to the first terminal.
  • the method performed by the server in the foregoing embodiment may be implemented by the server shown in FIG. 9 or FIG. 10.
  • the method performed by the first terminal in the foregoing embodiment may be implemented by the terminal shown in FIG. 6 or FIG.
  • the terminal shown in FIG. 6 or FIG. For details, refer to the corresponding embodiment in the above figure, and details are not described herein again.
  • the next APP is recommended as an example, and Meta-SGD is used as a sample learning algorithm model.
  • Meta-SGD is used as a sample learning algorithm model.
  • the server maintains ( ⁇ , ⁇ ) as a parameter of the meta-learner.
  • the steps performed by the server in the embodiment of the present invention are different from the steps performed by the server in the third embodiment: in the embodiment of the present invention, the server is Loss gradient received by each terminal (predicted loss gradient) Here Is a function of ( ⁇ , ⁇ ); assume that the terminal that returns the prediction feedback is 1, 2, ..., N', where terminal i returns the predicted loss gradient Then update ( ⁇ , ⁇ ) as follows:
  • scalar ⁇ is a fixed hyperparameter representing the learning rate when updating the meta learner.
  • Terminal side In the embodiment of the present invention, the terminal performs the following steps:
  • a counter S i is maintained to record the number of times the current terminal i has sent a predicted feedback (loss gradient). If it is the first time to perform small sample training, initialize S i ⁇ 0.
  • the terminal receives the parameter ( ⁇ , ⁇ ) sent by the service, the first parameter corresponds to ⁇ , the second parameter corresponds to ⁇ ; for the recommended model with parameter ⁇ , it is defined on the sample (x, k) (where x is the feature vector, k The loss function representing the sample label as the kth APP) is
  • Embodiment 7 of the present invention further provides a prediction method, where prediction refers to predicting a certain type of task based on a machine learning model, for example, image classification, application recommendation, and image recognition can all be regarded as a kind of prediction behavior, such as As shown in Figure 12, the method includes:
  • the first terminal acquires user information of the first terminal, and generates a target feature vector according to the user information.
  • the first terminal inputs the target feature vector into the target prediction model to obtain a target prediction result.
  • the target prediction model is a machine learning model trained by the first terminal according to the first parameter, the second parameter, and the historical data of the terminal, where the first parameter and the second parameter are corresponding to the machine learning model of the terminal sent by the server on the server.
  • Two parameters of the algorithm model, the first parameter is used as an initial parameter of the machine learning model of the first terminal, and the second parameter is used to indicate a manner in which the first terminal trains the machine learning model, the first parameter and the first parameter
  • the two parameters are obtained by the server according to multiple loss gradients fed back by multiple terminals, and any loss gradient is calculated by the corresponding terminal based on local historical data. How to calculate the loss gradient is described in detail in the corresponding part of the above embodiment, where the multiple terminals include The first terminal.
  • the machine learning model of the terminal is trained before use.
  • the specific training method is the method for training the machine learning model described in the above embodiment; optionally, before the prediction by the machine learning model, the method further includes S1030: The terminal sends a parameter update request to the server, where the parameter update request is used to request the server to send the first parameter and the second parameter of the latest update of the algorithm model; S1040, the server receives the parameter update request sent by the first terminal, The parameter update request is used to request the server to send a first parameter and a second parameter that are updated recently, the first terminal is any one of the multiple terminals; S1050, the server is to the first A terminal sends the first parameter and the second parameter of the last update.
  • S1060 The terminal receives the first parameter and the second parameter of the latest update sent by the server.
  • S1070 The terminal trains the target prediction model according to the received first updated parameter and the second parameter and the current historical data of the terminal.
  • the S1020 first terminal inputs the target feature vector into the target prediction model to obtain the target prediction result, which specifically includes: the first terminal inputs the target feature vector into the trained target prediction model to obtain the target prediction result.
  • the target prediction model can be predicted and then predicted based on the first parameter and the second parameter of the newly updated server and the newly generated historical data of the terminal, so that a better prediction effect can be achieved. .
  • the parameter update request sent by the first terminal to the server includes: a structure identifier of a machine learning model corresponding to the target prediction model, and the structure identifier is used by the server to determine an algorithm model corresponding to the target prediction model.
  • the method further includes: the first terminal acquires a user to score the prediction result of the target prediction result; and uploads the prediction result to the server, wherein the prediction result is scored, wherein The prediction result is divided into first terminal users to score the target prediction result, and the prediction result is used for determining the weighting coefficient by the server, and the weighting coefficient is used by the server to process the loss gradient uploaded by the plurality of terminals to obtain a weighted loss gradient, and the weighted loss gradient is used for
  • the server updates the first parameter and the second parameter.
  • the first terminal may obtain the prediction result of the target prediction result by sending the user to the server, or may obtain the prediction result of the target prediction result after the first terminal receives the user feedback request sent by the server to the terminal periodically. Score; the following is the second case:
  • the server sends a user feedback request to the terminal, which can be executed as follows: periodically (such as once a month) to send a user feedback request, and the user feedback request is used to request the terminal user to perform (subjective) evaluation on the prediction effect, in the range of 0 to 10.
  • the score is 0, the effect is very poor, 10 is very good;
  • the terminal receives the user feedback request and notifies the end user to score the prediction effect, and uploads the user to the target at the next upload of the predicted feedback (ie loss gradient or predicted loss)
  • the score of the prediction result of the prediction result the server refers to the user scoring when updating the parameter.
  • the usage of the end user's scoring may be: (a) the end user scores more High, indicating that the meta-learner is most effective in training the end user's model.
  • the weight of the end user is greater when updating the meta-learner parameters; (b) the lower the end-user score, indicating that the meta-learner should upgrade the terminal.
  • the user's model training effect the greater the weight of the end user when updating the meta learner parameters, the element here
  • the learner refers to the algorithm model; for example, adopting mode (a), that is, the higher the end user scores, the greater the corresponding weight, as follows:
  • the method performed by the server in the above embodiment may be implemented by the server shown in FIG. 9 or FIG. 10, and the method performed by the first terminal in the above embodiment may be implemented by the terminal shown in FIG. 6 or FIG. 7 or FIG.
  • the method performed by the first terminal in the above embodiment may be implemented by the terminal shown in FIG. 6 or FIG. 7 or FIG.
  • the algorithm model for the server and the machine learning model of the terminal (for example) the prediction model, optionally, the models at both ends are small-scale models, or the server is a small-scale model, or the terminal is a small-scale model, wherein the small-scale model is relative In the case of traditional neural networks.
  • the above embodiments it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof.
  • software it may be implemented in whole or in part in the form of a computer program product.
  • the computer program product includes one or more computer instructions.
  • the computer program instructions When the computer program instructions are loaded and executed on a computer, the processes or functions described in accordance with embodiments of the present invention are generated in whole or in part.
  • the computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable device.
  • the computer instructions can be stored in a computer readable storage medium or transferred from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be from a website site, computer, server or data center Transfer to another website site, computer, server, or data center by wire (eg, coaxial cable, fiber optic, digital subscriber line (DSL), or wireless (eg, infrared, wireless, microwave, etc.).
  • the computer readable storage medium can be any available media that can be accessed by a computer or a data storage device such as a server, data center, or the like that includes one or more available media.
  • the usable medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (such as a solid state disk (SSD)).
  • the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Accounting & Taxation (AREA)
  • Development Economics (AREA)
  • Finance (AREA)
  • Strategic Management (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Computing Systems (AREA)
  • Artificial Intelligence (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Marketing (AREA)
  • Economics (AREA)
  • General Business, Economics & Management (AREA)
  • Game Theory and Decision Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Medical Informatics (AREA)
  • Computational Linguistics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Probability & Statistics with Applications (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Mobile Radio Communication Systems (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本发明实施例公开了一种预测方法及终端、服务器。其方法包括服务器向多个终端发送第一模型参数和第二模型参数,第一模型参数和第二模型参数适配于终端的预测模型;服务器接收多个终端中至少一个终端发送的第一预测损失,至少一个终端中每个终端发送的第一预测损失为每个终端根据采用第一模型参数和第二模型参数的预测模型计算的;服务器根据至少一个终端发送的第一预测损失对第一模型参数进行更新,以获得更新后的第一模型参数,以及根据至少一个终端发送的第一预测损失对第二模型参数进行更新,以获得更新后的第二模型参数。采用本发明实施例,可以实现通过利用大量用户数据进行训练而得到体现用户差异性的预测模型。

Description

一种预测方法及终端、服务器 技术领域
本发明涉及预测模型领域,尤其涉及一种预测方法及终端、服务器。
背景技术
基于机器学习的预测系统通常分为模型训练和预测两部分,(1)模型训练:利用训练集数据训练一个适用于该任务的预测模型;其中,训练集通常包含大量的数据;(2)预测:使用训练出的模型对测试集数据进行预测。传统机器学习在解决终端预测任务时,一种方式是在终端本地单独进行模型训练,只能利用单一终端用户的样本,无法利用其它大量用户的信息(如相似的手机使用习惯),导致预测效果不佳;另一种方式是在云侧服务器训练一个统一的预测模型,但模型规模较大也影响到对单一用户的预测效果。
在保护用户隐私的前提下,如何利用大量用户数据训练可以体现用户差异性的预测模型是需要解决的问题。
发明内容
本发明实施例提供一种预测方法及终端、服务器,可以实现通过利用大量用户数据进行训练而得到体现用户差异性的预测模型。
第一方面,本发明实施例提供了一种预测方法,包括:
服务器向多个终端发送第一模型参数和第二模型参数,第一模型参数和第二模型参数适配于终端的预测模型;接收多个终端中至少一个终端发送的第一预测损失,至少一个终端中每个终端发送的第一预测损失为每个终端根据采用第一模型参数和第二模型参数的预测模型计算的;根据至少一个终端发送的第一预测损失对第一模型参数进行更新,以获得更新后的第一模型参数,以及根据至少一个终端发送的第一预测损失对第二模型参数进行更新,以获得更新后的第二模型参数。
在第一方面中,预测模型的训练可以在各个终端进行,这样能够起到保护各个终端的用户隐私的作用,以及终端将计算获得的预测损失反馈至服务器,以使服务器根据大量终端反馈的数据,再次进行模型参数的更新,这样可以利用大量用户的信息来准确地更新模型参数。
在一种可选的实施例中,服务器根据至少一个终端发送的第一预测损失对第一模型参数进行更新,以获得更新后的第一模型参数,以及根据至少一个终端发送的第一预测损失对第二模型参数进行更新,以获得更新后的第二模型参数具体是:服务器根据至少一个终端发送的第一预测损失,计算第二预测损失;服务器根据第二预测损失,按照参数更新规则对第一模型参数进行更新,以获得更新后的第一模型参数,以及按照参数更新规则对第二模型参数进行更新,以获得更新后的第二模型参数。
在一种可选的实施例中,服务器还可以向多个终端发送更新后的第一模型参数和更新后的第二模型参数,多个终端中的任一终端根据采用更新后的第一模型参数和更新后的第二模型参数的预测模型进行预测。
在一种可选的实施例中,多个终端属于同一群组;同一群组的终端具备共同特征。可选的,共同特征包括至少两个终端位于预设的地理区域内。由于属于同一群组的终端用户之间具有更多的共性,相应的元学习器可以更有针对性地学习一种适用于该群组的机制,这样能 够训练得到更适合该群组中的终端的预测模型,以达到更好的预测效果。
第二方面,本发明实施例提供了一种预测方法,包括:
终端接收服务器发送的第一模型参数和第二模型参数,第一模型参数和第二模型参数适配于终端的预测模型;根据训练集和预测模型对第一模型参数进行更新,以获得更新后的第一模型参数,训练集包括多个第一样本数据,第一样本数据包括第一特征向量和与第一特征向量对应的第一样本标签;获取测试集,并根据采用更新后的第一模型参数和第二模型参数的预测模型计算测试集的第一预测损失,测试集包括多个第二样本数据,第二样本数据包括第二特征向量和与第二特征向量对应的第二样本标签;向服务器发送第一预测损失,以使服务器根据第一预测损失更新第一模型参数和第二模型参数。
在第二方面中,预测模型的训练可以在多个终端进行,这样终端无需将自身的数据上传至服务器,能够起到保护各个终端的用户隐私的作用,以及终端将计算获得的预测损失反馈至服务器,以使服务器根据大量终端反馈的数据,再次进行模型参数的更新,这样可以利用大量用户的信息来准确地更新模型参数。
在一种可选的实施例中,终端在执行根据训练集和预测模型对第一模型参数进行更新,以获得更新后的第一模型参数方面具体是执行:根据预测模型计算训练集的第二预测损失,预测模型采用第一模型参数和第二模型参数;根据第二预测损失和第二模型参数,按照参数更新规则对第一模型参数进行更新,以获得更新后的第一模型参数。
可选的,终端在执行根据预测模型计算训练集的第二预测损失方面具体是执行:根据预测模型计算多个第一样本数据中每个第一样本数据对应的预测损失;根据每个第一样本数据对应的预测损失,计算多个第一样本数据的第二预测损失。
可选的,终端在执行根据预测模型计算多个第一样本数据中每个第一样本数据对应的预测损失方面具体是执行:将每个第一样本数据的第一特征向量输入至预测模型中,以获取每个第一样本数据的第一特征向量与第一样本标签相对应的概率,其中,预测模型采用第一模型参数和第二模型参数;根据第一特征向量与第一样本标签相对应的概率,按照损失计算规则计算每个第一样本数据的预测损失。
可选的,终端在执行将每个第一样本数据的第一特征向量输入至预测模型中,以获取每个第一样本数据的第一特征向量与第一样本标签相对应的概率方面具体是执行:获取预测模型包括的多个参考样本标签,多个参考样本标签包括每个第一样本标签;将每个第一样本数据的第一特征向量输入至预测模型中,以获取第一特征向量与各个参考样本标签相对应的概率;将参考样本标签为第一样本标签对应的概率确定为第一特征向量与第一样本标签相对应的概率。
在一种可选的实施例中,终端在执行根据采用更新后的第一模型参数和第二模型参数的预测模型计算测试集的第一预测损失方面具体是执行:根据模型参数更新后的预测模型计算测试集包括的多个第二样本数据中每个第二样本数据对应的预测损失,模型参数更新后的预测模型采用更新后的第一模型参数和第二模型参数;根据每个第二样本数据对应的预测损失,计算测试集的第一预测损失。
可选的,终端在执行根据模型参数更新后的预测模型计算测试集包括的多个第二样本数据中每个第二样本数据对应的预测损失方面具体是执行:将每个第二样本数据的第二特征向量输入至模型参数更新后的预测模型中,以获取每个第二样本数据的第二特征向量与第二样本标签相对应的概率;根据第二特征向量与第二样本标签相对应的概率,按照损失计算规则 计算每个第二样本数据的预测损失。
可选的,终端在执行将每个第二样本数据的第二特征向量输入至模型参数更新后的预测模型中,以获取每个第二样本数据的第二特征向量与第二样本标签相对应的概率方面具体是执行:获取模型参数更新后的预测模型包括的多个参考样本标签,多个参考样本标签包括每个第二样本标签;将每个第二样本数据的第二特征向量输入至模型参数更新后的预测模型中,以获取第二特征向量与各个参考样本标签相对应的概率;将参考样本标签为第二样本标签对应的概率确定为第二特征向量与第二样本标签相对应的概率。
第三方面,本发明实施例提供了一种预测方法,包括:
终端接收服务器发送的第一模型参数和第二模型参数,第一模型参数和第二模型参数适配于终端的预测模型;根据训练集和预测模型对第一模型参数进行更新,以获得更新后的第一模型参数,训练集包括多个样本数据,每个样本数据包括特征向量和与特征向量对应的样本标签;将待预测的目标特征向量输入至采用更新后的第一模型参数和第二模型参数的预测模型中,获取与目标特征向量对应的目标样本标签。
在第三方面中,在终端接收到服务器发送的第一模型参数和第二模型参数之后,首先根据训练集和预测模型对第一模型参数进行更新,以获得更新后的第一模型参数,在待预测的目标特征向量输入至采用更新后的第一模型参数的预测模型中,获取与目标特征向量对应的目标样本标签。这样终端在预测阶段也能够体现该终端与其他终端的差异性,达到更为准确的预测效果。
在一种可选的实施例中,终端在执行根据训练集和预测模型对第一模型参数进行更新,以获得更新后的第一模型参数方面具体是执行:根据预测模型计算训练集的中间预测损失,预测模型采用第一模型参数和第二模型参数;终端根据中间预测损失和第二模型参数,按照参数更新规则对第一模型参数进行更新,以获得更新后的第一模型参数。其中,中间预测损失可以体现出根据第一训练集的真实结果和预测结果之间的偏差,通过这一偏差来更新第一模型参数,提高预测模型的准确性。
可选的,终端在执行根据预测模型计算训练集的中间预测损失方面具体是执行:终端根据预测模型计算多个样本数据中每个样本数据对应的预测损失;终端根据每个样本数据对应的预测损失,计算多个样本数据的中间预测损失。
可选的,终端在执行根据预测模型计算多个样本数据中每个样本数据的预测损失方面具体是执行:终端将每个样本数据的特征向量输入至预测模型中,以获取每个样本数据的特征向量与样本标签相对应的概率;根据特征向量与样本标签相对应的概率,按照损失计算规则计算每个样本数据的预测损失。
可选的,终端在执行将每个样本数据的特征向量输入至预测模型中,以获取每个样本数据的特征向量与样本标签相对应的概率方面具体是执行:终端获取预测模型包括的多个参考样本标签,多个参考样本标签包括每个样本标签;终端将每个样本数据的特征向量输入至预测模型中,以获取特征向量与各个参考样本标签相对应的概率;终端将参考样本标签为样本标签对应的概率确定为特征向量与样本标签相对应的概率。
在一种可选的实施例中,终端在执行将待预测的目标特征向量输入至采用更新后的第一模型参数和第二模型参数的预测模型中,获取与目标特征向量对应的目标样本标签方面具体是执行:终端获取模型参数更新后的预测模型包括的多个参考样本标签,模型参数更新后的预测模型采用更新后的第一模型参数和第二模型参数;终端将待预测的目标特征向量输入至 模型参数更新后的预测模型中,以获取待预测的目标特征向量与各个参考样本标签相对应的参考概率;终端将多个参考概率中参考概率的最大值对应的参考样本标签确定为目标样本标签。
第四方面,本发明实施例提供了一种服务器,包括:
发送模块,用于向多个终端发送第一模型参数和第二模型参数,第一模型参数和第二模型参数适配于终端的预测模型;
接收模块,用于接收多个终端中至少一个终端发送的第一预测损失,至少一个终端中每个终端发送的第一预测损失为每个终端根据采用第一模型参数和第二模型参数的预测模型计算的;
处理模块,用于根据至少一个终端发送的第一预测损失对第一模型参数进行更新,以获得更新后的第一模型参数,以及根据至少一个终端发送的第一预测损失对第二模型参数进行更新,以获得更新后的第二模型参数。
可选的,该服务器还可以实现第一方面的部分或全部的可选的实现方式。
第五方面,本发明实施例提供了一种服务器。该服务器包括:存储器,用于存储计算机可执行程序代码;收发器,以及处理器,处理器与存储器、收发器耦合。其中存储器所存储的程序代码包括指令,当处理器执行指令时,使服务器执行上述第一方面中服务器所执行的方法。
第五方面,本发明实施例提供了一种终端,包括:
接收模块,用于接收服务器发送的第一模型参数和第二模型参数,第一模型参数和第二模型参数适配于终端的预测模型;
处理模块,用于根据训练集和预测模型对第一模型参数进行更新,以获得更新后的第一模型参数,训练集包括多个第一样本数据,第一样本数据包括第一特征向量和与第一特征向量对应的第一样本标签;
处理模块,具体用于获取测试集,并根据采用更新后的第一模型参数的预测模型计算测试集的第一预测损失,测试集包括多个第二样本数据,第二样本数据包括第二特征向量和与第二特征向量对应的第二样本标签;
发送模块,用于向服务器发送第一预测损失,以使服务器根据第一预测损失更新第一模型参数和第二模型参数。
可选的,该终端还可以实现第二方面的部分或全部的可选的实现方式。
第六方面,本发明实施例提供了另一种终端,包括:
接收模块,用于接收服务器发送的第一模型参数和第二模型参数,第一模型参数和第二模型参数适配于终端的预测模型;
处理模块,用于根据训练集和预测模型对第一模型参数进行更新,以获得更新后的第一模型参数,训练集包括多个样本数据,每个样本数据包括特征向量和与特征向量对应的样本标签;
处理模块,还用于将待预测的目标特征向量输入至采用更新后的第一模型参数和第二模型参数的预测模型中,获取与目标特征向量对应的目标样本标签。
可选的,该终端还可以实现第三方面的部分或全部的可选的实现方式。
第七方面,本发明实施例提供了一种终端。该终端包括:存储器,用于存储计算机可执行程序代码;收发器,以及处理器,处理器与存储器、收发器耦合。其中存储器所存储的程 序代码包括指令,当处理器执行指令时,使终端执行上述第二方面或第三方面中终端所执行的方法。
第八方面,提供了一种计算机程序产品,计算机程序产品包括:计算机程序代码,当计算机程序代码在计算机上运行时,使得计算机执行上述第一方面至第三方面及其任意可能的实现方式中的方法。
第九方面,提供了一种计算机可读介质,计算机可读介质存储有程序代码,当计算机程序代码在计算机上运行时,使得计算机执行上述第一方面至第三方面及其任意可能的实现方式中的方法。
第十方面,提供了一种训练机器学习模型方法,该方法包括:终端接收服务器发送的所述服务器上的算法模型的第一参数和第二参数,所述第一参数用于作为所述终端的机器学习模型的初始参数,所述第二参数用于指示所述终端训练机器学习模型的方式;所述终端根据所述第一参数、所述第二参数以及训练集数据训练所述终端上的机器学习模型,所述训练集数据包括多个训练样本,每一训练样本包括第一特征向量及对应的第一标签,所述第一特征向量根据所述终端的历史数据中的用户信息构建;所述终端根据测试数据以及所述机器学习模型得到测试结果,并根据所述测试结果计算损失梯度;所述终端将所述损失梯度上传给所述服务器,所述损失梯度用于所述服务器更新所述第一参数和所述第二参数。
第十方面的一种可能的实现方式,所述根据所述测试结果计算损失梯度,包括:所述终端根据所述测试结果和所述测试数据对应的标签计算预测损失;所述终端根据所述预测损失计算所述损失梯度。
第十方面的一种可能的实现方式,所述测试数据包括多个测试样本数据,每一测试样本数据包括第二特征向量以及对应的第二标签,每一测试样本数据对应一个测试结果;
其中,所述终端根据所述测试结果和所述测试数据对应的标签计算预测损失,包括:所述终端根据所述多个测试样本数据各自对应的测试结果和第二标签,计算所述多个测试样本数据各自的预测损失;
所述终端根据所述预测损失计算所述损失梯度,包括:所述终端根据所述多个测试样本数据各自的预测损失,计算所述多个测试样本数据各自的损失梯度;所述终端对所述多个测试样本数据对应的多个损失梯度进行平均处理,得到目标损失梯度;
所述终端将所述损失梯度上传给所述服务器,包括:终端将所述目标损失梯度上传给所述服务器。
第十方面的一种可能的实现方式,所述测试数据包括多个测试样本数据,每一测试样本数据包括第二特征向量以及对应的第二标签,每一测试样本数据对应一个测试结果;
其中,所述终端根据所述测试结果和所述测试数据对应的标签计算预测损失,包括:所述终端根据所述多个测试样本数据各自对应的测试结果和第二标签,计算所述多个测试样本数据各自的预测损失;所述终端对所述多个测试样本数据对应的多个预测损失进行平均,得到平均预测损失;
所述终端根据所述预测损失计算所述损失梯度,包括:所述终端根据所述平均预测损失计算目标损失梯度;
所述终端将所述损失梯度上传给所述服务器,包括:终端将所述目标损失梯度上传给所述服务器。
第十方面的一种可能的实现方式,在所述终端根据所述多个测试样本数据各自对应的测 试结果和第二标签,计算所述多个测试样本数据各自的预测损失之后,还包括:所述终端确认所述多个测试样本数据各自的预测损失满足预设条件,所述预设条件用于指示相对上一次计算的平均预测损失波动值小于预设阈值,所述平均预测损失为所诉终端对已多个测试样本数据对应的多个预测损失进行平均得到的。进一步地,该方法还包括:若所述终端确认测试样本数据i的预测损失不满足所述预设条件,所述终端不再计算所述测试样本数据i的预测损失对应的损失梯度或不根据所述测试样本数据i的预测损失计算所述平均预测损失,所述测试样本数据i为所述多个测试样本数据中任一个。
第十方面的一种可能的实现方式,在终端接收服务器发送的所述服务器的算法模型的第一参数和第二参数之前,包括:所述终端将所述机器学习模型的结构标识发送给所述服务器,所述结构标识用于所述服务器根据所述结构标识确定所述机器学习模型对应的所述算法模型。
第十一方面,提供了一种预测方法,该方法包括:第一终端获取所述第一终端的用户信息,并根据所述用户信息生成目标特征向量;所述第一终端将所述目标特征向量输入目标预测模型,得到目标预测结果;其中,所述目标预测模型为所述第一终端根据第一参数、第二参数以及所述第一终端的历史数据训练得到的本地机器学习模型,所述第一参数和所述第二参数为服务器发送的所述服务器的算法模型的两个参数,所述第一参数用于作为所述第一终端的机器学习模型的初始参数,所述第二参数用于指示所述第一终端训练机器学习模型的方式,所述第一参数和所述第二参数为所述服务器根据多个终端反馈的多个损失梯度得到,任一损失梯度为对应终端基于本地历史数据计算得到。
第十一方面的一种可能的实现方式,在所述第一终端将所述目标特征向量输入目标预测模型,得到目标预测结果之前,包括:所述第一终端向所述服务器发送参数更新请求,所述参数更新请求用于请求所述服务器发送所述算法模型的最近一次更新的第一参数和第二参数;所述第一终端接收所述服务器发送的所述最近一次更新的第一参数和第二参数;所述第一终端根据所述最近一次更新的第一参数和第二参数以及所述第一终端的历史数据训练所述目标预测模型;
其中,所述第一终端将所述目标特征向量输入目标预测模型,得到目标预测结果,包括:所述第一终端将所述目标特征向量输入训练后的目标预测模型,得到目标预测结果。
可选的,所述参数更新请求包括:所述目标预测模型对应的机器学习模型的结构标识,所述结构标识用于所述服务器根据所述结构标识确定所述目标预测模型对应的所述算法模型。
第十一方面的一种可能的实现方式,在所述第一终端将所述目标特征向量输入目标预测模型,得到目标预测结果之后,还包括:所述第一终端向所述服务器上传预测结果打分,其中,所述预测结果打分为所述第一终端的用户对所述目标预测结果的打分,所述预测结果打分用于所述服务器确定加权系数,所述加权系数用于所述服务器处理所述多个终端上传的损失梯度得到加权损失梯度,所述加权损失梯度用于所述服务器更新所述第一参数和所述第二参数,所述多个终端包括所述第一终端。
第十二方面,提供了一种训练机器学习模型的方法,该方法包括:服务器向多个终端发送所述服务器的算法模型的第一参数和第二参数,所述第一参数用于作为所述多个终端中每一终端的机器学习模型的初始参数,所述第二参数用于指示所述多个终端中每一终端的训练机器学习模型的方式,所述多个终端的机器学习模型具有相同的结构,可选的,所述多个终端属于同一群组,所述同一群组用于指示具有相同或相似的属性特征,可选的,所述属性特征包括地理区域;在预设时间窗内,所述服务器接收所述多个终端中至少一个终端上传的损 失梯度;所述服务器根据所述至少一个终端上传的损失梯度更新所述第一参数和所述第二参数。
第十二方面的一种可能的实现方式,在所述服务器向多个终端发送第一参数和第二参数之前,包括:所述服务器初始化所述算法模型的所述第一参数和所述第二参数。
第十二方面的一种可能的实现方式,该方法还包括:所述服务器根据所述多个终端上传损失梯度的概率,重置所述预设时间窗。
第十二方面的一种可能的实现方式,该方法还包括:所述服务器接收所述至少一个终端上传的预测结果打分,所述预测结果打分为终端用户对机器学习模型的预测结果的打分;所述服务器根据所述预测结果打分,确定加权系数;
其中,所述服务器根据所述至少一个终端上传的损失梯度更新所述第一参数和所述第二参数,包括:所述服务器根据所述加权系数对所述至少一个终端上传的损失梯度进行加权平均处理,得到加权损失梯度;所述服务器根据所述加权损失梯度更新所述第一参数和所述第二参数。
第十二方面的一种可能的实现方式,在服务器向多个终端发送第一参数和第二参数之前,还包括:所述服务器接收所述多个终端上传的各自机器学习模型的结构标识,所述结构标识用于所述服务器确定与所述机器学习模型的结构对应的所述算法模型。
第十二方面的一种可能的实现方式,该方法还包括:所述服务器接收到第一终端发送的参数更新请求,所述参数更新请求用于请求所述服务器发送最近一次更新的第一参数和第二参数,所述第一终端为所述多个终端中的任一个终端;所述服务器向所述第一终端发送最近一次更新的第一参数和第二参数。
第十三方面,提供了一种终端设备,该设备包括:处理器、存储介质;所述存储介质用于存储可编程指令;所述处理器用于调用所述存储介质上存储的可编程指令执行第十方面或第十方面任一可能的实现方式描述的方法。
第十四方面,提供了一种终端设备,该设备包括:处理器、存储介质;所述存储介质用于存储可编程指令;所述处理器用于调用所述存储介质上存储的可编程指令执行第十一方面或第十一方面的任一可能的实现方式描述的方法。
第十五方面,提供了一种服务器,该服务器包括:处理器、存储介质;所述存储介质用于存储可编程指令;所述处理器用于调用所述存储介质上存储的可编程指令执行第十二方面或第十二方面的任一可能的实现方式描述的方法。
第十六方面,提供了一种计算机可读存储介质,包括指令,当其在计算机上运行时,使得所述计算机执行第十方面或第十方面任一可能的实现方式描述的方法。
第十七方面,提供了一种计算机可读存储介质,其特征在于,包括指令,当其在计算机上运行时,使得所述计算机执行第十一方面或第十一方面的任一可能的实现方式描述的方法。
第十八方面,提供了一种计算机可读存储介质,其特征在于,包括指令,当其在计算机上运行时,使得所述计算机执行第十二方面或第十二方面的任一可能的实现方式描述的方法。
采用本发明实施例提供的方法、装置,可以实现在不向服务器上传本地隐私数据的情况下,能够使得终端利用大量其他终端用户数据训练本地机器学习模型,同时实现机器学习模型的性能和个性化。
附图说明
为了更清楚地说明本发明实施例或背景技术中的技术方案,下面将对本发明实施例或背景技术中所需要使用的附图进行说明。
图1为本发明实施例提供了一种可能的预测系统架构图;
图2为本发明实施例提供了一种预测方法;
图3为本发明实施例提供了另一种预测方法;
图4提供了为用户推荐应用软件的预测系统的示例图;
图5为本发明实施例提供了一种预测方法的示例图;
图6是本发明实施例提供的一种终端的结构示意图;
图7是本发明实施例提供的一种终端的结构示意图。
图8是本发明实施例提供的一种终端的结构示意图;
图9是本发明实施例提供的一种服务器的结构示意图;
图10是本发明实施例提供的一种服务器的结构示意图;
图11是本发明实施例提供的一种训练机器学习模型方法的流程图;
图12是本发明实施例提供的一种预测方法的流程图。
具体实施方式
下面结合本发明实施例中的附图对本发明实施例进行描述。
实施例一,请参见图1,为本发明实施例提供了一种可能的预测系统架构图。如图1所示,该预测系统架构图包括服务器和终端。服务器和终端之间可以实现数据传输。需要说明的是,图1中仅仅表示了1个终端,但是这并不构成对本发明实施例的限定,本发明实施例不限定终端的数量。
基于图1的系统架构图中,服务器与终端结合起来实现预测模型的训练和使用。例如,终端可以利用各自的数据在本地进行预测模型的训练和预测,这样并不会将用户的隐私数据上传至服务器,也起到了保护用户隐私的作用。而且终端还可以将预测效果反馈至服务器,以使服务器根据多个终端反馈的预测损失更新模型参数,这样服务器也参考了多个终端的信息,起到了利用大量用户的信息来更新模型参数的作用。
在本发明实施例中,在终端接收到服务器发送的第一模型参数和第二模型参数之后,首先根据训练集和预测模型对第一模型参数进行更新,以获得更新后的第一模型参数,在待预测的目标特征向量输入至采用更新后的第一模型参数和第二模型参数的预测模型中,获取与所述目标特征向量对应的目标样本标签。这样能够体现该终端与其他终端的差异性,达到更为准确的预测效果。
在本发明实施例中的一种可选实现方案中,服务器采用元学习器来维护预测模型的模型参数,元学习是一种两层机器学习架构,会对所学习的结果进行“再学习”,试图对错误的分类进行纠正,而对正确的分类加以巩固。因此元学习器的精度较高,在本发明实施例中采用元学习器的模式来实现模型参数的更新。举例来说,在这一预测系统架构图中,服务器用于存储以及更新适配于预测模型的模型参数,而终端中存储有与该模型参数相对应的预测模型,终端的预测模型可以采用服务器中的模型参数进行预测模型的训练和预测。
需要说明的是,本发明实施例中所涉及的第一训练集或第二训练集是用于训练预测模型的标签数据集合,测试集是用来测试模型预测能力的标签数据集合。其中,标签数据是包含正确标签的数据。在本发明实施例中,样本数据的预测损失可以理解为:预测结果与真实结 果之间的偏差,这里的预测结果是指特征向量通过预测模型得到的预测样本标签,真实结果是该特征向量原本应该对应的样本标签。
本发明实施例中所涉及的终端可以是具备通信功能的设备,例如可以是手持终端设备、笔记本电脑、用户单元(subscriber unit)、蜂窝电话(cellular phone)、智能电话(smart phone)、无线数据卡、个人数字助理(personal digital assistant,PDA)电脑、平板型电脑、无线调制解调器(modem)、手持设备(handheld)、膝上型电脑(laptop computer)、无绳电话(cordless phone)或者无线本地环路(wireless local loop,WLL)台、机器类型通信(machine type communication,MTC)终端等,例如,终端设备还可以是便携式、袖珍式、手持式、计算机内置的或者车载的移动装置。本发明实施例中所涉及的服务器可以是具备处理和通信功能的后台服务设备。本发明实施例对终端和服务器均不做限定。
实施例二,请参见图2,为本发明实施例提供了一种预测方法。该方法是由终端执行的,如图2所示,该预测方法包括步骤201至步骤203,请参见以下具体介绍。
201,终端接收服务器发送的第一模型参数和第二模型参数。
其中,在本发明实施例中,所述第一模型参数和第二模型参数适配于所述终端的预测模型。预测模型会包含模型参数,在本发明实施例中服务器可以向终端发送模型参数,另外,在模型训练阶段或模型预测阶段均可以进行模型参数的更新,相应的预测模型也会更新为采用更新后的模型参数。
在本发明实施例中,服务器维护一个以(θ,α)为参数的元学习器,其中,θ为第一模型参数,α为第二模型参数。在这一步骤中第一模型参数用θ 1表示,第二模型参数用α 1表示。服务器将(θ 11)数值作为预测模型的模型参数分发给多个终端,这里接收模型参数的执行主体为所分发的多个终端中的任意一个终端。
举例来说,服务器中初始化元学习器参数为(θ,α),其中θ为预测模型的初始参数,θ为向量,θ包括的每一项分量用θ j表示,而每一项θ j可以以如下方式随机初始化:
Figure PCTCN2017120294-appb-000001
其中
Figure PCTCN2017120294-appb-000002
代表期望为0,方差为
Figure PCTCN2017120294-appb-000003
的正态分布。
α为向量,α的各分量与θ的各分量一一对应(是因为在后续举例会使用到的更新规则需要执行向量减法运算,因此这里如此设定),α包括的每一项分量用α j表示,以如下方式随机初始化:
α j~U(0,0.1) for each j
其中U(0,0.1)为区间[0,0.1]上的均匀分布。
需要说明的是,这里仅仅是对服务器中初始化元学习器参数的举例说明。另外,本发明实施例对第一模型参数、第二模型参数并不做限定。
202,终端根据训练集和所述预测模型对所述第一模型参数进行更新,以获得更新后的第一模型参数。
其中,所述训练集包括多个样本数据,每个样本数据包括特征向量和与所述特征向量对应的样本标签。为了体现各个终端的差异性,各个终端可以采用自身的数据作为样本数据。步骤202具体可以通过以下步骤A11和A12来实现。
A11、所述终端根据预测模型计算所述训练集的中间预测损失。
其中,这里的训练集包括多个样本数据,所述多个样本数据中每个样本数据包括样本标 签和与所述样本标签对应的特征向量。在第一模型参数更新之后,这里的预测模型所采用的模型参数与第一模型参数和第二模型参数,即(θ 11)。
第一种可选的方案中,终端先计算多个样本数据中每个样本数据的预测损失,再计算多个预测损失的平均值,以得到中间预测损失,例如:
Figure PCTCN2017120294-appb-000004
其中,
Figure PCTCN2017120294-appb-000005
表示根据预测模型确定的训练集的中间预测损失;训练集为S train(m),m表示训练集的第m个样本数据,训练集中样本数据的数量为M;l m1)表示第m个样本数据的预测损失。
或者,第二种可选的方案中,终端先计算多个样本数据中每个样本数据的预测损失,再获取每个样本数据对应的权重,计算多个预测损失的平均值,以得到中间预测损失。例如:
Figure PCTCN2017120294-appb-000006
其中,
Figure PCTCN2017120294-appb-000007
表示根据预测模型确定的中间预测损失;训练集为S train(m),m表示训练集的第m个样本数据,训练集中样本数据的数量为M;l m1)表示第m个样本数据的预测损失,λ m表示第m个样本数据所对应的权重。
可选的,每个样本数据对应的权重可以是终端按照样本数据的关联信息所确定的,例如,根据样本数据的生成时刻来确定,以预测模型用于为用户推荐应用软件为例进行说明,训练集是根据用户的历史使用记录生成的,样本数据的样本标签可以为应用软件W的名称,特征向量为根据使用该应用软件W的位置、时间、手机电量、网络信号强度等特征构成的,则终端可以按照历史使用记录距离当前时刻的时长由长到短进行排序,并将时长分类以及设定各类时长所相应的权重,如越靠近当前时刻的权重值较大。在本发明实施例中,由于样本数据与预测模型有关,因此对样本数据的关联信息不做限定。
A12、所述终端根据所述中间预测损失和第二模型参数,按照参数更新规则对所述第一模型参数进行更新,以获得更新后的第一模型参数。
其中,参数更新规则为预先设定的,也可以对该参数更新规则进行变更。本发明实施例对参数更新规则不做限定。
举例来说,以小样本学习算法为例,参数更新规则可以按照以下公式来实现:
Figure PCTCN2017120294-appb-000008
其中,θ 2表示更新后的第一模型参数;θ 1表示更新前的第一模型参数;α 1表示第二模型参数;
Figure PCTCN2017120294-appb-000009
表示由所述训练集S train计算得到的中间预测损失;
Figure PCTCN2017120294-appb-000010
表示梯度;
Figure PCTCN2017120294-appb-000011
表示向量的分量乘法运算。运用
Figure PCTCN2017120294-appb-000012
运算的举例为:
Figure PCTCN2017120294-appb-000013
由于
Figure PCTCN2017120294-appb-000014
包含θ 1变量,通过
Figure PCTCN2017120294-appb-000015
运算可以实现对
Figure PCTCN2017120294-appb-000016
进行θ 1求导,以获得针对θ 1而言,
Figure PCTCN2017120294-appb-000017
的变化率。按照以上更新公式可以获得更新后的第一模型参数θ 2
其中,该第二模型参数可以在服务器侧是通过学习得到的,在第二模型参数通过学习更加准确之后,进一步保证了所更新的第一模型参数的准确性。
针对步骤A11和步骤A12而言,在一种可能的方案中,终端可以按照预设的迭代次数, 执行步骤202。举例来说,迭代次数为100,即步骤202需要按照步骤A11和A12循环执行100次,具体如下:
θ′ i←θ 1  //用θ 1表示第一模型参数,θ′ i表示迭代之前的第一模型参数;
for t=1,2,…,T do//迭代T步来优化本地预测模型,例如T=100
Figure PCTCN2017120294-appb-000018
  //for循环中执行的第一个步骤,计算中间预测损失;
Figure PCTCN2017120294-appb-000019
表示根据θ′ i计算的训练集的中间预测损失;
Figure PCTCN2017120294-appb-000020
表示训练集中每个样本数据对应的预测损失。
Figure PCTCN2017120294-appb-000021
        //for循环中执行的第二个步骤,更新迭代中的第一模型参数;也就是说在下一次迭代的过程中,采用当前迭代所更新后的第一模型参数来执行。
这样通过多次迭代来使得更新后的第一模型参数更为准确。其中,这里采用预测迭代次数来实现第一模型参数多次更新,可选的方案中,可以确定相邻两次迭代中前一次中间预测损失和当前次中间预测损失之间的差距,若差距小于预设的阈值,则不再执行迭代,并采用当前次的中间预测损失计算的第一模型参数。又一可选的方案中,可以确定相邻两次迭代中前一次更新第一模型参数和当前次更新第一模型参数之间的差距,若差距小于预设的阈值,则不再执行迭代,并采用当前次的更新第一模型参数确定为更新后的第一模型参数。这里仅为举例说明,本发明实施例对步骤A11和步骤A12的迭代次数以及迭代停止的条件均不做限定。
进一步的,针对步骤A11中对每个样本数据对应的预测损失是如何计算的可以参见一下步骤B11和步骤B12的详细介绍。
B11、终端将所述每个样本数据的特征向量输入至预测模型中,以获取所述每个样本数据的所述特征向量与所述样本标签相对应的概率。
其中,由于步骤B11是在第一模型参数更新之前,因此这里的预测模型仍采用的是第一模型参数和第二模型参数。
具体实现中,预测模型包含多个参考样本标签,所述多个参考样本标签包括每个样本数据对应的样本标签。也就是说,由于训练集已经包括了与特征向量对应的样本标签,预测模型所包含的多个参考样本标签至少应该包含训练集所包含的样本标签,这样可以准确的对预测模型进行训练。
进一步的,在该预测模型中按照采用所述第一模型参数概率计算规则,可以计算得到所述特征向量与各个参考样本标签相对应的概率;并获取参考样本标签为所述样本标签所对应的概率。
举例来说,以预测模型用于为用户推荐应用软件为例进行说明,多个参考样本标签包括应用名称P1、P2、P8、P9、P10、P3、P4、P5、P6、P7;样本标签包括应用名称P1、P2、P3、P4、P5、P6;依次对应的特征向量为x1、x2、x3、x4、x5、x6;采用第一模型参数的概率计算规则为
Figure PCTCN2017120294-appb-000022
按照这一概率计算规则,输入值x为任意一个特征向量的情况下,会得到对应到多个参考样本标签概率值。
例如,
Figure PCTCN2017120294-appb-000023
为输入特征向量x3的结果,该结果中包含分别对应到P1、P2、P8、P9、P10、P3、P4、P5、P6、P7的概率值,由于特征向量x3与样本标签为P3,并在结果中查找到参考样本标签为P3的结果作为样本标签P3所对应的概率。
B12、终端根据所述特征向量与所述样本标签相对应的概率,按照损失计算规则计算所述每个样本数据的预测损失。
具体实现中,损失计算规则为
Figure PCTCN2017120294-appb-000024
其中,x为特征向量,k为与特征向量中相对应的样本标签在多个参考样本标签中是第k个,
Figure PCTCN2017120294-appb-000025
表示特征向量与所述样本标签相对应的概率;
Figure PCTCN2017120294-appb-000026
表示样本数据对应的预测损失。
为了更好理解,概率计算规则与第一模型参数的相关性,以下通过一个简单的线性模型进行举例(这里的线性模型只是举例,也可以是更复杂的模型,如深度神经网络)。假设输入特征向量为x∈R m,其中m为特征向量维度,预测模型的第一模型参数为θ 1,则该模型的输出
Figure PCTCN2017120294-appb-000027
定义为:
Figure PCTCN2017120294-appb-000028
其中,θ=(ω,b);即ω∈R K×m和b∈R K均是预测模型的第一模型参数;σ是Softmax函数,其定义为:
Figure PCTCN2017120294-appb-000029
for z∈R K,k=1,2,...,K
模型输出
Figure PCTCN2017120294-appb-000030
是一个概率分布,其中第k个分量
Figure PCTCN2017120294-appb-000031
代表该样本标签是第k个APP的概率。这里K是一共输出的APP数量。
203,终端将待预测的目标特征向量输入至采用所述更新后的第一模型参数和所述第二模型参数的预测模型中,获取与所述目标特征向量对应的目标样本标签。
具体实现中,在包含更新后的第一模型参数以及第二模型参数的预测模型进行预测时,终端将待预测的目标特征向量输入该更新后的预测模型中,通过上述的描述,由于预测模型包含多个参考样本标签,因此会得到目标特征向量与各个参考样本标签相对应的参考概率;终端将多个参考概率中参考概率的最大值对应的参考样本标签确定为目标样本标签。
举例来说,以预测模型用于为用户推荐应用软件为例进行说明,为了便于理解,请参见图4,为本发明实施例提供了为用户推荐应用软件的预测模型的示例图,如图4所示,训练集中包含4个应用的图标,预测集表示待预测的下一个推荐使用的应用的图标。其中,训练集中每个应用的图标还包含了每个应用对应的特征向量,特征向量为根据使用该应用软件W的位置、时间、手机电量、网络信号强度等特征构成的。当多个参考应用名称为20个时,而对目标特征向量的预测结果是这20个APP中对应
Figure PCTCN2017120294-appb-000032
值最大所对应的一个应用名称。
在本发明实施例中,在终端接收到服务器发送的第一模型参数和第二模型参数之后,首先根据训练集和预测模型对第一模型参数进行更新,以获得更新后的第一模型参数,在待预测的目标特征向量输入至采用更新后的第一模型参数和第二模型参数的预测模型中,获取与所述目标特征向量对应的目标样本标签。这样能够体现该终端与其他终端的差异性,达到更为准确的预测效果。
实施例三,基于图1所示的系统架构图,请参见图3,为本发明实施例提供了另一种预测方法。该方法是由两个或两个以上的终端和服务器共同执行的,这里只画出其中一个终端与服务器的交互过程,对于其他终端与服务器的交互过程可以参考这一终端的详细描述。如 图3所示,该预测方法包括步骤301至步骤309,请参见以下具体介绍。
301,服务器向多个终端发送第一模型参数和第二模型参数。
其中,在本发明实施例中,所述第一模型参数和第二模型参数适配于所述终端的预测模型。预测模型会包含模型参数,在本发明实施例中服务器可以向终端发送模型参数,另外,在模型训练阶段或模型预测阶段均可以进行模型参数的更新,相应的预测模型也会更新为采用更新后的模型参数。
在本发明实施例中,服务器维护一个以(θ,α)为参数的元学习器,其中,θ为第一模型参数,α为第二模型参数。在这一步骤中第一模型参数用θ 1表示,第二模型参数用α 1表示。服务器将(θ 11)数值作为预测模型的模型参数分发给多个终端,这里接收模型参数的执行主体为所分发的多个终端中的任意一个终端。
举例来说,服务器中初始化元学习器参数为(θ,α),其中θ为预测模型的初始参数,θ为向量,θ包括的每一项分量用θ j表示,而每一项θ j可以以如下方式随机初始化:
Figure PCTCN2017120294-appb-000033
其中
Figure PCTCN2017120294-appb-000034
代表期望为0,方差为
Figure PCTCN2017120294-appb-000035
的正态分布。
α为向量,α的各分量与θ的各分量一一对应(是因为在后续举例会使用到的更新规则需要执行向量减法运算,因此这里如此设定),α包括的每一项分量用α j表示,以如下方式随机初始化:
α j~U(0,0.1)for each j
其中U(0,0.1)为区间[0,0.1]上的均匀分布。
需要说明的是,这里仅仅是对服务器中初始化元学习器参数的举例说明。另外,本发明实施例对第一模型参数、第二模型参数并不做限定。
相应地,对于多个终端中的一个终端而言,各个终端中存储有基于同一类型的预测模型。例如,各个预测模型均是基于同一算法的预测模型,且用于实现用一个预测任务的预测模型。对应各个终端接收到的服务器发送的第一模型参数和第二模型参数是适配于每个终端的预测模型的。
302,终端根据第一训练集和预测模型对所述第一模型参数进行更新,以获得更新后的第一模型参数。
其中,由于在本发明实施例中还有另一个训练集,由于处于不同阶段,因此这里采用第一训练集和第二训练集进行区分。这里的第一训练集包括多个第一样本数据,所述第一样本数据包括第一特征向量和与所述第一特征向量对应的第一样本标签。
其中,步骤302具体是通过根据预测模型计算所述训练集的第二预测损失,所述预测模型采用第一模型参数和第二模型参数,即(θ 11);再根据所述第二预测损失和所述第二模型参数,按照参数更新规则对所述第一模型参数进行更新,以获得更新后的第一模型参数。具体实现可以参考图2所示实施例中步骤202的详细描述,两者的区别在于:步骤302中第二训练集,对应至步骤202中是训练集,步骤302中是第二预测损失,对应至步骤202中是中间预测损失,是因为图2所示的实施例是在采用预测模型进行预测的阶段,图3所示实施例中的步骤302是在各个终端通过自身的数据对预测模型进行训练的阶段。虽然所在的阶段不同,但实现方式是相同的,在此不再赘述。
303,所述终端获取测试集,并根据采用所述更新后的第一模型参数和第二模型参数的预 测模型计算所述测试集的第一预测损失。
其中,所述测试集包括多个第二样本数据,所述第二样本数据包括第二特征向量和与所述第二特征向量对应的第二样本标签。这里的预测模型已采用更新后的第一模型参数,设定更新后的第一模型参数为θ 3,则预测模型所采用的模型参数为(θ3,α1)。
其中,测试集包括多个第二样本数据,所述多个第二样本数据中每个第二样本数据包括第二样本标签和与所述第二样本标签对应的第二特征向量。
第一种可选的方案中,终端先计算多个第二样本数据中每个第二样本数据的预测损失,再计算多个预测损失的平均值,以得到第一预测损失,例如:
Figure PCTCN2017120294-appb-000036
其中,θ 3表示更新后的第一模型参数;
Figure PCTCN2017120294-appb-000037
表示终端i根据更新后的第一模型参数确定的第一预测损失;测试集为S test(n),n表示测试集的第n个第二样本数据,测试集中第二样本数据的数量为N;l n3)表示第n个第二样本数据的预测损失。
或者,第二种可选的方案中,终端先计算多个第二样本数据中每个第二样本数据的预测损失,再获取每个第二样本数据对应的权重,计算多个预测损失的平均值,以得到第一预测损失。例如
Figure PCTCN2017120294-appb-000038
其中,θ 3表示更新后的第一模型参数;
Figure PCTCN2017120294-appb-000039
表示终端i根据更新后的第一模型参数确定的第一预测损失;测试集为S test(n),n表示测试集的第n个第二样本数据,测试集中第二样本数据的数量为N;l n3)表示第n个第二样本数据的预测损失,λ n表示第n个第二样本数据所对应的权重。
可选的,每个第二样本数据对应的权重可以是终端按照第二样本数据的关联信息所确定的,例如,根据第二样本数据的生成时刻来确定,以预测模型用于为用户推荐应用软件为例进行说明,第二样本数据是根据用户的历史使用记录生成的,即,第二样本数据的第二样本标签可以为应用软件W的名称,特征向量为根据使用该应用软件W的位置、时间、手机电量、网络信号强度等特征构成的,则终端可以按照历史使用记录距离当前时刻的时长由长到短进行排序,并将时长分类以及设定各类时长所相应的权重,如越靠近当前时刻的权重值较大。在本发明实施例中,由于第二样本数据与预测模型有关,因此对第二样本数据的关联信息不做限定。
进一步的,针对步骤303中对每个第二样本数据对应的预测损失是如何计算的可以参见图2所示实施例中步骤B11和步骤B12的详细介绍,在此不再赘述。
304,所述终端向所述服务器发送所述第一预测损失。
其中,终端在通过步骤303确定第一预测损失之后,向服务器发送该第一预测损失,以使服务器根据该第一预测损失以及其他终端发送的第一预测损失进行预测模型的更新,以得到更新后的模型参数。
305,服务器接收所述多个终端中至少一个终端发送的第一预测损失。
其中,服务器接收多个终端中至少一个终端发送的第一预测损失。这里每个终端反馈的第一预测损失在数值上并一定是相同的,是因为在本发明实施例中每个终端发送的第一预测 损失是每个终端根据第一模型参数和第二模型参数计算的。
306,服务器根据所述至少一个终端发送的第一预测损失对所述第一模型参数进行更新,以获得更新后的第一模型参数,以及根据所述至少一个终端发送的第一预测损失对所述第二模型参数进行更新,以获得更新后的第二模型参数。
其中,服务器根据至少一个终端反馈的第一预测损失对第一模型参数和第二模型参数进行更新,具体实现过程可以参考以下步骤C11和C12的详细描述。
C11、服务器根据至少一个终端发送的第一预测损失,计算第二预测损失。可选的方案中,服务器将多个第一预测损失的平均值确定为第二预测损失。又一可选的方案中,服务器可以获取各个终端的第一预测损失对应的权要,通过加权平均的运算方式,得到第二预测损失。
举例来说,服务器按照如下方式计算第二预测损失。值得注意的是,这里的第二预测损失与步骤302中所涉及的第二预测损失是不一样的,由于步骤302中的第二预测损失是由终端来确定的,这里是由服务器来确定的,且两者的计算方式也是不同的。
Figure PCTCN2017120294-appb-000040
其中,Q表示至少一个终端的数量;
Figure PCTCN2017120294-appb-000041
表示终端i根据步骤304中的θ 3计算的第一预测损失;L 33)表示第二预测损失;
C12、服务器根据所述第二预测损失,按照参数更新规则对所述第一模型参数进行更新,以获得所述更新后的第一模型参数,以及按照所述参数更新规则对所述第二模型参数进行更新,以获得更新后的第二模型参数。
又一值得注意的是,这里的参数更新规则与步骤302中所涉及的参数更新规则是不同的。可选的,这里的参数更新规则可以为预先设定的,本发明实施例对参数更新规则不做限定。
举例来说,参数更新规则可以按照以下公式来实现:
其中,θ 1表示第一模型参数;θ 2表示更新后的第一模型参数;β表示第一预设权重;由于L 33)是根据接收的第一预测损失计算的,θ 3也是根据θ 1更新得到的,因此L 33)也可以转换为包含θ 1变量的项,即L 31),通过
Figure PCTCN2017120294-appb-000043
运算可以实现对L 31)进行θ 1求导,以获得针对θ 1而言,L 31)的变化率。按照以上更新公式可以获得更新后的第一模型参数θ 2
第二模型参数可以按照以下方式来学习或更新。具体是:服务器根据所述第一预测损失,按照参数更新规则对所述第二模型参数进行更新,以获得更新后的第二模型参数。
举例来说,所述参数更新规则为:
Figure PCTCN2017120294-appb-000044
其中,α 1表示第二模型参数;α 2表示更新后的第二模型参数;γ表示第二预设权重;L 311)表示由所述每个终端发送的第一预测损失计算得到的第二预测损失,L 33)是根据接收的第一预测损失计算的,θ 3也是根据θ 1更新得到的,而θ 3的更新过程也包含α 1,因此L 33)也可以转换为包含θ 1变量和α 1变量的项,即L 311);
Figure PCTCN2017120294-appb-000045
表示梯度。由于这里又增加了一个变量。
可选的,本发明实施例对β和γ不做限定,两者在数值上可以相同,也可以不同。
307,所述服务器向所述多个终端发送所述更新后的第一模型参数和所述更新后的第二模型参数。
其中,根据步骤306可以知道更新后的第一模型参数为θ 2,更新后的第二模型参数为α 2;因此在这一情况下,服务器所发送的适配于终端的预测模型的模型参数为(θ 22)。
相应地,终端接收服务器发送的更新后的第一模型参数和所述更新后的第二模型参数,以实现根据更新后的第一模型参数和所述更新后的第二模型参数进行预测。
308,所述终端根据第二训练集对所述第一模型参数进行更新,以获得更新后的第一模型参数。
309,所述终端将待预测的目标特征向量输入至采用所述更新后的第一模型参数和所述第二模型参数的预测模型中,获取与所述目标特征向量对应的目标样本标签。
其中步骤308和步骤309可以参考图2所示实施例中步骤202和步骤203的详细描述,在此不再赘述。需要说明的是,步骤308在第一模型参数更新之前,预测模型的模型参数为(θ 22);更新后的第一模型参数可以用θ 4表示,具体的更新过程在此不再赘述。
在一种可选的实施例中,本发明实施例中服务器向至少两个终端发送的预测模型的模型参数可以按一定规则进行,例如,至少两个终端为E个终端,服务器可以向E个终端定时集中分发;或者,在需要更新预测模型的元学习器的情况下向E个终端发送预测模型的模型参数;或者,将E个终端进行分为F类,分批次向这F类终端来发送预测模型的信息等。本发明实施例对服务器发送预测模型的模型参数所依照的规则不做限定。
在一种可选的实施例中,本发明实施例中,终端向服务器发送的预测损失也可以是按照一定规则进行,例如服务器向至少两个终端中的每个终端发送反馈预测损失的时间,各个终端反馈预测损失的时间可以是相同的,以实现集中获取;或者,各个终端反馈预测损失的时间也可以是不同的,也实现分批次获取。又如,终端可以根据自身的模型训练情况可以反馈预测损失,例如,在终端计算得到预测损失之后,在一定时长内向服务器反馈预测损失等。本发明实施例对终端反馈预测损失所依照的规则不做限定。
在本发明实施例中,预测模型的训练可以在各个终端进行,这样能够起到保护各个终端的用户隐私问题,以及终端将计算获得的预测损失反馈至服务器,以使服务器根据大量终端反馈的数据,再次进行模型参数的更新,这样可以利用大量用户的信息来准确地更新预测模型的参数。另外,服务器可以向终端发送适配于终端的预测模型的模型参数以使终端实现预测,而在终端接收到服务器发送的模型参数之后,首先根据训练集和预测模型对第一模型参数进行更新,以获得更新后的第一模型参数,在待预测的目标特征向量输入至更新为更新后的第一模型参数的预测模型中,获取与所述目标特征向量对应的目标样本标签。这样能够体现该终端与其他终端的差异性,达到更为准确的预测效果。
接下来,对本发明实施例可以应用的另一种场景进行介绍。请参见图5,为本发明实施例提供了一种预测方法的示例图。如图5所示,包括服务器和多个群组,其中每个群组中包含至少两个终端,例如群组1中包括终端11、终端12等等。在这一场景中,服务器可以将多个终端按照一定的规则进行分组,使得每个群组所包含的至少两个终端之间具备共同特征。举例来说,至少两个终端之间具备共同特征包括这些终端的所在位置在一定的地理区域之内、这些终端中有相似的与预测模型相关的信息。举例来说,对于为用户推荐应用软件的预测系统,与预测模型相关的信息可以包括终端中所下载的应用的类型、用户使用终端的时长、用 户使用习惯和用户年龄段等。可选的,对于考虑到保护用户隐私信息的情况,可以按照终端的标识来进行分组,这里的终端标识可以包括硬件标识、网络之间互连的协议(Internet Protocol,IP)等。本发明实施例对此不做限定。
在图5所示的场景中,服务器可以每个群组进行单独管理,即一个群组对应一个预测模型,例如,对群组1中的终端11、终端12等执行图3所示实施例中的步骤,且在这一过程中并不会参考其他群组的终端所反馈的信息。由于属于同一群组的终端用户之间具有更多的共性,相应的元学习器可以更有针对性地学习一种适用于该群组的机制,这样能够训练得到更适合该群组中的终端的预测模型,以达到更好的预测效果。
实施例四,请参见图6,图6是本申请实施例提供的一种终端的结构示意图。在图6中包含终端600包括:
接收模块601,用于接收所述服务器发送的第一模型参数和第二模型参数,所述第一模型参数和所述第二模型参数适配于所述终端的预测模型;
处理模块602,用于根据训练集和所述预测模型对所述第一模型参数进行更新,以获得更新后的第一模型参数,所述训练集包括多个第一样本数据,所述第一样本数据包括第一特征向量和与所述第一特征向量对应的第一样本标签;
所述处理模块602,具体用于获取测试集,并根据采用所述更新后的第一模型参数的预测模型计算所述测试集的第一预测损失,所述测试集包括多个第二样本数据,所述第二样本数据包括第二特征向量和与所述第二特征向量对应的第二样本标签;
发送模块603,用于向所述服务器发送所述第一预测损失,以使服务器根据所述第一预测损失更新所述第一模型参数和所述第二模型参数;
其中,所述终端包括用于预测的预测模型;所述终端包括的预测模型与所述服务器的预测模型是同一类型的预测模型。
在一个可选的实施例中,所述处理模块602在执行根据训练集和所述预测模型对所述第一模型参数进行更新,以获得更新后的第一模型参数方面,具体是执行:
根据所述预测模型计算所述训练集的第二预测损失,所述预测模型采用所述第一模型参数和所述第二模型参数;
根据所述第二预测损失和所述第二模型参数,按照参数更新规则对所述第一模型参数进行更新,以获得更新后的第一模型参数。
在一个可选的实施例中,所述处理模块602在执行根据所述预测模型计算所述训练集的第二预测损失方面,具体是执行:
根据所述预测模型计算所述多个第一样本数据中每个第一样本数据对应的预测损失;
根据所述每个第一样本数据对应的预测损失,计算所述多个第一样本数据的第二预测损失。
在一个可选的实施例中,所述处理模块602在执行根据所述预测模型计算所述多个第一样本数据中每个第一样本数据的预测损失方面,具体是执行:
将所述每个第一样本数据的第一特征向量输入至预测模型中,以获取所述每个第一样本数据的所述第一特征向量与所述第一样本标签相对应的概率;
根据所述第一特征向量与所述第一样本标签相对应的概率,按照损失计算规则计算所述每个第一样本数据的预测损失。
在一个可选的实施例中,所述处理模块602在执行将所述每个第一样本数据的第一特征向量输入至预测模型中,以获取所述每个第一样本数据的所述第一特征向量与所述第一样本标签相对应的概率方面,具体是执行:
获取所述预测模型包括的多个参考样本标签,所述多个参考样本标签包括所述每个第一样本标签;
将所述每个第一样本数据的第一特征向量输入至所述预测模型中,以获取所述第一特征向量与各个参考样本标签相对应的概率;
将参考样本标签为所述第一样本标签对应的概率确定为所述第一特征向量与所述第一样本标签相对应的概率。
在一个可选的实施例中,所述处理模块602在执行根据采用所述更新后的第一模型参数和所述第二模型参数的预测模型计算所述测试集的第一预测损失方面,具体是执行:
根据模型参数更新后的预测模型计算所述测试集包括的多个第二样本数据中每个第二样本数据对应的预测损失,所述模型参数更新后的预测模型采用更新后的第一模型参数和所述第二模型参数;
根据所述每个第二样本数据对应的预测损失,计算所述测试集的第一预测损失。
在一个可选的实施例中,所述处理模块602在执行根据模型参数更新后的预测模型计算所述测试集包括的多个第二样本数据中每个第二样本数据对应的预测损失方面,具体是执行:
将所述每个第二样本数据的第二特征向量输入至所述模型参数更新后的预测模型中,以获取所述每个第二样本数据的所述第二特征向量与所述第二样本标签相对应的概率;
根据所述第二特征向量与所述第二样本标签相对应的概率,按照损失计算规则计算所述每个第二样本数据的预测损失。
在一个可选的实施例中,所述处理模块602在执行将所述每个第二样本数据的第二特征向量输入至所述模型参数更新后的预测模型中,以获取所述每个第二样本数据的所述第二特征向量与所述第二样本标签相对应的概率方面,具体是执行:
获取所述模型参数更新后的预测模型包括的多个参考样本标签,所述多个参考样本标签包括所述每个第二样本标签;
将所述每个第二样本数据的第二特征向量输入至模型参数更新后的预测模型中,以获取所述第二特征向量与各个参考样本标签相对应的概率;
将参考样本标签为所述第二样本标签对应的概率确定为所述第二特征向量与所述第二样本标签相对应的概率。
可以理解的,这一可行的方案下终端所包括的功能块的具体实现方式及相应的有益效果,可参考前述图2至图5所示实施例的具体介绍,这里不赘述。
请参见图7,图7是本申请实施例提供的一种终端的结构示意图。在图7中包含终端700包括:
接收模块701,用于接收服务器发送的第一模型参数和第二模型参数,所述第一模型参数和所述第二模型参数适配于所述终端的预测模型;
处理模块702,用于根据训练集和所述预测模型对所述第一模型参数进行更新,以获得更新后的第一模型参数,所述训练集包括多个样本数据,每个样本数据包括特征向量和与所述特征向量对应的样本标签;
所述处理模块702,还用于将待预测的目标特征向量输入至采用所述更新后的第一模型参数和所述第二模型参数的预测模型中,获取与所述目标特征向量对应的目标样本标签;
其中,所述终端包括的预测模型与所述服务器的预测模型是同一类型的预测模型。
在一个可选的实施例中,所述处理模块702在执行根据训练集和所述预测模型对所述第一模型参数进行更新,以获得更新后的第一模型参数方面,具体是执行:
根据所述预测模型计算所述训练集的中间预测损失,所述预测模型采用所述第一模型参数和所述第二模型参数;
根据所述中间预测损失和所述第二模型参数,按照参数更新规则对所述第一模型参数进行更新,以获得更新后的第一模型参数。
在一个可选的实施例中,所述处理模块702在执行根据所述预测模型计算所述训练集的中间预测损失方面,具体是执行:
根据所述预测模型计算所述多个样本数据中每个样本数据对应的预测损失;
根据所述每个样本数据对应的预测损失,计算所述多个样本数据的中间预测损失。
在一个可选的实施例中,所述处理模块702在执行根据所述预测模型计算所述多个样本数据中每个样本数据的预测损失方面,具体是执行:
将所述每个样本数据的特征向量输入至预测模型中,以获取所述每个样本数据的所述特征向量与所述样本标签相对应的概率,其中,所述预测模型采用所述第一模型参数和所述第二模型参数;
根据所述特征向量与所述样本标签相对应的概率,按照损失计算规则计算所述每个样本数据的预测损失。
在一个可选的实施例中,所述处理模块702在执行终端将所述每个样本数据的特征向量输入至所述预测模型中,以获取所述每个样本数据的所述特征向量与所述样本标签相对应的概率方面,具体是执行:
获取所述预测模型包括的多个参考样本标签,所述多个参考样本标签包括所述每个样本标签,其中,所述预测模型采用所述第一模型参数和所述第二模型参数;
将所述每个样本数据的特征向量输入至所述预测模型中,以获取所述特征向量与各个参考样本标签相对应的概率;
所述终端将参考样本标签为所述样本标签对应的概率确定为所述特征向量与所述样本标签相对应的概率。
在一个可选的实施例中,所述处理模块702在执行将待预测的目标特征向量输入至采用所述更新后的第一模型参数和所述第二模型参数的预测模型中,获取与所述目标特征向量对应的目标样本标签,具体是执行:
获取模型参数更新后的预测模型包括的多个参考样本标签,所述模型参数更新后的预测模型采用所述更新后的第一模型参数和所述第二模型参数;
将待预测的目标特征向量输入至模型参数更新后的预测模型中,以获取所述待预测的目标特征向量与各个参考样本标签相对应的参考概率;
将多个参考概率中参考概率的最大值对应的参考样本标签确定为目标样本标签。
可以理解的,这一可行的方案下终端所包括的功能块的具体实现方式及相应的有益效果,可参考前述图2至图5所示实施例的具体介绍,这里不赘述。
上述图6、图7所示实施例中的终端可以以图8所示的终端800实现。如图8所示,为 本发明实施例提供了另一种终端的结构示意图,图8所示的终端800包括:处理器801和收发器802,所述收发器802用于支持终端800与上述实施例中涉及的服务器之间的信息传输,例如实现图6所示实施例中接收模块601和发送模块603的功能,或者,例如实现图7所示实施例中接收模块701的功能。处理器801和收发器802通信连接,例如通过总线相连。所述终端800还可以包括存储器803。存储器803用于存储供终端800执行的程序代码和数据,处理器801用于执行存储器803中存储的应用程序代码,以实现图2或图5所示任一实施例提供的终端的动作。
需要说明的是,实际应用中终端可以包括一个或者多个处理器,该终端800的结构并不构成对本申请实施例的限定。
处理器801可以是中央处理器(central processing unit,CPU),网络处理器(network processor,NP),硬件芯片或者其任意组合。上述硬件芯片可以是专用集成电路(application-specific integrated circuit,ASIC),可编程逻辑器件(programmable logic device,PLD)或其组合。上述PLD可以是复杂可编程逻辑器件(complex programmable logic device,CPLD),现场可编程逻辑门阵列(field-programmable gate array,FPGA),通用阵列逻辑(generic array logic,GAL)或其任意组合。
存储器803可以包括易失性存储器(volatile memory),例如随机存取存储器(random access memory,RAM);存储器803也可以包括非易失性存储器(non-volatile memory),例如只读存储器(read-only memory,ROM),快闪存储器(flash memory),硬盘(hard disk drive,HDD)或固态硬盘(solid-state drive,SSD);存储器803还可以包括上述种类的存储器的组合。
在本发明实施例中还提供了一种计算机存储介质,可以用于存储图8所示实施例中所述终端所用的计算机软件指令,其包含用于执行上述实施例中为终端所设计的程序。该存储介质包括但不限于快闪存储器、硬盘、固态硬盘。
在本发明实施例中还提供了一种计算机程序产品,该计算机产品被计算设备运行时,可以执行上述图8实施例中为终端所设计的预测方法。
实施例五,请参见图9,图9是本申请实施例提供的一种服务器的结构示意图。图9所示的服务器900包括:
发送模块901,用于向多个终端发送第一模型参数和第二模型参数,所述第一模型参数和所述第二模型参数适配于所述终端的预测模型;
接收模块902,用于接收所述多个终端中至少一个终端发送的第一预测损失,所述至少一个终端中每个终端发送的第一预测损失为所述每个终端根据采用所述第一模型参数和所述第二模型参数的预测模型计算的;
处理模块903,用于根据所述至少一个终端发送的第一预测损失对所述第一模型参数进行更新,以获得更新后的第一模型参数,以及根据所述至少一个终端发送的第一预测损失对所述第二模型参数进行更新,以获得更新后的第二模型参数;
其中,所述终端包括用于预测的预测模型;所述终端包括的预测模型与所述服务器的预测模型是同一类型的预测模型。
在一个可选的实施例中,所述处理模块903在执行根据所述至少一个终端发送的第一预测损失对所述第一模型参数进行更新,以获得更新后的第一模型参数,以及根据所述至少一 个终端发送的第一预测损失对所述第二模型参数进行更新,以获得更新后的第二模型参数方面,具体是执行:
所述服务器根据所述至少一个终端发送的第一预测损失,计算第二预测损失;
所述服务器根据所述第二预测损失,按照参数更新规则对所述第一模型参数进行更新,以获得所述更新后的第一模型参数,以及按照所述参数更新规则对所述第二模型参数进行更新,以获得更新后的第二模型参数。
在一个可选的实施例中,所述发送模块901,还用于向所述多个终端发送所述更新后的第一模型参数和所述更新后的第二模型参数,以使所述多个终端中的任一终端根据采用所述更新后的第一模型参数和所述更新后的第二模型参数的预测模型进行预测。
在一个可选的实施例中,所述多个终端属于同一群组;同一群组的终端具备共同特征。
在一个可选的实施例中,所述共同特征包括所述至少两个终端位于预设的地理区域内。
可以理解的,关于图9的服务器包括的功能块的具体实现方式及相应的有益效果,可参考前述图3至图5的实施例的具体介绍,这里不赘述。
上述图9所示的服务器可以以图10所示的服务器1000实现。如图10所示,为本发明实施例提供了另一种服务器的结构示意图,图10所示的服务器1000包括:处理器1001和收发器1002,所述收发器1002用于支持服务器1000与上述实施例中涉及的终端之间的信息传输,例如实现图9所示实施例中发送模块901和接收模块902的功能。处理器1001和收发器1002通信连接,例如通过总线相连。所述服务器1000还可以包括存储器1003。存储器1003用于存储供服务器1000执行的程序代码和数据,处理器1001用于执行存储器1003中存储的应用程序代码,以实现图3至图5所示任一实施例提供的服务器的动作。
需要说明的是,实际应用中服务器可以包括一个或者多个处理器,该服务器1000的结构并不构成对本申请实施例的限定。
处理器1001可以是CPU,NP,硬件芯片或者其任意组合。上述硬件芯片可以是ASIC,PLD或其组合。上述PLD可以是CPLD,FPGA,GAL或其任意组合。
存储器1003可以包括易失性存储器,例如RAM;存储器1003也可以包括非易失性存储器,例如ROM,快闪存储器,硬盘或固态硬盘;存储器1003还可以包括上述种类的存储器的组合。
在本发明实施例中还提供了一种计算机存储介质,可以用于存储图9所示实施例中所述服务器所用的计算机软件指令,其包含用于执行上述实施例中为服务器所设计的程序。该存储介质包括但不限于快闪存储器、硬盘、固态硬盘。
在本发明实施例中还提供了一种计算机程序产品,该计算机产品被计算设备运行时,可以执行上述图9所示实施例中为服务器所设计的预测方法。
实施例六,与上面实施例三都在小样本联合学习框架下,两者的主要区别是:实施例三中终端向服务器上传预测损失,而本发明实施例中的终端向服务器上传损失梯度,简单来说根据预测损失计算损失梯度的步骤一个在终端执行(实施例六),一个在服务器执行(实施例三)。本发明实施例提供了一种训练机器学习模型的方法,在该实施例中,以第一终端与服务器交互为例,第一终端是与服务器建立连接的多个终端中的任一个,如图11所示,该方法包括:
S1,服务器将其维护的算法模型的第一参数和第二参数发送给包含第一终端在内的多个 终端,第一参数用于作为多个终端中每一终端的机器学习模型的初始参数,第二参数用于指示多个终端中每一终端的训练机器学习模型的方式,多个终端的机器学习模型具有相同的结构;可选的,在服务器向多个终端发送所述服务器的算法模型的第一参数和第二参数之前,服务器初始化算法模型的第一参数和第二参数,具体如何初始化可以参见实施例三中举例部分的描述。可选的,上述多个终端属于同一群组,同一群组用于指示具有相同或相似的属性特征;可选的,属性特征包括地理区域。也就说,服务器可以为某一地理范围内的终端维护一个共同的算法模型。
S2,第一终端接收服务器发送的算法模型的第一参数和第二参数,第一终端是S1中多个终端中的一个;
S3,第一终端根据接收到的第一参数、第二参数以及训练集数据训练待训练的机器学习模型,其中,训练集数据包括多个训练样本,每一训练样本包括第一特征向量及对应的第一标签,第一特征向量根据终端的历史数据中的用户信息构建;
S4,第一终端根据测试数据以及机器学习模型得到测试结果;
关于训练集数据和测试数据的确定,可以通过下面方式选取:假设终端用户共有M条历史记录,按时间顺序排列,设
Figure PCTCN2017120294-appb-000046
Figure PCTCN2017120294-appb-000047
取前M 1条历史记录作为训练集
Figure PCTCN2017120294-appb-000048
在后M 2条历史记录中随机选取Q条历史记录作为测试集
Figure PCTCN2017120294-appb-000049
其中1≤Q≤M 2;M 2=0,则不参加小样本训练和预测反馈,即不执行S3-S6;M 2≥1,当Q=1时,计算唯一测试样本的预测损失梯度,将梯度作为预测反馈上传至服务器;当Q>1时,为减少传输数据量,将Q个测试样本的预测损失进行统计处理之后再上传至服务器,统计操作可包含多种方式,如取均值后再计算梯度,将梯度上传至服务器。需要需注意的是,最终第一终端是否上传损失梯度,还需要满足下面将描述的预设条件。
S5,第一终端根据测试结果计算损失梯度;
S6,第一终端将计算得到的损失梯度上传给服务器,损失梯度用于服务器更新算法模型的第一参数和第二参数。
本发明实施例中步骤S3-S6对应实施例三中步骤302-304,主要区别在于本发明实施例是计算损失梯度并将损失梯度发送给服务器,而实施例三是计算预测损失并将预测损失发送给服务器,本发明实施例用损失梯度代替预测损失,可以减少上传数据大小。
S7,在预设时间窗内,服务器接收第一终端和多个终端中其他至少一个终端上传的损失梯度;可选的,服务器根据多个终端上传损失梯度的概率,重置所述预设时间窗,这里,多个个终端可以包括第一终端,也可以不包括第一终端。除了以预设时间窗为服务器接收中止条件,还可以已发送预测反馈(损失梯度)的终端数已达到数量阈值N 0为中止条件;数量阈值可以通过下面方法计算:假设服务器发送的终端为1,2,…,N,对终端i定义p i为历史上终端i向服务器发送的预测反馈次数和服务器向终端i发送的请求次数之间的比值(即p i是对终端i发送预测反馈的概率的估计),数量阈值定义为发送预测反馈的终端数的期望,即
Figure PCTCN2017120294-appb-000050
S8,服务器根据接收到的所有损失梯度更新第一参数和第二参数。
一个示例:如实施例三,以服务器维护以(θ,α)为参数的元学习器为例,可以理解的是:元学习器是算法模型的一种具体示例,假设反馈预测损失梯度的终端为1,2,…,N′,其中终端i返回的是预测损失梯度
Figure PCTCN2017120294-appb-000051
则以如下方式更新(θ,α):
Figure PCTCN2017120294-appb-000052
其中
Figure PCTCN2017120294-appb-000053
代表梯度;标量β是一个固定的超参数,代表更新元学习器时的学习率。
进一步地,S5第一终端根据测试结果计算损失梯度,具体包括:
S5.1,第一终端根据测试结果和测试数据对应的标签计算预测损失;
S5.2,第一终端根据预测损失计算损失梯度。
可选的,上述的测试数据包括多个测试样本数据,每一测试样本数据包括第二特征向量以及对应的第二标签,每一测试样本数据对应一个测试结果;
对应地,S5.1第一终端根据测试结果和测试数据对应的标签计算预测损失,具体包括:第一终端根据多个测试样本数据各自对应的测试结果和第二标签,计算该多个测试样本数据各自的预测损失;
S5.2第一终端根据预测损失计算所述损失梯度,具体包括:第一终端根据多个测试样本数据各自的预测损失,计算该多个测试样本数据各自的损失梯度;第一终端对上述计算的多个损失梯度进行平均处理,得到目标损失梯度;
S6第一终端将损失梯度上传给所述服务器,具体包括:第一终端将经过处理得到的目标损失梯度上传给服务器。
可选的,上述的测试数据包括多个测试样本数据,每一测试样本数据包括第二特征向量以及对应的第二标签,每一测试样本数据对应一个测试结果;
对应地,S5.1第一终端根据测试结果和测试数据对应的标签计算预测损失,具体包括:第一终端根据多个测试样本数据各自对应的测试结果和第二标签,计算该多个测试样本数据各自的预测损失;第一终端对多个测试样本数据对应的多个预测损失进行平均,得到平均预测损失;
S5.2第一终端根据预测损失计算损失梯度,具体包括:第一终端根据上述计算的平均预测损失计算目标损失梯度;
S6第一终端将所述损失梯度上传给所述服务器,具体包括:终端将根据平均预测算计算的目标损失梯度上传给服务器。
需要注意的,上面两个可选的实施例之外,本发明实施例针对测试数据包括多个测试样本数据的情况,可以计算每一测试样本的梯度损失,并均上传给服务器;或者,计算每一测试样本的预测损失,并上传给服务器,具体可以参见图2-5所对应的实施例中相关描述。
进一步地,在第一终端根据多个测试样本数据各自对应的测试结果和第二标签,计算该多个测试样本数据各自的预测损失之后,还包括:
第一终端确认多个测试样本数据各自的预测损失满足预设条件,预设条件用于指示相对上一次计算的平均预测损失波动值小于预设阈值。可选的,是否满足预设条件的判定是:假设历史上第一终端i已发送的S i次预测反馈对应的预测损失分别为
Figure PCTCN2017120294-appb-000054
计算它们的均值
Figure PCTCN2017120294-appb-000055
和标准差
Figure PCTCN2017120294-appb-000056
如果L i∈[μ-3σ,μ+3σ],则预测正常;否则预测异常;[μ-3σ,μ+3σ]相当于预设条件。
可选的,如果第一终端确认测试样本数据i的预测损失不满足所述预设条件,第一终端不再计算测试样本数据i的预测损失对应的损失梯度或不根据测试样本数据i的预测损失计算平均预测损失,测试样本数据i为该多个测试样本数据中任一个。
可选的,在S2第一终端接收服务器发送的算法模型的第一参数和第二参数之前,还包括:
S9,第一终端将机器学习模型的结构标识发送给服务器,结构标识用于服务器根据结构标识确定与机器学习模型对应的算法模型。尤其在多任务并行的情况下,可以通过标识确定所需要的算法模型参数。例如,第一终端上有分类机器学习模型和应用推荐机器学习模型,两个模型若是具有不同的模型结构,在需要训练分类机器学习模型时,可以上传该分类机器学习模型对应的标识,告知服务器所需要的算法模型的参数;同样,若是应用推荐机器学习模型,在需要训练应用推荐机器学习模型时,可以上传应用推荐机器学习模型对应的标识,告知服务器所需要的算法模型的参数;在第一终端计算能力允许的情况,即使第一终端需要同时训练分类机器学习模型和应用推荐机器学习模型两个模型,可以通过结构标识获取服务器上算法模型的参数,实现多任务同时进行。结构标识、机器学习模型、算法模型的关系可以是预先配置的,也可以是在获取之前通信协商的,具体对应关系部作任何限制。
对应的,在S1服务器向包含第一终端在内的多个终端发送第一参数和第二参数之前,该方法还包括:S10,所述服务器接收所述多个终端上传的各自机器学习模型的结构标识,所述结构标识用于所述服务器确定与所述机器学习模型的结构对应的所述算法模型。
可选的,该方法还包括:S11,服务器接收至少一个终端上传的预测结果打分,预测结果打分为终端用户对机器学习模型的预测结果的打分;S12服务器根据预测结果打分,确定加权系数;这里,至少一个终端可以包括第一终端,也可以不包括第一终端。
对应的,S8服务器根据至少一个终端上传的损失梯度更新第一参数和第二参数,具体包括:服务器根据加权系数对至少一个终端上传的损失梯度进行加权平均处理,得到加权损失梯度;服务器根据加权损失梯度更新第一参数和第二参数。例如,如实施例三,以服务器维护以(θ,α)为参数的元学习器为例,服务器接收到N′个终端发送的预测损失梯度
Figure PCTCN2017120294-appb-000057
则将所有梯度计算平均值
Figure PCTCN2017120294-appb-000058
用该平均值更新元学习器参数。
可选的,该方法还包括:S13,服务器接收到第一终端发送的参数更新请求,参数更新请求用于请求服务器发送最近一次更新的第一参数和第二参数,第一终端为所述多个终端中的任一个终端;
服务器向所述第一终端发送最近一次更新的第一参数和第二参数。
需要说明的,上面实施例中服务器所执行的方法可以由图9或图10所示服务器实现,上面实施例中第一终端所执行的方法可以由图6或图8所示终端实现,具体描述可以参见上面图所对应的实施例,此处不再赘述。
如实施例三,以推荐下一个APP为例,采用Meta-SGD作为小样本学习算法模型。为了避免冗余,前面各实施例已描述内容,可能不在本发明实施例中赘述,具体可以参见前面各实施例。
服务器:如实施例三,服务器维护(θ,α)为参数的元学习器,本发明实施例中服务器执行的步骤与实施例三中服务器执行的步骤区别是:本发明实施例中,服务器从各终端接收的损失梯度(预测损失梯度)
Figure PCTCN2017120294-appb-000059
这里
Figure PCTCN2017120294-appb-000060
是关于(θ,α)的函数;假设返回预测反馈的终端为1,2,…,N′,其中终端i返回的是预测损失梯度
Figure PCTCN2017120294-appb-000061
则以如下方式更新(θ,α):
Figure PCTCN2017120294-appb-000062
其中
Figure PCTCN2017120294-appb-000063
代表梯度;标量β是一个固定的超参数,代表更新元学习器时的学习率。
终端侧:本发明实施例中,终端执行以下步骤:
维护一个计数器S i,记录当前终端i已发送预测反馈(损失梯度)的次数。如果是第一次进行小样本训练,则初始化S i←0。
假设终端用户共有M条历史记录,按时间顺序排列,设
Figure PCTCN2017120294-appb-000064
Figure PCTCN2017120294-appb-000065
取前M 1条历史记录作为训练集
Figure PCTCN2017120294-appb-000066
在后M 2条历史记录中随机选取Q条历史记录作为测试集
Figure PCTCN2017120294-appb-000067
其中1≤Q≤M 2
终端接收服务发送的参数(θ,α),第一参数对应θ,第二参数对应α;对参数为θ的推荐模型,定义它在样本(x,k)上(其中x为特征向量,k代表该样本标签为第k个APP)的损失函数为
Figure PCTCN2017120294-appb-000068
以如下方式训练推荐模型(//后的内容为注释):
θ′ i←θ//用θ初始化本地预测模型
for t=1,2,…,T do//迭代T步来优化本地预测模型,例如T=100
Figure PCTCN2017120294-appb-000069
//计算训练集损失
Figure PCTCN2017120294-appb-000070
//更新预测模型参数,这里“
Figure PCTCN2017120294-appb-000071
”是向量的分量乘法运算,例如
Figure PCTCN2017120294-appb-000072
计算θ′ i在测试集上的预测损失:
Figure PCTCN2017120294-appb-000073
如果预测结果没有出现异常,则将预测损失
Figure PCTCN2017120294-appb-000074
的梯度
Figure PCTCN2017120294-appb-000075
上传至服务器,并更新计数器S i←S i+1;如果出现异常,则不上传预测反馈,不更新计数器。异常的判定条件:
假设历史上终端i已发送的S i次预测反馈对应的预测损失分别为
Figure PCTCN2017120294-appb-000076
计算它们的均值
Figure PCTCN2017120294-appb-000077
和标准差
Figure PCTCN2017120294-appb-000078
如果L i∈[μ-3σ,μ+3σ],则预测正常;否则预测异常。
实施例七,本发明实施例还提供了一种预测方法,预测是指基于机器学习模型预测某一类任务,例如:图片分类、应用推荐、图像识别都可以看作是一种预测行为,如图12所示,该方法包括:
S1010,第一终端获取第一终端的用户信息,并根据该用户信息生成目标特征向量;
S1020,第一终端将上述的目标特征向量输入目标预测模型,得到目标预测结果;
其中,目标预测模型是第一终端根据第一参数、第二参数以及终端的历史数据训练得到的机器学习模型,第一参数和第二参数为服务器发送的该服务器上与终端的机器学习模型对应的算法模型的两个参数,第一参数用于作为第一终端的机器学习模型的初始参数,第二参数用于指示第一终端训练机器学习模型的方式,所述第一参数和所述第二参数为服务器根据多个终端反馈的多个损失梯度得到,任一损失梯度为对应终端基于本地历史数据计算得到, 具体怎样计算损失梯度乐意参见上面实施例相应部分描述,所述多个终端包括所该第一终端。
一般情况,终端的机器学习模型是在使用之前训练好的,具体训练的方式是上面实施例所描述的训练机器学习模型的方法;可选的,在通过机器学习模型预测之前,该方法还包括:S1030,终端向服务器发送参数更新请求,参数更新请求用于请求服务器发送算法模型的最近一次更新的第一参数和第二参数;S1040,所述服务器接收到第一终端发送的参数更新请求,所述参数更新请求用于请求所述服务器发送最近一次更新的第一参数和第二参数,所述第一终端为所述多个终端中的任一个终端;S1050,所述服务器向所述第一终端发送最近一次更新的第一参数和第二参数。S1060,终端接收所述服务器发送的最近一次更新的第一参数和第二参数;S1070,终端根据接收到的最近一次更新的第一参数和第二参数以及终端的目前的历史数据训练目标预测模型;对应的,S1020第一终端将所述目标特征向量输入目标预测模型,得到目标预测结果,具体包括:第一终端将目标特征向量输入训练后的目标预测模型,得到目标预测结果。这样可以再使用目标预测模型之前,再基于服务器新更新的第一参数和第二参数以及终端本地新产生的历史数据对该目标预测模型进行一次训练后再进行预测,能够实现更好地预测效果。
可选的,上述第一终端发送给服务器的参数更新请求包括:目标预测模型对应的机器学习模型的结构标识,结构标识用于服务器根据确定与目标预测模型对应的算法模型。
进一步地,在第一终端将所述目标特征向量输入目标预测模型,得到目标预测结果之后,还包括:第一终端获取用户对目标预测结果的预测结果打分;并向服务器上传预测结果打分,其中,预测结果打分为第一终端用户对目标预测结果的打分,该预测结果打分用于服务器确定加权系数,加权系数用于服务器处理多个终端上传的损失梯度得到加权损失梯度,加权损失梯度用于服务器更新第一参数和第二参数。第一终端可以是主动获取并向服务器发送用户对目标预测结果的预测结果打分,也可以是第一终端接收到服务器周期性向终端发送的用户反馈请求后获取并上传用户对目标预测结果的预测结果打分;下面以第二种情况为例:
服务器向终端发送用户反馈请求,可以按如下方式执行:周期性(如每个月一次)发送用户反馈请求,用户反馈请求用于要求终端用户对预测效果进行(主观)评价,在0~10之间打分,0为效果极差,10为效果极好;终端接收用户反馈请求后并通知终端用户对预测效果进行打分,在下一次上传预测反馈(即损失梯度或者预测损失)时同时上传用户对目标预测结果的预测结果的打分;服务器在更新参数时参考用户打分,如果没有接收到终端用户的打分,则使用默认值5分,终端用户的打分的使用方式可能是:(a)终端用户打分越高,说明元学习器对该终端用户的模型训练最有效,在更新元学习器参数时该终端用户对应的权重越大;(b)终端用户打分越低,说明元学习器越应该提升该终端用户的模型训练效果,在更新元学习器参数时该终端用户对应的权重越大,这里元学习器是指算法模型;例如,采用方式(a),即终端用户打分越高对应权重越大,具体如下:
假设返回预测反馈的终端为1,2,…,N′,终端i返回的是预测损失梯度
Figure PCTCN2017120294-appb-000079
则以如下方式更新(θ,α):
Figure PCTCN2017120294-appb-000080
其中,
Figure PCTCN2017120294-appb-000081
代表梯度;标量β是一个固定的超参数,代表更新元学习器时的学习率;c i为终端i的用户打分,λ为固定系数。
需要说明的,上面实施例中服务器所执行的方法可以由图9或图10所示服务器实现,上面实施例中第一终端所执行的方法可以由图6或图7或图8所示终端实现,具体描述可以参 见上面图所对应的实施例,此处不再赘述。
针对服务器的算法模型和终端的机器学习模型(例如)预测模型,可选的,两端的模型都是小规模模型,或者服务器为小规模模型,或者终端为小规模模型,其中小规模模型是相对于传统神经网络而言的。
本申请的说明书和权利要求书及所述附图中的术语“第一”、“第二”、“第三”和“第四”等是用于区别不同对象,而不是用于描述特定顺序。此外,术语“包括”和“具有”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选的还包括没有列出的步骤或单元,或可选的还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。
本领域普通技术人员可以理解,在本申请的各种实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本发明实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random Access Memory,RAM)等。
以上所揭露的仅为本发明较佳实施例而已,当然不能以此来限定本发明之权利范围,因此依本发明权利要求所作的等同变化,仍属本发明所涵盖的范围。

Claims (25)

  1. 一种训练机器学习模型方法,其特征在于,包括:
    终端接收服务器发送的所述服务器上的算法模型的第一参数和第二参数,所述第一参数用于作为所述终端的机器学习模型的初始参数,所述第二参数用于指示所述终端训练机器学习模型的方式;
    所述终端根据所述第一参数、所述第二参数以及训练集数据训练所述终端上的机器学习模型,所述训练集数据包括多个训练样本,每一训练样本包括第一特征向量及对应的第一标签,所述第一特征向量根据所述终端的历史数据中的用户信息构建;
    所述终端根据测试数据以及所述机器学习模型得到测试结果,并根据所述测试结果计算损失梯度;
    所述终端将所述损失梯度上传给所述服务器,所述损失梯度用于所述服务器更新所述第一参数和所述第二参数。
  2. 根据权利要求1所述的方法,其特征在于,所述根据所述测试结果计算损失梯度,包括:
    所述终端根据所述测试结果和所述测试数据对应的标签计算预测损失;
    所述终端根据所述预测损失计算所述损失梯度。
  3. 根据权利要求2所述的方法,其特征在于,所述测试数据包括多个测试样本数据,每一测试样本数据包括第二特征向量以及对应的第二标签,每一测试样本数据对应一个测试结果;
    其中,所述终端根据所述测试结果和所述测试数据对应的标签计算预测损失,包括:
    所述终端根据所述多个测试样本数据各自对应的测试结果和第二标签,计算所述多个测试样本数据各自的预测损失;
    所述终端根据所述预测损失计算所述损失梯度,包括:
    所述终端根据所述多个测试样本数据各自的预测损失,计算所述多个测试样本数据各自的损失梯度;
    所述终端对所述多个测试样本数据对应的多个损失梯度进行平均处理,得到目标损失梯度;
    所述终端将所述损失梯度上传给所述服务器,包括:
    终端将所述目标损失梯度上传给所述服务器。
  4. 根据权利要求2所述的方法,其特征在于,所述测试数据包括多个测试样本数据,每一测试样本数据包括第二特征向量以及对应的第二标签,每一测试样本数据对应一个测试结果;
    其中,所述终端根据所述测试结果和所述测试数据对应的标签计算预测损失,包括:
    所述终端根据所述多个测试样本数据各自对应的测试结果和第二标签,计算所述多个测试样本数据各自的预测损失;
    所述终端对所述多个测试样本数据对应的多个预测损失进行平均,得到平均预测损失;
    所述终端根据所述预测损失计算所述损失梯度,包括:
    所述终端根据所述平均预测损失计算目标损失梯度;
    所述终端将所述损失梯度上传给所述服务器,包括:
    终端将所述目标损失梯度上传给所述服务器。
  5. 根据权利要求3或4所述的方法,其特征在于,在所述终端根据所述多个测试样本数据各自对应的测试结果和第二标签,计算所述多个测试样本数据各自的预测损失之后,还包括:
    所述终端确认所述多个测试样本数据各自的预测损失满足预设条件,所述预设条件用于指示相对上一次计算的平均预测损失波动值小于预设阈值,所述平均预测损失为所诉终端对已多个测试样本数据对应的多个预测损失进行平均得到的。
  6. 根据权利要求5所述的方法,其特征在于,包括:
    若所述终端确认测试样本数据i的预测损失不满足所述预设条件,所述终端不再计算所述测试样本数据i的预测损失对应的损失梯度或不根据所述测试样本数据i的预测损失计算所述平均预测损失,所述测试样本数据i为所述多个测试样本数据中任一个。
  7. 根据权利要求1-6任一项所述的方法,其特征在于,在终端接收服务器发送的所述服务器的算法模型的第一参数和第二参数之前,包括:
    所述终端将所述机器学习模型的结构标识发送给所述服务器,所述结构标识用于所述服务器根据所述结构标识确定所述机器学习模型对应的所述算法模型。
  8. 一种预测方法,其特征在于,包括:
    第一终端获取所述第一终端的用户信息,并根据所述用户信息生成目标特征向量;
    所述第一终端将所述目标特征向量输入目标预测模型,得到目标预测结果;
    其中,所述目标预测模型为所述第一终端根据第一参数、第二参数以及所述第一终端的历史数据训练得到的本地机器学习模型,所述第一参数和所述第二参数为服务器发送的所述服务器的算法模型的两个参数,所述第一参数用于作为所述第一终端的机器学习模型的初始参数,所述第二参数用于指示所述第一终端训练机器学习模型的方式,所述第一参数和所述第二参数为所述服务器根据多个终端反馈的多个损失梯度得到,任一损失梯度为对应终端基于本地历史数据计算得到。
  9. 根据权利要求2所述的方法,其特征在于,在所述第一终端将所述目标特征向量输入目标预测模型,得到目标预测结果之前,包括:
    所述第一终端向所述服务器发送参数更新请求,所述参数更新请求用于请求所述服务器发送所述算法模型的最近一次更新的第一参数和第二参数;
    所述第一终端接收所述服务器发送的所述最近一次更新的第一参数和第二参数;
    所述第一终端根据所述最近一次更新的第一参数和第二参数以及所述第一终端的历史数据训练所述目标预测模型;
    其中,所述第一终端将所述目标特征向量输入目标预测模型,得到目标预测结果,包括:
    所述第一终端将所述目标特征向量输入训练后的目标预测模型,得到目标预测结果。
  10. 根据权利要求9所述的方法,其特征在于,所述参数更新请求包括:所述目标预测模型对应的机器学习模型的结构标识,所述结构标识用于所述服务器根据所述结构标识确定所述目标预测模型对应的所述算法模型。
  11. 根据权利要求8-10任一项所述的方法,其特征在于,在所述第一终端将所述目标特征向量输入目标预测模型,得到目标预测结果之后,还包括:
    所述第一终端向所述服务器上传预测结果打分,其中,所述预测结果打分为所述第一终端的用户对所述目标预测结果的打分,所述预测结果打分用于所述服务器确定加权系数,所述 加权系数用于所述服务器处理所述多个终端上传的损失梯度得到加权损失梯度,所述加权损失梯度用于所述服务器更新所述第一参数和所述第二参数,所述多个终端包括所述第一终端。
  12. 一种训练机器学习模型的方法,其特征在于,包括:
    服务器向多个终端发送所述服务器的算法模型的第一参数和第二参数,所述第一参数用于作为所述多个终端中每一终端的机器学习模型的初始参数,所述第二参数用于指示所述多个终端中每一终端的训练机器学习模型的方式,所述多个终端的机器学习模型具有相同的结构;
    在预设时间窗内,所述服务器接收所述多个终端中至少一个终端上传的损失梯度;
    所述服务器根据所述至少一个终端上传的损失梯度更新所述第一参数和所述第二参数。
  13. 根据权利要求12所述的方法,其特征在于,在所述服务器向多个终端发送第一参数和第二参数之前,包括:
    所述服务器初始化所述算法模型的所述第一参数和所述第二参数。
  14. 根据权利要求12或13所述的方法,其特征在于,包括:
    所述服务器根据所述多个终端上传损失梯度的概率,重置所述预设时间窗。
  15. 根据权利要求12-14任选一所述的方法,其特征在于,所述多个终端属于同一群组,所述同一群组用于指示具有相同或相似的属性特征。
  16. 根据权利要求15所述的方法,其特征在于,所述属性特征包括地理区域。
  17. 根据权利要求12-16任一项所述的方法,其特征在于,还包括:
    所述服务器接收所述至少一个终端上传的预测结果打分,所述预测结果打分为终端用户对机器学习模型的预测结果的打分;
    所述服务器根据所述预测结果打分,确定加权系数;
    其中,所述服务器根据所述至少一个终端上传的损失梯度更新所述第一参数和所述第二参数,包括:
    所述服务器根据所述加权系数对所述至少一个终端上传的损失梯度进行加权平均处理,得到加权损失梯度;
    所述服务器根据所述加权损失梯度更新所述第一参数和所述第二参数。
  18. 根据权利要求12-17任选一所述的方法,其特征在于,在服务器向多个终端发送第一参数和第二参数之前,还包括:
    所述服务器接收所述多个终端上传的各自机器学习模型的结构标识,所述结构标识用于所述服务器确定与所述机器学习模型的结构对应的所述算法模型。
  19. 根据权利要求12-18任选一所述的方法,其特征在于,包括:
    所述服务器接收到第一终端发送的参数更新请求,所述参数更新请求用于请求所述服务器发送最近一次更新的第一参数和第二参数,所述第一终端为所述多个终端中的任一个终端;
    所述服务器向所述第一终端发送最近一次更新的第一参数和第二参数。
  20. 一种终端,其特征在于,包括:处理器、存储介质;
    所述存储介质用于存储可编程指令;
    所述处理器用于调用所述存储介质上存储的可编程指令执行权利要求1-7任一项所述的方法。
  21. 一种终端,其特征在于,包括:处理器、存储介质;
    所述存储介质用于存储可编程指令;
    所述处理器用于调用所述存储介质上存储的可编程指令执行权利要求8-11任一项所述的方法。
  22. 一种服务器,其特征在于,包括:处理器、存储介质;
    所述存储介质用于存储可编程指令;
    所述处理器用于调用所述存储介质上存储的可编程指令执行权利要求12-19任一项所述的方法。
  23. 一种计算机可读存储介质,其特征在于,包括指令,当其在计算机上运行时,使得所述计算机执行权利要求1-7任一项所述的方法。
  24. 一种计算机可读存储介质,其特征在于,包括指令,当其在计算机上运行时,使得所述计算机执行权利要求8-11任一项所述的方法。
  25. 一种计算机可读存储介质,其特征在于,包括指令,当其在计算机上运行时,使得所述计算机执行权利要求12-19任一项所述的方法。
PCT/CN2017/120294 2017-11-07 2017-12-29 一种预测方法及终端、服务器 WO2019090954A1 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
EP17931484.4A EP3693912A4 (en) 2017-11-07 2017-12-29 PREDICTION METHOD, TERMINAL DEVICE AND SERVER
CN201780095993.7A CN111226238B (zh) 2017-11-07 2017-12-29 一种预测方法及终端、服务器
US16/863,110 US11580457B2 (en) 2017-11-07 2020-04-30 Prediction method, terminal, and server

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201711084325.2A CN109754105B (zh) 2017-11-07 2017-11-07 一种预测方法及终端、服务器
CN201711084325.2 2017-11-07

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/863,110 Continuation US11580457B2 (en) 2017-11-07 2020-04-30 Prediction method, terminal, and server

Publications (1)

Publication Number Publication Date
WO2019090954A1 true WO2019090954A1 (zh) 2019-05-16

Family

ID=66400884

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/120294 WO2019090954A1 (zh) 2017-11-07 2017-12-29 一种预测方法及终端、服务器

Country Status (4)

Country Link
US (1) US11580457B2 (zh)
EP (1) EP3693912A4 (zh)
CN (2) CN109754105B (zh)
WO (1) WO2019090954A1 (zh)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110287934A (zh) * 2019-07-02 2019-09-27 北京搜狐互联网信息服务有限公司 一种对象检测方法、装置、客户端及服务器
CN110689137A (zh) * 2019-09-24 2020-01-14 网易传媒科技(北京)有限公司 参数确定方法、系统、介质和电子设备
CN111079022A (zh) * 2019-12-20 2020-04-28 深圳前海微众银行股份有限公司 基于联邦学习的个性化推荐方法、装置、设备及介质
CN111985000A (zh) * 2020-08-21 2020-11-24 深圳前海微众银行股份有限公司 模型服务输出方法、装置、设备及存储介质
CN112767028A (zh) * 2021-01-20 2021-05-07 每日互动股份有限公司 一种活跃用户数量的预测方法、计算机设备及存储介质
US20220147767A1 (en) * 2020-11-10 2022-05-12 Nec Laboratories America, Inc. Domain generalized margin via meta-learning for deep face recognition
EP4050528A4 (en) * 2019-11-30 2022-12-28 Huawei Technologies Co., Ltd. MODEL UPDATE SYSTEM, MODEL UPDATE PROCEDURE AND RELEVANT DEVICE

Families Citing this family (28)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3502978A1 (en) * 2017-12-22 2019-06-26 Siemens Healthcare GmbH Meta-learning system
CN112313679A (zh) * 2018-06-27 2021-02-02 索尼公司 信息处理设备、信息处理方法和程序
CN112039934A (zh) * 2019-06-03 2020-12-04 大唐移动通信设备有限公司 一种信息反馈、反馈信息处理方法及装置
CN110298185A (zh) * 2019-06-28 2019-10-01 北京金山安全软件有限公司 一种模型训练方法、装置、电子设备及存储介质
CN110309923B (zh) * 2019-07-03 2024-04-26 深圳前海微众银行股份有限公司 横向联邦学习方法、装置、设备及计算机存储介质
CN110727494B (zh) * 2019-09-30 2023-06-23 Oppo广东移动通信有限公司 应用图标控制方法及相关装置
JP7442550B2 (ja) * 2019-12-20 2024-03-04 京東方科技集團股▲ふん▼有限公司 推論演算装置、モデル訓練装置、及び推論演算システム
CN111476403A (zh) * 2020-03-17 2020-07-31 华为技术有限公司 预测模型构建方法和相关装置
CN111898740B (zh) * 2020-07-31 2021-07-20 北京达佳互联信息技术有限公司 预测模型的模型参数更新方法及装置
CN111950295A (zh) * 2020-08-10 2020-11-17 北京嘀嘀无限科技发展有限公司 一种训练自然语言处理模型的方法和系统
CN111709409B (zh) * 2020-08-20 2020-11-20 腾讯科技(深圳)有限公司 人脸活体检测方法、装置、设备及介质
CN112000215A (zh) * 2020-08-25 2020-11-27 北京字节跳动网络技术有限公司 终端控制方法、装置和电子设备
CN111915023B (zh) * 2020-08-28 2021-09-07 支付宝(杭州)信息技术有限公司 一种基于联邦学习的超参数确定方法及装置
CN112257774B (zh) * 2020-10-20 2024-03-15 平安科技(深圳)有限公司 基于联邦学习的目标检测方法、装置、设备及存储介质
CN112863175B (zh) * 2020-12-31 2022-11-22 平安科技(深圳)有限公司 汽车道路监测数据处理方法、装置、设备及存储介质
CN112766388A (zh) * 2021-01-25 2021-05-07 深圳中兴网信科技有限公司 模型获取方法、电子设备和可读存储介质
CN112990478B (zh) * 2021-02-22 2022-08-26 上海嗨普智能信息科技股份有限公司 联邦学习数据处理系统
CN113011603A (zh) * 2021-03-17 2021-06-22 深圳前海微众银行股份有限公司 模型参数更新方法、装置、设备、存储介质及程序产品
CN113240461B (zh) * 2021-05-07 2022-08-16 广州银行股份有限公司 基于纵向联邦学习的潜在客户的识别方法、系统及介质
US12014397B2 (en) * 2021-08-17 2024-06-18 Shopper Scientist Llc In-store computerized product promotion system with product prediction model that outputs a target product message based on products selected in a current shopping session
CN113849665A (zh) * 2021-09-02 2021-12-28 中科创达软件股份有限公司 多媒体数据识别方法、装置、设备及存储介质
CN113835964B (zh) * 2021-09-26 2023-07-18 湘潭大学 基于小样本学习的云数据中心服务器能耗预测方法
CN113891338B (zh) * 2021-09-29 2023-08-29 广东电网有限责任公司广州供电局 一种电力施工现场LoRa终端发送速率的自适应调节方法
CN116264712A (zh) * 2021-12-15 2023-06-16 维沃移动通信有限公司 数据收集方法及装置、第一设备、第二设备
CN114734845A (zh) * 2022-03-31 2022-07-12 上海电享信息科技有限公司 超级充电枪温度控制方法、系统和基于其的超级充电枪
CN114925750A (zh) * 2022-04-25 2022-08-19 北京三快在线科技有限公司 信息推荐方法、装置、计算机可读存储介质及电子设备
CN114792173B (zh) * 2022-06-20 2022-10-04 支付宝(杭州)信息技术有限公司 预测模型训练方法和装置
CN115600512B (zh) * 2022-12-01 2023-04-14 深圳先进技术研究院 一种基于分布式学习的刀具寿命预测方法

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105528652A (zh) * 2015-12-03 2016-04-27 北京金山安全软件有限公司 一种预测模型的建立方法及终端
CN106548210A (zh) * 2016-10-31 2017-03-29 腾讯科技(深圳)有限公司 机器学习模型训练方法及装置
CN107169573A (zh) * 2017-05-05 2017-09-15 第四范式(北京)技术有限公司 利用复合机器学习模型来执行预测的方法及系统

Family Cites Families (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7689419B2 (en) * 2005-09-22 2010-03-30 Microsoft Corporation Updating hidden conditional random field model parameters after processing individual training samples
CN102508907B (zh) 2011-11-11 2013-11-20 北京航空航天大学 一种基于训练集优化的推荐系统的动态推荐方法
WO2013074634A1 (en) * 2011-11-15 2013-05-23 Icelero Llc Method and system for private distributed collaborative filtering
JP2015184823A (ja) * 2014-03-20 2015-10-22 株式会社東芝 モデルパラメータ算出装置、モデルパラメータ算出方法およびコンピュータプログラム
US9721024B2 (en) * 2014-12-19 2017-08-01 Facebook, Inc. Searching for ideograms in an online social network
CN105989441A (zh) * 2015-02-11 2016-10-05 阿里巴巴集团控股有限公司 模型参数调整方法和装置
CN106156810B (zh) * 2015-04-26 2019-12-03 阿里巴巴集团控股有限公司 通用机器学习算法模型训练方法、系统和计算节点
CN107025205B (zh) * 2016-01-30 2021-06-22 华为技术有限公司 一种分布式系统中的训练模型的方法及设备
CN107133436A (zh) * 2016-02-26 2017-09-05 阿里巴巴集团控股有限公司 一种多重抽样模型训练方法及装置
CN107153630B (zh) * 2016-03-04 2020-11-06 阿里巴巴集团控股有限公司 一种机器学习系统的训练方法和训练系统
CN107229966B (zh) * 2016-03-25 2021-03-16 阿里巴巴集团控股有限公司 一种模型数据更新方法、装置及系统
CN107229518B (zh) * 2016-03-26 2020-06-30 阿里巴巴集团控股有限公司 一种分布式集群训练方法和装置
CN107292326A (zh) * 2016-03-31 2017-10-24 阿里巴巴集团控股有限公司 一种模型的训练方法和装置
US10380503B2 (en) * 2016-04-08 2019-08-13 Here Global B.V. Distributed online learning for privacy-preserving personal predictive models
JP6703264B2 (ja) * 2016-06-22 2020-06-03 富士通株式会社 機械学習管理プログラム、機械学習管理方法および機械学習管理装置
US11158418B2 (en) * 2018-08-21 2021-10-26 4medica, Inc. Systems and methods for integrating communications in a healthcare network

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105528652A (zh) * 2015-12-03 2016-04-27 北京金山安全软件有限公司 一种预测模型的建立方法及终端
CN106548210A (zh) * 2016-10-31 2017-03-29 腾讯科技(深圳)有限公司 机器学习模型训练方法及装置
CN107169573A (zh) * 2017-05-05 2017-09-15 第四范式(北京)技术有限公司 利用复合机器学习模型来执行预测的方法及系统

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110287934A (zh) * 2019-07-02 2019-09-27 北京搜狐互联网信息服务有限公司 一种对象检测方法、装置、客户端及服务器
CN110287934B (zh) * 2019-07-02 2022-12-02 北京搜狐互联网信息服务有限公司 一种对象检测方法、装置、客户端及服务器
CN110689137B (zh) * 2019-09-24 2022-11-25 网易传媒科技(北京)有限公司 参数确定方法、系统、介质和电子设备
CN110689137A (zh) * 2019-09-24 2020-01-14 网易传媒科技(北京)有限公司 参数确定方法、系统、介质和电子设备
JP2023504103A (ja) * 2019-11-30 2023-02-01 華為技術有限公司 モデル更新システム、モデル更新方法及び関連装置
EP4050528A4 (en) * 2019-11-30 2022-12-28 Huawei Technologies Co., Ltd. MODEL UPDATE SYSTEM, MODEL UPDATE PROCEDURE AND RELEVANT DEVICE
JP7401677B2 (ja) 2019-11-30 2023-12-19 華為技術有限公司 モデル更新システム、モデル更新方法及び関連装置
CN111079022A (zh) * 2019-12-20 2020-04-28 深圳前海微众银行股份有限公司 基于联邦学习的个性化推荐方法、装置、设备及介质
CN111079022B (zh) * 2019-12-20 2023-10-03 深圳前海微众银行股份有限公司 基于联邦学习的个性化推荐方法、装置、设备及介质
CN111985000A (zh) * 2020-08-21 2020-11-24 深圳前海微众银行股份有限公司 模型服务输出方法、装置、设备及存储介质
US20220147767A1 (en) * 2020-11-10 2022-05-12 Nec Laboratories America, Inc. Domain generalized margin via meta-learning for deep face recognition
US11977602B2 (en) * 2020-11-10 2024-05-07 Nec Corporation Domain generalized margin via meta-learning for deep face recognition
CN112767028A (zh) * 2021-01-20 2021-05-07 每日互动股份有限公司 一种活跃用户数量的预测方法、计算机设备及存储介质

Also Published As

Publication number Publication date
US20200258006A1 (en) 2020-08-13
CN109754105B (zh) 2024-01-05
CN109754105A (zh) 2019-05-14
CN111226238A (zh) 2020-06-02
US11580457B2 (en) 2023-02-14
CN111226238B (zh) 2023-10-24
EP3693912A1 (en) 2020-08-12
EP3693912A4 (en) 2020-08-12

Similar Documents

Publication Publication Date Title
WO2019090954A1 (zh) 一种预测方法及终端、服务器
US10902332B2 (en) Recommendation system construction method and apparatus
US11983646B2 (en) Bias scoring of machine learning project data
US10067746B1 (en) Approximate random number generator by empirical cumulative distribution function
CN103970604A (zh) 基于MapReduce架构实现图处理的方法和装置
CN111783810B (zh) 用于确定用户的属性信息的方法和装置
US11334758B2 (en) Method and apparatus of data processing using multiple types of non-linear combination processing
CN111044062B (zh) 路径规划、推荐方法和装置
CN111128307A (zh) 代谢路径预测方法、装置、终端设备及可读存储介质
CN116662672B (zh) 价值对象信息发送方法、装置、设备和计算机可读介质
US20220167034A1 (en) Device topological signatures for identifying and classifying mobile device users based on mobile browsing patterns
CN116668351A (zh) 服务质量预测方法、装置、计算机设备及存储介质
CN110322039B (zh) 一种点击率预估方法、服务器及计算机可读存储介质
US20240291684A1 (en) Communication method and apparatus applied to computer cluster
CN115860856A (zh) 一种数据处理方法、装置、电子设备及存储介质
US20220318649A1 (en) Method and apparatus for adapting machine learning to changes in user interest
CN116113962A (zh) 跨分布式机器学习环境的张量比较
US11531917B1 (en) Probabilistic forecasting with nonparametric quantile functions
CN110378512A (zh) 预测股票的方法及装置、计算机设备、存储介质
CN111353585A (zh) 神经网络模型的结构搜索方法和装置
CN115018009B (zh) 对象描述方法、网络模型的训练方法及装置
CN117094031B (zh) 工业数字孪生数据隐私保护方法及相关介质
US20240354609A1 (en) Modeling of ai rule-engine behavior in quantum computers
US20230244752A1 (en) Augmenting mathematical optimization models generated from historical data
CN115392428A (zh) 一种网络架构搜索方法和装置

Legal Events

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

Ref document number: 17931484

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2017931484

Country of ref document: EP

Effective date: 20200507