WO2024140630A1 - 一种模型训练方法及其相关设备 - Google Patents

一种模型训练方法及其相关设备 Download PDF

Info

Publication number
WO2024140630A1
WO2024140630A1 PCT/CN2023/141760 CN2023141760W WO2024140630A1 WO 2024140630 A1 WO2024140630 A1 WO 2024140630A1 CN 2023141760 W CN2023141760 W CN 2023141760W WO 2024140630 A1 WO2024140630 A1 WO 2024140630A1
Authority
WO
WIPO (PCT)
Prior art keywords
model
target
trained
data sets
data set
Prior art date
Legal status (The legal status 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 status listed.)
Ceased
Application number
PCT/CN2023/141760
Other languages
English (en)
French (fr)
Inventor
陈奕梦
胡天阳
李震国
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to EP23910555.4A priority Critical patent/EP4621739A4/en
Publication of WO2024140630A1 publication Critical patent/WO2024140630A1/zh
Priority to US19/249,081 priority patent/US20250322240A1/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V40/00Recognition of biometric, human-related or animal-related patterns in image or video data
    • G06V40/10Human or animal bodies, e.g. vehicle occupants or pedestrians; Body parts, e.g. hands
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/096Transfer learning
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/77Processing image or video features in feature spaces; using data integration or data reduction, e.g. principal component analysis [PCA] or independent component analysis [ICA] or self-organising maps [SOM]; Blind source separation
    • G06V10/774Generating sets of training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/77Processing image or video features in feature spaces; using data integration or data reduction, e.g. principal component analysis [PCA] or independent component analysis [ICA] or self-organising maps [SOM]; Blind source separation
    • G06V10/776Validation; Performance evaluation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/82Arrangements for image or video recognition or understanding using pattern recognition or machine learning using neural networks
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/87Arrangements for image or video recognition or understanding using pattern recognition or machine learning using selection of the recognition techniques, e.g. of a classifier in a multiple classifier system
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0464Convolutional networks [CNN, ConvNet]
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0475Generative networks
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/06Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons
    • G06N3/063Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons using electronic means
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/09Supervised learning

