A machine learning method and device
By constructing a concept space and training the model based on sample correlation, the problem of low model accuracy in small sample learning in meta-learning is solved and the prediction accuracy is improved.
Patent Information
- Application Number
- CN202011375881.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-30
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2040-11-30
AI Technical Summary
In small-sample learning, existing meta-learning algorithms cannot share information about samples of the same type or similar categories in different tasks, resulting in low output accuracy of the trained model.
By constructing the concept space corresponding to the data set, the model is trained based on the measurement of samples in the space, iteratively updates using the sample information in the support set and query set, extracts feature vectors and performs mapping, and calculates the distance between samples to improve the model's performance. Forecast accuracy.
The output accuracy of the model in small sample learning is improved, and the neural network is trained through the correlation between samples, making the predicted label more accurate.
Smart Images

Figure CN112801265B
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and in particular to a machine learning method and device. Background Art
[0002] Existing machine learning algorithms have excellent performance when the sample size is sufficient. However, in practical applications, due to the high cost of manual labeling and the unavailability of labels, attention has begun to be paid to solutions for few-shot learning, which requires machine learning algorithms to give reasonable prediction results even when the training samples are limited.
[0003] Meta-learning is a solution to the small sample learning problem. Meta-learning randomly samples a large number of tasks similar to the target small sample task in a training set with sufficient samples, trains a meta-model with good generalization performance, and learns on a small number of training samples of the target task, and finally obtains a prediction model suitable for the target small sample task.
[0004] However, when performing small sample learning, each update of the meta-model is based on the categories involved in the current small sample task, which may result in lower output accuracy of the trained model due to differences between the same or similar samples, or differences between samples of the same or different categories. Summary of the invention
[0005] The present application provides a machine learning method and device for constructing a concept space corresponding to a data set in small sample learning, training a model based on the measurement of the sample in the space, and obtaining a model with higher output accuracy.
[0006] In view of this, in a first aspect, the present application provides a machine learning method, characterized by comprising:
[0007] A support set and a query set are obtained, wherein the actual labels included in the samples in the support set and the query set include multiple types of information, and the multiple types of information correspond to conceptual spaces of multiple dimensions; then, the target neural network is iteratively updated at least once using the support set and the query set to obtain an updated target neural network, wherein the target neural network includes a meta-model and a conceptual space mapping model, and any update in at least one iterative update includes: taking at least one support sample in the support set as an input to the meta-model to obtain at least one set of first feature vectors, and taking at least one query sample in the query set as an input to the meta-model to obtain at least one set of second feature vectors, and the meta-model is used to extract features of the input samples; through the conceptual space mapping model, Map at least one group of first feature vectors to a concept space of multiple dimensions to obtain at least one group of third feature vectors, and map at least one group of second feature vectors to a concept space of multiple dimensions to obtain at least one group of fourth feature vectors; obtain the distance between at least one query sample and at least one support sample in the concept space of multiple dimensions based on at least one group of third feature vectors and at least one group of fourth feature vectors; obtain a predicted label for at least one query sample based on the distance between at least one query sample and at least one support sample; obtain a loss value for at least one query sample based on the predicted label of at least one query sample; update the target neural network based on the loss value of at least one query sample to obtain the target neural network updated in the current iteration.
[0008] Therefore, in the embodiment of the present application, a concept space can be constructed based on the samples included in the support set and the query set, and the samples can be mapped to the concept space of each dimension, and then the distance between the samples in the concept space can be used to train the target neural network. The distance can represent the degree of association between the samples, so that in the process of training the target neural network, the training can be performed based on the degree of association between the samples, so that the output accuracy of the target neural network obtained in the end is higher.
[0009] In a possible implementation, the target neural network also includes a probability prediction model, which is used to calculate the correlation between the sample corresponding to the input vector and multiple dimensions. The above method may also include: using at least one group of first feature vectors as input to the probability prediction model, outputting at least one group of first probability vectors, and using at least one group of second feature vectors as input to the probability prediction model, outputting at least one group of second probability vectors, the probability prediction model is used to calculate the correlation between the sample corresponding to the input vector and multiple dimensions, and at least one group of first probability vectors and at least one group of second probability vectors are used to obtain at least one query sample to obtain a predicted label.
[0010] Therefore, in the implementation manner of the present application, the probability prediction model can also be used to predict the correlation between the sample and multiple dimensions, and the predicted label can be obtained based on the correlation, so that the process of obtaining the predicted label refers to the correlation between the sample and multiple dimensions, and the obtained predicted label is more accurate.
[0011] In a possible implementation, the multiple types of information include information of multiple classifications of samples in the support set and the query set, and obtaining a predicted label for at least one query sample based on the distance between at least one query sample and at least one supporting sample may include: calculating the weights corresponding to the distances between the first query sample and each supporting sample in the at least one supporting sample based on the first probability vector corresponding to the first query sample and at least one group of first probability vectors, where the first query sample is any one of the at least one query sample; calculating the probability that the category of the first query sample is multiple categories based on the distance between the first query sample and at least one supporting sample, and the weights corresponding to the distances between the first query sample and each supporting sample in the at least one supporting sample, to obtain a predicted label for the first query sample.
[0012] In the implementation manner of the present application, a specific method for obtaining a prediction label through a probability vector is provided, so that the process of obtaining the prediction label refers to the correlation between the sample and multiple dimensions, and the obtained prediction label is more accurate.
[0013] In a possible implementation, according to the distance between the first query sample and at least one supporting sample, and the weights corresponding to the distance between the first query sample and each supporting sample in the at least one supporting sample, the probability that the category of the first query sample is a plurality of categories is calculated to obtain a predicted label of the first query sample, which may include: according to the second probability vector of the first query sample and the first probability vector of the at least one supporting sample, obtaining the weight of the distance between the first query sample and the at least one supporting sample in each dimensional concept space in a plurality of dimensions; performing a weighted operation on the distance between the first query sample and the at least one supporting sample according to the weight to obtain a first distance sum; determining a supporting sample classified as a first category from at least one supporting sample, the first category being any category among the plurality of categories; performing a weighted operation on the distance between the first query sample and the supporting sample classified as the first category according to the weight to obtain a second distance sum; and calculating a predicted probability of the first query sample being classified as the first category according to the first distance sum and the second distance sum, wherein the predicted probability is used to obtain a predicted label.
[0014] Therefore, in the implementation of the present application, the weight corresponding to the distance can be combined to calculate the probability that the predicted category of the query sample is each category, so as to obtain the predicted label of the query sample, and the obtained predicted label is more accurate.
[0015] In a possible implementation, the multiple types of information include information of multiple classifications of samples in the support set and the query set, and the target neural network further includes a comparison aggregation model, which is used to obtain the relationship between the attributes and categories of the samples corresponding to the input vectors;
[0016] The above method may also include: extracting multiple groups of sample subsets from the support set, each group of sample subsets includes at least three samples, and the three samples include at least two samples of different categories; using the first feature vector of each sample in the multiple groups of sample subsets as the input of the comparative aggregation model to obtain an aggregation vector, the aggregation vector includes the attributes of the samples in the support set and the association relationship between the categories, and the aggregation vector is used to obtain the prediction label.
[0017] Therefore, in an embodiment of the present application, multiple groups of sample subsets can be extracted from the support set, each group of sample subsets includes at least samples of different categories and samples of the same or similar categories, so as to obtain an aggregation vector for representing the association between the attributes of the sample and the category, so that when predicting the label of the sample later, the aggregation vector can be referred to to obtain a more accurate prediction label.
[0018] In a possible implementation, the comparative aggregation model includes a first fully connected layer and a second fully connected layer, and the first feature vector of each sample in multiple groups of sample subsets is used as an input of a preset comparative aggregation model to obtain an aggregation vector, which may include: inputting the first feature vectors of multiple groups of sample subsets into the first fully connected layer to obtain multiple groups of fifth feature vectors; summing the multiple groups of fifth feature vectors to obtain a feature vector sum; and using the feature vector sum as the input of the second fully connected layer to obtain an aggregation vector.
[0019] Therefore, in an embodiment of the present application, the comparison aggregation model may specifically include at least two fully connected layers, providing a specific structure of a comparison aggregation model, and outputting the association relationship between the attributes and categories of the samples through the fully connected layers.
[0020] In a possible implementation, the actual labels of the samples in the support set and the query set include multiple categories and multiple attributes, the multiple categories are associated with the multiple attributes, the multiple dimensions are dimensions corresponding to each attribute of the samples in the support set and the query set, or the multiple dimensions are dimensions corresponding to each category of the samples in the support set and the query set.
[0021] Therefore, in the implementation manner of the present application, when the label of the sample includes categories and attributes, the concept space can be constructed based on the categories, or based on the attributes, or based on both categories and attributes at the same time, so that the target neural network can be subsequently trained based on the measurement of the sample in the concept space, thereby combining the differences and connections between the samples to train the target neural network, making the output accuracy of the target neural network higher.
[0022] In a second aspect, the present application provides a machine learning device, comprising:
[0023] An acquisition module is used to acquire a support set and a query set. The actual labels included in the samples in the support set and the query set include multiple types of information. The multiple types of information correspond to concept spaces of multiple dimensions.
[0024] A training module is used to perform at least one iterative update on a target neural network using a support set and a query set to obtain an updated target neural network, wherein the target neural network includes a meta-model and a concept space mapping model, and any one of the at least one iterative updates includes: taking at least one support sample in the support set as an input of the meta-model to obtain at least one set of first feature vectors, and taking at least one query sample in the query set as an input of the meta-model to obtain at least one set of second feature vectors, wherein the meta-model is used to extract features of the input samples; mapping at least one set of first feature vectors to a concept space of multiple dimensions through the concept space mapping model to obtain at least one set of third feature vectors, and mapping at least one set of second feature vectors to a concept space of multiple dimensions to obtain at least one set of fourth feature vectors; obtaining a distance between at least one query sample and at least one support sample in the concept space of multiple dimensions according to at least one set of third feature vectors and at least one set of fourth feature vectors; obtaining a predicted label for at least one query sample according to the distance between at least one query sample and at least one support sample; obtaining a loss value of at least one query sample according to the predicted label of at least one query sample; updating the target neural network according to the loss value of at least one query sample to obtain the target neural network after the current iterative update.
[0025] In a possible implementation, the target neural network further includes a probability prediction model.
[0026] The training module is also used to use at least one group of first feature vectors as input to the probability prediction model and output at least one group of first probability vectors, and to use at least one group of second feature vectors as input to the probability prediction model and output at least one group of second probability vectors. The probability prediction model is used to calculate the correlation between the samples corresponding to the input vectors and multiple dimensions. The at least one group of first probability vectors and the at least one group of second probability vectors are used to obtain at least one query sample to obtain a predicted label.
[0027] In a possible implementation, the multiple types of information include information on multiple classifications of samples in a support set and a query set, and the training module is further used to: calculate the weights corresponding to the distances between the first query sample and each supporting sample in at least one supporting sample based on a first probability vector corresponding to the first query sample and at least one group of first probability vectors, where the first query sample is any one of the at least one query sample; calculate the probability that the category of the first query sample is multiple categories based on the distance between the first query sample and at least one supporting sample, and the weights corresponding to the distances between the first query sample and each supporting sample in at least one supporting sample, to obtain a predicted label for the first query sample.
[0028] In a possible implementation, the training module is further used to: obtain the weight of the distance between the first query sample and the at least one supporting sample in each dimensional concept space of multiple dimensions based on the second probability vector of the first query sample and the first probability vector of at least one supporting sample; perform a weighted operation on the distance between the first query sample and the at least one supporting sample based on the weight to obtain a first distance sum; determine a supporting sample classified as a first category from at least one supporting sample, where the first category is any category of multiple categories; perform a weighted operation on the distance between the first query sample and the supporting sample classified as the first category based on the weight to obtain a second distance sum; and calculate the predicted probability of the first query sample being classified as the first category based on the first distance sum and the second distance sum, and the predicted probability is used to obtain a predicted label.
[0029] In a possible implementation, the multiple types of information include information of multiple classifications of samples in the support set and the query set, and the target neural network further includes a comparison aggregation model, which is used to obtain the relationship between the attributes and categories of the samples corresponding to the input vectors;
[0030] The training module is also used to: extract multiple groups of sample subsets from the support set, each group of sample subsets includes at least three samples, and the three samples include at least two samples of different categories; use the first feature vector of each sample in the multiple groups of sample subsets as the input of the comparative aggregation model to obtain an aggregation vector, the aggregation vector includes the attributes of the samples in the support set and the association relationship between the categories, and the aggregation vector is used to obtain the prediction label.
[0031] In one possible implementation, the comparative aggregation model includes a first fully connected layer and a second fully connected layer, and a training module, and is further used to: input the first feature vectors of multiple groups of sample subsets into the first fully connected layer to obtain multiple groups of fifth feature vectors; perform sum operations on the multiple groups of fifth feature vectors to obtain feature vector sum; and use the feature vector sum as input to the second fully connected layer to obtain an aggregation vector.
[0032] In a possible implementation, the actual labels of the samples in the support set and the query set include multiple categories and multiple attributes, the multiple categories are associated with the multiple attributes, the multiple dimensions are dimensions corresponding to each attribute of the samples in the support set and the query set, or the multiple dimensions are dimensions corresponding to each category of the samples in the support set and the query set.
[0033] In a third aspect, an embodiment of the present application provides a machine learning device, which has the function of implementing the machine learning method of the first aspect. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions.
[0034] In a fourth aspect, an embodiment of the present application provides a machine learning device, comprising: a processor and a memory, wherein the processor and the memory are interconnected via a line, and the processor calls the program code in the memory to execute the processing-related functions in the machine learning method shown in any one of the first aspects above. Optionally, the machine learning device can be a chip.
[0035] In the fifth aspect, an embodiment of the present application provides a machine learning device, which can also be called a digital processing chip or chip. The chip includes a processing unit and a communication interface. The processing unit obtains program instructions through the communication interface, and the program instructions are executed by the processing unit. The processing unit is used to perform functions related to processing in the above-mentioned first aspect or any optional embodiment of the first aspect.
[0036] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, comprising instructions, which, when executed on a computer, enables the computer to execute the method in the above-mentioned first aspect or any optional implementation manner of the first aspect.
[0037] In a seventh aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method in the above-mentioned first aspect or any optional implementation manner of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A schematic diagram of an artificial intelligence main framework used in this application;
[0039] Figure 2 A schematic diagram of a system architecture provided by this application;
[0040] Figure 3 Another system architecture diagram provided by this application;
[0041] Figure 4 A flowchart of a machine learning method provided in an embodiment of the present application;
[0042] Figure 5 A sample classification schematic diagram provided for an embodiment of the present application;
[0043] Figure 6 A flowchart of another machine learning method provided in an embodiment of the present application;
[0044] Figure 7 A schematic diagram of the structure of a classification network provided in an embodiment of the present application;
[0045] Figure 8 A schematic diagram of another application scenario provided for an embodiment of the present application;
[0046] Fig. 9 A flowchart of another machine learning method provided in an embodiment of the present application;
[0047] Fig.10 A schematic diagram of the structure of a machine learning device provided in an embodiment of the present application;
[0048] Fig.11 A schematic diagram of the structure of another machine learning device provided in an embodiment of the present application;
[0049] Fig.12 A schematic diagram of the structure of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0050] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0051] First, the overall workflow of the artificial intelligence system is described. Figure 1 , Figure 1 The figure shows a structural diagram of the main framework of artificial intelligence. The following is an explanation of the above artificial intelligence theme framework from the two dimensions of "intelligent information chain" (horizontal axis) and "IT value chain" (vertical axis). Among them, the "intelligent information chain" reflects a series of processes from data acquisition to processing. For example, it can be a general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, intelligent execution and output. In this process, the data has undergone a condensation process of "data-information-knowledge-wisdom". The "IT value chain" reflects the value that artificial intelligence brings to the information technology industry from the underlying infrastructure of human intelligence, information (providing and processing technology implementation) to the industrial ecology process of the system.
[0052] (1) Infrastructure
[0053] Infrastructure provides computing power support for artificial intelligence systems, enables communication with the outside world, and supports it through the basic platform. It communicates with the outside world through sensors; computing power is provided by smart chips, such as central processing units (CPU), neural-network processing units (NPU), graphics processing units (GPU), application specific integrated circuits (ASIC) or field programmable gate arrays (FPGA) and other hardware acceleration chips; the basic platform includes distributed computing frameworks and networks and other related platform guarantees and support, which can include cloud storage and computing, interconnected networks, etc. For example, sensors communicate with the outside world to obtain data, and these data are provided to the smart chips in the distributed computing system provided by the basic platform for calculation.
[0054] (2) Data
[0055] The data on the upper layer of the infrastructure is used to represent the data sources in the field of artificial intelligence. The data involves graphics, images, voice, text, and IoT data of traditional devices, including business data of existing systems and perception data such as force, displacement, liquid level, temperature, and humidity.
[0056] (3) Data processing
[0057] Data processing usually includes data training, machine learning, deep learning, search, reasoning, decision-making and other methods.
[0058] Among them, machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, and training.
[0059] Reasoning refers to the process of simulating human intelligent reasoning in computers or intelligent systems, using formalized information to perform machine thinking and solve problems based on reasoning control strategies. Typical functions are search and matching.
[0060] Decision-making refers to the process of making decisions after intelligent information is reasoned, usually providing functions such as classification, sorting, and prediction.
[0061] (4) General ability
[0062] After the data has undergone the data processing mentioned above, some general capabilities can be further formed based on the results of the data processing, such as an algorithm or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.
[0063] (5) Smart products and industry applications
[0064] Smart products and industry applications refer to the products and applications of artificial intelligence systems in various fields. They are the encapsulation of the overall artificial intelligence solution, which productizes intelligent information decision-making and realizes practical applications. Its application areas mainly include: smart terminals, smart transportation, smart medical care, autonomous driving, safe cities, etc.
[0065] The embodiments of the present application involve related applications of machine learning. In order to better understand the solutions of the embodiments of the present application, the relevant terms and concepts of machine learning that may be involved in the embodiments of the present application are first introduced below.
[0066] Machine learning: Build statistical models, use optimization methods to fit model parameters on sample data, and make predictions on new sample data.
[0067] Automatic machine learning (AutoML): refers to designing a series of advanced control systems to operate machine learning models so that the models can automatically learn appropriate parameters and configurations without human intervention. In learning models based on deep neural networks, automatic computational learning mainly includes network architecture search and global parameter setting. Among them, network architecture search is used to allow computers to generate the most suitable neural network architecture for the problem based on data, which has the characteristics of high training complexity and great performance improvement.
[0068] A machine learning task usually includes a training part and a prediction part. In the prediction part, the parameters of the statistical model can be used to predict the training sample data, and the update direction of the parameters of the statistical model can be calculated based on the prediction error. The process is repeated until the parameters converge. In the prediction part, the trained model can be used to predict new samples.
[0069] Loss function: also known as cost function, a measure of the difference between the predicted output of a machine learning model for a sample and the true value of the sample (also known as the supervised value), that is, it is used to measure the difference between the predicted output of a machine learning model for a sample and the true value of the sample. The loss function can usually include mean square error, cross entropy, logarithm, exponential loss functions, etc. For example, the mean square error can be used as a loss function, defined as The specific loss function can be selected according to the actual application scenario.
[0070] Gradient: The vector of derivatives of the loss function with respect to the parameters.
[0071] Stochastic gradient: The number of samples in machine learning is very large, so the loss function calculated each time is calculated using randomly sampled data, and the corresponding gradient is called stochastic gradient.
[0072] Back propagation (BP): An algorithm that calculates the gradient of model parameters based on the loss function and updates the model parameters.
[0073] Training: Use stochastic gradient to perform multiple rounds of iterations on sample data to fit the model parameters and reduce the value of the loss function.
[0074] Few-shot Learning: Machine learning is performed using only a small number of samples. Machine learning based on small samples is widely needed in the industry (such as scenarios with small sample sizes or high data collection costs such as face recognition or voiceprint recognition). Few-shot learning combines limited supervised information (small samples) with prior knowledge (unlabeled or weakly labeled samples, other data sets and labels, other models, etc.) so that the model can effectively learn the information in small samples.
[0075] Meta-learning: It can be understood as learning how to learn, and is a solution paradigm for small sample learning problems. Meta-learning randomly samples a large number of tasks similar to the target small sample task in a training set with sufficient samples, trains a meta-model with good generalization performance, and learns on a small number of training samples of the target task, and finally obtains a prediction model suitable for the target small sample task.
[0076] Support set: a training set in a small sample learning task. In the following implementations of this application, samples in the support set are referred to as support samples.
[0077] Query set: a validation set or test set in a small sample learning task. In the following implementations of this application, samples in the query set are referred to as query samples.
[0078] Embedding: refers to the feature representation of samples, usually the penultimate layer of a neural network.
[0079] The machine learning method provided in the embodiment of the present application can be executed on a server or on a terminal device. The terminal device can be a mobile phone with image processing function, a tablet personal computer (TPC), a media player, a smart TV, a laptop computer (LC), a personal digital assistant (PDA), a personal computer (PC), a camera, a video camera, a smart watch, a wearable device (WD) or an autonomous driving vehicle, etc., and the embodiment of the present application does not limit this.
[0080] See attached Figure 2 , the embodiment of the present application provides a system architecture 200. The system architecture includes a database 230 and a client device 240. The data acquisition device 260 is used to collect data and store it in the database 230, and the training module 202 generates a target model / rule 201 based on the data maintained in the database 230. The following will describe in more detail how the training module 202 obtains the target model / rule 201 based on the data. The target model / rule 201 is the neural network mentioned in the following embodiments of the present application. For details, refer to the following Figure 4-Figure 9 Related description in .
[0081] The calculation module may include a training module 202. The target model / rule obtained by the training module 202 may be applied to different systems or devices. Figure 2 In the embodiment, the execution device 210 is configured with a transceiver 212, which can be a wireless transceiver, an optical transceiver or a wired interface (such as an I / O interface), etc., to interact with external devices. The "user" can input data to the transceiver 212 through the client device 240. For example, in the following implementation of the present application, the client device 240 can send a target task to the execution device 210, request the execution device to build a neural network, and send a database for training to the execution device 210.
[0082] The execution device 210 can call data, codes, etc. in the data storage system 250 , and can also store data, instructions, etc. in the data storage system 250 .
[0083] The calculation module 211 processes the input data using the target model / rule 201 . Specifically, the calculation module 211 is used to: obtain a support set and a query set, the actual labels included in the samples in the support set and the query set include multiple types of information, and the multiple types of information correspond to concept spaces of multiple dimensions; use at least one support sample in the support set as the input of the meta-model to obtain at least one group of first feature vectors, and use at least one query sample in the query set as the input of the meta-model to obtain at least one group of second feature vectors, and the meta-model is used to extract the features of the input samples; through the concept space mapping model, map at least one group of first feature vectors to the concept space of multiple dimensions to obtain at least one group of third feature vectors, and map at least one group of second feature vectors to the concept space of multiple dimensions to obtain at least one group of fourth feature vectors; obtain the distance between at least one query sample and at least one support sample in the concept space of multiple dimensions according to the at least one group of third feature vectors and at least one group of fourth feature vectors; obtain the predicted label of at least one query sample according to the distance between at least one query sample and at least one support sample; obtain the loss value of at least one query sample according to the predicted label of at least one query sample; update the meta-model and the concept space mapping model according to the loss value of at least one query sample to obtain an updated meta-model and an updated concept space mapping model.
[0084] Finally, the transceiver 212 returns the constructed neural network to the client device 240 so that the neural network can be deployed in the client device 240 or other devices.
[0085] More deeply, the training module 202 can obtain corresponding target models / rules 201 for different tasks based on different data to provide users with better results.
[0086] In the attached Figure 2 In the case shown in , the data input into the execution device 210 can be determined based on the user's input data. For example, the user can operate in the interface provided by the transceiver 212. In another case, the client device 240 can automatically input data into the transceiver 212 and obtain the result. If the client device 240 automatically inputs data and needs to obtain the user's authorization, the user can set the corresponding authority in the client device 240. The user can view the results output by the execution device 210 on the client device 240, and the specific presentation form can be a specific method such as display, sound, action, etc. The client device 240 can also serve as a data collection terminal to store the collected data associated with the target task into the database 230.
[0087] The training or updating process mentioned in the present application can be performed by the training module 202. It is understandable that the training process of the neural network is to learn the way to control the spatial transformation, more specifically, to learn the weight matrix. The purpose of training the neural network is to make the output of the neural network as close to the expected value as possible. Therefore, the weight vector of each layer of the neural network in the neural network can be updated according to the difference between the predicted value and the expected value of the current network (of course, the weight vector can usually be initialized before the first update, that is, the parameters of each layer in the deep neural network are pre-configured). For example, if the predicted value of the network is too high, the value of the weight in the weight matrix is adjusted to reduce the predicted value, and after continuous adjustment, the value output by the neural network is close to or equal to the expected value. Specifically, the difference between the predicted value and the expected value of the neural network can be measured by a loss function or an objective function. Taking the loss function as an example, the higher the output value (loss) of the loss function, the greater the difference. The training of the neural network can be understood as the process of minimizing the loss as much as possible. The process of updating the weight of the starting network and training the serial network in the following embodiments of the present application can refer to this process, which will not be repeated below.
[0088] like Figure 2 As shown, the target model / rule 201 is obtained by training according to the training module 202. The target model / rule 201 may be a classification network in the present application in the embodiment of the present application, and the classification network may be a deep convolutional neural network (DCNN), a recurrent neural network (RNNS), etc. The neural network mentioned in the present application may include various types, such as a deep neural network (DNN), a convolutional neural network (CNN), a recurrent neural network (RNN), or a residual network or other neural network.
[0089] Among them, in the training stage, the database 230 can be used to store a sample set for training, and the sample set can be divided into a support sample set (support set) and a query set (query set). The support sample set includes M groups of support samples and the annotation results of each support sample, and the query set includes M groups of query samples and the annotation results of each query sample. The value of M is an integer greater than or equal to 1. The training device 220 generates a target model / rule 201 for processing samples, and iteratively trains the target model / rule 201 using the sample set in the database to obtain a mature target model / rule 201, which is specifically manifested as a neural network. The neural network obtained by the training device 220 can be applied to different systems or devices.
[0090] In the inference phase, the execution device 210 can call the data, code, etc. in the data storage system 240, or store the data, instructions, etc. in the data storage system 240. The data storage system 240 can be placed in the execution device 210, or the data storage system 240 can be an external memory relative to the execution device 210. The calculation module 211 can process the samples obtained by the execution device 210 through the neural network to obtain the prediction result. The specific expression form of the prediction result is related to the function of the neural network.
[0091] It should be noted that the attached Figure 2 This is only an exemplary schematic diagram of a system architecture provided by an embodiment of the present application, and the positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation. Figure 2 In the embodiment, the data storage system 250 is an external memory relative to the execution device 210. In other scenarios, the data storage system 250 may also be placed in the execution device 210.
[0092] The target model / rule 101 constructed according to the construction module 202 can be applied to different systems or devices, such as mobile phones, tablet computers, laptops, augmented reality (AR) / virtual reality (VR), vehicle terminals, etc., and can also be servers or cloud devices.
[0093] The target model / rule 101 in the embodiment of the present application can be the target neural network in the present application. Specifically, the target neural network provided in the embodiment of the present application can be CNN, deep convolutional neural networks (DCNN), recurrent neural network (RNN), etc.
[0094] See attached Figure 3 , the embodiment of the present application also provides a system architecture 300. The execution device 210 is implemented by one or more servers, and optionally cooperates with other computing devices, such as data storage, routers, load balancers, etc.; the execution device 210 can be arranged on a physical site, or distributed on multiple physical sites. The execution device 210 can use the data in the data storage system 250, or call the program code in the data storage system 250 to implement the following of the present application Figure 6 Corresponding steps of a deep learning training method for a computing device.
[0095] Users can operate their respective user devices (e.g., local device 401 and local device 402) to interact with execution device 210. Each local device can represent any computing device, such as a personal computer, a computer workstation, a smart phone, a tablet computer, a smart camera, a smart car or other type of cellular phone, a media consumption device, a wearable device, a set-top box, a game console, etc.
[0096] The local device of each user can interact with the execution device 210 through a communication network of any communication mechanism / communication standard, and the communication network can be a wide area network, a local area network, a point-to-point connection, or any combination thereof. Specifically, the communication network may include a wireless network, a wired network, or a combination of a wireless network and a wired network. The wireless network includes, but is not limited to: a fifth generation mobile communication technology (5th-Generation, 5G) system, a long term evolution (long termevolution, LTE) system, a global system for mobile communication (global system for mobile communication, GSM) or a code division multiple access (code division multiple access, CDMA) network, a wideband code division multiple access (wideband code division multiple access, WCDMA) network, wireless fidelity (wireless fidelity, WiFi), Bluetooth (bluetooth), Zigbee protocol (Zigbee), radio frequency identification technology (radio frequency identification, RFID), long range (Lora) wireless communication, near field communication (near field communication, NFC) in any one or more combinations. The wired network may include a fiber optic communication network or a network composed of a coaxial cable, etc.
[0097] In another implementation, one or more aspects of the execution device 210 may be implemented by each local device, for example, the local device 301 may provide local data or feedback calculation results to the execution device 210. The local device may also be referred to as a computing device.
[0098] It should be noted that all functions of the execution device 210 can also be implemented by the local device. For example, the local device 301 implements the functions of the execution device 210 and provides services to its own user, or provides services to the user of the local device 302.
[0099] In the existing meta-learning scenario, taking the classification task as an example, it is assumed that the target small sample task is to use the support set of N categories and K samples in each category for learning, and complete the prediction task on the query set of the same N categories and m samples in each category. In order to simulate the target small sample classification task, the meta-learning method samples a large number of small sample tasks in the meta-train set containing B categories as follows: first, randomly select N categories from the B categories, and then randomly extract K+m samples from the meta-training data of the N categories to obtain a small sample task data set of size N*(k+m). Among them, N*K samples are used as the support set, and N*m samples are used as the query set. During training, the meta-learning method uses the data of the support set and the meta-model to obtain a model that adapts to the small sample task (common methods include: gradient update of the meta-model; calculation of the support set class center, etc.), and then uses the task model to predict the label of the query set data and calculate the loss function to update the meta-model. The meta-model obtained in this way can use the support set to obtain a small-sample task model with the maximum accuracy likelihood estimate in the average sense in each small-sample task.
[0100] However, the learning method of existing meta-learning algorithms cannot share information about samples of the same or similar categories in different tasks. During the training process, the calculation of the loss function or distance metric is only based on the supporting data set of the current small sample task. Therefore, each update of the meta-learning model is only based on the categories involved in the current small sample task, so the samples of the same or similar categories scattered in different small sample tasks cannot share information; similarly, this task-independent learning method cannot capture the differences and connections between tasks. Unable to share information about samples of the same or similar categories in different tasks For example, during the training process, it may not be possible to capture the similar attributes of "dog" and "cake", and the similar information of "dog" scattered in different tasks. It is also impossible to capture the differences and connections between tasks. For example, the same red boots and red slippers belong to two different categories in the small sample classification task - boots and slippers, and belong to the same category - red in the small sample classification task. It is impossible to classify by shoe shape or color according to different tasks and focus on the specific information of the same sample. Therefore, when training the model, the prediction accuracy of the trained model may be low due to the inability to share information about samples of the same or similar categories in different tasks, and the inability to capture the differences and connections between tasks.
[0101] Therefore, the present application provides a machine learning method, which trains a model with higher prediction accuracy through a metric-based meta-learning method. The machine learning method provided by the present application is described in detail below.
[0102] See also Figure 4 , a flow chart of a machine learning method provided in this application is as follows.
[0103] 401. Get support set and query set.
[0104] Among them, the support set and the query set may include multiple samples, and the label values and / or attributes included in the actual labels of the multiple samples constitute multiple types of information. The multiple types can correspond to conceptual spaces of multiple dimensions, and one dimension can correspond to one type.
[0105] Specifically, the support set and the query set may include multiple support sample subsets, each sample has a corresponding actual label, and the actual label may include the type corresponding to each sample. For example, in the classification learning scenario, the actual label of each sample may include the category of the sample, or may also include the attributes of the object in the sample, etc. For another example, in the regression task learning scenario, the actual label of each sample may include the user's score.
[0106] In different scenarios, the meaning of the sample type may be different. For example, in a classification scenario, the multiple types may be sample categories or attributes related to the sample categories. For example, in a regression scenario, the multiple types may include sample values.
[0107] The following is an illustrative introduction to some specific application scenarios.
[0108] In some scenarios, the samples included in the support set and query set can be used to learn the regression task. For example, the support set and query set may include multiple users' evaluations of multiple movies or music in different dimensions, such as user 1's evaluation of movie 1 is 10 points (including 5 points for the director and 5 points for the actors), and user 2's evaluation of movie 1 is 5 points (including 3 points for the director and 2 points for the actors).
[0109] In some scenarios, the samples included in the support set and the query set can be used for classification learning. Each support sample subset can include samples of one classification. For example, Figure 5 As shown, the support set may include samples classified as “dolphin” and “cat”.
[0110] More specifically, in some classification scenarios, the sample label may include the sample category, and the multi-dimensional concept space may include a space constructed based on multiple categories, with each category corresponding to a dimensional space. For example, the sample category may include: cat, dog, tiger, bird, etc., and the constructed space includes spaces of dimensions such as cat, dog, tiger, bird, etc.
[0111] In other classification scenarios, the multi-dimensional concept space may include a space constructed based on multiple attributes. For example, the samples in the support set may include multiple categories of shoes, and the multiple attributes of the samples may include: heel height, color, toe shape, etc. The constructed multi-dimensional concept space may include a space with dimensions such as heel height, color, toe shape, etc.
[0112] Of course, in some classification scenarios, the multi-dimensional concept space may include a space constructed based on multiple categories and multiple attributes, with each dimension corresponding to a category or an attribute.
[0113] It can be understood that in the classification scenario, the multiple types mentioned above can include multiple categories or multiple attributes. For example, when the labels of the samples in the support set and the query set include categories and attributes, the space can be constructed based on the attributes of the samples, and each attribute corresponds to a dimension, resulting in a multi-dimensional conceptual space. For another example, when the labels of the samples in the support set and the query set only include categories, the space can be constructed based on the categories, and each category corresponds to a dimensional space, resulting in a multi-dimensional space.
[0114] Taking the classification task as an example, the target small sample task may include: using a support set of N categories, each of which includes k samples, to learn and complete the prediction task on the query set of the same N categories and m samples per category. For example, in order to simulate the target small sample classification task, a large number of small sample tasks are sampled in a meta-train set containing B categories as follows: first, randomly select N categories from the B categories, and then randomly extract k+m samples from the meta-training data of the N categories to obtain a small sample task data set of size N*(k+m). Among them, N*k samples are used as the support set, and N*m samples are used as the query set. If the label of each sample includes a classification, it can correspond to a concept space of N dimensions, and each dimension corresponds to a classification. If the labels corresponding to the samples of the N categories include C attributes, then the C attributes can correspond to a concept space of C dimensions, and each dimension corresponds to an attribute. Of course, in this scenario, we can also construct a space of N dimensions corresponding to N categories, or a space of C+N dimensions corresponding to C attributes and N categories.
[0115] Taking the regression task as an example, assuming that the input is x and the true objective function is y=f1(x)+f2(x), the target small sample tasks may include: each task contains a support set of k samples, completes the prediction of y on the query set of m samples, and estimates f1(·) and f2(·) respectively.
[0116] After obtaining the support set and the query set, the support set and the query set can be used for small sample learning, that is, the target neural network is trained to obtain the trained target neural network. The target neural network may include a meta-model and a concept space mapping model, the meta-model is used to extract features, and the concept space mapping model is used to map the input vector to a concept space of multiple dimensions. The process of training the neural network is described below, refer to the following steps 402-409.
[0117] 402. Use at least one support sample in the support set and at least one query sample in the query set as inputs of the meta-model to obtain at least one set of first feature vectors and at least one set of second feature vectors.
[0118] The meta-model may be a model for extracting features, such as a convolutional neural network (CNN), a fully connected network (FCN), a recurrent neural network (RNN), or a residual neural network (ResNet). For example, the input of the meta-model may be a vector or matrix of samples, and the output may be a feature vector of length d.
[0119] It should be noted that the support samples mentioned below in this application are samples in the support set, and the query samples are samples in the query set.
[0120] Therefore, by taking the samples in the support set as the input of the meta-model, the features of the support samples can be extracted and the first feature vector corresponding to the support samples can be output. Also, by taking the samples in the query set as the input of the meta-model, the features of the query samples can be extracted and the second feature vector corresponding to the query samples can be output.
[0121] For example, the input of the meta-model can be a vector or matrix of samples, and the output is a d-dimensional vector. The support set can include N*k samples. The vector of the N*K samples is used as the input of the meta-model to obtain N*k d-dimensional feature vectors.
[0122] 403. Map at least one group of first eigenvectors and at least one group of second eigenvectors to the conceptual space of the multiple dimensions through a conceptual space mapping model to obtain at least one group of third eigenvectors and at least one group of fourth eigenvectors.
[0123] The concept space mapping model can be used to map the input vector into a concept space of multiple dimensions. The concept space of multiple dimensions can be a space of multiple dimensions corresponding to the multiple types included in the support set query set. The mapping method can be a linear mapping or a nonlinear mapping. For example, the concept space mapping model can include one or more fully connected layers (FC) for linear mapping or nonlinear mapping.
[0124] Specifically, the first feature vector can be mapped to a concept space of multiple dimensions using a concept space mapping model to obtain a third feature vector, which can be used to represent the position of the first feature vector in each space after being mapped to the concept space of each dimension. The second feature vector can also be mapped to a concept space of multiple dimensions using a concept space mapping model to obtain a fourth feature vector, which can be used to represent the position of the second feature vector in each space after being mapped to the concept space of multiple dimensions.
[0125] For example, the structure of the concept space mapping model can be a fully connected layer (FC), which maps the input feature vector to a concept space of C dimensions through linear mapping. For example, the input of the concept space mapping model can be a d-dimensional vector output by the meta-model, and the output is a d'-dimensional feature vector. The support set can include N*k samples, and the vectors of the N*K samples are used as the input of the meta-model to obtain N*k d-dimensional feature vectors, and then the N*k d-dimensional feature vectors are used as the input of the concept space mapping model, that is, the N*k d-dimensional feature vectors are mapped to a concept space of C dimensions, and N*k d'-dimensional vectors mapped by the N*k d-dimensional feature vectors in the C-dimensional space are obtained.
[0126] 404. Obtain a distance between at least one query sample and at least one support sample in a concept space of multiple dimensions according to at least one set of third eigenvectors and at least one set of fourth eigenvectors.
[0127] After obtaining the feature vectors of the support samples and the query samples in the concept spaces of multiple dimensions respectively, the distance between each query sample and each support sample in the concept spaces of multiple dimensions is calculated.
[0128] It can be understood that after mapping the feature vectors of the query sample and the support sample to the concept space, the positions of the feature vectors of the query sample and the support sample in the concept space of each dimension can be known, so that the distance between the query sample and the support sample in the concept space of each dimension can be calculated.
[0129] For example, the Euclidean distance between the third eigenvector and all fourth eigenvectors may be calculated to obtain the distance between the query sample and all supporting samples in the concept space of multiple dimensions.
[0130] It should be noted that the process of outputting the third eigenvector and the fourth eigenvector in the present application can be understood as two paths. One path is to input the supporting sample into the metamodel, and use the first eigenvector output by the metamodel as the input of the concept space mapping model to obtain the third eigenvector. The other path is to input the query sample into the metamodel, and use the second eigenvector output by the metamodel as the input of the concept space mapping model to obtain the fourth eigenvector. These two paths can be carried out simultaneously or successively. The present application is only illustrative of the simultaneous implementation as an example, and is not intended to be limiting. The specific implementation can be adjusted according to the actual application scenario.
[0131] 405. Obtain a predicted label for at least one query sample according to a distance between at least one query sample and at least one support sample.
[0132] After obtaining the distance between each query sample and each support sample in the concept space of each dimension, the label of the query sample can be predicted based on the distance to obtain the predicted label. It can be understood that the correlation between the query sample and each support sample can be determined based on the distance. Generally, the closer the distance, the higher the correlation, and the farther the distance, the lower the correlation, so that the predicted label of the query sample can be obtained.
[0133] For example, each dimension can represent a category, and based on the distance between the query sample and all supporting samples in each category, it can be calculated which category of supporting samples the query sample is closest to, so that the category with the closest distance is used as the predicted label of the query sample.
[0134] For another example, each dimension can represent an attribute, and each category has a corresponding range in each attribute. Based on the distance between the query sample and all supporting samples in each category, the correlation between the query sample and the supporting samples in each space can be calculated. Then, based on the calculated correlation, the attribute range with the highest correlation with the query sample is determined, and then compared with the attribute ranges of each category to determine the category closest to the query sample, that is, the predicted label.
[0135] More specifically, for example, the distance between the query sample and all supporting samples can be weighted, and then the natural exponents of the weighted values can be taken and summed, with the sum being used as the denominator. The distance between the query sample and a certain category of supporting samples can then be weighted, the natural exponents can be taken and summed, with the sum being used as the numerator. The probability that the query sample is classified into the multiple categories can then be obtained, and the category with the largest probability value can be taken as the predicted label for the query sample.
[0136] 406. Obtain a loss value of at least one query sample according to the predicted label of at least one query sample.
[0137] Among them, after obtaining the predicted label of the query sample, the loss value between the predicted label of the query sample and the query label can be calculated.
[0138] Specifically, the loss value can be calculated using algorithms such as mean square error, cross entropy or mean absolute error. For example, the label of the sample may include information such as category and attribute, and the loss function that can be used is the cross entropy between the predicted category and the true category of the query sample, and the sum of the cross entropy between the predicted concept label of the query sample and the true concept label.
[0139] 407. Update the meta-model and the concept space mapping model according to the loss value of at least one query sample to obtain an updated meta-model and an updated concept space mapping model.
[0140] After obtaining the loss value of the query sample, the target neural network can be updated, that is, the meta-model and the concept space mapping model are updated to obtain an updated meta-model and an updated concept space mapping model.
[0141] Specifically, the machine learning method provided in the present application can be applied to classification models or regression models, etc. The meta-model and the concept space mapping model can be partial models in the classification model or regression model. The classification model or regression model can also include other models or network layers, such as output layer, fully connected layer, etc., which can be adjusted according to the actual application scenario.
[0142] More specifically, there are many ways to update the model, such as calculating the gradient of the loss function of the small sample classification task on the query set, and then updating the parameters of the meta-model, the concept space mapping model, etc. For example, the update can be performed through the back propagation (BP) algorithm, and the size of the parameters in the initial model is corrected during the training process, so that the error loss of the model becomes smaller and smaller. Furthermore, the forward transmission of the input signal until the output will generate error loss, and the parameters in the initial model are updated by back-propagating the error loss information, so that the error loss converges. The back propagation algorithm is a back propagation movement dominated by error loss, which aims to obtain the optimal model parameters, such as the optimal weight matrix.
[0143] 408. Determine whether to terminate the iteration. If so, execute step 409; if not, execute step 402.
[0144] After an iterative update of the model, it can be determined whether the termination condition is met. If the termination condition is met, the iteration can be terminated, that is, step 409 is executed. If the termination condition is not met, step 402 can be continued, that is, the features of the support samples and the query samples are extracted again and used as the input of the meta-model obtained in the current iteration, etc.
[0145] Specifically, the termination condition may include but is not limited to one or more of the following: the iteration duration exceeds the preset duration, the loss value is less than the preset loss value, the number of iterations exceeds the preset number, or the difference between the output accuracy of the model obtained in the current iteration and the output accuracy of the model obtained in the previous or multiple iterations is less than the preset difference, etc.
[0146] 409. Terminate the iteration.
[0147] Among them, after the termination condition is met, the iteration process can be terminated and the model obtained in the current iteration is output.
[0148] Generally, the machine learning method provided in the present application can be applied to a classification model or a regression model, etc. After the meta-model and the concept space mapping model are updated, the final classification model or regression model can be output.
[0149] Therefore, in the implementation of the present application, a multi-dimensional concept space can be constructed based on various types of information of samples of the query set and the support set, and then the features of the query sample and the support sample can be extracted and mapped to the concept space, and then the distance between the query sample and the support sample in the concept space of each dimension can be calculated, and the prediction label of the query sample can be obtained based on the distance. Among them, the distance between the query sample and the support sample in the concept space of each dimension can be used to represent the correlation between the query sample and the type corresponding to each dimension, reflecting the difference or connection between the samples, so that the prediction label of the query sample can be generated based on the difference and connection between the query sample and the support sample and machine learning can be performed, so that the final model refers to the correlation between the samples, and the output accuracy of the model is improved.
[0150] The above describes the process of the machine learning method provided in the present application. The following describes the process of the machine learning method provided in the present application in more detail in combination with a specific scenario for classification learning.
[0151] See also Figure 6 , a flow chart of another machine learning method provided in this application is described as follows.
[0152] 601. Obtain a support set and a query set.
[0153] 602. Use at least one support sample in the support set and at least one query sample in the query set as inputs of the meta-model to obtain at least one set of first feature vectors and at least one set of second feature vectors.
[0154] 603. Map at least one group of first eigenvectors and at least one group of second eigenvectors to the conceptual space of the multiple dimensions through a conceptual space mapping model to obtain at least one group of third eigenvectors and at least one group of fourth eigenvectors.
[0155] 604. Obtain a distance between at least one query sample and at least one support sample in a concept space of multiple dimensions according to at least one set of third eigenvectors and at least one set of fourth eigenvectors.
[0156] Among them, steps 601-604 are similar to the aforementioned steps 401-404 and will not be repeated here.
[0157] 605. Use at least one group of first feature vectors and at least one group of second feature vectors as inputs of a probability prediction model, and output at least one group of first probability vectors and at least one group of second probability vectors.
[0158] The target neural network may also include a probability prediction model for calculating the correlation between the sample corresponding to the input vector and the aforementioned multiple dimensions.
[0159] After obtaining the third eigenvector corresponding to the supporting sample and the fourth eigenvector corresponding to the query sample, the third eigenvector and the fourth vector are respectively input into the probability prediction model, and the probability prediction model is used to predict the correlation between the samples corresponding to the input vectors and multiple dimensions, thereby obtaining a first probability vector and a second probability vector. The first probability vector is used to represent the correlation between the supporting sample and each dimension, and the second probability vector is used to represent the correlation between the query sample and each dimension.
[0160] Specifically, in a possible scenario, the aforementioned multiple dimensions are the dimensions of the attributes carried in the sample's label, and the first probability vector can be used to represent the degree of association between the category of the support sample and each attribute, and the second probability vector can be used to represent the degree of association between the query sample and each attribute. For example, if the categories included in the samples in the support set and the query set include cats, dogs, birds, etc., and the attributes may include information such as color, size, and body shape, then the probability vector can represent the degree of association between the category of the corresponding sample and the color, size, or body shape.
[0161] In another possible scenario, the aforementioned multiple dimensions may be the dimensions of the categories carried in the labels in the samples, and the first probability vector may represent the association between the categories of the support samples and each category, and the second probability vector may be used to represent the association between the categories of the query samples and each category. For example, if the categories of the samples in the support set and the query set may include plum blossoms, orchids, lavender, etc., the probability vector may represent the association between the categories of the corresponding samples and the categories of plum blossoms, orchids, lavender, etc.
[0162] In another possible scenario, the aforementioned multiple dimensions may be the dimensions corresponding to the categories and attributes of the labels carried in the samples, respectively. The first probability vector may represent the relationship between the category of the support sample and various categories and various attributes, and the second probability vector represents the relationship between the category of the query sample and various categories and various attributes. For example, the categories of samples in the support set and the query set may include plum blossoms, orchids, sunflowers, etc., and the attributes carried by the labels in the samples may include attributes such as petal size, petal shape, and color. Then, the first probability vector may include the degree of association between the category of the sample and plum blossoms, orchids, sunflowers, etc., and the degree of association between the category of the sample and attributes such as petal size, petal shape, and color.
[0163] It should be noted that the present application does not limit the execution order of step 604 and step 605. Step 604 may be executed first, or step 605 may be executed first, or step 604 and step 605 may be executed simultaneously. The present application only uses the example of executing step 604 first as an illustrative explanation, and is not intended to be limiting. The specific execution order may be adjusted according to the actual application scenario.
[0164] 606. Calculate the weights corresponding to the distances between the query sample and each supporting sample according to the first probability vector corresponding to the query sample and at least one group of first probability vectors.
[0165] When predicting the label of the query sample, the correlation between the query sample and various categories or attributes can be referred to, and then the weight corresponding to the distance between the query sample and each supporting sample is determined according to the correlation, so as to obtain the predicted label of the query sample more accurately.
[0166] It can be understood that the degree of influence of the distance between the query sample and each supporting sample in the concept space of each dimension on the category of the query sample can be determined by referring to the category of the sample and the degree of association between various categories or various attributes, so that more accurate prediction labels can be obtained later.
[0167] Generally, the higher the correlation, the higher the weight value corresponding to the distance between the query sample and each supporting sample in the corresponding dimension, and the lower the correlation, the lower the weight value corresponding to the distance between the query sample and each supporting sample in the corresponding dimension. For example, the probability vector of the query sample and the probability vector of all supporting samples can be element-wise multiplied, and the obtained value can be used as the weight of the distance between the query sample and all supporting samples in the concept space of multiple dimensions.
[0168] For example, the distance between the query sample and each of the N*k supporting samples can be expressed as [s1, s2, s3…sc], which respectively represent the distance between the query sample and the supporting sample in each concept space. The probability vector of the query sample can be expressed as [p1, p2, p3…pc]. The probability vector [p1, p2, p3…pc] of the query sample can be inner-producted with the N*k distances [s1, s2, s3…sc] to obtain the weights [q1, q2, q3…qc] of the distance between the query sample and the N*k supporting samples in the concept space of C dimensions.
[0169] 607. Extract multiple groups of sample subsets from the support sample set, each group of sample subset includes at least three samples, and the three samples include at least two samples of different categories.
[0170] Each sample subset includes no less than 3 samples, and the 3 samples include at least two samples of different categories. For example, a sample subset may include 3 samples, including two identical or similar samples, i.e. samples with similar properties, and two samples of different categories. For example, if the support set includes samples classified as cats, dogs, pigs, and foxes, then two samples classified as dogs and one sample classified as foxes can be selected from them to obtain a sample subset.
[0171] It should be noted that the present application does not limit the execution order of step 603 and step 607. Step 603 may be executed first, or step 607 may be executed first, or step 603 and step 607 may be executed simultaneously. The present application only uses the example of executing step 603 first as an illustrative explanation, and is not intended to be limiting. The specific execution order may be adjusted according to the actual application scenario.
[0172] 608. Use the first feature vector of each sample in the multiple groups of sample subsets as input of the comparative aggregation model to obtain an aggregation vector.
[0173] Among them, the target neural network can also include a comparative aggregation model, which is used to output the correlation between the attributes of the samples in the support set and the categories of the samples. By taking each group of sample subsets that includes at least samples of different categories as the input of the comparative aggregation model, the relationship between different categories and attributes can be obtained.
[0174] Specifically, the first eigenvectors of multiple groups of sample subsets can be input into the first fully connected layer to obtain multiple groups of fifth eigenvectors, and the multiple groups of fifth eigenvectors can be summed to obtain the eigenvector sum, and the eigenvector sum can be used as the input of the second fully connected layer to obtain the aggregation vector.
[0175] For example, multiple triplets are extracted from a support set of size N*k (a group of at least three samples). Taking each group of triplets including three samples (sample No. 1, sample No. 2 and sample No. 3) as an example, sample No. 1 and sample No. 2 are samples of the same type, and sample No. 1 and sample No. 3 are samples of different categories; or, sample No. 1 and sample No. 2 are similar samples (such as the same attribute), and sample No. 1 and sample No. 3 are samples of different attributes; or, sample No. 1 and sample No. 2 are similar samples, and sample No. 1 and sample No. 3 are samples of different categories. The meta-model outputs three d-dimensional feature vectors for the samples of the triplet respectively. The three d-dimensional feature vectors are combined into a d*3 matrix and input into the first fully connected layer to obtain a d”-dimensional vector. The d”-dimensional vectors of all triplet are summed and input into the second fully connected layer. The number of neurons included in the second fully connected layer is usually related to the number of dimensions of the concept space. For example, if a concept space of C dimensions is constructed, the second fully connected layer usually has C neurons. The output of the second fully connected layer is subjected to a soft-max operation to obtain a vector of length C, i.e., the aggregation vector. The aggregation vector represents the association between the attribute and the category of the sample. For example, the aggregation vector can be expressed as [j1, j2, …, jc]. Taking [0.1, 0.5, 0.1 … 0.1] as an example, its length is C, corresponding to the concept space of C dimensions, i.e., C types of attributes. For example, 0.1 means that the degree to which attribute 1 affects the category is marked as 0.1, 0.5 means that the degree to which attribute 2 affects the category is marked as 0.5, and so on.
[0176] It should be noted that when the sample label contains attributes and categories, the aggregation vector represents the relationship between the attributes and categories of the sample in the support set. When the sample label only contains categories, the aggregation vector can represent the relationship between the categories of the samples in the support set. For ease of understanding, this application only uses the aggregation vector to represent the relationship between the attributes and categories of the samples in the support set as an example for illustrative explanation. The following aggregation vector can also be replaced by the relationship between the categories of the samples in the support set, which will not be repeated below.
[0177] 609. According to the distance between the query sample and at least one supporting sample, the weights corresponding to the distance between the query sample and each supporting sample in the at least one supporting sample, and the aggregation vector, calculate the probability that the category of the query sample is multiple categories to obtain a predicted label.
[0178] Among them, after the weight value is obtained by the above calculation, the influence of each distance value on the prediction of the category of the query sample can be determined. Combined with the aggregation vector representing the association between the category and attributes of the samples in the support set, the probability that the category of the query sample is multiple categories can be calculated, that is, the predicted label.
[0179] Specifically, based on the weights corresponding to the distances between the query sample and each of the support samples in the at least one support sample, a weighted operation can be performed on the distance between the query sample and the at least one support sample to obtain a first distance sum. A support sample classified into any category (the first category is taken as an example here) is determined from the at least one support sample, and a weighted operation is performed on the distance between the query sample and the support sample classified into the first category according to the weight to obtain a second distance sum, wherein the difference between calculating the second distance sum and calculating the first distance sum is that in the weighted operation process when calculating the second distance sum, the weight is not only derived from the weight calculated in the aforementioned step 606, but also combined with the weight of each attribute in the aggregate vector, thereby obtaining the second distance sum. Subsequently, the first distance sum is used as the denominator and the second distance sum is used as the numerator to obtain the probability value that the category of the query sample is the first category.
[0180] For example, a weighted operation is performed on the distances [s1, s2, s3...sc] between the query sample and the N*k supporting samples, and the weights are expressed as [q1, q2, q3...qc] to obtain the first distance and S1. A weighted operation is performed on the distances between the query sample and the k supporting samples of each category to obtain N second distances and S2. The difference is that in addition to [q1, q2, q3...qc], the weight value also adds an aggregation vector [j1, j2,..., jc] as the weight to calculate S2. Then use S1 as the denominator and N S2 as the numerator to obtain N probability values, that is, the probability of the query sample being each of the N categories, thereby obtaining the predicted label of the query sample. Alternatively, the category corresponding to the maximum probability value is selected from the N categories as the predicted label of the query sample. For a more specific example, the calculation method for the probability that the sample category belongs to category y can be expressed as:
[0181]
[0182]
[0183] Θ={φ,L c ,κ,v}
[0184] Among them, S represents the support set, y represents one of the categories, φ represents the output of the meta-model, and L c (c=1,...,C) is the output of the concept space mapping model, κ is the output of the probability prediction model, represents the value of the sample x output in the cth dimension, v represents the output of the comparative aggregation model, v(S) c Represents the value at the cth position in the C dimensions represented by the aggregate vector.
[0185] Therefore, in the implementation manner of the present application, the degree of association between categories or the degree of association between categories and attributes can be combined to predict the label of the sample. Compared with using independent samples for prediction, the method provided in the present application can improve the accuracy of the obtained predicted label.
[0186] 610. Calculate the loss between the predicted label and the actual label of the query sample.
[0187] After obtaining the aggregation vector and the predicted label of the query sample, the loss value between the predicted label and the actual label of the query sample can be calculated in combination with the aggregation vector.
[0188] Specifically, the loss value can be calculated using algorithms such as mean square error, cross entropy or mean absolute error. For example, the label of the sample may include information such as category and attribute. The loss function that can be used is the cross entropy between the predicted category and the true category of the query sample, and the sum of the KL divergence between the predicted concept label of the query sample and the true concept label. The concept label is the label that includes the attributes of the sample. For example, the maximum value can be selected from the probability vector [p1, p2, p3...pc] corresponding to the query sample as the predicted concept label of the query sample.
[0189] It should be noted that steps 610 to 613 in the embodiment of the present application are similar to the aforementioned steps 407 to 409 and will not be repeated here.
[0190] 611. Update meta-model, concept space mapping model, probability prediction model and comparison aggregation model.
[0191] In addition to updating the meta-model and the concept space mapping model, the probability prediction model and the comparison aggregation model can also be updated, so that the correlation between the attributes and categories output by the probability prediction model, as well as the attributes that affect the categories, can be combined to output more accurate prediction results.
[0192] It can be understood that the machine learning method provided in this application can be applied to a classification network, which may include a metamodel, a concept space mapping model, a probability prediction model, a comparison aggregation model, and an output module. Usually, the parameters of the metamodel, the concept space mapping model, the probability prediction model, and the comparison aggregation model are related to the sample types of the support set and the query set. Therefore, the parameters of the metamodel, the concept space mapping model, the probability prediction model, and the comparison aggregation model can be updated through the support set and the query set, and the calculation method of the output module can be a pre-set method, and there is no need to update the parameters. Of course, in some scenarios, the output module can also be updated, and it can be adjusted according to the actual application scenario.
[0193] 612. Determine whether to terminate the iteration. If so, execute step 613; if not, execute step 602.
[0194] Among them, step 612 can refer to the aforementioned step 408, which will not be repeated here.
[0195] 613. Terminate the iteration.
[0196] After the iteration is terminated, the trained classification network can be used for forward reasoning, such as predicting the category of the input sample or predicting the value of the input sample. The classification network includes the aforementioned meta-model, concept space mapping model, probability prediction model and comparison aggregation model, and can also include an output module, which is used to organize the output results of the meta-model, concept space mapping model, probability prediction model and comparison aggregation model to obtain a prediction label. The sample to be classified is used as the input of the neural network, and the meta-model can be used to extract features to obtain feature vectors. The feature vectors are mapped to the concept space of multiple dimensions through the concept space mapping model, and the concept labels corresponding to the input samples are output through the probability prediction model. Then, the output module is used to calculate the probability of the sample to be classified being each category, and then the category with the largest probability is taken as the prediction label of the sample to be classified.
[0197] Therefore, in the implementation mode of the present application, the connection between the attribute and the category or the attribute and the task, or the category and the task is established with the help of the concept space. The inherent attribute information of the sample is modeled by the concept space mapping model and the probability prediction model, and the relationship between the attribute and the category in the specific task is corrected by the comparison aggregation model, thereby combining the difference and connection between the attribute and category of the sample, so that the prediction effect of the sample is better and the output accuracy is higher. It can be understood that the connection between the attributes, categories or tasks of the sample can be established to maximize the use of small sample semantic information, thereby improving the performance of the meta-learning algorithm in multi-semantic small sample tasks. The degree of association between samples is represented by the distance between the feature vectors of the samples in the concept space, and the difference and connection between samples can be established, further improving the performance of the meta-learning algorithm in multi-semantic small sample tasks. In addition, when performing forward reasoning, no additional memory, energy consumption or time cost is required, and the accuracy of the prediction results output by forward reasoning is improved without increasing the cost required for forward reasoning.
[0198] The above describes in detail the process of the machine learning method provided in the present application. The machine learning method provided in the present application can be applied to small sample learning. The following takes the training target neural network as a classification network as an example to describe the machine learning method provided in the present application in detail.
[0199] First, see Figure 7 , a structural diagram of a classification network provided in this application.
[0200] The classification network 70 provided in the present application may include a meta-model 701 , a concept space mapping model 702 , a probability prediction model 703 , a comparison aggregation model 704 and an output module 705 .
[0201] The meta-model 701 is used to extract the features of the input samples and output feature vectors.
[0202] The concept space mapping model 702 is used to map the input vector to the concept space of each dimension and output the feature vector mapped to the concept space.
[0203] The probability prediction model 703 is used to calculate the correlation between the sample corresponding to the input vector and each dimension, and output a probability vector. For example, if each dimension corresponds to an attribute, the probability prediction model 703 can be used to calculate the correlation between the category of the sample corresponding to the input vector and each attribute. If each dimension corresponds to a category, the probability prediction model 703 can be used to calculate the correlation between the category of the sample corresponding to the input vector and each category. Generally, the probability prediction model 703 can be used to map the feature vector output by the metamodel 701 to a vector with a length of C (i.e., the number of dimensions of the concept space) and a sum of 1. The maximum value in the vector can usually be taken as the conceptual label of the sample, such as indicating that the correlation between a certain attribute pair and the category of the sample is the largest.
[0204] The comparison aggregation model 704 is used to output the relationship between the attributes and categories of all samples in the support set to obtain an aggregation vector. It can be understood that the aggregation vector can be used to represent the association between the attributes and categories of all samples in the support set. Therefore, the influence of each attribute on the identification of the sample category can be known based on the aggregation vector.
[0205] The output module 705 is used to output the predicted label of the sample, such as the classification result or regression result of the predicted sample, based on the output results of the concept space mapping model 702, the probability prediction model 703 and the comparison aggregation model 704.
[0206] For ease of understanding, the forward reasoning process of the classification network provided in this application may include the following process:
[0207] First, given a small sample target task data (the support set contains N new categories, each with k samples; the query set contains the same N categories, each with m samples), the support set data is processed in the same way as the training process of the aforementioned steps 601-608, and N*k*C d'-dimensional feature vectors and N*k C-dimensional probability vectors and an aggregation vector of length C can be obtained. Then, the sample is input to the classification network, and the predicted label of the input sample is obtained by the method mentioned in the aforementioned step 609.
[0208] For example, the following is a detailed description of an iteration process of the machine learning method provided by the present application, taking a more specific application scenario of a classification task as an example. Among them, an iteration in the machine learning method provided by the present application may include multiple stages, such as Fig. 9 As shown, they are introduced below respectively.
[0209] Phase 1: Data preparation.
[0210] Multi-semantic small sample classification task: For example, Figure 8 As shown, the support set and query set are from the UTZappos50K shoe dataset. Each image can be measured from 6 attributes: such as shoe mouth shape, heel height, insole, material, subcategory, and toe style. According to different attributes, the pictures will have different classifications, and each attribute contains 16 subcategories on average. The target small sample task is to randomly extract a certain attribute, use the support set of 5 categories under the attribute, with 1 or 5 samples in each category for learning, and complete the prediction task on the query set of the same 5 categories and 15 samples in each category. Among them, there can be many ways to classify shoes. This application distinguishes multi-semantic samples according to specific concepts. Figure 8 The results of clustering multi-semantic shoe samples according to the concepts of "category" (left) and "heel height" (right), such as casual shoes, sandals, and boots in the "category" concept space, and flat shoes, mid-heel shoes, and high-heeled shoes in the "heel height" space.
[0211] In order to simulate the target small sample classification task, a large amount of small sample task data is sampled in the meta-train set as follows: first, randomly select 1 attribute from the 6 attributes, then randomly select N = 5 categories from the 16 categories of the attribute, and randomly select k + m samples from each category to obtain a small sample task dataset of size N*(1+k). N*k samples are used as the support set, and N*m samples are used as the query set. (where k = 1 or 5, m = 15).
[0212] Phase 2: Model initialization.
[0213] Initialize the parameters in the meta-model, concept space mapping model, probability prediction model, comparison aggregation model, and output module.
[0214] The input of the meta-model is a sample vector / matrix, and the output is a feature vector of length d;
[0215] The input of the concept space mapping model is the d-dimensional output of the meta-model, and the output is a d'-dimensional feature vector. The structure is a fully connected layer. The concept space mapping model can include one or more mapping functions to map the input vector to the concept space of each dimension.
[0216] The probability prediction model is used to map the d-dimensional feature vector output by the meta-model into a vector of length C and sum to 1. The dimension with the largest value is the concept label prediction value of the corresponding sample. The structure of the probability prediction function can be a fully connected layer plus a soft-max layer.
[0217] The input of the comparative aggregation model is the support set of k samples in each of N categories. The output is a vector of length C and sum to 1. The values of the C dimensions correspond to the importance of different concepts in the current small sample task. The structure of the comparative aggregation function contains two fully connected layers and one soft-max layer.
[0218] Phase 3: Enriching semantics.
[0219] Then, based on the small sample classification task data obtained by the above sampling, the d-dimensional feature vectors obtained by the meta-model of the support set and the query set data are calculated, and the obtained N*k d-dimensional feature vectors are input into the concept space mapping function and the probability prediction function respectively. Then, each support set sample can obtain a d'-dimensional feature vector in the C-dimensional concept space and a C-dimensional probability vector.
[0220] Stage 4: Comparative aggregation.
[0221] First, triples are extracted from the support set of N*k, where samples No. 1 and No. 2 are samples of the same type, and samples No. 1 and No. 3 are samples of different types.
[0222] The triplet samples are input into the meta-model separately to obtain three d-dimensional feature vectors, which are combined into a d*3 matrix and input into the first fully connected layer to obtain a d"-dimensional vector. The d"-dimensional vectors are summed and input into another fully connected layer containing C neurons and soft-max is calculated to obtain a vector of length C, which is the output of the comparison aggregation model.
[0223] Phase 5: Loss calculation.
[0224] Calculate the distance between the query sample and the support sample in the C-dimensional concept space (the Euclidean distance between d'-dimensional feature vectors);
[0225] Multiply the probability vector of the query sample and the probability vectors of all support samples element by element to obtain the weight of the distance between the query sample and each support sample in the concept space of C dimensions;
[0226] The distance between the query sample and each support sample in the concept space of C dimensions is weighted, and the natural index is taken and summed as the denominator. The distance of the support set samples that only belong to category y (any one of the aforementioned N categories) is also calculated and weighted, and the natural index is taken and summed as the numerator. The difference from calculating the denominator is that when calculating the numerator, the output of the comparison aggregation model is also combined as a weight for weighted operation. Then, the probability that the query sample belongs to category y can be obtained, and thus the probability that the category of the query sample belongs to each category in the N categories can be obtained. The category with the largest probability value among the N categories is taken as the predicted category of the query sample.
[0227] The loss function may be selected as the cross entropy between the predicted category and the true category of the query set sample, and the sum of the KL divergence between the predicted concept label of the query set sample and the true concept label. The predicted concept label is one or more attributes corresponding to the one or more probability values with the largest value in the probability vector output by the probability prediction model.
[0228] Phase 6: Model update.
[0229] After calculating the value of the loss function, the gradient is calculated based on the value of the loss function, and the parameters of the meta-model, concept space mapping function, probability prediction function and comparison aggregation function are updated.
[0230] After one iteration is completed, if the convergence conditions are not met, such as the iteration time exceeds the preset time, the loss value is less than the preset loss value, the number of iterations exceeds the preset number, or the difference between the output accuracy of the model obtained in the current iteration and the output accuracy of the model obtained in the previous or multiple iterations is less than the preset difference, the iterative training of the classification network can be terminated.
[0231] For ease of understanding, refer to Table 1, which provides an exemplary illustration of the model accuracy obtained by the machine learning method provided in this application and the output accuracy of the models obtained by some existing training methods.
[0232] Model Output accuracy (5 categories, 1 supporting sample each) SCE-Net 32.60±0.84 ProtoNet 38.19±0.55 MetaOptNet 38.66±0.55 This application 39.19±0.57 Model Output accuracy (5 classes, 5 supporting samples each) SCE-Net 43.71±0.91 ProtoNet 46.87±0.60 MetaOptNet 46.55±0.58 This application 48.29±0.58
[0233] Table 1
[0234] Obviously, the output accuracy of the model obtained by the machine learning method provided in this application is higher, and the more small sample task data given, the more accurate the output result of the model will be, and the higher the recognition accuracy will be.
[0235] The above has introduced the method provided by the present application in detail. The following is an introduction to the device provided by the present application.
[0236] First, the present application provides a machine learning device, which can be used to execute the machine learning method provided by the present application, and the machine learning device can specifically include:
[0237] An acquisition module 1001 is used to acquire a support set and a query set, wherein the actual labels included in the samples in the support set and the query set include multiple types of information, and the multiple types of information correspond to concept spaces of multiple dimensions;
[0238] The training module 1002 is used to perform at least one iterative update on the target neural network using the support set and the query set to obtain an updated target neural network, wherein the target neural network includes a meta-model and a concept space mapping model, and any one of the at least one iterative updates includes: taking at least one support sample in the support set as the input of the meta-model to obtain at least one set of first feature vectors, and taking at least one query sample in the query set as the input of the meta-model to obtain at least one set of second feature vectors, and the meta-model is used to extract the features of the input samples; mapping at least one set of first feature vectors to a concept space of multiple dimensions through the concept space mapping model to obtain at least one set of third feature vectors, and mapping at least one set of second feature vectors to a concept space of multiple dimensions to obtain at least one set of fourth feature vectors; obtaining the distance between at least one query sample and at least one support sample in the concept space of multiple dimensions according to the at least one set of third feature vectors and at least one set of fourth feature vectors; obtaining a predicted label of at least one query sample according to the distance between at least one query sample and at least one support sample; obtaining a loss value of at least one query sample according to the predicted label of at least one query sample; updating the target neural network according to the loss value of at least one query sample to obtain the target neural network after the current iterative update.
[0239] In a possible implementation, the target neural network also includes a probability prediction model, and the training module 1002 is also used to use at least one group of first feature vectors as input to the probability prediction model and output at least one group of first probability vectors, and use at least one group of second feature vectors as input to the probability prediction model and output at least one group of second probability vectors. The probability prediction model is used to calculate the correlation between samples corresponding to the input vectors and multiple dimensions, and at least one group of first probability vectors and at least one group of second probability vectors are used to obtain at least one query sample to obtain a predicted label.
[0240] In a possible implementation, the multiple types of information include information of multiple classifications of samples in the support set and the query set, and the training module 1002 is further used to: calculate the weights corresponding to the distances between the first query sample and each supporting sample in the at least one supporting sample according to the first probability vector corresponding to the first query sample and at least one group of first probability vectors, where the first query sample is any one of the at least one query sample; calculate the probability that the category of the first query sample is multiple categories according to the distance between the first query sample and the at least one supporting sample, and the weights corresponding to the distances between the first query sample and each supporting sample in the at least one supporting sample, to obtain a predicted label for the first query sample.
[0241] In a possible implementation, the training module 1002 is further used to: obtain the weight of the distance between the first query sample and the at least one supporting sample in each dimensional concept space of multiple dimensions based on the second probability vector of the first query sample and the first probability vector of the at least one supporting sample; perform a weighted operation on the distance between the first query sample and the at least one supporting sample based on the weight to obtain a first distance sum; determine a supporting sample classified as a first category from the at least one supporting sample, where the first category is any category of multiple categories; perform a weighted operation on the distance between the first query sample and the supporting sample classified as the first category based on the weight to obtain a second distance sum; and calculate the predicted probability of the first query sample being classified as the first category based on the first distance sum and the second distance sum, and the predicted probability is used to obtain a predicted label.
[0242] In one possible implementation, the multiple types of information include information of multiple classifications of samples in the support set and the query set, and the target neural network also includes a comparative aggregation model, which is used to obtain the relationship between the attributes and categories of the samples corresponding to the input vector; the training module 1002 is also used to: extract multiple groups of sample subsets from the support set, each group of sample subsets includes at least three samples, and the three samples include at least two samples of different categories; use the first feature vector of each sample in the multiple groups of sample subsets as the input of the comparative aggregation model to obtain an aggregation vector, the aggregation vector includes the association relationship between the attributes and categories of the samples in the support set, and the aggregation vector is used to obtain a predicted label.
[0243] In one possible implementation, the comparative aggregation model includes a first fully connected layer and a second fully connected layer, and the training module 1002 is further used to: input the first feature vectors of multiple groups of sample subsets into the first fully connected layer to obtain multiple groups of fifth feature vectors; perform sum operations on the multiple groups of fifth feature vectors to obtain feature vector sum; and use the feature vector sum as input to the second fully connected layer to obtain an aggregation vector.
[0244] In a possible implementation, the actual labels of the samples in the support set and the query set include multiple categories and multiple attributes, the multiple categories are associated with the multiple attributes, the multiple dimensions are dimensions corresponding to each attribute of the samples in the support set and the query set, or the multiple dimensions are dimensions corresponding to each category of the samples in the support set and the query set.
[0245] See also Fig.11 , a structural schematic diagram of another machine learning device provided in this application is described as follows.
[0246] The machine learning device may include a processor 1101 and a memory 1102. The processor 1101 and the memory 1102 are interconnected via a line. The memory 1102 stores program instructions and data.
[0247] The memory 1102 stores the aforementioned Figure 4-Figure 9 The program instructions and data corresponding to the steps in .
[0248] Processor 1101 is used to execute the above Figure 4-Figure 9 The method steps are performed by the machine learning device shown in any embodiment.
[0249] Optionally, the machine learning device may further include a transceiver 1103 for receiving or sending data.
[0250] In an embodiment of the present application, a computer-readable storage medium is also provided, in which a program for generating a vehicle driving speed is stored. When the computer is running on a computer, the computer executes the above-mentioned Figure 4-Figure 9 The illustrated embodiments describe steps in a method.
[0251] Optionally, the aforementioned Fig.11 The machine learning device shown in is a chip.
[0252] The embodiment of the present application also provides a machine learning device, which can also be called a digital processing chip or chip. The chip includes a processing unit and a communication interface. The processing unit obtains program instructions through the communication interface. The program instructions are executed by the processing unit. The processing unit is used to execute the aforementioned Figure 4-Figure 9 The method steps are performed by the machine learning device shown in any embodiment.
[0253] The embodiment of the present application also provides a digital processing chip. The digital processing chip integrates a circuit and one or more interfaces for implementing the above-mentioned processor 1101, or the function of the processor 1101. When the digital processing chip integrates a memory, the digital processing chip can complete the method steps of any one or more of the above-mentioned embodiments. When the digital processing chip does not integrate a memory, it can be connected to an external memory through a communication interface. The digital processing chip implements the actions performed by the machine learning device in the above-mentioned embodiment according to the program code stored in the external memory.
[0254] The present application also provides a computer program product which, when executed on a computer, enables the computer to execute the above Figure 4-Figure 9 The illustrated embodiment describes the steps performed by the machine learning device in the method.
[0255] The machine learning device provided in the embodiment of the present application may 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. The processing unit may execute the computer execution instructions stored in the storage unit to enable the chip in the server to execute the above Figure 4-Figure 9 The machine learning method described in the illustrated embodiment. Optionally, 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, 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.
[0256] Specifically, the aforementioned processing unit or processor may be a central processing unit (CPU), a neural-network processing unit (NPU), a graphics processing unit (GPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC) or a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0257] For example, see Fig.12 , Fig.12 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 120, NPU 120 is mounted on the host CPU (Host CPU) as a coprocessor, and the host CPU assigns tasks. The core part of the NPU is the operation circuit 120, and the controller 1204 controls the operation circuit 1203 to extract matrix data in the memory and perform multiplication operations.
[0258] In some implementations, the operation circuit 1203 includes multiple processing units (process engines, PEs) inside. In some implementations, the operation circuit 1203 is a two-dimensional systolic array. The operation circuit 1203 can also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the operation circuit 1203 is a general-purpose matrix processor.
[0259] For example, assume there is an input matrix A, a weight matrix B, and an output matrix C. The operation circuit takes the corresponding data of matrix B from the weight memory 1202 and caches it on each PE in the operation circuit. The operation circuit takes the matrix A data from the input memory 1201 and performs matrix operation with matrix B, and the partial result or final result of the matrix is stored in the accumulator 1208.
[0260] The unified memory 1206 is used to store input data and output data. The weight data is directly transferred to the weight memory 1202 through the direct memory access controller (DMAC) 1205. The input data is also transferred to the unified memory 1206 through the DMAC.
[0261] The bus interface unit (BIU) 1210 is used for the interaction between the AXI bus and the DMAC and the instruction fetch buffer (IFB) 1209 .
[0262] The bus interface unit 1210 (BIU) is used for the instruction fetch memory 1209 to obtain instructions from the external memory, and is also used for the storage unit access controller 1205 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
[0263] DMAC is mainly used to transfer input data in the external memory DDR to the unified memory 1206 or to transfer weight data to the weight memory 1202 or to transfer input data to the input memory 1201.
[0264] The vector calculation unit 1207 includes multiple operation processing units, and further processes the output of the operation circuit when necessary, 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 feature planes, etc.
[0265] In some implementations, the vector calculation unit 1207 can store the processed output vector to the unified memory 1206. For example, the vector calculation unit 1207 can apply a linear function and / or a nonlinear function to the output of the operation circuit 1203, such as linear interpolation of the feature plane extracted by the convolution layer, and then, for example, a vector of accumulated values to generate an activation value. In some implementations, the vector calculation unit 1207 generates a normalized value, a pixel-level summed value, or both. In some implementations, the processed output vector can be used as an activation input to the operation circuit 1203, for example, for use in a subsequent layer in a neural network.
[0266] An instruction fetch buffer 1209 connected to the controller 1204 is used to store instructions used by the controller 1204;
[0267] Unified memory 1206, input memory 1201, weight memory 1202 and instruction fetch memory 1209 are all On-Chip memories. External memories are private to the NPU hardware architecture.
[0268] Among them, the operations of each layer in the recurrent neural network can be performed by the operation circuit 1203 or the vector calculation unit 1207.
[0269] The processor mentioned in any of the above can be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more processors for controlling the above Figure 4-Figure 9 The method is performed by a program of an integrated circuit.
[0270] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0271] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, 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 read-only memory (ROM), a random access memory (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 server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0272] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0273] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. 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, for example, the computer instructions may be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or a data center that includes one or more available media integrations. 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.
[0274] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0275] Finally, it should be noted that the above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A machine learning method, It is characterized in that include: Acquire a support set and a query set, wherein actual labels included in samples in the support set and the query set include multiple types of information, and the multiple types of information correspond to concept spaces of multiple dimensions; The target neural network is iteratively updated at least once using the support set and the query set to obtain an updated target neural network, wherein the target neural network includes a meta-model and a concept space mapping model, and any update in the at least one iterative update includes: taking at least one support sample in the support set as an input of the meta-model to obtain at least one set of first feature vectors, and taking at least one query sample in the query set as an input of the meta-model to obtain at least one set of second feature vectors, wherein the meta-model is used to extract features of the input samples; mapping the at least one set of first feature vectors to the concept space of the multiple dimensions through the concept space mapping model to obtain at least one set of third feature vectors, and mapping the at least one set of second feature vectors to the concept space of the multiple dimensions to obtain at least one set of third feature vectors, and mapping the at least one set of second feature vectors to the concept space of the multiple dimensions to obtain at least one set of third feature vectors. In a concept space of multiple dimensions, at least one set of fourth eigenvectors is obtained; according to the at least one set of third eigenvectors and the at least one set of fourth eigenvectors, a distance between the at least one query sample and the at least one supporting sample in the concept space of multiple dimensions is obtained; according to the distance between the at least one query sample and the at least one supporting sample, a predicted label is obtained for the at least one query sample; according to the predicted label of the at least one query sample, a loss value of the at least one query sample is obtained; according to the loss value of the at least one query sample, the target neural network is updated to obtain the target neural network after the current iteration update; the supporting sample is any one of the following: image, speech, text; the query sample is any one of the following: image, speech, text.
2. The method according to claim 1, It is characterized in that The target neural network also includes a probability prediction model, and the probability prediction model is used to calculate the correlation between the sample corresponding to the input vector and the multiple dimensions. The method also includes: The at least one group of first feature vectors is used as the input of the probability prediction model to output at least one group of first probability vectors, and the at least one group of second feature vectors is used as the input of the probability prediction model to output at least one group of second probability vectors. The probability prediction model is used to calculate the correlation between the samples corresponding to the input vectors and the multiple dimensions. The at least one group of first probability vectors and the at least one group of second probability vectors are used to obtain the predicted label for the at least one query sample.
3. The method according to claim 2, It is characterized in that The multiple types of information include information of multiple classifications of samples in the support set and the query set. The step of obtaining a predicted label for the at least one query sample according to the distance between the at least one query sample and the at least one supporting sample comprises: Calculating weights corresponding to distances between the first query sample and each supporting sample in the at least one supporting sample according to a first probability vector corresponding to a first query sample and the at least one group of first probability vectors, wherein the first query sample is any one of the at least one query sample; According to the distance between the first query sample and the at least one supporting sample, and the weights corresponding to the distances between the first query sample and each supporting sample in the at least one supporting sample, the probabilities that the category of the first query sample is a plurality of categories are calculated to obtain a predicted label of the first query sample.
4. The method according to claim 3, It is characterized in that The step of calculating the probabilities that the categories of the first query sample are the multiple categories according to the distance between the first query sample and the at least one supporting sample and the weights corresponding to the distances between the first query sample and each supporting sample in the at least one supporting sample, and obtaining the predicted label of the first query sample includes: Obtaining, according to the second probability vector of the first query sample and the first probability vector of the at least one supporting sample, a weight of the distance between the first query sample and the at least one supporting sample in each dimensional concept space of the multiple dimensions; Performing a weighted operation on the distance between the first query sample and the at least one supporting sample according to the weight to obtain a first distance sum; Determine a supporting sample classified into a first category from the at least one supporting sample, where the first category is any category among the multiple categories; Performing a weighted operation on the distance between the first query sample and the supporting samples classified into the first category according to the weight to obtain a second distance sum; A predicted probability that the first query sample is classified into the first category is calculated based on the first distance sum and the second distance sum, and the predicted probability is used to obtain the predicted label.
5. The method according to any one of claims 1 to 4, It is characterized in that The multiple types of information include information of multiple classifications of samples in the support set and the query set, and the target neural network also includes a comparative aggregation model, which is used to obtain the relationship between the attributes and categories of the samples corresponding to the input vectors; The method further comprises: Extracting multiple groups of sample subsets from the support set, each group of sample subsets includes at least three samples, and the three samples include at least two samples of different categories; The first feature vector of each sample in the plurality of sample subsets is used as an input of a comparative aggregation model to obtain an aggregation vector, wherein the aggregation vector includes an association relationship between attributes and categories of the samples in the support set, and the aggregation vector is used to obtain the predicted label.
6. The method according to claim 5, It is characterized in that The comparative aggregation model includes a first fully connected layer and a second fully connected layer. The first feature vector of each sample in the plurality of sample subsets is used as an input of the comparative aggregation model to obtain an aggregation vector, including: Inputting the first feature vectors of the plurality of groups of sample subsets into the first fully connected layer to obtain a plurality of groups of fifth feature vectors; Performing a sum operation on the multiple groups of fifth eigenvectors to obtain an eigenvector sum; The feature vector and the feature vector are used as inputs of the second fully connected layer to obtain the aggregated vector.
7. The method according to any one of claims 1 to 4, It is characterized in that The actual labels of the samples in the support set and the query set include multiple categories and multiple attributes, the multiple categories are associated with the multiple attributes, the multiple dimensions are dimensions corresponding to each attribute of the samples in the support set and the query set, or the multiple dimensions are dimensions corresponding to each category of the samples in the support set and the query set.
8. A machine learning device, It is characterized in that include: An acquisition module, used to acquire a support set and a query set, wherein the actual labels included in the samples in the support set and the query set include multiple types of information, and the multiple types of information correspond to concept spaces of multiple dimensions; A training module, used to use the support set and the query set to iteratively update the target neural network at least once to obtain an updated target neural network, wherein the target neural network includes a meta-model and a concept space mapping model, and any update in the at least one iterative update includes: taking at least one support sample in the support set as an input of the meta-model to obtain at least one group of first feature vectors, and taking at least one query sample in the query set as an input of the meta-model to obtain at least one group of second feature vectors, and the meta-model is used to extract features of the input samples; mapping the at least one group of first feature vectors to the concept space of the multiple dimensions through the concept space mapping model to obtain at least one group of third feature vectors, and mapping the at least one group of second feature vectors to In the concept space of the multiple dimensions, at least one group of fourth eigenvectors is obtained; based on the at least one group of third eigenvectors and the at least one group of fourth eigenvectors, the distance between the at least one query sample and the at least one supporting sample in the concept space of the multiple dimensions is obtained; based on the distance between the at least one query sample and the at least one supporting sample, a predicted label is obtained for the at least one query sample; based on the predicted label of the at least one query sample, a loss value of the at least one query sample is obtained; based on the loss value of the at least one query sample, the target neural network is updated to obtain the target neural network after the current iteration update; the supporting sample is any one of the following: image, speech, text; the query sample is any one of the following: image, speech, text.
9. The device according to claim 8, It is characterized in that The target neural network also includes a probability prediction model, The training module is also used to use the at least one group of first feature vectors as input to the probability prediction model and output at least one group of first probability vectors, and to use the at least one group of second feature vectors as input to the probability prediction model and output at least one group of second probability vectors. The probability prediction model is used to calculate the correlation between the samples corresponding to the input vectors and the multiple dimensions. The at least one group of first probability vectors and the at least one group of second probability vectors are used to obtain the predicted label for the at least one query sample.
10. The device according to claim 9, It is characterized in that The multiple types of information include information of multiple classifications of samples in the support set and the query set. The training module is further used for: Calculating weights corresponding to distances between the first query sample and each supporting sample in the at least one supporting sample according to a first probability vector corresponding to a first query sample and the at least one group of first probability vectors, wherein the first query sample is any one of the at least one query sample; According to the distance between the first query sample and the at least one supporting sample, and the weights corresponding to the distances between the first query sample and each supporting sample in the at least one supporting sample, the probabilities that the category of the first query sample is a plurality of categories are calculated to obtain a predicted label of the first query sample.
11. The device according to claim 10, It is characterized in that The training module is also used for: Obtaining, according to the second probability vector of the first query sample and the first probability vector of the at least one supporting sample, a weight of the distance between the first query sample and the at least one supporting sample in each dimensional concept space of the multiple dimensions; Performing a weighted operation on the distance between the first query sample and the at least one supporting sample according to the weight to obtain a first distance sum; Determine a supporting sample classified into a first category from the at least one supporting sample, where the first category is any category among the multiple categories; Performing a weighted operation on the distance between the first query sample and the supporting samples classified into the first category according to the weight to obtain a second distance sum; A predicted probability that the first query sample is classified into the first category is calculated based on the first distance sum and the second distance sum, and the predicted probability is used to obtain the predicted label.
12. The device according to any one of claims 8 to 11, It is characterized in that The multiple types of information include information of multiple classifications of samples in the support set and the query set, and the target neural network also includes a comparative aggregation model, which is used to obtain the relationship between the attributes and categories of the samples corresponding to the input vectors; The training module is also used for: Extracting multiple groups of sample subsets from the support set, each group of sample subsets includes at least three samples, and the three samples include at least two samples of different categories; The first feature vector of each sample in the plurality of sample subsets is used as an input of a comparative aggregation model to obtain an aggregation vector, wherein the aggregation vector includes an association relationship between attributes and categories of the samples in the support set, and the aggregation vector is used to obtain the predicted label.
13. The device according to claim 12, It is characterized in that The comparison aggregation model includes a first fully connected layer and a second fully connected layer, and the training module is further used for: Inputting the first feature vectors of the plurality of groups of sample subsets into the first fully connected layer to obtain a plurality of groups of fifth feature vectors; Performing a sum operation on the multiple groups of fifth eigenvectors to obtain an eigenvector sum; The feature vector and the feature vector are used as inputs of the second fully connected layer to obtain the aggregated vector.
14. The device according to any one of claims 8 to 11, It is characterized in that The actual labels of the samples in the support set and the query set include multiple categories and multiple attributes, the multiple categories are associated with the multiple attributes, the multiple dimensions are dimensions corresponding to each attribute of the samples in the support set and the query set, or the multiple dimensions are dimensions corresponding to each category of the samples in the support set and the query set.
15. A machine learning device, It is characterized in that The method comprises a processor, wherein the processor is coupled to a memory, wherein the memory stores a program, and when the program instructions stored in the memory are executed by the processor, the method according to any one of claims 1 to 7 is implemented. 16 . A computer-readable storage medium comprising a program, which, when executed by a processing unit, performs the method according to claim 1 .
17. A machine learning device, It is characterized in that The method comprises a processing unit and a communication interface, wherein the processing unit obtains program instructions through the communication interface, and when the program instructions are executed by the processing unit, the method according to any one of claims 1 to 7 is implemented.