Definitions

  • the embodiments of the present application relate to the field of artificial intelligence (AI) technology, and in particular to a model training method and related equipment.
  • AI artificial intelligence
  • the platform only considers the matching degree between the pre-trained model and the task that the user needs to complete, and the factors considered are relatively single.
  • the final model obtained in this way cannot have good functions, resulting in a low user experience.
  • the first aspect of the present application provides a model training method, the method comprising:
  • multiple pre-trained models are evaluated based on multiple data sets to obtain first evaluation values of the multiple pre-trained models and second evaluation values of the multiple pre-trained models, including: processing multiple data sets through a target pre-trained model to obtain features of the multiple data sets, the target pre-trained model being any one of the multiple pre-trained models; processing the features of the multiple data sets through a preset target predictor to obtain the predicted probabilities of the labels of the multiple data sets; determining the first evaluation value of the target prediction model based on the features of the multiple data sets; determining the second evaluation value of the target prediction model based on the predicted probabilities of the labels of the multiple data sets.
  • the data set can be input into the target pre-trained model to process the data set through the target pre-trained model, thereby obtaining the features of the data set.
  • the same operations as those performed on the data set can also be performed, so the features of the multiple data sets can be finally obtained.
  • the features of the data set can be input into a preset target predictor to process the features of the data set through a target prediction model, thereby obtaining the predicted probability of the label of the data set.
  • the same operation as that performed on the data set can also be performed, so that the predicted probability of the labels of the multiple data sets can be finally obtained.
  • the features of the multiple data sets can be processed to obtain a first evaluation value of the target prediction model.
  • the predicted probabilities of the labels of the multiple data sets can be processed to obtain a second evaluation value of the target prediction model.
  • determining the first evaluation value of the target prediction model based on the features of multiple data sets includes: constructing a probability distribution of the features of the multiple data sets based on the features of the multiple data sets; determining the non-overlapping parts between the probability distributions of the features of the multiple data sets; and calculating the non-overlapping parts to obtain the first evaluation value of the target prediction model.
  • the features of the data set can be used to construct the probability distribution of the features of the data set. For the remaining data sets in the multiple data sets, the same operation as that performed on the data set can also be performed, so that the probability distribution of the features of the multiple data sets can be finally obtained.
  • the non-overlapping parts between the probability distributions of the features of the multiple data sets can be determined. After obtaining the non-overlapping parts between the probability distributions of the features of the multiple data sets, the non-overlapping parts can be calculated by a preset first evaluation formula to obtain the first evaluation value of the target prediction model.
  • determining the second evaluation value of the target prediction model includes: determining the overlapping portion between the probability distributions of features of multiple data sets; calculating the predicted probabilities of the overlapping portion and the labels of multiple data sets to obtain the second evaluation value of the target prediction model.
  • the overlapping portion between the probability distributions of features of multiple data sets can be determined.
  • the predicted probabilities of the non-overlapping portion and the labels of multiple data sets can be calculated using a preset second evaluation formula to obtain the second evaluation value of the target prediction model.
  • a model to be trained is trained to obtain a target model, including: processing the target data set through the first pre-trained model to obtain a first feature of the target data set, where the target data set is any one of the multiple data sets; processing the first feature of the target data set through the first model to be trained to obtain a first predicted probability of a label of the target data set; processing the target data set through the second pre-trained model to obtain a second feature of the target data set; processing the second feature of the target data set through the second model to be trained to obtain a second predicted probability of a label of the target data set; determining a target loss based on the first feature, the second feature, the first predicted probability, the second predicted probability and the true probability of the label of the target data set; updating the parameters of the first model to be trained based on the target loss until the model training conditions are met to obtain the target model.
  • the data set may be referred to as a target data set.
  • the target data set may be input into the first pre-trained model to process the target data set through the first pre-trained model to obtain the first feature of the target data set.
  • the first feature of the target data set may be input into the first model to be trained to obtain the first feature of the target data set through the first pre-trained model.
  • the first model to be trained processes the first feature of the target data set, thereby obtaining the first predicted probability of the label of the target data set.
  • the target data set can also be input into the second pre-trained model to process the target data set through the second pre-trained model to obtain the second feature of the target data set.
  • the second feature of the target data set can be input into the second model to be trained, so as to process the second feature of the target data set through the second model to be trained, thereby obtaining the second predicted probability of the label of the target data set.
  • the first feature of the target data set, the second feature of the target data set, the first predicted probability of the label of the target data set, and the second predicted probability of the label of the target data set can be calculated by a preset loss function to obtain the target loss.
  • the target loss can be used to update the parameters of the first model to be trained, and in multiple data sets, the next data set can be used to continue training the first model to be trained after the updated parameters until the model training conditions are met, then the first model to be trained that has completed the training is the target model.
  • determining the target loss includes: calculating the first feature and the second feature to obtain a first loss, the first loss is used to indicate the similarity between the first feature and the second feature; calculating the first predicted probability, the second predicted probability, and the true probability of the label of the target data set to obtain a second loss, the second loss is used to indicate the difference between the first predicted probability and the true probability; based on the first loss and the second loss, constructing the target loss.
  • the first feature of the target data set and the second feature of the target data set can be calculated by a preset first loss function to obtain a first loss, the first loss is used to indicate the similarity between the first feature of the target data set and the second feature of the target data set. Then, the first predicted probability of the label of the target data set, the second predicted probability of the label of the target data set, and the true probability of the label of the target data set are calculated by a preset second loss function to obtain a second loss, the second loss is used to indicate the difference between the first predicted probability of the label of the target data set and the true probability of the label of the target data set. Finally, the target loss is constructed based on the first loss and the second loss.
  • the second aspect of an embodiment of the present application provides a model training device, which includes: an acquisition module, used to acquire multiple data sets of a target task; an evaluation module, used to evaluate multiple pre-trained models based on the multiple data sets to obtain evaluation values of the multiple pre-trained models, and the evaluation values are used to indicate the difference between the performances of the pre-trained models on the multiple data sets; a determination module, used to determine a first pre-trained model and a second pre-trained model from the multiple pre-trained models, the first pre-trained model is the model that best matches the target task, and the second pre-trained model is the model with the highest evaluation value or the model with the lowest evaluation value; a training module, used to train the model to be trained based on the multiple data sets, the first pre-trained model and the second pre-trained model to obtain a target model, and the model composed of the first pre-trained model and the target model is used to complete the target task.
  • the target model is obtained based on multiple data sets of the target task, the first pre-trained model and the second pre-trained model, and the first pre-trained model is the model that best matches the target task, and the second pre-trained model is the model with the highest evaluation value or the model with the lowest evaluation value, it can be seen that in the process of obtaining the final model (composed of the first pre-trained model and the target model), not only the matching degree between the pre-trained model and the target task that the user needs to complete is considered, but also the performance differences of the pre-trained model on multiple data sets of the target task are considered. The factors considered are relatively comprehensive.
  • the final model obtained by this training method can have good generalization ability and functions, which is conducive to improving user experience.
  • the evaluation module is used to: process multiple data sets through a target pre-trained model to obtain features of the multiple data sets, where the target pre-trained model is any one of the multiple pre-trained models; process the features of the multiple data sets through a preset target predictor to obtain prediction probabilities of labels of the multiple data sets; determine a first evaluation value of the target prediction model based on the features of the multiple data sets; and determine a second evaluation value of the target prediction model based on the prediction probabilities of the labels of the multiple data sets.
  • the evaluation module is used to: construct a probability distribution of features of multiple data sets based on features of multiple data sets; determine the non-overlapping parts between the probability distributions of features of multiple data sets; and calculate the non-overlapping parts to obtain a first evaluation value of the target prediction model.
  • the evaluation module is used to: determine the overlapping portion between the probability distributions of features of multiple data sets; and calculate the predicted probabilities of the overlapping portion and the labels of the multiple data sets to obtain a second evaluation value of the target prediction model.
  • a training module is used to: process a target data set through a first pre-trained model to obtain a first feature of the target data set, where the target data set is any one of a plurality of data sets; process the first feature of the target data set through a first model to be trained to obtain a first predicted probability of a label of the target data set; process the target data set through a second pre-trained model to obtain a second feature of the target data set; process the second feature of the target data set through a second model to be trained to obtain a second predicted probability of the label of the target data set; determine a target loss based on the first feature, the second feature, the first predicted probability, the second predicted probability and the true probability of the label of the target data set; and update the parameters of the first model to be trained based on the target loss until the model training conditions are met to obtain the target model.
  • the processor is coupled to the memory through an interface.
  • multiple pre-trained models can be evaluated based on the multiple data sets to obtain evaluation values of the multiple pre-trained models, wherein the evaluation values are used to indicate the differences between the performances of the pre-trained models on the multiple data sets.
  • a first pre-trained model and a second pre-trained model can be selected from the multiple pre-trained models.
  • the model to be trained can be trained based on the multiple data sets, the first pre-trained model and the second pre-trained model to obtain a target model.
  • the model composed of the first pre-trained model and the target model can be used to complete the target task that the user needs to complete.
  • FIG1 is a schematic diagram of a structure of an artificial intelligence main framework
  • FIG2a is a schematic diagram of a structure of a model training system provided in an embodiment of the present application.
  • FIG2c is a schematic diagram of a device related to model training provided in an embodiment of the present application.
  • FIG3 is a schematic diagram of the architecture of the system 100 provided in an embodiment of the present application.
  • FIG5 is a schematic diagram of a probability distribution provided by an embodiment of the present application.
  • FIG7 is a schematic diagram of the role of the correlation migration indicator provided in an embodiment of the present application.
  • FIG. 10 is a schematic diagram of the structure of a chip provided in an embodiment of the present application.
  • the embodiments of the present application provide a model training method and related equipment.
  • the final model obtained through training can have good generalization ability and functions, which is conducive to improving user experience.
  • neural network models with specific functions based on user needs. Therefore, users can use neural network models with specific functions to complete the tasks they need to complete, such as image processing, target detection, speech recognition, and text translation.
  • the platform can collect multiple pre-trained models in advance. These pre-trained models are usually trained using a large amount of data and computing power, and have various basic functions. Therefore, the platform can build a pre-trained model library based on these pre-trained models. After determining the tasks that the user needs to complete, the platform can select several pre-trained models that match the tasks that the user needs to complete from the multiple pre-trained models in the pre-trained model library, and use these pre-trained models to train the training models to obtain the target model. Then, the platform can build these pre-trained models and the target model into a final model with specific functions, and then provide the model to the user, so that the user can use the model to complete the tasks that he needs to complete.
  • AI technology is a technical discipline that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence. AI technology obtains the best results by sensing the environment, acquiring knowledge and using knowledge.
  • artificial intelligence technology is a branch of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence.
  • Using artificial intelligence for data processing is a common application of artificial intelligence.
  • the target model can be obtained in the following ways:
  • the first feature of the target data set, the second feature of the target data set, the first predicted probability of the label of the target data set, and the second predicted probability of the label of the target data set can be calculated using a preset loss function to obtain a target loss.
  • the auxiliary pre-trained model and the main pre-trained model are used to train the classifier to be trained, thereby obtaining a trained classifier. Then, the model composed of the main pre-trained model and the trained classifier can be used as the final model provided to the user.
  • multiple pre-trained models can be evaluated based on the multiple data sets to obtain evaluation values of the multiple pre-trained models, wherein the evaluation values are used to indicate the differences between the performances of the pre-trained models on the multiple data sets.
  • a first pre-trained model and a second pre-trained model can be selected from the multiple pre-trained models.
  • the model to be trained can be trained based on the multiple data sets, the first pre-trained model, and the second pre-trained model to obtain a target model.
  • the model formed by the first pre-trained model and the target model can be used to complete the target task that the user needs to complete.
  • An evaluation module 802 is used to evaluate multiple pre-trained models based on multiple data sets to obtain evaluation values of the multiple pre-trained models, where the evaluation values are used to indicate the differences between the performances of the pre-trained models on the multiple data sets;
  • a determination module 803 is used to determine a first pre-trained model and a second pre-trained model from a plurality of pre-trained models, wherein the first pre-trained model is a model that best matches the target task, and the second pre-trained model is a model with a highest evaluation value or a model with a lowest evaluation value;
  • the training module 804 is used to train the model to be trained based on multiple data sets, the first pre-trained model and the second pre-trained model to obtain a target model.
  • the model composed of the first pre-trained model and the target model is used to complete the target task.
  • multiple pre-trained models can be evaluated based on the multiple data sets to obtain evaluation values of the multiple pre-trained models, wherein the evaluation values are used to indicate the differences between the performances of the pre-trained models on the multiple data sets.
  • a first pre-trained model and a second pre-trained model can be selected from the multiple pre-trained models.
  • the model to be trained can be trained based on the multiple data sets, the first pre-trained model and the second pre-trained model to obtain a target model.
  • the model composed of the first pre-trained model and the target model can be used to complete the target task that the user needs to complete.
  • the target model is obtained based on multiple data sets of the target task, the first pre-trained model and the second pre-trained model, and the first pre-trained model is the model that best matches the target task, and the second pre-trained model is the model with the highest evaluation value or the model with the lowest evaluation value, it can be seen that in the process of obtaining the final model (composed of the first pre-trained model and the target model), not only the matching degree between the pre-trained model and the target task that the user needs to complete is considered, but also the performance differences of the pre-trained model on multiple data sets of the target task are considered. The factors considered are relatively comprehensive.
  • the final model obtained by this training method can have good generalization ability and functions, which is conducive to improving user experience.
  • the evaluation value includes a first evaluation value and a second evaluation value.
  • the evaluation module is used to evaluate multiple pre-trained models based on multiple data sets to obtain first evaluation values of the multiple pre-trained models and second evaluation values of the multiple pre-trained models.
  • the first evaluation value is used to indicate the difference between the features of the multiple data sets obtained by the pre-trained model
  • the second evaluation value is used to indicate the difference between the predicted probabilities of the labels of the multiple data sets obtained by the pre-trained model.
  • the evaluation module is used to: process multiple data sets through a target pre-trained model to obtain features of the multiple data sets, where the target pre-trained model is any pre-trained model of the multiple pre-trained models;
  • the evaluation module is used to: construct a probability distribution of features of multiple data sets based on features of multiple data sets; determine the non-overlapping parts between the probability distributions of features of multiple data sets; and calculate the non-overlapping parts to obtain a first evaluation value of the target prediction model.
  • a target loss is determined; based on the target loss, the parameters of the first model to be trained are updated until the model training conditions are met, thereby obtaining a target model.
  • the training module is used to: calculate the first feature and the second feature to obtain a first loss, where the first loss is used to indicate the similarity between the first feature and the second feature; calculate the first predicted probability, the second predicted probability, and the true probability of the label of the target data set to obtain a second loss, where the second loss is used to indicate the difference between the first predicted probability and the true probability; and construct a target loss based on the first loss and the second loss.
  • FIG. 9 is a structural diagram of the training device provided by the embodiment of the present application.
  • the training device 900 can be specifically manifested as a mobile phone, a tablet, a laptop computer, an intelligent wearable device, a server, etc., which is not limited here.
  • the function of model training in the corresponding embodiment of FIG. 4 can be implemented on the training device 900.
  • the training device 900 includes: a receiver 901, a transmitter 902, a processor 903 and a memory 904 (wherein the number of processors 903 in the training device 900 can be one or more, and FIG.
  • the processor 903 may include an application processor 9031 and a communication processor 9032.
  • the receiver 901, the transmitter 902, the processor 903 and the memory 904 may be connected via a bus or other means.
  • the memory 904 may include a read-only memory and a random access memory, and provides instructions and data to the processor 903. A portion of the memory 904 may also include a non-volatile random access memory (NVRAM).
  • NVRAM non-volatile random access memory
  • the memory 904 stores processor and operation instructions, executable modules or data structures, or subsets thereof, or extended sets thereof, wherein the operation instructions may include various operation instructions for implementing various operations.
  • the processor 903 controls the operation of the training device.
  • the various components of the training device are coupled together through a bus system, wherein the bus system may include a power bus, a control bus, and a status signal bus in addition to a data bus.
  • the bus system may include a power bus, a control bus, and a status signal bus in addition to a data bus.
  • various buses are referred to as bus systems in the figure.
  • the method disclosed in the above embodiment of the present application can be applied to the processor 903, or implemented by the processor 903.
  • the processor 903 can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 903 or the instruction in the form of software.
  • the above processor 903 can be a general processor, a digital signal processor (digital signal processing, DSP), a microprocessor or a microcontroller, and can further include an application specific integrated circuit (application specific integrated circuit, ASIC), a field programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
  • the processor 903 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiment of the present application.
  • the general processor can be a microprocessor or the processor can also be any conventional processor, etc.
  • the steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to be executed, or a combination of hardware and software modules in the decoding processor can be executed.
  • the software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc.
  • the storage medium is located in the memory 904, and the processor 903 reads the information in the memory 904 and completes the steps of the above method in combination with its hardware.
  • the receiver 901 can be used to receive input digital or character information and generate signal input related to the relevant settings and function control of the training device.
  • the transmitter 902 can be used to output digital or character information through the first interface; the transmitter 902 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; the transmitter 902 can also include a display device such as a display screen.
  • the processor 903 is used to complete model training through the model library in the embodiment corresponding to Figure 4, and provide the obtained final model to the user device, so that the user can complete the task that the user needs to complete based on the final model through the user device, that is, execute the task processing method.
  • the present application also relates to a computer storage medium, wherein the computer readable storage medium stores a program for performing signal processing.
  • the program when it is run on a computer, makes the computer execute the steps executed by the aforementioned training device, or makes the computer execute the steps executed by the aforementioned training device.
  • An embodiment of the present application also relates to a computer program product, which stores instructions, which, when executed by a computer, enable the computer to execute the steps executed by the aforementioned execution device, or enable the computer to execute the steps executed by the aforementioned training device.
  • the training device or terminal device provided in the embodiment of the present application may specifically be a chip, and the chip includes: a processing unit and a communication unit, wherein the processing unit may be, for example, a processor, and the communication unit may be, for example, an input/output interface, a pin or a circuit, etc.
  • the processing unit may execute the computer execution instructions stored in the storage unit so that the chip in the execution device executes the data processing method described in the above embodiment, or so that the chip in the training device executes the data processing method described in the above embodiment.
  • the storage unit is a storage unit in the chip, such as a register, a cache, etc.
  • the storage unit may also be a storage unit located outside the chip in the wireless access device end, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
  • ROM read-only memory
  • RAM random access memory
  • FIG. 10 is a schematic diagram of the structure of a chip provided in an embodiment of the present application.
  • the chip can be expressed as a neural network processor NPU 1000.
  • NPU 1000 is mounted on the host CPU (Host CPU) as a coprocessor, and tasks are assigned by the Host CPU.
  • the core part of the NPU is the operation circuit 1003, which is controlled by the controller 1004 to extract matrix data from the memory and perform multiplication operations.
  • the operation circuit 1003 includes multiple processing units (Process Engine, PE) inside.
  • the operation circuit 1003 is a two-dimensional systolic array.
  • the operation circuit 1003 can also be a one-dimensional systolic array or other electronic circuits that can perform mathematical operations such as multiplication and addition.
  • the operation circuit 1003 is a general-purpose matrix processor.
  • the operation circuit takes the corresponding data of matrix B from the weight memory 1002 and caches it on each PE in the operation circuit.
  • the operation circuit takes the matrix A data from the input memory 1001 and performs matrix operation with matrix B.
  • the partial result or final result of the matrix is stored in the accumulator 1008.
  • the unified memory 1006 is used to store input data and output data.
  • the weight data is directly transferred to the weight memory 1002 through the direct memory access controller (DMAC) 1005.
  • the input data is also transferred to the unified memory 1006 through the DMAC.
  • DMAC direct memory access controller
  • BIU stands for Bus Interface Unit, that is, the bus interface unit 1013, which is used for the interaction between AXI bus and DMAC and instruction fetch buffer (IFB) 1009.
  • IOB instruction fetch buffer
  • the bus interface unit 1013 (Bus Interface Unit, BIU for short) is used for the instruction fetch memory 1009 to obtain instructions from the external memory, and is also used for the storage unit access controller 1005 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
  • DMAC is mainly used to transfer input data in the external memory DDR to the unified memory 1006 or to transfer weight data to the weight memory 1002 or to transfer input data to the input memory 1001.
  • the vector calculation unit 1007 includes multiple operation processing units, and when necessary, further processes the output of the operation circuit 1003, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. It is mainly used for non-convolutional/fully connected layer network calculations in neural networks, such as Batch Normalization, pixel-level summation, upsampling of predicted label planes, etc.
  • the vector calculation unit 1007 can store the processed output vector to the unified memory 1006.
  • the vector calculation unit 1007 can apply a linear function; or a nonlinear function to the output of the operation circuit 1003, such as linear interpolation of the predicted label plane extracted by the convolution layer, and then, for example, a vector of accumulated values to generate an activation value.
  • the vector calculation unit 1007 generates a normalized value, a pixel-level summed value, or both.
  • the processed output vector can be used as an activation input to the operation circuit 1003, for example, for use in a subsequent layer in a neural network.
  • An instruction fetch buffer 1009 connected to the controller 1004 is used to store instructions used by the controller 1004;
  • Unified memory 1006, input memory 1001, weight memory 1002 and instruction fetch memory 1009 are all on-chip memories. External memories are private to the NPU hardware architecture.
  • the processor mentioned in any of the above places may be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the above program.
  • the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., may be located in One place, or it can be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment.
  • the connection relationship between the modules indicates that there is a communication connection between them, which can be specifically implemented as one or more communication buses or signal lines.
  • the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
  • a computer device which can be a personal computer, a training device, or a network device, etc.
  • all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof.
  • all or part of the embodiments may be implemented in the form of a computer program product.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium.
  • the available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
  • a magnetic medium e.g., a floppy disk, a hard disk, a tape
  • an optical medium e.g., a DVD
  • a semiconductor medium e.g., a solid-state drive (SSD)

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Evolutionary Computation (AREA)
  • Health & Medical Sciences (AREA)
  • General Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Biophysics (AREA)
  • Biomedical Technology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Computational Linguistics (AREA)
  • Molecular Biology (AREA)
  • Mathematical Physics (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Multimedia (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Databases & Information Systems (AREA)
  • Medical Informatics (AREA)
  • Neurology (AREA)
  • Human Computer Interaction (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)
  • Electrically Operated Instructional Devices (AREA)

Abstract

本申请实施例公开了一种模型训练方法及其相关设备,应用于人工智能领域,其训练得到的最终模型,可具备良好的泛化能力以及功能,有利于提高用户体验。本申请的方法包括:获取目标任务的多个数据集;基于多个数据集对多个预训练模型进行评估,得到多个预训练模型的评估值,评估值用于指示预训练模型在多个数据集上的表现之间的差异;从多个预训练模型中,确定第一预训练模型和第二预训练模型,第一预训练模型为与目标任务最匹配的模型,第二预训练模型为评估值最高的模型或评估值最低的模型;基于多个数据集、第一预训练模型和第二预训练模型,对待训练模型进行训练,得到目标模型,第一预训练模型与目标模型所构成的模型用于完成目标任务。

Description

一种模型训练方法及其相关设备
本申请要求于2022年12月26日提交国家知识产权局、申请号为202211675360.2、发明名称为“一种模型训练方法及其相关设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请实施例涉及人工智能(artificial intelligence,AI)技术领域,尤其涉及一种模型训练方法及其相关设备。
背景技术
随着AI技术的快速发展,某些提供远程服务的平台可基于用户的需求,为用户提供具备特定功能的神经网络模型,故用户可使用具备特定功能的神经网络模型来完成自身所需完成的任务。
目前,平台可提前收集多个预训练模型(pre-trained model),这些预训练模型通常是使用大量的数据和算力训练得到的,具备各种基本的功能,故平台可基于这些预训练模型构建出一个预训练模型库。在确定用户所需完成的任务后,平台可从预训练模型库的多个预训练模型中,选择与用户所需完成的任务相匹配的若干个预训练模型,并利用这若干个预训练模型构建具备特定功能的最终模型,再将该模型提供给用户,故用户可使用该模型来完成自身所需完成的任务。
然而,在前述获取最终模型的过程中,平台仅考虑到预训练模型与用户所需完成的任务之间的匹配度,所考虑的因素较为单一,以这种方式所得到的最终模型,无法具备良好的功能,导致用户体验较低。
发明内容
本申请实施例提供了一种模型训练方法及其相关设备,训练得到的最终模型,可具备良好的泛化能力以及功能,有利于提高用户体验。
本申请的第一方面提供了一种模型训练方法,该方法包括:
在确定用户所需完成的目标任务后,可获取目标任务的多个数据集。
得到目标任务的多个数据集后,可利用多个数据集对预训练模型库中的多个预训练模型进行评估,从而得到多个预训练模型的评估值。需要说明的是,对于多个预训练模型中的任意一个预训练模型而言,该预训练模型的评估值用于指示该预训练模型在多个数据集上的表现之间的差异。
得到多个预训练模型的评估值后,在多个预训练模型中,可将与用户所需完成的目标任务最匹配的模型确定为第一预训练模型。在剩余的预训练模型中,可将评估值最高的模型或评估值最低的模型确定为第二预训练模型。
得到第一预训练模型和第二预训练模型后,可使用多个数据集、第一预训练模型和第二预训练模型,对待训练模型进行训练,得到目标模型。得到目标模型后,可将第一预训练模型与目标模型拼接在一起,二者所构成的模型可提供给用户,故用户可使用该模型来完成自身所需完成的目标任务。
从上述方法可以看出:在获取用户所需完成的目标任务的多个数据集后,可基于多个数据集对多个预训练模型进行评估,从而得到多个预训练模型的评估值,其中,评估值用于指示预训练模型在多个数据集上的表现之间的差异。然后,可从多个预训练模型中,选择第一预训练模型以及第二预训练模型。最后,可基于多个数据集、第一预训练模型和第二预训练模型,对待训练模型进行训练,从而得到目标模型。那么,第一预训练模型与目标模型所构成的模型可用于完成用户所需完成的目标任务。前述过程中,由于目标模型是基于目标任务的多个数据集、第一预训练模型以及第二预训练模型得到的,而第一预训练模型为与目标任务最匹配的模型,第二预训练模型为评估值最高的模型或评估值最低的模型,可见,在获取最终模型(由第一预训练模型与目标模型构成)的过程中,不仅考虑了预训练模型与用户所需完成的目标任务之间的匹配度,还考虑了预训练模型在目标任务的多个数据集上的性能表现差异,所考虑的因素较为全面,以这种训练方式所得到的最终模型,可具备良好的泛化能力以及功能,有利于提高用户体验。
在一种可能实现的方式中,评估值包含第一评估值以及第二评估值,基于多个数据集对多个预训练模型进行评估,得到多个评估值包括:基于多个数据集对多个预训练模型进行评估,得到多个预训练模型的第一评估值和多个预训练模型的第二评估值,第一评估值用于指示预训练模型所得到的多个数据集的特征之间的差异,第二评估值用指示预训练模型所得到的多个数据集的标签的预测概率之间的差异。前述实现方式中,多个预训练模型的预估值可包含多个预训练模型的第一预估值以及多个预训练模型的第二预估值。需要说明的是,对于多个预训练模型中的任意一个预训练模型而言,该预训练模型的第一评估值用于指示该预训练模型所得到的多个数据集的特征之间的差异,该预训练模型的第二评估值用指示该预训练模型所得到的多个数据集的标签的预测概率之间的差异。
在一种可能实现的方式中,基于多个数据集对多个预训练模型进行评估,得到多个预训练模型的第一评估值和多个预训练模型的第二评估值包括:通过目标预训练模型对多个数据集进行处理,得到多个数据集的特征,目标预训练模型为多个预训练模型的任意一个预训练模型;通过预置的目标预测器对多个数据集的特征进行处理,得到多个数据集的标签的预测概率;基于多个数据集的特征,确定目标预测模型的第一评估值;基于多个数据集的标签的预测概率,确定目标预测模型的第二评估值。前述实现方式中,对于多个预训练模型中的任意一个模型,即目标预训练模型,对于多个数据集中的任意一个数据集,可将该数据集输入至目标预训练模型,以通过目标预训练模型对该数据集进行处理,从而得到该数据集的特征。对于多个数据集中的其余数据集,也可执行如同对该数据集所执行的操作,故最终可得到多个数据集的特征。得到多个数据集的特征后,对于多个数据集中的任意一个数据集,可将该数据集的特征输入至预置的目标预测器,以通过目标预测模型对该数据集的特征进行处理,从而得到该数据集的标签的预测概率。对于多个数据集中的其余数据集,也可执行如同对该数据集所执行的操作,故最终可得到多个数据集的标签的预测概率。得到多个数据集的特征后,可对多个数据集的特征进行处理,从而得到目标预测模型的第一评估值。得到多个数据集的标签的预测概率,可对多个数据集的标签的预测概率进行处理,从而得到目标预测模型的第二评估值。
在一种可能实现的方式中,基于多个数据集的特征,确定目标预测模型的第一评估值包括:基于多个数据集的特征,构建多个数据集的特征的概率分布;确定多个数据集的特征的概率分布之间的未重叠部分;对未重叠部分进行计算,得到目标预测模型的第一评估值。前述实现方式中,得到多个数据集的特征后,对于多个数据集中的任意一个数据集,可利用该数据集的特征构建该数据集的特征的概率分布。对于多个数据集中的其余数据集,也可执行如同对该数据集所执行的操作,故最终可得到多个数据集的特征的概率分布。得到多个数据集的特征的概率分布后,可确定多个数据集的特征的概率分布之间的未重叠部分。得到多个数据集的特征的概率分布之间的未重叠部分后,可通过预置的第一评估公式对未重叠部分进行计算,从而得到目标预测模型的第一评估值。
在一种可能实现的方式中,基于多个数据集的标签的预测概率,确定目标预测模型的第二评估值包括:确定多个数据集的特征的概率分布之间的重叠部分;对重叠部分以及多个数据集的标签的预测概率进行计算,得到目标预测模型的第二评估值。前述实现方式中,得到多个数据集的特征的概率分布后,可确定多个数据集的特征的概率分布之间的重叠部分。得到多个数据集的特征的概率分布之间的重叠部分后,可通过预置的第二评估公式对未重叠部分以及多个数据集的标签的预测概率进行计算,从而得到目标预测模型的第二评估值。
在一种可能实现的方式中,基于多个数据集、第一预训练模型和第二预训练模型,对待训练模型进行训练,得到目标模型包括:通过第一预训练模型对目标数据集进行处理,得到目标数据集的第一特征,目标数据集为多个数据集中的任意一个数据集;通过第一待训练模型对目标数据集的第一特征进行处理,得到目标数据集的标签的第一预测概率;通过第二预训练模型对目标数据集进行处理,得到目标数据集的第二特征;通过第二待训练模型对目标数据集的第二特征进行处理,得到目标数据集的标签的第二预测概率;基于第一特征、第二特征、第一预测概率、第二预测概率以及目标数据集的标签的真实概率,确定目标损失;基于目标损失更新第一待训练模型的参数,直至满足模型训练条件,得到目标模型。前述实现方式中,对于多个数据集中的任意一个数据集,可将该数据集称为目标数据集。首先,可将目标数据集输入至第一预训练模型,以通过第一预训练模型对目标数据集进行处理,从而得到目标数据集的第一特征。得到目标数据集的第一特征后,可将目标数据集的第一特征输入至第一待训练模型,以通过 第一待训练模型对目标数据集的第一特征进行处理,从而得到目标数据集的标签的第一预测概率。同样地,还可将目标数据集输入至第二预训练模型,以通过第二预训练模型对目标数据集进行处理,从而得到目标数据集的第二特征。得到目标数据集的第二特征后,可将目标数据集的第二特征输入至第二待训练模型,以通过第二待训练模型对目标数据集的第二特征进行处理,从而得到目标数据集的标签的第二预测概率。得到目标数据集的第一特征、目标数据集的第二特征、目标数据集的标签的第一预测概率以及目标数据集的标签的第二预测概率后,可通过预置的损失函数对目标数据集的第一特征、目标数据集的第二特征、目标数据集的标签的第一预测概率、目标数据集的标签的第二预测概率以及目标数据集的标签的真实概率进行计算,从而得到目标损失。得到目标损失后,可使用目标损失更新第一待训练模型的参数,并在多个数据集中,使用下一个数据集继续对更新参数后的第一待训练模型进行训练,直至满足模型训练条件,那么,完成训练的第一待训练模型即为目标模型。
在一种可能实现的方式中,基于第一特征、第二特征、第一预测概率、第二预测概率以及目标数据集的标签的真实概率,确定目标损失包括:对第一特征以及第二特征进行计算,得到第一损失,第一损失用于指示第一特征以及第二特征之间的相似度;对第一预测概率、第二预测概率以及目标数据集的标签的真实概率进行计算,得到第二损失,第二损失用于指示第一预测概率与真实概率之间的差异;基于第一损失以及第二损失,构建目标损失。前述实现方式中,可通过预置的第一损失函数对目标数据集的第一特征以及目标数据集的第二特征进行计算,得到第一损失,第一损失用于指示目标数据集的第一特征以及目标数据集的第二特征之间的相似度。接着,通过预置的第二损失函数对目标数据集的标签的第一预测概率、目标数据集的标签的第二预测概率以及目标数据集的标签的真实概率进行计算,得到第二损失,第二损失用于指示目标数据集的标签的第一预测概率与目标数据集的标签的真实概率之间的差异。最后,基于第一损失以及第二损失构建目标损失。
本申请实施例的第二方面提供了一种模型训练装置,该装置包括:获取模块,用于获取目标任务的多个数据集;评估模块,用于基于多个数据集对多个预训练模型进行评估,得到多个预训练模型的评估值,评估值用于指示预训练模型在多个数据集上的表现之间的差异;确定模块,用于从多个预训练模型中,确定第一预训练模型和第二预训练模型,第一预训练模型为与目标任务最匹配的模型,第二预训练模型为评估值最高的模型或评估值最低的模型;训练模块,用于基于多个数据集、第一预训练模型和第二预训练模型,对待训练模型进行训练,得到目标模型,第一预训练模型与目标模型所构成的模型用于完成目标任务。
从上述装置可以看出:在获取用户所需完成的目标任务的多个数据集后,可基于多个数据集对多个预训练模型进行评估,从而得到多个预训练模型的评估值,其中,评估值用于指示预训练模型在多个数据集上的表现之间的差异。然后,可从多个预训练模型中,选择第一预训练模型以及第二预训练模型。最后,可基于多个数据集、第一预训练模型和第二预训练模型,对待训练模型进行训练,从而得到目标模型。那么,第一预训练模型与目标模型所构成的模型可用于完成用户所需完成的目标任务。前述过程中,由于目标模型是基于目标任务的多个数据集、第一预训练模型以及第二预训练模型得到的,而第一预训练模型为与目标任务最匹配的模型,第二预训练模型为评估值最高的模型或评估值最低的模型,可见,在获取最终模型(由第一预训练模型与目标模型构成)的过程中,不仅考虑了预训练模型与用户所需完成的目标任务之间的匹配度,还考虑了预训练模型在目标任务的多个数据集上的性能表现差异,所考虑的因素较为全面,以这种训练方式所得到的最终模型,可具备良好的泛化能力以及功能,有利于提高用户体验。
在一种可能实现的方式中,评估值包含第一评估值以及第二评估值,评估模块,用于基于多个数据集对多个预训练模型进行评估,得到多个预训练模型的第一评估值和多个预训练模型的第二评估值,第一评估值用于指示预训练模型所得到的多个数据集的特征之间的差异,第二评估值用指示预训练模型所得到的多个数据集的标签的预测概率之间的差异。
在一种可能实现的方式中,评估模块,用于:通过目标预训练模型对多个数据集进行处理,得到多个数据集的特征,目标预训练模型为多个预训练模型的任意一个预训练模型;通过预置的目标预测器对多个数据集的特征进行处理,得到多个数据集的标签的预测概率;基于多个数据集的特征,确定目标预测模型的第一评估值;基于多个数据集的标签的预测概率,确定目标预测模型的第二评估值。
在一种可能实现的方式中,评估模块,用于:基于多个数据集的特征,构建多个数据集的特征的概率分布;确定多个数据集的特征的概率分布之间的未重叠部分;对未重叠部分进行计算,得到目标预测模型的第一评估值。
在一种可能实现的方式中,评估模块,用于:确定多个数据集的特征的概率分布之间的重叠部分;对重叠部分以及多个数据集的标签的预测概率进行计算,得到目标预测模型的第二评估值。
在一种可能实现的方式中,训练模块,用于:通过第一预训练模型对目标数据集进行处理,得到目标数据集的第一特征,目标数据集为多个数据集中的任意一个数据集;通过第一待训练模型对目标数据集的第一特征进行处理,得到目标数据集的标签的第一预测概率;通过第二预训练模型对目标数据集进行处理,得到目标数据集的第二特征;通过第二待训练模型对目标数据集的第二特征进行处理,得到目标数据集的标签的第二预测概率;基于第一特征、第二特征、第一预测概率、第二预测概率以及目标数据集的标签的真实概率,确定目标损失;基于目标损失更新第一待训练模型的参数,直至满足模型训练条件,得到目标模型。
在一种可能实现的方式中,训练模块,用于:对第一特征以及第二特征进行计算,得到第一损失,第一损失用于指示第一特征以及第二特征之间的相似度;对第一预测概率、第二预测概率以及目标数据集的标签的真实概率进行计算,得到第二损失,第二损失用于指示第一预测概率与真实概率之间的差异;基于第一损失以及第二损失,构建目标损失。
本申请实施例的第三方面提供了一种模型训练装置,该装置包括存储器和处理器;存储器存储有代码,处理器被配置为执行代码,当代码被执行时,模型训练装置用于执行如第一方面或第一方面中的任意一种可能的实现方式所述的方法。
本申请实施例的第四方面提供了一种电路系统,该电路系统包括处理电路,该处理电路配置为执行如第一方面或第一方面中的任意一种可能的实现方式所述的方法。
本申请实施例的第五方面提供了一种芯片系统,该芯片系统包括处理器,用于调用存储器中存储的计算机程序或计算机指令,以使得该处理器执行如第一方面或第一方面中的任意一种可能的实现方式所述的方法。
在一种可能的实现方式中,该处理器通过接口与存储器耦合。
在一种可能的实现方式中,该芯片系统还包括存储器,该存储器中存储有计算机程序或计算机指令。
本申请实施例的第六方面提供了一种计算机存储介质,该计算机存储介质存储有计算机程序,该程序在由计算机执行时,使得计算机实施如第一方面或第一方面中的任意一种可能的实现方式所述的方法。
本申请实施例的第七方面提供了一种计算机程序产品,该计算机程序产品存储有指令,该指令在由计算机执行时,使得计算机实施如第一方面或第一方面中的任意一种可能的实现方式所述的方法。
本申请实施例中,在获取用户所需完成的目标任务的多个数据集后,可基于多个数据集对多个预训练模型进行评估,从而得到多个预训练模型的评估值,其中,评估值用于指示预训练模型在多个数据集上的表现之间的差异。然后,可从多个预训练模型中,选择第一预训练模型以及第二预训练模型。最后,可基于多个数据集、第一预训练模型和第二预训练模型,对待训练模型进行训练,从而得到目标模型。那么,第一预训练模型与目标模型所构成的模型可用于完成用户所需完成的目标任务。前述过程中,由于目标模型是基于目标任务的多个数据集、第一预训练模型以及第二预训练模型得到的,而第一预训练模型为与目标任务最匹配的模型,第二预训练模型为评估值最高的模型或评估值最低的模型,可见,在获取最终模型(由第一预训练模型与目标模型构成)的过程中,不仅考虑了预训练模型与用户所需完成的目标任务之间的匹配度,还考虑了预训练模型在目标任务的多个数据集上的性能表现差异,所考虑的因素较为全面,以这种训练方式所得到的最终模型,可具备良好的泛化能力以及功能,有利于提高用户体验。
附图说明
图1为人工智能主体框架的一种结构示意图;
图2a为本申请实施例提供的模型训练系统的一个结构示意图;
图2b为本申请实施例提供的模型训练系统的另一结构示意图;
图2c为本申请实施例提供的模型训练的相关设备的一个示意图;
图3为本申请实施例提供的系统100架构的一个示意图;
图4为本申请实施例提供的模型训练方法的一个流程示意图;
图5为本申请实施例提供的概率分布的一个示意图;
图6为本申请实施例提供的模型指标的一个示意图;
图7为本申请实施例提供的相关性迁移指标所起作用的一个示意图;
图8为本申请实施例提供的模型训练装置的一个结构示意图;
图9为本申请实施例提供的训练设备的一个结构示意图;
图10为本申请实施例提供的芯片的一个结构示意图。
具体实施方式
本申请实施例提供了一种模型训练方法及其相关设备,训练得到的最终模型,可具备良好的泛化能力以及功能,有利于提高用户体验。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的术语在适当情况下可以互换,这仅仅是描述本申请的实施例中对相同属性的对象在描述时所采用的区分方式。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,以便包含一系列单元的过程、方法、系统、产品或设备不必限于那些单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它单元。
随着AI技术的快速发展,某些提供远程服务的平台可基于用户的需求,为用户提供具备特定功能的神经网络模型,故用户可使用具备特定功能的神经网络模型来完成自身所需完成的任务,例如,图像处理、目标检测、语音识别以及文本翻译等各类任务。
目前,平台可提前收集多个预训练模型(pre-trained model),这些预训练模型通常是使用大量的数据和算力训练得到的,具备各种基本的功能,故平台可基于这些预训练模型构建出一个预训练模型库。在确定用户所需完成的任务后,平台可从预训练模型库的多个预训练模型中,选择与用户所需完成的任务相匹配的若干个预训练模型,并利用这若干个预训练模型对待训练模型进行训练,从而得到目标模型。然后,平台可将这若干个预训练模型以及目标模型构建成具备特定功能的最终模型,再将该模型提供给用户,故用户可使用该模型来完成自身所需完成的任务。
然而,在前述获取最终模型的过程中,平台仅考虑到预训练模型与用户所需完成的任务之间的匹配度,所考虑的因素较为单一,以这种方式所得到的最终模型,无法具备良好的功能,导致用户体验较低。
为了解决上述问题,本申请实施例提供了一种模型训练方法,该方法可结合人工智能(artificial intelligence,AI)技术实现。AI技术是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能的技术学科,AI技术通过感知环境、获取知识并使用知识获得最佳结果。换句话说,人工智能技术是计算机科学的一个分支,它企图了解智能的实质,并生产出一种新的能以人类智能相似的方式做出反应的智能机器。利用人工智能进行数据处理是人工智能常见的一个应用方式。
首先对人工智能系统总体工作流程进行描述,请参见图1,图1为人工智能主体框架的一种结构示意图,下面从“智能信息链”(水平轴)和“IT价值链”(垂直轴)两个维度对上述人工智能主题框架进行阐述。其中,“智能信息链”反映从数据的获取到处理的一列过程。举例来说,可以是智能信息感知、智能信息表示与形成、智能推理、智能决策、智能执行与输出的一般过程。在这个过程中,数据经历了“数据—信息—知识—智慧”的凝练过程。“IT价值链”从人智能的底层基础设施、信息(提供和处理技术实现)到系统的产业生态过程,反映人工智能为信息技术产业带来的价值。
(1)基础设施
基础设施为人工智能系统提供计算能力支持,实现与外部世界的沟通,并通过基础平台实现支撑。通过传感器与外部沟通;计算能力由智能芯片(CPU、NPU、GPU、ASIC、FPGA等硬件加速芯片)提供;基础平台包括分布式计算框架及网络等相关的平台保障和支持,可以包括云存储和计算、互联互通网络等。举例来说,传感器和外部沟通获取数据,这些数据提供给基础平台提供的分布式计算系统中的智能 芯片进行计算。
(2)数据
基础设施的上一层的数据用于表示人工智能领域的数据来源。数据涉及到图形、图像、语音、文本,还涉及到传统设备的物联网数据,包括已有系统的业务数据以及力、位移、液位、温度、湿度等感知数据。
(3)数据处理
数据处理通常包括数据训练,机器学习,深度学习,搜索,推理,决策等方式。
其中,机器学习和深度学习可以对数据进行符号化和形式化的智能信息建模、抽取、预处理、训练等。
推理是指在计算机或智能系统中,模拟人类的智能推理方式,依据推理控制策略,利用形式化的信息进行机器思维和求解问题的过程,典型的功能是搜索与匹配。
决策是指智能信息经过推理后进行决策的过程,通常提供分类、排序、预测等功能。
(4)通用能力
对数据经过上面提到的数据处理后,进一步基于数据处理的结果可以形成一些通用的能力,比如可以是算法或者一个通用系统,例如,翻译,文本的分析,计算机视觉的处理,语音识别,图像的识别等等。
(5)智能产品及行业应用
智能产品及行业应用指人工智能系统在各领域的产品和应用,是对人工智能整体解决方案的封装,将智能信息决策产品化、实现落地应用,其应用领域主要包括:智能终端、智能交通、智能医疗、自动驾驶、智慧城市等。
接下来介绍几种本申请的应用场景。
图2a为本申请实施例提供的模型训练系统的一个结构示意图,该模型训练系统包括用户设备以及数据处理设备。其中,用户设备包括手机、个人电脑或者信息处理中心等智能终端。用户设备为模型训练的发起端,作为模型训练请求的发起方,通常由用户通过用户设备发起请求。
上述数据处理设备可以是云服务器、网络服务器、应用服务器以及管理服务器等具有数据处理功能的设备或服务器。数据处理设备通过交互接口接收来自智能终端的请求,再通过存储数据的存储器以及数据处理的处理器环节进行机器学习,深度学习,搜索,推理,决策等方式的处理。数据处理设备中的存储器可以是一个统称,包括本地存储以及存储历史数据的数据库,数据库可以在数据处理设备上,也可以在其它网络服务器上。
在图2a所示的模型训练系统中,用户设备可以接收用户的指令,用户设备可确定用户所需完成的目标任务以及目标任务的数据集,然后向数据处理设备发起请求,使得数据处理设备针对用户设备得到的目标任务以及数据集执行模型训练应用,从而得到针对用于完成目标任务的模型。示例性的,接收到用户的指令后,用户设备可基于该指令,获取用户所需完成的目标任务以及目标任务的数据集。然后,用户设备可向数据处理设备发起模型训练请求,以使得数据处理设备基于该请求,可利用预训练模型以及目标任务的数据集对待训练模型完成训练,从而得到目标模型,并将预训练模型以及目标模型所构建的模型返回给用户设备,以使得用户设备利用该模型完成自身所需完成的目标任务。
在图2a中,数据处理设备可以执行本申请实施例的模型训练方法。
图2b为本申请实施例提供的模型训练系统的另一结构示意图,在图2b中,用户设备直接作为数据处理设备,该用户设备能够直接获取来自用户的指令并直接由用户设备本身的硬件进行处理,具体过程与图2a相似,可参考上面的描述,在此不再赘述。
在图2b所示的模型训练系统中,用户设备可以接收用户的指令,用户设备可基于该指令,获取用户所需完成的目标任务以及目标任务的数据集。然后,用户设备可利用预训练模型以及目标任务的数据集对待训练模型完成训练,从而得到目标模型。如此一来,用户设备可利用预训练模型以及目标模型所构建的模型完成自身所需完成的目标任务。
在图2b中,用户设备自身就可以执行本申请实施例的模型训练方法。
图2c为本申请实施例提供的模型训练的相关设备的一个示意图。
上述图2a和图2b中的用户设备具体可以是图2c中的本地设备301或者本地设备302,图2a中的数据处理设备具体可以是图2c中的训练设备210,其中,数据存储系统250可以存储训练设备210的待处理数据,数据存储系统250可以集成在训练设备210上,也可以设置在云上或其它网络服务器上。
图2a和图2b中的处理器可以通过神经网络模型或者其它模型(例如,基于支持向量机的模型等等)进行数据训练/机器学习/深度学习,并利用数据最终训练或者学习得到可用于完成目标任务的模型。
图3为本申请实施例提供的系统100架构的一个示意图,在图3中,训练设备120配置输入/输出(input/output,I/O)接口112,用于与外部设备进行信息交互,用户可以通过客户设备140向I/O接口112输入指令,所述指令在本申请实施例中可以包括:各个待调度任务、可调用资源以及其他参数等等。
首先,训练设备120基于用户输入的指令,可确定用户所需完成的任务。
接着,训练设备120可以针对用户所需完成的任务,基于不同的训练数据训练出相应的目标模型/规则,该相应的目标模型/规则即可以用于实现用户所需完成的任务,从而为用户提供所需的结果。其中,训练数据可通过多种方式获取:例如,在计算模块111执行模型训练等相关的处理过程中,训练设备120可以调用数据存储系统150中的数据、代码等以用于相应的处理,也可以将相应训练得到的模型等存入数据存储系统150中。又如,在计算模块111执行模型训练等相关的处理过程中,训练设备120可以从数据库130中获取训练数据,这些训练数据通常是来自于数据采集设备160采集的训练样本。
最后,I/O接口112将训练得到的模型返回给客户设备140,从而提供给用户,以供用户完成自身所需完成的任务。
在图3中所示情况下,用户可以手动给定指令,该手动给定可以通过I/O接口112提供的界面进行操作。另一种情况下,客户设备140可以自动地向I/O接口112发送指令,如果要求客户设备140自动发送指令需要获得用户的授权,则用户可以在客户设备140中设置相应权限。用户可以在客户设备140查看训练设备120输出的结果,具体的呈现形式可以是显示、声音、动作等具体方式。客户设备140也可以作为数据采集端,在用户的指示下采集各种数据以作为新的样本数据,并存入数据库130。
值得注意的是,图3仅是本申请实施例提供的一种系统架构的示意图,图中所示设备、器件、模块等之间的位置关系不构成任何限制,例如,在图3中,数据存储系统150相对训练设备120是外部存储器,在其它情况下,也可以将数据存储系统150置于训练设备120中。
本申请实施例还提供的一种芯片,该芯片包括神经网络处理器NPU。该芯片可以被设置在如图3所示的训练设备120中,用以完成训练设备120的训练工作并输出目标模型/规则。
神经网络处理器NPU,NPU作为协处理器挂载到主中央处理器(centralprocessing unit,CPU)(host CPU)上,由主CPU分配任务。NPU的核心部分为运算电路,控制器控制运算电路提取存储器(权重存储器或输入存储器)中的数据并进行运算。
在一些实现中,运算电路内部包括多个处理单元(process engine,PE)。在一些实现中,运算电路是二维脉动阵列。运算电路还可以是一维脉动阵列或者能够执行例如乘法和加法这样的数学运算的其它电子线路。在一些实现中,运算电路是通用的矩阵处理器。
举例来说,假设有输入矩阵A,权重矩阵B,输出矩阵C。运算电路从权重存储器中取矩阵B相应的数据,并缓存在运算电路中每一个PE上。运算电路从输入存储器中取矩阵A数据与矩阵B进行矩阵运算,得到的矩阵的部分结果或最终结果,保存在累加器(accumulator)中。
向量计算单元可以对运算电路的输出做进一步处理,如向量乘,向量加,指数运算,对数运算,大小比较等等。例如,向量计算单元可以用于神经网络中非卷积/非FC层的网络计算,如池化(pooling),批归一化(batch normalization),局部响应归一化(local response normalization)等。
在一些实现种,向量计算单元能将经处理的输出的向量存储到统一缓存器。例如,向量计算单元可以将非线性函数应用到运算电路的输出,例如累加值的向量,用以生成激活值。在一些实现中,向量计算单元生成归一化的值、合并值,或二者均有。在一些实现中,处理过的输出的向量能够用作到运算电路的激活输入,例如用于在神经网络中的后续层中的使用。
统一存储器用于存放输入数据以及输出数据。
权重数据直接通过存储单元访问控制器(direct memory accesscontroller,DMAC)将外部存储器中 的输入数据搬运到输入存储器和/或统一存储器、将外部存储器中的权重数据存入权重存储器,以及将统一存储器中的数据存入外部存储器。
总线接口单元(bus interface unit,BIU),用于通过总线实现主CPU、DMAC和取指存储器之间进行交互。
与控制器连接的取指存储器(instruction fetch buffer),用于存储控制器使用的指令;
控制器,用于调用指存储器中缓存的指令,实现控制该运算加速器的工作过程。
一般地,统一存储器,输入存储器,权重存储器以及取指存储器均为片上(On-Chip)存储器,外部存储器为该NPU外部的存储器,该外部存储器可以为双倍数据率同步动态随机存储器(double data rate synchronous dynamic random accessmemory,DDR SDRAM)、高带宽存储器(high bandwidth memory,HBM)或其他可读可写的存储器。
由于本申请实施例涉及大量神经网络的应用,为了便于理解,下面先对本申请实施例涉及的相关术语及神经网络等相关概念进行介绍。
(1)神经网络
神经网络可以是由神经单元组成的,神经单元可以是指以xs和截距1为输入的运算单元,该运算单元的输出可以为:
其中,s=1、2、……n,n为大于1的自然数,Ws为xs的权重,b为神经单元的偏置。f为神经单元的激活函数(activation functions),用于将非线性特性引入神经网络中,来将神经单元中的输入信号转换为输出信号。该激活函数的输出信号可以作为下一层卷积层的输入。激活函数可以是sigmoid函数。神经网络是将许多个上述单一的神经单元联结在一起形成的网络,即一个神经单元的输出可以是另一个神经单元的输入。每个神经单元的输入可以与前一层的局部接受域相连,来提取局部接受域的特征,局部接受域可以是由若干个神经单元组成的区域。
神经网络中的每一层的工作可以用数学表达式y=a(Wx+b)来描述:从物理层面神经网络中的每一层的工作可以理解为通过五种对输入空间(输入向量的集合)的操作,完成输入空间到输出空间的变换(即矩阵的行空间到列空间),这五种操作包括:1、升维/降维;2、放大/缩小;3、旋转;4、平移;5、“弯曲”。其中1、2、3的操作由Wx完成,4的操作由+b完成,5的操作则由a()来实现。这里之所以用“空间”二字来表述是因为被分类的对象并不是单个事物,而是一类事物,空间是指这类事物所有个体的集合。其中,W是权重向量,该向量中的每一个值表示该层神经网络中的一个神经元的权重值。该向量W决定着上文所述的输入空间到输出空间的空间变换,即每一层的权重W控制着如何变换空间。训练神经网络的目的,也就是最终得到训练好的神经网络的所有层的权重矩阵(由很多层的向量W形成的权重矩阵)。因此,神经网络的训练过程本质上就是学习控制空间变换的方式,更具体的就是学习权重矩阵。
因为希望神经网络的输出尽可能的接近真正想要预测的值,所以可以通过比较当前网络的预测值和真正想要的目标值,再根据两者之间的差异情况来更新每一层神经网络的权重向量(当然,在第一次更新之前通常会有初始化的过程,即为神经网络中的各层预先配置参数),比如,如果网络的预测值高了,就调整权重向量让它预测低一些,不断的调整,直到神经网络能够预测出真正想要的目标值。因此,就需要预先定义“如何比较预测值和目标值之间的差异”,这便是损失函数(loss function)或目标函数(objective function),它们是用于衡量预测值和目标值的差异的重要方程。其中,以损失函数举例,损失函数的输出值(loss)越高表示差异越大,那么神经网络的训练就变成了尽可能缩小这个loss的过程。
(2)反向传播算法
神经网络可以采用误差反向传播(back propagation,BP)算法在训练过程中修正初始的神经网络模型中参数的大小,使得神经网络模型的重建误差损失越来越小。具体地,前向传递输入信号直至输出会 产生误差损失,通过反向传播误差损失信息来更新初始的神经网络模型中参数,从而使误差损失收敛。反向传播算法是以误差损失为主导的反向传播运动,旨在得到最优的神经网络模型的参数,例如权重矩阵。
下面从神经网络的训练侧和神经网络的应用侧对本申请提供的方法进行描述。
本申请实施例提供的模型训练方法,涉及数据序列的处理,具体可以应用于数据训练、机器学习、深度学习等方法,对训练数据(例如,本申请实施例中的目标任务的多个数据集)进行符号化和形式化的智能信息建模、抽取、预处理、训练等,最终得到训练好的神经网络(例如,本申请实施例中的目标模型以及第一预训练模型所组成的模型);并且,本申请实施例提供的任务处理方法可以运用上述训练好的神经网络,将用户的输入数据(例如,图像数据、语音数据、文本数据等等)输入到所述训练好的神经网络中,得到输出数据,从而完成用户所需完成的任务。需要说明的是,本申请实施例提供的模型训练方法和任务处理方法是基于同一个构思产生的发明,也可以理解为一个系统中的两个部分,或一个整体流程的两个阶段:如模型训练阶段和模型应用阶段。
图4为本申请实施例提供的模型训练方法的一个流程示意图,如图4所示,该方法包括:
401、获取目标任务的多个数据集。
本实施例中,在确定用户所需完成的目标任务后,可获取目标任务的多个数据集,需要说明的是,每个数据集均包含多个训练数据,多个数据集通常包含相同类型的训练数据,但不同数据集所属的域(来源)通常不同。例如,当目标任务为从狗的图像中识别出狗时,可获取第一个数据集,第二个数据集,第三个数据集,...,以及最后一个数据集,其中,第一个数据集包含多个哈士奇的图像,第二个数据集包含多个田园犬的图像,第三个数据集包含多个泰迪的图像,...,最后一个数据集包含多个藏獒的图像等等。
402、基于多个数据集对多个预训练模型进行评估,得到多个预训练模型的评估值,评估值用于指示预训练模型在多个数据集上的表现之间的差异。
得到目标任务的多个数据集后,可利用多个数据集对预训练模型库中的多个预训练模型进行评估,从而得到多个预训练模型的评估值。需要说明的是,对于多个预训练模型中的任意一个预训练模型而言,该预训练模型的评估值用于指示该预训练模型在多个数据集上的表现之间的差异。
具体地,多个预训练模型的预估值可包含多个预训练模型的第一预估值(也可以称为多样性迁移指标)以及多个预训练模型的第二预估值(也可以称为相关性迁移指标)。需要说明的是,对于多个预训练模型中的任意一个预训练模型而言,该预训练模型的第一评估值用于指示该预训练模型所得到的多个数据集的特征之间的差异,该预训练模型的第二评估值用指示该预训练模型所得到的多个数据集的标签的预测概率之间的差异。
更具体地,可通过以下方式来获取多个预训练模型的评估值:
(1)对于多个预训练模型中的任意一个模型,下文将该预训练模型称为目标预训练模型。对于多个数据集中的任意一个数据集,可将该数据集输入至目标预训练模型,以通过目标预训练模型对该数据集进行处理(例如,特征提取等等),从而得到该数据集的特征。需要说明的是,该数据集通常包含多个训练数据,故该数据集的特征也可以理解为该数据集所包含的多个训练数据的特征。对于多个数据集中的其余数据集,也可执行如同对该数据集所执行的操作,故最终可得到多个数据集的特征。
(2)得到多个数据集的特征后,对于多个数据集中的任意一个数据集,可将该数据集的特征输入至预置的目标预测器(已训练的神经网络模型),以通过目标预测模型对该数据集的特征进行处理(例如,特征提取等等),从而得到该数据集的标签的预测概率。需要说明的是,该数据集通常包含多个训练数据,且每个训练数据的标签是已确认的(即每个训练数据的标签的真实概率是已知的),故该数据集的标签也可以理解为该数据集所包含的多个训练数据的标签。对于多个数据集中的其余数据集,也可执行如同对该数据集所执行的操作,故最终可得到多个数据集的标签的预测概率。
(3)得到多个数据集的特征后,可对多个数据集的特征进行处理,从而得到目标预测模型的第一评估值。
更具体地,可通过以下方式来获取目标预测模型的第一评估值:
(3.1)得到多个数据集的特征后,对于多个数据集中的任意一个数据集,可利用该数据集的特征 构建该数据集的特征的概率分布。需要说明的是,该数据集的特征即该数据集包含的多个训练数据的特征,由于不同训练数据的特征有可能是相同的取值,故基于这多个训练数据的特征可算出不同取值的特征的出现概率(即不同取值的特征所占的比例),以不同取值的特征的出现概率可构建该数据集的特征的概率分布,其中,所构建的概率分布可以为以下任意一种:高斯分布,伯努利分布,泊松分布,几何分布,以及beta分布等等。对于多个数据集中的其余数据集,也可执行如同对该数据集所执行的操作,故最终可得到多个数据集的特征的概率分布。
例如,设存在两个数据集,分别为数据集e以及数据集e′,目标预训练模型为f。将数据集e以及数据集e′分别输入目标预训练模型f后,目标预训练模型f可以对数据集e进行处理,得到数据集e的特征z,并对数据集e′进行处理,得到数据集e′的特征z。然后,可利用数据集e的特征z构建概率分布pe(z),并利用数据集e′的特征z构建概率分布pe′(z)。
(3.2)得到多个数据集的特征的概率分布后,可确定多个数据集的特征的概率分布之间的未重叠部分。需要说明的是,多个数据集的特征的概率分布可呈现为多个曲线(多个数据集的特征的概率分布与多个曲线一一对应),那么,多个曲线之间未重叠在一起的部分,即多个数据集的特征的概率分布之间的未重叠部分。
依旧如上述例子,如图5所示(图5为本申请实施例提供的概率分布的一个示意图),曲线1为概率分布pe(z),曲线2为概率分布pe′(z),基于图5可知,曲线1和曲线2之间存在未重叠部分,该未重叠部分可表示为Se,e′
(3.3)得到多个数据集的特征的概率分布之间的未重叠部分后,可通过预置的第一评估公式对未重叠部分进行计算,从而得到目标预测模型的第一评估值。
依旧如上述例子,确定两个概率分布之间的未重叠部分Se,e′后,可通过以下公式计算目标预训练模型f的第一评估值:
(4)得到多个数据集的标签的预测概率,可对多个数据集的标签的预测概率进行处理,从而得到目标预测模型的第二评估值。
更具体地,可通过以下方式来获取目标预测模型的第二评估值:
(4.1)得到多个数据集的特征的概率分布后,可确定多个数据集的特征的概率分布之间的重叠部分。需要说明的是,多个数据集的特征的概率分布可呈现为多个曲线(多个数据集的特征的概率分布与多个曲线一一对应),那么,多个曲线之间重叠在一起的部分,即多个数据集的特征的概率分布之间的重叠部分。
依旧如上述例子,如图5所示,曲线1为概率分布pe(z),曲线2为概率分布pe′(z),基于图 5可知,曲线1和曲线2之间存在重叠部分,该重叠部分可表示为Te,e′
(4.2)得到多个数据集的特征的概率分布之间的重叠部分后,可通过预置的第二评估公式对未重叠部分以及多个数据集的标签的预测概率进行计算,从而得到目标预测模型的第二评估值。
依旧如上述例子,确定两个概率分布之间的重叠部分Te,e′后,可通过以下公式计算目标预训练模型f的第二评估值:
上式中,y为标签;pe(y丨z)为目标预测器对数据集e的特征z进行处理后,所得到的数据集e的标签的预测概率;pe′(y丨z)为目标预测器对数据集e′的特征z进行处理后,所得到的数据集e′的标签的预测概率。
(5)对于多个预训练模型中的其余预训练模型,也可执行如同对目标预训练模型所执行的操作,故最终可得到多个预训练模型的第一预估值以及多个预训练模型的第二预估值。
403、从多个预训练模型中,确定第一预训练模型和第二预训练模型,第一预训练模型为与目标任务最匹配的模型,第二预训练模型为评估值最高的模型或评估值最低的模型。
得到多个预训练模型的评估值后,在多个预训练模型中,可将与用户所需完成的目标任务最匹配的模型确定为第一预训练模型(也可以称为主预训练模型)。在剩余的预训练模型中,可将评估值最高的模型或评估值最低的模型确定为第二预训练模型(也可以称为辅助预训练模型)。
具体地,由于评估值包含第一评估值以及第二评估值,第一评估值用于指示预训练模型所得到的多个数据集的特征之间的差异,当第一评估值越低时,说明差异越小,则预训练模型的性能越好越稳定,第二评估值用于指示预训练模型所得到的多个数据集的标签的预测概率之间的差异,当第二评估值越低时,说明差异越小,则预训练模型的性能越好越稳定。那么,在选择第二预训练模型的时候,可选择第一评估值最大的预训练模型以及第二评估值最大的预训练模型为第二预训练模型,或者,选择第一评估值最小的预训练模型以及第二评估值最小的预训练模型为第二预训练模型。
404、基于多个数据集、第一预训练模型和第二预训练模型,对待训练模型进行训练,得到目标模型,第一预训练模型与目标模型所构成的模型用于完成目标任务。
得到第一预训练模型和第二预训练模型后,可使用多个数据集(需要说明的是,步骤404中的多个数据集既可以为步骤401中的多个数据集,也可以是基于步骤401中的多个数据集进行混合后重新划分而成的新的多个数据集,此处不做限制)、第一预训练模型和第二预训练模型,对待训练模型进行训练,得到目标模型。得到目标模型后,可将第一预训练模型与目标模型拼接在一起(例如,令第一预训练模型的输出端与目标模型的输入端连接),二者所构成的模型可提供给用户,故用户可使用该模型来完成自身所需完成的目标任务。
具体地,可通过以下方式来获取目标模型:
(1)对于多个数据集中的任意一个数据集,可将该数据集称为目标数据集。首先,可将目标数据集输入至第一预训练模型,以通过第一预训练模型对目标数据集进行处理(例如,特征提取等等),从而得到目标数据集的第一特征。
(2)得到目标数据集的第一特征后,可将目标数据集的第一特征输入至第一待训练模型,以通过 第一待训练模型对目标数据集的第一特征进行处理(例如,特征提取等等),从而得到目标数据集的标签的第一预测概率。
(3)同样地,还可将目标数据集输入至第二预训练模型,以通过第二预训练模型对目标数据集进行处理(例如,特征提取等等),从而得到目标数据集的第二特征。
(4)得到目标数据集的第二特征后,可将目标数据集的第二特征输入至第二待训练模型,以通过第二待训练模型对目标数据集的第二特征进行处理(例如,特征提取等等),从而得到目标数据集的标签的第二预测概率。
(5)得到目标数据集的第一特征、目标数据集的第二特征、目标数据集的标签的第一预测概率以及目标数据集的标签的第二预测概率后,可通过预置的损失函数对目标数据集的第一特征、目标数据集的第二特征、目标数据集的标签的第一预测概率、目标数据集的标签的第二预测概率以及目标数据集的标签的真实概率进行计算,从而得到目标损失。
更具体地,可通过以下方式来获取目标损失:
(5.1)通过预置的第一损失函数对目标数据集的第一特征以及目标数据集的第二特征进行计算,得到第一损失,第一损失用于指示目标数据集的第一特征以及目标数据集的第二特征之间的相似度。
(5.2)通过预置的第二损失函数对目标数据集的标签的第一预测概率、目标数据集的标签的第二预测概率以及目标数据集的标签的真实概率进行计算,得到第二损失,第二损失用于指示目标数据集的标签的第一预测概率与目标数据集的标签的真实概率之间的差异。
(5.3)基于第一损失以及第二损失构建目标损失。
依旧如上述例子,设选择的与用户任务最匹配的预训练模型为主预训练模型fM,选择的第一评估值最大的预训练模型为辅助预训练模型fd,选择的第二评估值最大的预训练模型为辅助预训练模型fc,目标数据集为X。其中,主预训练模型fM连接有第一待训练分类器,辅助预训练模型fc的输出端连接有第二待训练分类器。
在对两个分类器进行训练的过程中,可通过以下公式来获取目标损失:
上式中,L′为目标损失;δ、λ为常数;fM(X)为主预训练模型fM对目标数据集为X进行处理后,所得到的特征;fd(X)为辅助预训练模型fd对目标数据集为X进行处理后,所得到的特征;y为目标数据集的标签;为第一待训练分类器对特征fM(X)进行处理后,所得到的目标数据集的标签的预测概率;为第二待训练分类器对特征fc(X)进行处理后,所得到的目标数据集的标签的预测概率;fc(X)为辅助预训练模型fc对目标数据集为X进行处理后,所得到的特征;p为目标数据集的标签的真实概率。
可以理解的是,HSIC(fM(X),fd(X))yfc(X)即前述的第一损失,即前 述的第二损失。
(6)得到目标损失后,可使用目标损失更新第一待训练模型的参数,并在多个数据集中,使用下一个数据集继续对更新参数后的第一待训练模型进行训练,直至满足模型训练条件(需要说明的是,当第二预训练模型为评估值最大的预训练模型时,该条件为目标损失收敛(最小化),当预训练模型为评估值最小的预训练模型时,该条件为目标损失最大化),那么,完成训练的第一待训练模型即为目标模型。
为了进一步理解本申请实施例提供的模型训练方法,下文结合一个具体应用例对该方法作进一步的介绍。该应用例包含:
设存在两个数据集,分别为数据集e以及数据集e′,预训练模型为f,数据集e的特征z的概率分布为pe(z),数据集e′的特征z的概率分布为pe′(z)。以pe(z)为例,用表示预训练模型在数据集e上提取的所有特征。此处取高斯分布,高斯分布的表达式为:
上式中,Σ为基于Φ估计得到的协方差矩阵;μ为期望值。
在该分布中,取5%分位数为阈值τe,基于该阈值可将数据集e′划分为:
同理,对于概率分布pe′(z),可得到Se,e′以及Te,e′。进一步地,可得以及
那么,可计算预训练模型的多样性迁移指标:
接着,可计算预训练模型的相关性迁移指标:
如此一来,可得到模型库中所有预训练模型的多样性迁移指标以及相关性迁移指标。那么,可以从这些预训练模型中,按照一定的标准选择主预训练模型,并在剩余的预训练模型中,将多样性迁移指标最大的预训练模型以及相关性迁移指标最大的预训练模型作为辅助预训练模型。
结合数据集e以及数据集e′,利用辅助预训练模型以及主预训练模型,对待训练的分类器进行训练,从而得到训练好的分类器。那么,主预训练模型以及训练好的分类器构成而成的模型可作为最终提供给用户的模型。
此外,还可将本申请实施例最终提供给用户的模型,与相关技术提供的模型进行比较。具体地,设预训练模型库中由多个预训练模型,通过数据集一可得到这些预训练模型的多样性迁移指标以及相关性迁移指标,如图6所示(图6为本申请实施例提供的模型指标的一个示意图)。其中,ViT-B-16为选择的主预训练模型,pirl为多样性迁移指标主导的辅助预训练模型,inception-v3为相关性迁移指标主导的辅助预训练模型。如此一来,基于数据集一、ViT-B-16、pirl、inception-v3对待训练的分类器进行训练后,可得到已训练的分类器,以ViT-B-16与该分类器构成的模型作为最终模型,并将该最终模型与相关技术的模型进行比较,比较结果如表一所示:
表一
基于表一可知,本申请实施例得到的最终模型,在表征泛化能力的各项指标上,均优于相关技术一提供的模型和相关技术二提供的模型。
进一步地,还可在数据集二上验证迁移指标对模型选择和融合的指导意义。如图7所示(图7为本申请实施例提供的相关性迁移指标所起作用的一个示意图),该图显示了选取不同相关性迁移指标的预训练模型作为辅助预训练模型(fc)时,得到的最终模型的OoD准确率。基于图7可知,最终模型的OoD准确率随着辅助预训练模型(fc)的相关性迁移指标增大而增大。
本申请实施例中,在获取用户所需完成的目标任务的多个数据集后,可基于多个数据集对多个预训练模型进行评估,从而得到多个预训练模型的评估值,其中,评估值用于指示预训练模型在多个数据集上的表现之间的差异。然后,可从多个预训练模型中,选择第一预训练模型以及第二预训练模型。最后,可基于多个数据集、第一预训练模型和第二预训练模型,对待训练模型进行训练,从而得到目标模型。那么,第一预训练模型与目标模型所构成的模型可用于完成用户所需完成的目标任务。前述过程中,由于目标模型是基于目标任务的多个数据集、第一预训练模型以及第二预训练模型得到的,而第一预训练 模型为与目标任务最匹配的模型,第二预训练模型为评估值最高的模型或评估值最低的模型,可见,在获取最终模型(由第一预训练模型与目标模型构成)的过程中,不仅考虑了预训练模型与用户所需完成的目标任务之间的匹配度,还考虑了预训练模型在目标任务的多个数据集上的性能表现差异,所考虑的因素较为全面,以这种训练方式所得到的最终模型,可具备良好的泛化能力以及功能,有利于提高用户体验。
进一步地,本申请实施例提供了多样性迁移指标(第一评估值)以及相关性迁移指标(第二评估值),多个维度的量化指标能够从多个维度上去描述预训练模型在目标任务的性能表现差异,提供了目标模型的训练过程的可解释性分析,有助于增强用户对训练过程的理解。
更进一步地,本申请实施例中,多个维度的量化指标可以作为预训练模型的选择依据,为模型融合算法提供有效指导,充分利用预训练模型库蕴含的多样性,且可解释性强。
以上是对本申请实施例提供的模型训练方法所进行的详细说明,以下将对本申请实施例提供的模型训练装置进行介绍。图8为本申请实施例提供的模型训练装置的一个结构示意图,如图8所示,该装置包括:
获取模块801,用于获取目标任务的多个数据集;
评估模块802,用于基于多个数据集对多个预训练模型进行评估,得到多个预训练模型的评估值,评估值用于指示预训练模型在多个数据集上的表现之间的差异;
确定模块803,用于从多个预训练模型中,确定第一预训练模型和第二预训练模型,第一预训练模型为与目标任务最匹配的模型,第二预训练模型为评估值最高的模型或评估值最低的模型;
训练模块804,用于基于多个数据集、第一预训练模型和第二预训练模型,对待训练模型进行训练,得到目标模型,第一预训练模型与目标模型所构成的模型用于完成目标任务。
本申请实施例中,在获取用户所需完成的目标任务的多个数据集后,可基于多个数据集对多个预训练模型进行评估,从而得到多个预训练模型的评估值,其中,评估值用于指示预训练模型在多个数据集上的表现之间的差异。然后,可从多个预训练模型中,选择第一预训练模型以及第二预训练模型。最后,可基于多个数据集、第一预训练模型和第二预训练模型,对待训练模型进行训练,从而得到目标模型。那么,第一预训练模型与目标模型所构成的模型可用于完成用户所需完成的目标任务。前述过程中,由于目标模型是基于目标任务的多个数据集、第一预训练模型以及第二预训练模型得到的,而第一预训练模型为与目标任务最匹配的模型,第二预训练模型为评估值最高的模型或评估值最低的模型,可见,在获取最终模型(由第一预训练模型与目标模型构成)的过程中,不仅考虑了预训练模型与用户所需完成的目标任务之间的匹配度,还考虑了预训练模型在目标任务的多个数据集上的性能表现差异,所考虑的因素较为全面,以这种训练方式所得到的最终模型,可具备良好的泛化能力以及功能,有利于提高用户体验。
在一种可能实现的方式中,评估值包含第一评估值以及第二评估值,评估模块,用于基于多个数据集对多个预训练模型进行评估,得到多个预训练模型的第一评估值和多个预训练模型的第二评估值,第一评估值用于指示预训练模型所得到的多个数据集的特征之间的差异,第二评估值用指示预训练模型所得到的多个数据集的标签的预测概率之间的差异。
在一种可能实现的方式中,评估模块,用于:通过目标预训练模型对多个数据集进行处理,得到多个数据集的特征,目标预训练模型为多个预训练模型的任意一个预训练模型;
通过预置的目标预测器对多个数据集的特征进行处理,得到多个数据集的标签的预测概率;基于多个数据集的特征,确定目标预测模型的第一评估值;基于多个数据集的标签的预测概率,确定目标预测模型的第二评估值。
在一种可能实现的方式中,评估模块,用于:基于多个数据集的特征,构建多个数据集的特征的概率分布;确定多个数据集的特征的概率分布之间的未重叠部分;对未重叠部分进行计算,得到目标预测模型的第一评估值。
在一种可能实现的方式中,评估模块,用于:确定多个数据集的特征的概率分布之间的重叠部分;对重叠部分以及多个数据集的标签的预测概率进行计算,得到目标预测模型的第二评估值。
在一种可能实现的方式中,训练模块,用于:通过第一预训练模型对目标数据集进行处理,得到目 标数据集的第一特征,目标数据集为多个数据集中的任意一个数据集;通过第一待训练模型对目标数据集的第一特征进行处理,得到目标数据集的标签的第一预测概率;通过第二预训练模型对目标数据集进行处理,得到目标数据集的第二特征;通过第二待训练模型对目标数据集的第二特征进行处理,得到目标数据集的标签的第二预测概率;
基于第一特征、第二特征、第一预测概率、第二预测概率以及目标数据集的标签的真实概率,确定目标损失;基于目标损失更新第一待训练模型的参数,直至满足模型训练条件,得到目标模型。
在一种可能实现的方式中,训练模块,用于:对第一特征以及第二特征进行计算,得到第一损失,第一损失用于指示第一特征以及第二特征之间的相似度;对第一预测概率、第二预测概率以及目标数据集的标签的真实概率进行计算,得到第二损失,第二损失用于指示第一预测概率与真实概率之间的差异;基于第一损失以及第二损失,构建目标损失。
需要说明的是,上述装置各模块/单元之间的信息交互、执行过程等内容,由于与本申请方法实施例基于同一构思,其带来的技术效果与本申请方法实施例相同,具体内容可参考本申请实施例前述所示的方法实施例中的叙述,此处不再赘述。
本申请实施例还涉及一种训练设备,图9为本申请实施例提供的训练设备的一个结构示意图。如图9所示,训练设备900具体可以表现为手机、平板、笔记本电脑、智能穿戴设备、服务器等,此处不做限定。其中,训练设备900上可实现图4对应实施例中模型训练的功能。具体的,训练设备900包括:接收器901、发射器902、处理器903和存储器904(其中训练设备900中的处理器903的数量可以一个或多个,图9中以一个处理器为例),其中,处理器903可以包括应用处理器9031和通信处理器9032。在本申请的一些实施例中,接收器901、发射器902、处理器903和存储器904可通过总线或其它方式连接。
存储器904可以包括只读存储器和随机存取存储器,并向处理器903提供指令和数据。存储器904的一部分还可以包括非易失性随机存取存储器(non-volatile random access memory,NVRAM)。存储器904存储有处理器和操作指令、可执行模块或者数据结构,或者它们的子集,或者它们的扩展集,其中,操作指令可包括各种操作指令,用于实现各种操作。
处理器903控制训练设备的操作。具体的应用中,训练设备的各个组件通过总线系统耦合在一起,其中总线系统除包括数据总线之外,还可以包括电源总线、控制总线和状态信号总线等。但是为了清楚说明起见,在图中将各种总线都称为总线系统。
上述本申请实施例揭示的方法可以应用于处理器903中,或者由处理器903实现。处理器903可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器903中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器903可以是通用处理器、数字信号处理器(digital signal processing,DSP)、微处理器或微控制器,还可进一步包括专用集成电路(application specific integrated circuit,ASIC)、现场可编程门阵列(field-programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。该处理器903可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器904,处理器903读取存储器904中的信息,结合其硬件完成上述方法的步骤。
接收器901可用于接收输入的数字或字符信息,以及产生与训练设备的相关设置以及功能控制有关的信号输入。发射器902可用于通过第一接口输出数字或字符信息;发射器902还可用于通过第一接口向磁盘组发送指令,以修改磁盘组中的数据;发射器902还可以包括显示屏等显示设备。
本申请实施例中,在一种情况下,处理器903,用于通过图4对应实施例中的模型库,完成模型训练,并将得到的最终模型提供给用户设备,以使得用户通过用户设备基于最终模型完成用户所需完成的任务,即执行任务处理方法。
本申请实施例还涉及一种计算机存储介质,该计算机可读存储介质中存储有用于进行信号处理的程 序,当其在计算机上运行时,使得计算机执行如前述训练设备所执行的步骤,或者,使得计算机执行如前述训练设备所执行的步骤。
本申请实施例还涉及一种计算机程序产品,该计算机程序产品存储有指令,该指令在由计算机执行时使得计算机执行如前述执行设备所执行的步骤,或者,使得计算机执行如前述训练设备所执行的步骤。
本申请实施例提供的训练设备或终端设备具体可以为芯片,芯片包括:处理单元和通信单元,所述处理单元例如可以是处理器,所述通信单元例如可以是输入/输出接口、管脚或电路等。该处理单元可执行存储单元存储的计算机执行指令,以使执行设备内的芯片执行上述实施例描述的数据处理方法,或者,以使训练设备内的芯片执行上述实施例描述的数据处理方法。可选地,所述存储单元为所述芯片内的存储单元,如寄存器、缓存等,所述存储单元还可以是所述无线接入设备端内的位于所述芯片外部的存储单元,如只读存储器(read-only memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(random access memory,RAM)等。
具体的,请参阅图10,图10为本申请实施例提供的芯片的一个结构示意图,所述芯片可以表现为神经网络处理器NPU 1000,NPU 1000作为协处理器挂载到主CPU(Host CPU)上,由Host CPU分配任务。NPU的核心部分为运算电路1003,通过控制器1004控制运算电路1003提取存储器中的矩阵数据并进行乘法运算。
在一些实现中,运算电路1003内部包括多个处理单元(Process Engine,PE)。在一些实现中,运算电路1003是二维脉动阵列。运算电路1003还可以是一维脉动阵列或者能够执行例如乘法和加法这样的数学运算的其它电子线路。在一些实现中,运算电路1003是通用的矩阵处理器。
举例来说,假设有输入矩阵A,权重矩阵B,输出矩阵C。运算电路从权重存储器1002中取矩阵B相应的数据,并缓存在运算电路中每一个PE上。运算电路从输入存储器1001中取矩阵A数据与矩阵B进行矩阵运算,得到的矩阵的部分结果或最终结果,保存在累加器(accumulator)1008中。
统一存储器1006用于存放输入数据以及输出数据。权重数据直接通过存储单元访问控制器(Direct Memory Access Controller,DMAC)1005,DMAC被搬运到权重存储器1002中。输入数据也通过DMAC被搬运到统一存储器1006中。
BIU为Bus Interface Unit即,总线接口单元1013,用于AXI总线与DMAC和取指存储器(Instruction Fetch Buffer,IFB)1009的交互。
总线接口单元1013(Bus Interface Unit,简称BIU),用于取指存储器1009从外部存储器获取指令,还用于存储单元访问控制器1005从外部存储器获取输入矩阵A或者权重矩阵B的原数据。
DMAC主要用于将外部存储器DDR中的输入数据搬运到统一存储器1006或将权重数据搬运到权重存储器1002中或将输入数据数据搬运到输入存储器1001中。
向量计算单元1007包括多个运算处理单元,在需要的情况下,对运算电路1003的输出做进一步处理,如向量乘,向量加,指数运算,对数运算,大小比较等等。主要用于神经网络中非卷积/全连接层网络计算,如Batch Normalization(批归一化),像素级求和,对预测标签平面进行上采样等。
在一些实现中,向量计算单元1007能将经处理的输出的向量存储到统一存储器1006。例如,向量计算单元1007可以将线性函数;或,非线性函数应用到运算电路1003的输出,例如对卷积层提取的预测标签平面进行线性插值,再例如累加值的向量,用以生成激活值。在一些实现中,向量计算单元1007生成归一化的值、像素级求和的值,或二者均有。在一些实现中,处理过的输出的向量能够用作到运算电路1003的激活输入,例如用于在神经网络中的后续层中的使用。
控制器1004连接的取指存储器(instruction fetch buffer)1009,用于存储控制器1004使用的指令;
统一存储器1006,输入存储器1001,权重存储器1002以及取指存储器1009均为On-Chip存储器。外部存储器私有于该NPU硬件架构。
其中,上述任一处提到的处理器,可以是一个通用中央处理器,微处理器,ASIC,或一个或多个用于控制上述程序执行的集成电路。
另外需说明的是,以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于 一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。另外,本申请提供的装置实施例附图中,模块之间的连接关系表示它们之间具有通信连接,具体可以实现为一条或多条通信总线或信号线。
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到本申请可借助软件加必需的通用硬件的方式来实现,当然也可以通过专用硬件包括专用集成电路、专用CPU、专用存储器、专用元器件等来实现。一般情况下,凡由计算机程序完成的功能都可以很容易地用相应的硬件来实现,而且,用来实现同一功能的具体硬件结构也可以是多种多样的,例如模拟电路、数字电路或专用电路等。但是,对本申请而言更多情况下软件程序实现是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在可读取的存储介质中,如计算机的软盘、U盘、移动硬盘、ROM、RAM、磁碟或者光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,训练设备,或者网络设备等)执行本申请各个实施例所述的方法。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。
所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、训练设备或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、训练设备或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存储的任何可用介质或者是包含一个或多个可用介质集成的训练设备、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(Solid State Disk,SSD))等。

Claims (17)

  1. 一种模型训练方法,其特征在于,所述方法包括:
    获取目标任务的多个数据集;
    基于所述多个数据集对多个预训练模型进行评估,得到所述多个预训练模型的评估值,所述评估值用于指示预训练模型在所述多个数据集上的表现之间的差异;
    从所述多个预训练模型中,确定第一预训练模型和第二预训练模型,所述第一预训练模型为与所述目标任务最匹配的模型,所述第二预训练模型为评估值最高的模型或评估值最低的模型;
    基于所述多个数据集、所述第一预训练模型和所述第二预训练模型,对待训练模型进行训练,得到目标模型,所述第一预训练模型与所述目标模型所构成的模型用于完成所述目标任务。
  2. 根据权利要求1所述的方法,其特征在于,所述评估值包含第一评估值以及第二评估值,所述基于所述多个数据集对多个预训练模型进行评估,得到多个评估值包括:
    基于所述多个数据集对多个预训练模型进行评估,得到所述多个预训练模型的第一评估值和所述多个预训练模型的第二评估值,所述第一评估值用于指示预训练模型所得到的所述多个数据集的特征之间的差异,所述第二评估值用指示预训练模型所得到的所述多个数据集的标签的预测概率之间的差异。
  3. 根据权利要求2所述的方法,其特征在于,所述基于所述多个数据集对多个预训练模型进行评估,得到所述多个预训练模型的第一评估值和所述多个预训练模型的第二评估值包括:
    通过所述目标预训练模型对所述多个数据集进行处理,得到所述多个数据集的特征,所述目标预训练模型为所述多个预训练模型的任意一个预训练模型;
    通过预置的目标预测器对所述多个数据集的特征进行处理,得到所述多个数据集的标签的预测概率;
    基于所述多个数据集的特征,确定所述目标预测模型的第一评估值;
    基于所述多个数据集的标签的预测概率,确定所述目标预测模型的第二评估值。
  4. 根据权利要求3所述的方法,其特征在于,所述基于所述多个数据集的特征,确定所述目标预测模型的第一评估值包括:
    基于所述多个数据集的特征,构建所述多个数据集的特征的概率分布;
    确定所述多个数据集的特征的概率分布之间的未重叠部分;
    对所述未重叠部分进行计算,得到所述目标预测模型的第一评估值。
  5. 根据权利要求4所述的方法,其特征在于,所述基于所述多个数据集的标签的预测概率,确定所述目标预测模型的第二评估值包括:
    确定所述多个数据集的特征的概率分布之间的重叠部分;
    对所述重叠部分以及所述多个数据集的标签的预测概率进行计算,得到所述目标预测模型的第二评估值。
  6. 根据权利要求1至5任意一项所述的方法,其特征在于,所述基于所述多个数据集、所述第一预训练模型和所述第二预训练模型,对待训练模型进行训练,得到目标模型包括:
    通过所述第一预训练模型对目标数据集进行处理,得到所述目标数据集的第一特征,所述目标数据集为所述多个数据集中的任意一个数据集;
    通过所述第一待训练模型对所述目标数据集的第一特征进行处理,得到所述目标数据集的标签的第一预测概率;
    通过所述第二预训练模型对所述目标数据集进行处理,得到所述目标数据集的第二特征;
    通过所述第二待训练模型对所述目标数据集的第二特征进行处理,得到所述目标数据集的标签的第二预测概率;
    基于所述第一特征、所述第二特征、所述第一预测概率、所述第二预测概率以及所述目标数据集的标签的真实概率,确定目标损失;
    基于所述目标损失更新所述第一待训练模型的参数,直至满足模型训练条件,得到目标模型。
  7. 根据权利要求6所述的方法,其特征在于,所述基于所述第一特征、所述第二特征、所述第一预测概率、所述第二预测概率以及所述目标数据集的标签的真实概率,确定目标损失包括:
    对所述第一特征以及所述第二特征进行计算,得到第一损失,所述第一损失用于指示所述第一特征以及所述第二特征之间的相似度;
    对所述第一预测概率、所述第二预测概率以及所述目标数据集的标签的真实概率进行计算,得到第二损失,所述第二损失用于指示所述第一预测概率与所述真实概率之间的差异;
    基于所述第一损失以及所述第二损失,构建目标损失。
  8. 一种模型训练装置,其特征在于,所述装置包括:
    获取模块,用于获取目标任务的多个数据集;
    评估模块,用于基于所述多个数据集对多个预训练模型进行评估,得到所述多个预训练模型的评估值,所述评估值用于指示预训练模型在所述多个数据集上的表现之间的差异;
    确定模块,用于从所述多个预训练模型中,确定第一预训练模型和第二预训练模型,所述第一预训练模型为与所述目标任务最匹配的模型,所述第二预训练模型为评估值最高的模型或评估值最低的模型;
    训练模块,用于基于所述多个数据集、所述第一预训练模型和所述第二预训练模型,对待训练模型进行训练,得到目标模型,所述第一预训练模型与所述目标模型所构成的模型用于完成所述目标任务。
  9. 根据权利要求8所述的装置,其特征在于,所述评估值包含第一评估值以及第二评估值,所述评估模块,用于基于所述多个数据集对多个预训练模型进行评估,得到所述多个预训练模型的第一评估值和所述多个预训练模型的第二评估值,所述第一评估值用于指示预训练模型所得到的所述多个数据集的特征之间的差异,所述第二评估值用指示预训练模型所得到的所述多个数据集的标签的预测概率之间的差异。
  10. 根据权利要求9所述的装置,其特征在于,所述评估模块,用于:
    通过所述目标预训练模型对所述多个数据集进行处理,得到所述多个数据集的特征,所述目标预训练模型为所述多个预训练模型的任意一个预训练模型;
    通过预置的目标预测器对所述多个数据集的特征进行处理,得到所述多个数据集的标签的预测概率;
    基于所述多个数据集的特征,确定所述目标预测模型的第一评估值;
    基于所述多个数据集的标签的预测概率,确定所述目标预测模型的第二评估值。
  11. 根据权利要求10所述的装置,其特征在于,所述评估模块,用于:
    基于所述多个数据集的特征,构建所述多个数据集的特征的概率分布;
    确定所述多个数据集的特征的概率分布之间的未重叠部分;
    对所述未重叠部分进行计算,得到所述目标预测模型的第一评估值。
  12. 根据权利要求11所述的装置,其特征在于,所述评估模块,用于:
    确定所述多个数据集的特征的概率分布之间的重叠部分;
    对所述重叠部分以及所述多个数据集的标签的预测概率进行计算,得到所述目标预测模型的第二评估值。
  13. 根据权利要求8至12任意一项所述的装置,其特征在于,所述训练模块,用于:
    通过所述第一预训练模型对目标数据集进行处理,得到所述目标数据集的第一特征,所述目标数据集为所述多个数据集中的任意一个数据集;
    通过所述第一待训练模型对所述目标数据集的第一特征进行处理,得到所述目标数据集的标签的第一预测概率;
    通过所述第二预训练模型对所述目标数据集进行处理,得到所述目标数据集的第二特征;
    通过所述第二待训练模型对所述目标数据集的第二特征进行处理,得到所述目标数据集的标签的第二预测概率;
    基于所述第一特征、所述第二特征、所述第一预测概率、所述第二预测概率以及所述目标数据集的标签的真实概率,确定目标损失;
    基于所述目标损失更新所述第一待训练模型的参数,直至满足模型训练条件,得到目标模型。
  14. 根据权利要求13所述的装置,其特征在于,所述训练模块,用于:
    对所述第一特征以及所述第二特征进行计算,得到第一损失,所述第一损失用于指示所述第一特征以及所述第二特征之间的相似度;
    对所述第一预测概率、所述第二预测概率以及所述目标数据集的标签的真实概率进行计算,得到第二损失,所述第二损失用于指示所述第一预测概率与所述真实概率之间的差异;
    基于所述第一损失以及所述第二损失,构建目标损失。
  15. 一种模型训练装置,其特征在于,所述装置包括存储器和处理器;所述存储器存储有代码,所述处理器被配置为执行所述代码,当所述代码被执行时,所述模型训练装置执行如权利要求1至7任意一项所述的方法。
  16. 一种计算机存储介质,其特征在于,所述计算机存储介质存储有一个或多个指令,所述指令在由一个或多个计算机执行时使得所述一个或多个计算机实施权利要求1至7任一所述的方法。
  17. 一种计算机程序产品,其特征在于,所述计算机程序产品存储有指令,所述指令在由计算机执行时,使得所述计算机实施权利要求1至7任意一项所述的方法。
PCT/CN2023/141760 2022-12-26 2023-12-26 一种模型训练方法及其相关设备 Ceased WO2024140630A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP23910555.4A EP4621739A4 (en) 2022-12-26 2023-12-26 MODEL TRAINING METHOD AND ASSOCIATED DEVICE
US19/249,081 US20250322240A1 (en) 2022-12-26 2025-06-25 Model training method and related device thereof

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211675360.2 2022-12-26
CN202211675360.2A CN118262380A (zh) 2022-12-26 2022-12-26 一种模型训练方法及其相关设备

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US19/249,081 Continuation US20250322240A1 (en) 2022-12-26 2025-06-25 Model training method and related device thereof

Publications (1)

Publication Number Publication Date
WO2024140630A1 true WO2024140630A1 (zh) 2024-07-04

Family

ID=91601313

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/141760 Ceased WO2024140630A1 (zh) 2022-12-26 2023-12-26 一种模型训练方法及其相关设备

Country Status (4)

Country Link
US (1) US20250322240A1 (zh)
EP (1) EP4621739A4 (zh)
CN (1) CN118262380A (zh)
WO (1) WO2024140630A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118779625A (zh) * 2024-09-11 2024-10-15 江西省通信产业服务有限公司 基于人工智能的设备状态评估方法及系统
CN119721869A (zh) * 2025-02-26 2025-03-28 中国飞行试验研究院 基于机器学习数据处理系统预测试飞员认知能力的方法

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108197664A (zh) * 2018-01-24 2018-06-22 北京墨丘科技有限公司 模型获取方法、装置、电子设备及计算机可读存储介质
CN113283551A (zh) * 2021-07-22 2021-08-20 智者四海(北京)技术有限公司 多模态预训练模型的训练方法、训练装置及电子设备
CN114282935A (zh) * 2021-08-25 2022-04-05 腾讯科技(深圳)有限公司 一种内容推荐方法、装置、电子设备和存储介质
CN115131633A (zh) * 2022-06-14 2022-09-30 华为技术有限公司 一种模型迁移方法、装置及电子设备

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108197664A (zh) * 2018-01-24 2018-06-22 北京墨丘科技有限公司 模型获取方法、装置、电子设备及计算机可读存储介质
CN113283551A (zh) * 2021-07-22 2021-08-20 智者四海(北京)技术有限公司 多模态预训练模型的训练方法、训练装置及电子设备
CN114282935A (zh) * 2021-08-25 2022-04-05 腾讯科技(深圳)有限公司 一种内容推荐方法、装置、电子设备和存储介质
CN115131633A (zh) * 2022-06-14 2022-09-30 华为技术有限公司 一种模型迁移方法、装置及电子设备

Non-Patent Citations (1)

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

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118779625A (zh) * 2024-09-11 2024-10-15 江西省通信产业服务有限公司 基于人工智能的设备状态评估方法及系统
CN119721869A (zh) * 2025-02-26 2025-03-28 中国飞行试验研究院 基于机器学习数据处理系统预测试飞员认知能力的方法

Also Published As

Publication number Publication date
CN118262380A (zh) 2024-06-28
EP4621739A1 (en) 2025-09-24
US20250322240A1 (en) 2025-10-16
EP4621739A4 (en) 2026-04-08

Similar Documents

Publication Publication Date Title
CN112541159A (zh) 一种模型训练方法及相关设备
CN114169393B (zh) 一种图像分类方法及其相关设备
WO2024001806A1 (zh) 一种基于联邦学习的数据价值评估方法及其相关设备
US20250322240A1 (en) Model training method and related device thereof
WO2023197857A1 (zh) 一种模型切分方法及其相关设备
US20250284880A1 (en) Summary Generation Method and Related Device Thereof
US20250225405A1 (en) Action prediction method and related device therefor
WO2024160186A1 (zh) 一种模型训练方法及其相关设备
WO2023246735A1 (zh) 一种项目推荐方法及其相关设备
WO2025021142A1 (zh) 一种目标检测方法及其相关设备
WO2023185541A1 (zh) 一种模型训练方法及其相关设备
WO2025002088A1 (zh) 一种目标检测方法及其相关设备
WO2025016352A1 (zh) 一种视频评估方法及其相关设备
WO2024199404A1 (zh) 一种消费预测方法及其相关设备
WO2024179485A1 (zh) 一种图像处理方法及其相关设备
WO2023231796A1 (zh) 一种视觉任务处理方法及其相关设备
WO2025113374A1 (zh) 一种任务信息获取方法以及相关设备
US20240265256A1 (en) Model training method and related device
WO2024239927A1 (zh) 一种模型训练方法及其相关设备
WO2024175014A1 (zh) 一种图像处理方法及其相关设备
CN114821214A (zh) 一种模型处理方法和装置
WO2024235107A1 (zh) 一种物体模型旋转方法及其相关设备
WO2024260361A1 (zh) 一种表格识别方法及其相关设备
WO2024061123A1 (zh) 一种图像处理方法及其相关设备
WO2024140973A1 (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: 23910555

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2023910555

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2023910555

Country of ref document: EP

Effective date: 20250616

NENP Non-entry into the national phase

Ref country code: DE

WWP Wipo information: published in national office

Ref document number: 2023910555

Country of ref document: EP