A training method for neural network and related equipment

By adding a second loss function in the neural network training to indicate the similarity between the prediction result and the correct result, the problem of the neural network ignoring the feature differences of multiple small sample tasks in small sample learning is solved, and the accuracy of the prediction result is improved. .

CN111950596BActive Publication Date: 2024-09-20HUAWEI TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202010680648.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-15
Publication Date
2024-09-20
Estimated Expiration
2040-07-15

AI Technical Summary

Technical Problem

In meta-learning, the prediction results output by deep learning-based neural networks in the small-sample learning process are low in accuracy, mainly because the neural network learns too much about the differences in feature dimensions of different samples in the same small-sample task, while ignoring multiple Differences in feature dimensions between small sample tasks.

Method used

In the training stage, in addition to learning the characteristics of the supporting samples, it also learns the characteristics of M groups of supporting samples. By adding a second loss function to indicate the similarity between the predicted results and the correct results, the neural network can learn multiple tasks in small sample tasks. Absolute relationships between small sample tasks.

Benefits of technology

The accuracy of the prediction results of the neural network in small sample learning is improved, so that it can not only learn the feature differences in one small sample task, but also learn the feature differences between multiple small sample tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111950596B
    Figure CN111950596B
Patent Text Reader

Abstract

The present application relates to meta-learning technology in the field of artificial intelligence, and discloses a training method for a neural network and related equipment. The method includes: inputting a first sample subset into a first neural network, generating first feature information and a first prediction result of a first query sample, generating a second prediction result of the first query sample according to the second feature information corresponding to the M groups of support samples included in the sample set, the first annotation result and the first feature information, and training the first neural network; the first loss function indicates the similarity between the first prediction result and the second annotation result, and the second loss function indicates the similarity between the first prediction result and the second prediction result, or indicates the similarity between the second prediction result and the second annotation result. At the same time, the difference in feature dimensions between different samples in a small sample task and the difference in feature dimensions between samples of multiple categories corresponding to multiple small sample tasks are learned to improve the accuracy of the prediction results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence, and in particular to a training method for a neural network and related equipment. Background Art

[0002] Artificial Intelligence (AI) is the use of computers or computer-controlled machines to simulate, extend and expand human intelligence. AI includes the study of the design principles and implementation methods of various intelligent machines, so that machines have the functions of perception, reasoning and decision-making. At present, few-shot learning of neural networks based on deep learning is a feasible research direction of AI.

[0003] Meta-learning is an important branch of small-sample learning research. The main idea of ​​meta-learning is to train the neural network by using a large number of small-sample tasks similar to the target small-sample task when the target task has few training samples, so that the trained neural network has a good initial value on the target task, and then use a small number of training samples of the target small-sample task to adjust the trained neural network.

[0004] However, the accuracy of the prediction results output by the neural network is still low. Therefore, a training scheme that can improve the accuracy of the prediction results output by the neural network under the premise of using meta-learning for training is urgently needed. Summary of the invention

[0005] The embodiments of the present application provide a training method and related equipment for a neural network. During the training process of a small sample task, not only the characteristics of supporting samples in a small sample task are learned, but also the characteristics of M groups of supporting samples are learned. That is, the neural network can not only learn the relative relationship within a small sample task in a small sample learning, but also learn the absolute relationship between multiple small sample tasks, thereby improving the accuracy of the output prediction results.

[0006] To solve the above technical problems, the present application provides the following technical solutions:

[0007] In the first aspect, the embodiment of the present application provides a training method for a neural network, which can be used in the field of meta-learning in the field of artificial intelligence. The method includes: a training device obtains a first sample subset from a sample set, the sample set includes M groups of support samples and M groups of query samples, and the first sample subset includes a first support sample and a first query sample; the training device also obtains the annotation result of each first support sample. The training device inputs the first sample subset and the annotation result of each first support sample into the first neural network, the first neural network generates the first feature information of the first query sample, and obtains the first prediction result corresponding to the first query sample output by the first neural network, the first prediction result is generated according to the similarity between the feature information of the first support sample and the first feature information and the annotation result of each first support sample. The training device generates a second prediction result corresponding to the first query sample according to the M second feature information corresponding to the M groups of support samples, the M first annotation results corresponding to the M groups of support samples, and the first feature information of the first query sample. Each of the M second feature information indicates the feature of a group of support samples in the M groups of support samples, and each of the M first annotation results indicates the correct result corresponding to a group of support samples in the M groups of support samples. The training device iteratively trains the first neural network according to the first loss function and the second loss function until the preset conditions are met. The first loss function indicates the similarity between the first prediction result and the second annotation result, and the second loss function indicates the similarity between the first prediction result and the second prediction result, or the second loss function indicates the similarity between the second prediction result and the second annotation result, and the second annotation result is the correct result of the first query sample. Both the first loss function and the second loss function can be a cross entropy loss function or a relative entropy loss function.

[0008] In this implementation, the neural network finally obtained learns too much about the difference in feature dimensions between different samples in the same small sample task, while ignoring the difference in feature dimensions between multiple different categories of samples corresponding to multiple different small sample tasks, resulting in a low accuracy of the prediction result output by the neural network. In order to solve the above problem, in the training phase of this scheme, in each small sample task, a second prediction result corresponding to the first query sample is generated according to the second feature information corresponding to the M group support samples, the first annotation result corresponding to the M group support samples, and the feature information of the first query sample, and a second loss function is added to indicate the similarity between the first prediction result and the second prediction result, or the similarity between the second prediction result and the correct result. Thus, the neural network can not only learn the features of the support samples in a small sample task during the training process of a small sample task, but also learn the features of the M group support samples, that is, the neural network can not only learn the differences in feature dimensions between different samples in a small sample task, but also learn the differences in feature dimensions between multiple different categories of samples corresponding to multiple different small sample tasks in a small sample learning, thereby improving the accuracy of the output prediction result.

[0009] In a possible implementation of the first aspect, after the training device inputs the first sample subset into the first neural network, the method further includes: the training device generates feature information of the first support sample through the first neural network, the first support sample is selected from the first group, and the first group is one of the M groups; the feature information of the first support sample is added to the first queue of the feature information library. Wherein, the feature information library includes M queues corresponding to the M groups of support samples one by one, the first queue is a queue corresponding to the first group among the M queues, and is used to store feature information corresponding to the support samples of the first group, and the first queue is also used to store annotation results corresponding to the support samples of the first group. Before the training device generates the second prediction result corresponding to the first query sample according to the second feature information corresponding to the M groups of support samples, the first annotation results corresponding to the M groups of support samples, and the first feature information, the method further includes: the training device obtains M second feature information corresponding to the M groups of support samples and M first annotation results corresponding to the M groups of support samples according to the feature information library.

[0010] In this implementation, the training device uses the feature information generated during each training process to generate features for each group of support samples in the M groups, thereby improving the efficiency of the training process.

[0011] In a possible implementation of the first aspect, the second queue is any queue among the M queues, and the second queue includes feature information of at least one supporting sample. The training device obtains the second feature information corresponding to the M groups of supporting samples according to the feature information library, including: the training device averages the feature information of all supporting samples included in the second queue to obtain a second feature information corresponding to the second queue. In this implementation, the second feature information corresponding to the second queue is obtained by averaging the feature information of all supporting samples included in the second queue, which is simple to operate and easy to implement.

[0012] In a possible implementation of the first aspect, when the first neural network is a neural network for regression, the method further includes: the training device adds the labeling result of each first support sample to the first queue of the feature information library. The feature information library includes M queues corresponding to M groups of support samples one by one, and the first queue is a queue corresponding to the first group among the M queues, which is used to store feature information corresponding to the support samples of the first group. The training device obtains the second feature information corresponding to the M groups of support samples according to the feature information library, including: the training device averages the feature information of all support samples included in the second queue to obtain a second feature information corresponding to the second queue. The training device obtains the first labeling result corresponding to the M groups of support samples according to the feature information library, including: the training device averages the labeling results of all support samples included in the second queue to obtain a first labeling result corresponding to the second queue, and the second queue is any queue among the M queues.

[0013] In a possible implementation manner of the first aspect, the training device may pre-set the length threshold of the second queue to be the first threshold, that is, the second queue can store at most feature information of the first threshold number of supporting samples.

[0014] In a possible implementation manner of the first aspect, the second queue adopts a first-in-first-out queue structure.

[0015] In a possible implementation of the first aspect, a training device generates a second prediction result corresponding to a first query sample according to second feature information corresponding to M groups of support samples, first annotation results corresponding to the M groups of support samples, and the first feature information, including: the training device performs a similarity calculation operation according to the second feature information and the first feature information to obtain first similarity information, the first similarity information indicating the similarity between the first feature information of a first query sample and the M second feature information, and the similarity between the first query sample and each group of support samples in the M groups of support samples. The training device generates a second prediction result according to the first similarity information and the M first annotation results.

[0016] In this implementation, the second prediction result is generated by calculating the similarity by utilizing the features of each group of support samples in the M groups of support samples and the M first annotation results corresponding to the M groups of support samples. The operation is simple and easy to implement.

[0017] In a possible implementation of the first aspect, when the first neural network is a neural network for classifying samples, the first sample subset includes N categories of first support samples, and the first prediction result indicates the predicted category of the first query sample in the N categories. The training device generates a second prediction result corresponding to the first query sample according to the second feature information corresponding to the M groups of support samples, the first annotation results corresponding to the M groups of support samples, and the feature information of the first query sample, including: the training device generates a first classification category according to the second feature information corresponding to the M groups of support samples, the first annotation results corresponding to the M groups of support samples, and the feature information of the first query sample. The first classification category indicates the predicted category of the first query sample in the M categories, and the M elements included in a first classification category are used to indicate the probability that a first query sample belongs to each category in the M categories. The training device obtains a second prediction result from the first classification category, the second prediction result indicates the predicted category of the first query sample in the N categories, and the second prediction result can be expressed as including N elements selected from the aforementioned M elements, and the selected N elements are used to indicate the probability that a first query sample belongs to each category in the N categories.

[0018] In this implementation, the training device first generates the probability that the first query sample belongs to each of the M categories based on the second feature information corresponding to the M groups of support samples, the first annotation results corresponding to the M groups of support samples, and the feature information of the first query sample, and then determines the probability that the first query sample belongs to each of the N categories based on the probability that the first query sample belongs to each of the M categories, thereby ensuring that in a small sample task, the training device learns the features of each of the M categories in the process of classifying a first query sample, so as to improve the accuracy of the output result of the trained first neural network.

[0019] In a possible implementation of the first aspect, when the first neural network is a neural network for regression, the training device generates a second prediction result based on the first similarity information and M first labeling results, including: the training device generates a weight for each of the M first labeling results based on the first similarity information, and performs weighted summation based on the weight of each first labeling result in the M first labeling results and the M first labeling results to generate a second prediction result.

[0020] In a possible implementation of the first aspect, the first neural network is a neural network that performs regression processing on samples. In this implementation, the trained first neural network can be used not only to classify samples, but also to regress samples, which expands the application scenarios of this solution.

[0021] In a possible implementation of the first aspect, the M groups are grouped based on one or more of the following: users, locations, or times corresponding to the supporting samples. In this implementation, multiple grouping bases for the M groups of supporting samples are provided in the application scenario of regression, thereby improving the implementation flexibility of this solution.

[0022] In a possible implementation manner of the first aspect, at least one first support sample included in the first sample subset comes from the same group of the M groups, and at least one first query sample included in the first sample subset comes from the same group of the M groups.

[0023] In a possible implementation of the first aspect, the first neural network is any one of the following neural networks: a fully connected neural network, a convolutional neural network, or a residual neural network. In this implementation, the first neural network can be a fully connected neural network, a convolutional neural network, or a residual neural network, which improves the implementation flexibility of this solution.

[0024] In the second aspect, the embodiment of the present application also provides a sample processing method, which can be used in the field of meta-learning in the field of artificial intelligence. The method includes: the execution device obtains a third support sample and a third query sample; the execution device inputs the third support sample and the third query sample into the first neural network, so as to output the third prediction result corresponding to the third query sample through the first neural network, and the third prediction result is generated according to the similarity between the feature information of the third support sample and the feature information of the third query sample. Wherein, the first neural network is trained according to the first loss function and the second loss function, the first loss function indicates the similarity between the prediction result output by the first neural network and the correct result, the second loss function indicates the similarity between the prediction result output by the first neural network and the second prediction result corresponding to the third query sample, or the second loss function indicates the similarity between the second prediction result and the correct result, the second prediction result is obtained according to the second feature information corresponding to the M group support sample, the correct result corresponding to the M group support sample and the feature information of the third query sample, the third support sample can be attributed to the support sample of the third group, the third query sample can be attributed to the query sample of the third group, and the third group is one of the M groups.

[0025] For the specific implementation methods of the steps in the second aspect of the embodiment of the present application and the various possible implementation methods of the second aspect, the specific meanings of the nouns in each possible implementation method, and the beneficial effects brought about by each possible implementation method, please refer to the description of the various possible implementation methods in the first aspect, and will not be repeated here one by one.

[0026] In a third aspect, the embodiment of the present application provides a training device for a neural network, which can be used in the field of meta-learning in the field of artificial intelligence. The training device for a neural network includes an acquisition module, an input module, a generation module, and a training module. Among them, the acquisition module is used to acquire a first sample subset from a sample set, the sample set includes M groups of support samples and M groups of query samples, and the first sample subset includes a first support sample and a first query sample; the input module is used to input the first sample subset into the first neural network, the first neural network generates the first feature information of the first query sample, and obtains the first prediction result corresponding to the first query sample output by the first neural network, and the first prediction result is generated according to the similarity between the feature information of the first support sample and the first feature information; the generation module is used to generate a second prediction result corresponding to the first query sample according to the second feature information corresponding to the M groups of support samples, the first annotation result corresponding to the M groups of support samples, and the first feature information of the first query sample, each of the first annotation results indicates the correct result corresponding to a group of support samples in the M groups of support samples; the training module is used to iteratively train the first neural network according to the first loss function and the second loss function until the preset conditions are met. The first loss function indicates the similarity between the first prediction result and the second annotation result, and the second loss function indicates the similarity between the first prediction result and the second prediction result, or the second loss function indicates the similarity between the second prediction result and the second annotation result, and the second annotation result is the correct result of the first query sample.

[0027] In the third aspect of the embodiment of the present application, the training device of the neural network can also be used to implement the steps performed by the training device in the various possible implementation methods of the first aspect. For the specific implementation methods of the third aspect of the embodiment of the present application and the various possible implementation methods of the third aspect, as well as the beneficial effects brought about by each possible implementation method, you can refer to the description of the various possible implementation methods in the first aspect, and will not be repeated here one by one.

[0028] In a fourth aspect, an embodiment of the present application provides a sample processing device that can be used in the field of meta-learning in the field of artificial intelligence. The sample processing device includes an acquisition module and an input module. Among them, the acquisition module is used to acquire a third support sample and a third query sample; the input module is used to input the third support sample and the third query sample into the first neural network, so as to output the third prediction result corresponding to the third query sample through the first neural network, and the third prediction result is generated according to the similarity between the feature information of the third support sample and the feature information of the third query sample. The first neural network is trained according to the first loss function and the second loss function, the first loss function indicates the similarity between the prediction result output by the first neural network and the correct result, the second loss function indicates the similarity between the prediction result output by the first neural network and the second prediction result corresponding to the third query sample, or the second loss function indicates the similarity between the second prediction result and the correct result, the second prediction result is obtained according to the second feature information corresponding to the M group support sample, the correct result corresponding to the M group support sample and the feature information of the third query sample, the third support sample can be attributed to the support sample of the third group, the third query sample can be attributed to the query sample of the third group, and the third group is one of the M groups.

[0029] In the fourth aspect of the embodiment of the present application, the training device of the neural network can also be used to implement the steps performed by the execution device in the various possible implementation methods of the second aspect. For the specific implementation methods of the fourth aspect of the embodiment of the present application and the various possible implementation methods of the fourth aspect, as well as the beneficial effects brought about by each possible implementation method, you can refer to the description of the various possible implementation methods in the second aspect, and will not be repeated here one by one.

[0030] In a fifth aspect, an embodiment of the present application provides a training device, which may include a processor, the processor and a memory are coupled, the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the training method of the neural network described in the first aspect is implemented. For the steps performed by the training device in each possible implementation method of the processor performing the first aspect, please refer to the first aspect for details, and no further description is given here.

[0031] In a sixth aspect, an embodiment of the present application provides an execution device, which may include a processor, the processor and a memory are coupled, the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the sample processing method described in the second aspect is implemented. For the steps executed by the execution device in each possible implementation method of the processor executing the second aspect, please refer to the second aspect for details, which will not be repeated here.

[0032] In a seventh aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer-readable storage medium is run on a computer, the computer executes the neural network training method described in the first aspect, or the sample processing method described in the second aspect.

[0033] In an eighth aspect, an embodiment of the present application provides a circuit system, which includes a processing circuit, and the processing circuit is configured to execute the neural network training method described in the first aspect above, or the processing circuit is configured to execute the sample processing method described in the second aspect above.

[0034] In a ninth aspect, an embodiment of the present application provides a computer program, which, when executed on a computer, enables the computer to execute the neural network training method described in the first aspect above, or enables the computer to execute the sample processing method described in the second aspect above.

[0035] In the tenth aspect, an embodiment of the present application provides a chip system, which includes a processor for supporting a training device or an execution device to implement the functions involved in the above aspects, for example, sending or processing the data and / or information involved in the above methods. In one possible design, the chip system also includes a memory, which is used to store program instructions and data necessary for a server or communication device. The chip system can be composed of chips, or it can include chips and other discrete devices. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 A schematic diagram of the structure of the artificial intelligence main framework provided in the embodiment of the present application;

[0037] Figure 2 A system architecture diagram of a sample processing system provided in an embodiment of the present application;

[0038] Figure 3 A schematic diagram of a flow chart of a neural network training method provided in an embodiment of the present application;

[0039] Figure 4 A schematic diagram of a first sample subset in a neural network training method provided in an embodiment of the present application;

[0040] Figure 5 Another schematic diagram of the first sample subset in the neural network training method provided in an embodiment of the present application;

[0041] Figure 6 A schematic diagram of a process for generating a first prediction result in a neural network training method provided in an embodiment of the present application;

[0042] Figure 7 A schematic diagram of a feature information library in a neural network training method provided in an embodiment of the present application;

[0043] Figure 8 Another schematic diagram of a flow chart of a neural network training method provided in an embodiment of the present application;

[0044] Fig. 9 A schematic diagram of another flow chart of a neural network training method provided in an embodiment of the present application;

[0045] Fig.10 A schematic diagram of a flow chart of a sample processing method provided in an embodiment of the present application;

[0046] Fig.11 A schematic diagram of the structure of a neural network training device provided in an embodiment of the present application;

[0047] Fig.12 Another structural schematic diagram of a neural network training device provided in an embodiment of the present application;

[0048] Fig.13 A schematic diagram of the structure of a sample processing device provided in an embodiment of the present application;

[0049] Fig.14 A schematic diagram of the structure of a training device provided in an embodiment of the present application;

[0050] Fig.15 A schematic diagram of the structure of an execution device provided in an embodiment of the present application;

[0051] Fig.16 A schematic diagram of the structure of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION

[0052] The embodiments of the present application provide a training method and related equipment for a neural network. During the training process of a small sample task, not only the characteristics of supporting samples in a small sample task are learned, but also the characteristics of M groups of supporting samples are learned. That is, the neural network can not only learn the relative relationship within a small sample task in a small sample learning, but also learn the absolute relationship between multiple small sample tasks, thereby improving the accuracy of the output prediction results.

[0053] The terms "first", "second", etc. 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 terms used in this way can be interchanged under appropriate circumstances. This is merely a way of distinguishing objects with the same properties when describing the embodiments of the present application. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, so that a process, method, system, product, or device that includes a series of units is not necessarily limited to those units, but may include other units that are not explicitly listed or inherent to these processes, methods, products, or devices.

[0054] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0055] 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.

[0056] (1) Infrastructure

[0057] The infrastructure provides computing power support for the artificial intelligence system, enables communication with the outside world, and is supported by the basic platform. It communicates with the outside world through sensors; computing power is provided by smart chips, as an example, the smart chip includes hardware acceleration chips such as central processing unit (CPU), neural-network processing unit (NPU), graphics processing unit (GPU), application specific integrated circuit (ASIC), field programmable gate array (FPGA); 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.

[0058] (2) Data

[0059] The data on the upper layer of the infrastructure indicates the data source 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.

[0060] (3) Data processing

[0061] Data processing usually includes data training, machine learning, deep learning, search, reasoning, decision-making and other methods.

[0062] Among them, machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, and training.

[0063] 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.

[0064] Decision-making refers to the process of making decisions after intelligent information is reasoned, usually providing functions such as classification, sorting, and prediction.

[0065] (4) General ability

[0066] 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, image classification, personalized image management, personalized battery charging management, text analysis, computer vision processing, speech recognition, etc.

[0067] (5) Smart products and industry applications

[0068] 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 application. Its application areas mainly include: smart terminals, smart manufacturing, smart transportation, smart homes, smart medical care, smart security, autonomous driving, safe cities, etc.

[0069] The embodiments of the present application are mainly applied to application scenarios in which a neural network is trained using a meta-learning technique. The trained neural network can be applied to the above-mentioned various application fields to achieve classification, regression or other functions. The processing objects of the trained neural network can be image samples, discrete data samples, text samples or voice samples, etc. As an example, in an image classification scenario, due to the wide variety of objects to be classified, the training device generally cannot guarantee that there are a large number of training samples for each category of objects. In this case, a meta-learning technique can be used to train the neural network to learn to learn, that is, to train the neural network to learn the ability of new categories of images. As another example, in a personalized image management scenario, when taking photos for a user, a smart terminal can take multiple images continuously, and select the image that best meets the user's aesthetic taste from the multiple images to display to the user. Since the aesthetic tastes of different users are different, and the training device generally cannot collect a large number of training samples for each user, a meta-learning technique can be used to train the neural network to learn the aesthetic taste of new users for images. As another example, in a personalized battery charging management scenario, the charging time can be regressed based on the discrete data of the user's mobile phone model, battery model, charging location, charging time or other data. The regression logic between the discrete data and charging time of different users may be different. The training device generally cannot collect a large number of training samples for each user. In this case, meta-learning technology can be used to train the neural network to learn the logical relationship between the discrete data and charging time of new users. In addition, the embodiments of the present application can also be applied to voice wake-up personalized management scenarios, under-screen fingerprint personalized management scenarios, etc. It should be understood that the examples given here are only for the convenience of understanding the application scenarios of the embodiments of the present application, and the application scenarios of the embodiments of the present application are not exhaustive.

[0070] Based on the above scenarios, the present application embodiment provides a neural network training method. In order to facilitate understanding of this solution, first combine Figure 2 The system architecture of the sample processing system in which the neural network training method provided in the embodiment of the present application is located is introduced. Please refer to Figure 2 , Figure 2 A system architecture diagram of a sample processing system provided in an embodiment of the present application. Figure 2 In the example, the sample processing system 200 includes an execution device 210 , a training device 220 , a database 230 and a data storage system 240 , and the execution device 210 includes a computing module 211 .

[0071] Among them, in the training stage, the database 230 is 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 sample set (query set). The support sample set includes M groups of support samples and the annotation results of each support sample, and the query sample 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.

[0072] 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.

[0073] In some embodiments of the present application, for example Figure 2 In the embodiment, the "user" can directly interact with the execution device 210, that is, the execution device 210 and the client device are integrated into the same device. Figure 2It is only a schematic diagram of the architecture of two sample processing systems provided by an embodiment of the present invention, and the positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation. In other embodiments of the present application, the execution device 210 and the client device can be independent devices, and the execution device 210 is configured with an input / output interface to interact with the client device for data. The "user" can input the collected samples to the input / output interface through the client device, and the execution device 210 returns the prediction results to the client device through the input / output interface.

[0074] In combination with the above description, the embodiment of the present application provides a training method for a neural network. In the training stage of the neural network, in the process of executing each small sample task, not only the neural network is trained in a traditional way, but also the second feature information corresponding to the M group support sample, the first annotation result corresponding to the M group support sample and the first feature information of the first query sample are used to generate a second prediction result corresponding to the first query sample, and each of the first annotation results indicates the correct result corresponding to a group of support samples in the M group support samples. A second loss function is added, and the training goal of the second loss function is to close the similarity between the first prediction result and the second prediction result, or the training goal of the second loss function is to close the similarity between the second prediction result and the second annotation result. Therefore, in the training process corresponding to a small sample task, not only the features of the support samples in a small sample task can be learned, but also the features of the M group support samples can be learned, that is, the neural network can not only learn the relative relationship within a small sample task in a small sample learning, but also learn the absolute relationship between multiple small sample tasks, thereby improving the accuracy of the output prediction result. Since this method affects both the training phase and the reasoning phase, and the implementation processes of the training phase and the reasoning phase are different, the specific implementation processes of the above two phases are described below.

[0075] 1. Training Phase

[0076] In the embodiment of the present application, the training phase refers to the above Figure 2 The training device 220 performs a training operation on the target model / rule 201. Since the neural network trained by the embodiment of the present application can be used for classification, regression or other functions, and the training steps are different when the neural network is used for classification and when the neural network is used for regression, the training processes of the two functions are introduced separately below.

[0077] (1) The neural network trained for classification

[0078] In the embodiments of the present application, the neural network trained for classification refers to the prediction result output by the neural network is based on the output of the classification network. For example, speech recognition and speech translation are all realized through the classification network, which is also regarded as the neural network trained for classification. Figure 3 , Figure 3 A flowchart of a neural network training method provided in an embodiment of the present application, the method may include:

[0079] 301. The training device creates a feature information library.

[0080] In an embodiment of the present application, the training device creates a feature information library before training the neural network. The feature information library is also called a meta-repository, and the feature information library includes M queues corresponding to M groups of support samples. In this embodiment, the categories of support samples of different groups in the M groups of support samples are different, that is, the M groups of support samples include a total of M types of support samples. Each of the M queues is used to store feature information corresponding to a group of support samples and annotation results corresponding to a group of support samples.

[0081] Since the function of the neural network in this embodiment is to perform classification, the classification basis of different queues in the M queues is category. As an example, if the neural network is used for image classification, the different categories can be cats, dogs, dolphins, hippos, etc. As another example, if the neural network is used for personalized image management, the different categories can be images that user A likes, images that user A doesn't like, images that user B likes, images that user B doesn't like, etc. Or, the different categories can be images that category A users like, images that category A users don't like, images that category B users like, images that category B users don't like, etc. As another example, if the neural network is used for personalized speech recognition, the difference between different categories of speech can be different accents. It should be understood that this is not exhaustive.

[0082] Among them, each of the M queues can be stored in a key-value manner. The training device distinguishes different queues by different "keys", and the key can also be called a token, which is used to uniquely identify a queue. Each of the M queues can also include a queue category. Optionally, since the categories of different queues are different in this embodiment, the category of each team can be directly used as the identification information of the team (that is, the key of the team). Furthermore, the category of each team can be expressed in the form of one-hot encoding. The "value" in each queue includes feature information of multiple supporting samples. The one-hot encoding used to indicate the category can be specifically expressed as a vector including M elements. As an example, the value of M is 64, and the 64 categories are cat, dog, lion, strawberry, sofa, ..., coffee table and apple. The category represented by the one-hot encoding (0, 0, 1, 0, 0, ..., 0, 0) is lion. The 64 categories are not exhaustively enumerated here, and the elements not expanded in the one-hot encoding are all 0. It should be understood that in other implementations, the value of M can also be more or less. The examples here are only for ease of understanding and are not used to limit this solution.

[0083] Specifically, since the sample set includes a total of M queues, the training device needs to initialize M keys (also referred to as initializing M tokens). Optionally, the training device can set a queue length threshold for each queue during the initialization phase, that is, the number of feature information stored in each queue needs to be less than or equal to a first threshold. The value of the first threshold can be a preset multiple of the sum of the number of supporting samples of each category and the number of query samples in each column in a small sample task. As an example, the preset multiple can be 5, 6, 7, 8, 9 or 10, etc., and the value of the first threshold can be 500, 1000 or other numerical values, etc., which are not limited here. In order to understand this solution more intuitively, the representation of one queue among M queues can be as follows:

[0084] Q c ={φ(x i ),y i =c}and|Q c |=max_len; (1)

[0085] Among them, Q c represents the queue of category c among the M queues, φ(x i ),y i =c represents the queue of category c, which is used to store the feature information of the supporting samples labeled with category c. c|=max_len represents that the length threshold of the queue of category c is max_len, that is, a queue can store feature information of max_len supporting samples at most, the value of max_len (that is, the first threshold) is preset, and category c is any category among M categories. It should be understood that the example in formula (1) is only for the convenience of understanding this scheme and is not used to limit this scheme.

[0086] Further optionally, each of the M queues may adopt a first in first out (FIFO) queue structure.

[0087] 302. The training device obtains a first sample subset from the sample set, where the first sample subset includes a first support sample and a first query sample.

[0088] In the embodiment of the present application, before executing the small sample task, the training device obtains a first sample subset from the sample set, and one first sample subset corresponds to a small sample task. The sample set includes M groups of support samples and M groups of query samples, and the samples included in the M groups of support samples and the M groups of query samples do not overlap with each other, so as to ensure that the support samples and the query samples do not overlap in a small sample task.

[0089] Among them, a first sample subset includes N types of first support samples and n first query samples, each type of first support samples in the N types of first support samples includes at least one first support sample, and the correct category of any query sample is included in the aforementioned N categories; N is an integer greater than or equal to 1 and less than or equal to M, and n is an integer greater than or equal to 1. Among them, the categories of the M groups of support samples and the M groups of query samples can refer to the introduction of the categories of the M queues in step 301, which will not be repeated here.

[0090] Specifically, in an application scenario, a neural network is used to classify objects in a sample, and the value of N is greater than or equal to 2. Then step 302 may include: the training device randomly selects N types of first support samples from the M groups of support samples, and randomly selects n first query samples from the N types of query samples included in the M groups of query samples, and any first query sample of the n first query samples belongs to one of the aforementioned N categories. As an example, for example, the value of N is 5, the support sample and the query sample are specifically images, and the categories of the N types of support images are cats, dogs, lions, strawberries and apples, respectively. Then the category of any query image is one of cats, dogs, lions, strawberries or apples. As another example, for example, the value of N is 3, the support sample and the query sample are specifically voices, and the categories of the N types of supported voices are the voice of the owner himself, the voice of user A (non-owner) and the voice of user B (non-owner), respectively. It should be understood that the examples here are only for the convenience of understanding this solution and are not used to limit this solution. It should be understood that the examples here are only for the convenience of understanding this solution.

[0091] For a more intuitive understanding of the concept of the first sample subset, please refer to Figure 4 , Figure 4 A schematic diagram of a first sample subset in the neural network training method provided in an embodiment of the present application. Figure 4 In this example, both the support sample and the query sample are images. Figure 4 As shown, the first sample subset for performing a small sample task includes 4 categories of first support images and multiple first query images; the 4 categories are dog, wolf, table and sofa, each category of first support images includes at least one first support image, and the multiple first query images include images of the correct categories of dog and sofa. The category dog ​​and the category sofa are both in the aforementioned 4 categories. It should be understood that Figure 4 The examples are only used to facilitate understanding of the concept of the first sample subset and are not used to limit this solution.

[0092] In another application scenario, the neural network is used to perform personalized management of images, and the value of N is 2. Then the M categories (i.e., corresponding to M groups) in the sample set support samples and the classification basis between samples of different categories in the M query samples is related to the user. In one case, the classification basis of the aforementioned M categories is the two dimensions of user and whether to like, that is, a group of samples includes an image that a user likes, or includes an image that a user does not like. Optionally, the training device can obtain the characteristics of each user based on the data of each user in the multiple users in the sample set, and then cluster the multiple users based on the characteristics of each user, then a group of samples includes a class of images that the user likes, or includes a class of images that the user does not like.

[0093] Step 302 may include: the training device randomly determines a first user from multiple users included in the M types of support images, or randomly determines a first type of user from multiple types of users included in the M types of support images, that is, determines two groups of support images from the M groups of support images, namely, the Pth group of support images and the Qth group of support images, and determines two groups of query images from the M groups of query images, namely, the Pth group of query images and the Qth group of query images. The Pth group of support images includes support images that the first user (or the first type of user) likes, and the Qth group of support images includes support images that the first user (or the first type of user) does not like; the Pth group of query images includes query images that the first user (or the first type of user) likes, and the Qth group of query images includes query images that the first user (or the first type of user) does not like.

[0094] The training device randomly selects at least one support image from the P-th group of support images, and randomly selects at least one support image from the Q-th group of support images, and uses the aforementioned selected support image as the first support image in the first sample subset. The training device randomly selects at least one query image from the P-th group of query images, and / or randomly selects at least one query image from the Q-th group of query images, and uses the aforementioned selected query image as the first query image in the first sample subset.

[0095] For a more intuitive understanding of the concept of the first sample subset, please refer to Figure 5 , Figure 5 A schematic diagram of a first sample subset in the neural network training method provided in an embodiment of the present application. Figure 5 In the example, both the support sample and the query sample are images, and all images included in the first sample set are selected from images of user A. Figure 5 As shown, the first sample subset includes two types of first support images, namely, images that user A does not like and images that user A likes. The first sample subset includes multiple first query images, such as Figure 5 As shown, the first sample subset includes images that user A does not like and images that user A likes. It should be understood that in actual situations, the first query image included in the first sample subset may also only select images that user A likes, or only select images that user A does not like. Figure 5 The examples are only used to facilitate understanding of the concept of the first sample subset and are not used to limit this solution.

[0096] Furthermore, the training device also obtains the correct category of each first support sample (i.e., the labeling result of each first support sample) and the correct category of each first query sample (i.e., the labeling result of each first query sample). In a small sample task, the support sample is used to guide the neural network to learn the characteristics of each type of first support sample in N types of first support samples, and the query sample is used to test the classification ability of the neural network.

[0097] 303. The training device inputs the first sample subset into the first neural network, obtains the first feature information of the first query sample and the feature information of the first support sample generated by the first neural network, and obtains the first prediction result corresponding to the first query sample output by the first neural network, and the first neural network is used to classify the samples.

[0098] In an embodiment of the present application, after obtaining a first sample subset for performing a small sample task, the training device can input N categories of first support samples, the labeling results of each first support sample (i.e., the correct category) and n first query samples into the first neural network, so as to perform a feature extraction operation on each first support sample and each first query sample through the first neural network to obtain first feature information of the first query sample and feature information of each first support sample.

[0099] The training device generates the class center of each category in N categories respectively according to the feature information of each first support sample in N categories of first support samples through the first neural network. Specifically, for the second category in N categories, the second category is any category in N categories. After the training device generates the feature information of each first support sample through the first neural network, the feature information of each first support sample belonging to the second category can be obtained according to the labeling result of each first support sample. The training device averages the feature information of all first support samples belonging to the second category through the first neural network to obtain the class center of the second category in N categories; the training device performs the above operation on each category in N categories through the first neural network to obtain the class center of each category in N categories.

[0100] After obtaining the class center of each of the N classes, the training device generates a first prediction result corresponding to each first query sample through a first neural network, and the first prediction result is generated based on the similarity between the feature information of the first support sample and the first feature information of the first query sample.

[0101] For any first query sample among at least one first query sample, the training device calculates the distance between the first feature information of a first query sample and the class center of each category in N categories through the first neural network, that is, calculates the similarity between the first feature information of a first query sample and the class center of each category in N categories, and obtains the second classification category of the first query sample (that is, the first prediction result of the first query sample). The second classification category of the first query sample can also be called the label of the first query sample. The closer the first feature information of the first query sample is to the class center of a category in N categories, the greater the probability that the first query sample belongs to this category. The training device performs the above operation on each first query sample through the first neural network to obtain the second classification category of each first query sample (that is, the first prediction result of each first query sample). The second classification category of the first query sample is used to indicate the predicted classification of the first query sample in N categories.

[0102] As an example, for example, the first query sample is an image, and the N categories are dog, wolf, table, and sofa, respectively. The second classification category of the first query image indicates that the category of the first query image is dog. As another example, for example, the first query sample is an image, and the N categories are images that user A likes and images that user A doesn't like, respectively. The second classification category of the first query image indicates that the category of the first query image is images that user A likes.

[0103] Among them, the first neural network can specifically be a convolutional neural network or a residual neural network. As an example, the first neural network can be a 4-layer convolutional neural network. As another example, the first neural network can be a residual network (ResNet) 12, etc. The first neural network can also be other neural networks used for classification, etc., which are not exhaustive here. The first neural network includes a feature extraction network and a first classification network, and the first classification network can be specifically expressed as a classifier. The feature extraction network is used to generate feature information of the first support sample and feature information of the first query sample, and the first classification network is used to generate category indication information of the first query sample.

[0104] For a more intuitive understanding of this solution, please refer to Figure 6 , Figure 6 A schematic diagram of a flow chart for generating a first prediction result in a neural network training method provided in an embodiment of the present application. Figure 6 In the example, the support sample and the query sample are both images, the value of N is 4, and the four categories are dog, wolf, table and sofa. The training device inputs the first sample subset into the first neural network, extracts features from each first support image through the first neural network, and generates four class centers according to the feature information of each first support image. Figure 6In the figure, four triangles represent four class centers, which respectively indicate the features of all supporting images of the dog category, the features of all supporting images of the wolf category, the features of all supporting images of the table category, and the features of all supporting images of the sofa category. The training device generates feature information of each first query image through a first neural network, and calculates the distance between the feature information of a first query image and the four class centers through the first neural network to output a first prediction result of the first query sample. The aforementioned first prediction result indicates the predicted category of the first query sample among the four categories. It should be understood that Figure 4 The examples are only used to facilitate understanding of the concept of the first sample subset and are not used to limit this solution.

[0105] 304. The training device adds the feature information of the first supporting sample to the first queue of the feature information library.

[0106] In the embodiment of the present application, the training device will perform a meta repo update after each step 303 generates feature information of each first support sample. For a first support sample, in one implementation, the training device selects a first queue corresponding to the first support sample from M queues according to the group corresponding to the first support sample, and puts the feature information of the first support sample into the first queue. Specifically, since the M queues correspond one-to-one to the M groups of support samples, the first support sample is selected from the first group, and the feature information of the first support sample is put into the first queue corresponding to the first group, and the first queue is used to store the feature information corresponding to the support samples of the first group.

[0107] In another implementation, since each of the M queues includes category information, the training device selects a first queue corresponding to the one first support sample from the M queues based on the labeling result corresponding to the one first support sample (that is, the correct category of the one first support sample), and puts the feature information of the one first support sample into the first queue.

[0108] Optionally, since the first queue adopts a “first-in, first-out” queue structure, the training device may add the feature information of the first supporting sample to the end of the first queue.

[0109] Further optionally, since the length of the first queue can be set to a first threshold in advance, the training device can determine whether the length of the first queue reaches the first threshold before adding the characteristic information of the first supporting sample to the first queue. If it reaches the first threshold, the characteristic information at the head of the first queue will be deleted, and the characteristic information of the first supporting sample will be added to the tail of the first queue.

[0110] The training device performs the above operation on each first supporting sample in the first sample subset to add the feature information of each first supporting sample to the first queue of the feature information library. It should be noted that, since a first sample subset includes N types of first supporting samples, the training device will add the feature information of all first supporting samples in the first sample subset to N different first queues respectively.

[0111] For a more intuitive understanding of this solution, please refer to Figure 7 , Figure 7 A schematic diagram of a feature information library in a neural network training method provided in an embodiment of the present application. The feature information library includes M queues, Figure 7 The M rows shown in FIG. 1 correspond to M queues respectively, and the second queue is any one of the M queues. Figure 7 As shown, the second queue includes a token and multiple A1s. The token can also be called a key. The multiple A1s in the second queue are the values ​​of the second queue. In the application scenario where the first neural network is used for classification, any A1 indicates feature information of a supporting sample. Figure 7 In the example, a queue stores feature information of up to 12 supporting samples. It should be understood that in actual situations, at the beginning of the feature information library, the values ​​in each queue are empty, and the values ​​in each queue are continuously supplemented during the process of iteratively updating the first neural network. Figure 7 The examples in are only for the convenience of understanding the concept of feature information library. When applied to regression scenarios, each A1 not only indicates the feature information of a supporting sample, but also indicates the labeling result of a supporting sample. The examples here are not used to limit this solution.

[0112] 305. The training device obtains, according to the feature information library, second feature information corresponding to the M groups of support samples and first labeling results corresponding to the M groups of support samples.

[0113] In an embodiment of the present application, the training device obtains M second feature information corresponding to M groups of support samples and M first labeling results corresponding to the M groups of support samples based on the feature information library, and each of the M first labeling results indicates the correct result (i.e., the correct category) corresponding to a group of support samples in the M groups of support samples.

[0114] The feature information library includes M queues corresponding to M groups of support samples, and each queue may include feature information of one or more support samples. Each of the M second feature information is used to reflect the feature information of all support samples in one queue. Since one queue in the M queues corresponds to a class of support samples, a second feature information corresponding to a group of support samples in the M groups of support samples can also be understood as a class center corresponding to a group of support samples in the M groups of support samples.

[0115] Specifically, for a second feature information corresponding to any group of support samples in the M groups of support samples, the training device obtains the feature information of all support samples included in the second queue and the category of the second queue from the M queues included in the feature information library, averages the feature information of all support samples included in the second queue, obtains a second feature information corresponding to the second queue (that is, obtains a second feature information corresponding to a group of support samples in the M groups of support samples), and determines the category of the second queue as a first labeling result corresponding to a group of support samples in the M groups of support samples. The second queue is any one of the M queues.

[0116] In the embodiment of the present application, by taking the average value of the feature information of all supporting samples included in the second queue, a second feature information corresponding to the second queue is obtained, which is simple to operate and easy to implement.

[0117] It should be noted that the embodiment of the present application does not limit the execution order of step 305 , and step 305 may be executed before or after any one of step 302 , step 303 and step 304 .

[0118] In an embodiment of the present application, a feature information library is configured in the training device, and the feature information library includes M queues corresponding to M groups of support samples one by one, and each of the M queues is used to store feature information of a group of support samples; during each training process, feature information of each first support sample is generated by the first neural network, and the feature information of each first support sample generated by the first neural network is added to the corresponding queue. The training device can obtain M second feature information corresponding to the M groups of support samples according to the feature information library, that is, the training device will continuously update the feature information library during each training process. In the aforementioned manner, the training device uses the feature information generated during each training process to generate features of each group of support samples in the M groups, thereby improving the efficiency of the training process.

[0119] 306. The training device generates a second prediction result corresponding to the first query sample according to the second feature information corresponding to the M groups of support samples, the first annotation results corresponding to the M groups of support samples, and the first feature information of the first query sample.

[0120] In an embodiment of the present application, for any first query sample among the one or more first query samples included in the first sample subset, after obtaining the M second feature information corresponding to the M groups of support samples and the M first annotation results corresponding to the M groups of support samples, the training device performs a similarity calculation operation based on the M second feature information and the first feature information of a first query sample to obtain the first similarity information, and the first similarity information indicates the similarity between the first feature information of a first query sample and the M second feature information, that is, the similarity between the first query sample and each group of support samples in the M groups of support samples. The training device generates a second prediction result based on the first similarity information and the M first annotation results corresponding to the M groups of support samples.

[0121] In an embodiment of the present application, the second prediction result of the first query sample is generated by utilizing the similarity between the features of the first query sample and the features of each group of support samples in the M groups of support samples and the M first annotation results corresponding to the M groups of support samples. The second prediction result is generated by calculating the similarity, which is simple to operate and easy to implement.

[0122] Specifically, the training device forms a first classification category based on the first similarity information and the M first annotation results corresponding to the M groups of support samples. The first classification category indicates the predicted category of the first query sample in the M categories; the M second feature information corresponds one-to-one to the M categories, and the third feature information is any feature information of the M second feature information. The higher the similarity between the first feature information and the third feature information, the greater the probability that the first query sample belongs to the category corresponding to the third feature information.

[0123] The training device obtains a second prediction result from the first classification category, and the second prediction result indicates the predicted category of the first query sample in the N categories. Among them, a first classification category can be expressed as a vector including M elements, and the M elements included in a first classification category are used to indicate the probability that a first query sample belongs to each category in the M categories. The second prediction result can be expressed as including N elements selected from the aforementioned M elements, and the selected N elements are used to indicate the probability that a first query sample belongs to each category in the N categories.

[0124] As an example, for example, the value of M is 6, and the M categories are images liked by user A, images disliked by user A, images liked by user B, images disliked by user B, images liked by user C, and images disliked by user C, and the value of N is 2, and the N categories are images liked by user B and images disliked by user B. The first classification category is specifically expressed as (0.05, 0.1, 0.7, 0.01, 0.09, 0.05), indicating the probability that a first query image belongs to each category in the M categories; the second prediction result can be (0.7, 0.01), indicating the probability that a first query image belongs to each category in the N categories.

[0125] As another example, for example, the value of M is 12, the value of N is 3, the M categories are cat, dog, lion, strawberry, sofa, coffee table, apple, chestnut, milk, wolf, tiger and dolphin, and the N categories are cat, dog and lion. The first classification category is specifically expressed as (0.01, 0.8, 0.01, 0.01, 0.02, 0.05, 0.01, 0.01, 0.01, 0.02, 0.03, 0.02), indicating the probability that a first query image belongs to each of the M categories; the second prediction result can be (0.01, 0.8, 0.01), indicating the probability that a first query image belongs to each of the N categories.

[0126] It should be understood that M can also take a larger or smaller value, and N can also take a larger value. The above examples are only for the convenience of understanding the present solution and are not used to limit the present solution.

[0127] Specifically, the training device inputs the second feature information corresponding to the M groups of support samples, the first annotation results corresponding to the M groups of support samples, and the first feature information of each first query sample in at least one first query sample into the second classification network to generate a first classification category through the second classification network, and then obtain the second prediction result from the first classification category. Among them, the difference between the second classification network and the first classification network is that the second classification network can realize the classification of M categories, and the first classification network can only realize the classification of N categories. The second classification network can be expressed as a classifier. Further, the second classification network can be expressed as a linear classifier. As an example, the second classification network is specifically expressed as a support vector machine (SVM). The feature extraction network in the first neural network and the second classification network can form a second neural network. Further, the formula of the second neural network can be as follows:

[0128]

[0129] in, Represents the second neural network, SVM represents the second classification network, and φ represents the feature extraction network of the first neural network. It should be understood that the examples given here are only for the convenience of understanding the present solution and are not used to limit the present solution.

[0130] In an embodiment of the present application, the training device first generates a probability that the first query sample belongs to each of the M categories based on the second feature information corresponding to the M groups of support samples, the first annotation results corresponding to the M groups of support samples, and the feature information of the first query sample, and then determines the probability that the first query sample belongs to each of the N categories based on the probability that the first query sample belongs to each of the M categories, thereby ensuring that in a small sample task, the training device learns the features of each of the M categories in the process of classifying a first query sample, so as to improve the accuracy of the output result of the trained first neural network.

[0131] 307. The training device iteratively trains the first neural network according to the first loss function and the second loss function until a preset condition is met, the first loss function indicates the similarity between the first prediction result and the second annotation result, the second loss function indicates the similarity between the first prediction result and the second prediction result, or the second loss function indicates the similarity between the second prediction result and the second annotation result.

[0132] In an embodiment of the present application, during a training process, after obtaining the first prediction result of each first query sample and the second prediction result of each first query sample, the training device can generate a function value of the first loss function and a function value of the second loss function, and use the function value of the first loss function and the function value of the second loss function to perform reverse derivation to update the weight parameters of the first neural network, thereby completing one training of the first neural network.

[0133] The first loss function indicates the similarity between the first prediction result (i.e., the predicted category) of each first query sample and the second annotation result (i.e., the correct category) of each first query sample. The second loss function indicates the similarity between the first prediction result of each first query sample and the second prediction result of each first query sample, or the second loss function indicates the similarity between the second prediction result of each first query sample and the second annotation result of each first query sample.

[0134] Furthermore, the first loss function may specifically be a cross entropy loss function, a relative entropy loss function, or other types of loss functions, and the second loss function may be a cross entropy loss function, a relative entropy loss function, or other types of loss functions, etc., which are not exhaustively listed here.

[0135] Specifically, in a training process, after generating the function value of the first loss function and the function value of the second loss function, the training device can perform a weighted sum of the function value of the first loss function and the function value of the second loss function to obtain a total function value, perform gradient differentiation on the total function value, and reversely update the weight parameters of the feature extraction network included in the first neural network. The weight of the function value of the first loss function and the function value of the second loss function is a hyperparameter. An example of the formula of the first loss function and the second loss function can be as follows:

[0136]

[0137] Wherein, formula (3) represents the sum of the first loss function and the second loss function, represents the first sample subset corresponding to a small sample task, represents the first query sample in the first sample subset, represents the correct category of the first query sample (i.e., the second annotation result), represents the predicted category of the first query sample in N categories (that is, the first prediction result), represents the first loss function, indicating the similarity between the first prediction result and the second annotation result, represents the predicted category of the first query sample in N categories obtained by the second classification network (that is, the second prediction result), represents the second loss function, indicating the similarity between the first prediction result and the second prediction result, and λ represents the weight of the second loss function, which is a hyperparameter.

[0138] The training goal of formula (3) is to get smaller and smaller, that is, the training goal is to shorten the similarity between the first prediction result of each first query sample and the second annotation result of each first query sample, and shorten the similarity between the first prediction result of each first query sample and the second prediction result of each first query sample. It should be understood that formula (3) is only an example for the convenience of understanding the first loss function and the second loss function. The second loss function can also be used to indicate the similarity between the second prediction result of each first query sample and the second annotation result of each first query sample.

[0139] In one case, after the training device performs a training on the first neural network based on a first sample subset corresponding to a small sample task, the training device may re-enter step 303 to iteratively train the first neural network using the same first sample subset until the first preset condition is met, and then re-enter step 302 to sample another first sample subset corresponding to another small sample task from the sample set, and then iteratively train the first neural network based on the other first sample subset until the first preset condition is met. The first preset condition may be that the iteration satisfies a preset number of times, or may be that the convergence conditions of the first loss function and the second loss function are met. The training device repeatedly uses a preset number of small sample tasks to iteratively train the first neural network, and the preset number may be 20,000, 30,000, or other numbers.

[0140] In another case, after the training device performs a training on the first neural network based on a first sample subset corresponding to a small sample task, the training device may re-enter step 302 to sample another first sample subset corresponding to another small sample task from the sample set, and then perform the next training on the first neural network based on the other first sample subset until the second preset condition is met. The second preset condition is that the number of iterations reaches a preset number, which may be 20,000, 30,000, or other numbers.

[0141] For a more intuitive understanding of this solution, please refer to Figure 8 , Figure 8A flow chart of a neural network training method provided in an embodiment of the present application. The training device inputs a first sample subset into a feature extraction network of a first neural network, so as to extract features from each first support image and each first query image through the feature extraction network, and obtain feature information of each first support image and first feature information of each first query image. The training device generates four class centers according to the feature information of each first support image, and the four class centers respectively indicate the features of all support images of the dog category, the features of all support images of the wolf category, the features of all support images of the table category, and the features of all support images of the sofa category. The training device inputs the four class centers and the first feature information of each first query image into a first classification network, and obtains the first prediction result of each first query image output by the first classification network. The training device inputs the first feature information of each first query image, the M second feature information corresponding to the M groups of support samples, and the M first annotation results corresponding to the M groups of support samples into a second classification network, so as to obtain the second prediction result of each first query image through the second classification network. The training device generates a function value of a first loss function according to the first prediction result of each first query image and the second annotation result of each first query image, and the first loss function indicates the similarity between the first prediction result and the second annotation result; and generates a function value of a second loss function according to the first prediction result of each first query image and the second prediction result of each first query image, and the second loss function indicates the similarity between the first prediction result and the second prediction result. The training device updates the weight parameters of the first neural network according to the function value of the first loss function and the function value of the second loss function to implement a training of the first neural network. It should be understood that Figure 8 The example in the example is only an example to facilitate understanding of the present invention and is not intended to limit the present invention.

[0142] In the embodiment of the present application, optionally, the training device can obtain multiple trained first neural networks corresponding to the multiple small sample tasks one by one by using multiple small sample tasks to iteratively train the first neural network until a preset condition is met. The training device can use a test sample set to perform accuracy tests on the multiple trained first neural networks corresponding to the multiple small sample tasks one by one to select a trained first neural network with the highest accuracy.

[0143] The training device can sample a small sample task corresponding to the target task from the sample set corresponding to the target task, and the training device uses the small sample task corresponding to the target task to iteratively train the first neural network with the highest accuracy after training again until the first preset condition is met, thereby obtaining the final trained first neural network. The process of each training in the aforementioned iterative training can refer to the description of steps 802 to 807, which will not be repeated here.

[0144] In the embodiment of the present application, since the neural network finally obtained learns too much about the difference in feature dimensions between different samples in the same small sample task, and ignores the difference in feature dimensions between multiple different categories of samples corresponding to multiple different small sample tasks, the accuracy of the prediction result output by the neural network is low. In order to solve the above problem, in the training stage of this scheme, in each small sample task, the second prediction result corresponding to the first query sample will be generated according to the second feature information corresponding to the M group support sample, the first annotation result corresponding to the M group support sample and the feature information of the first query sample, and a second loss function is added to indicate the similarity between the first prediction result and the second prediction result, or the similarity between the second prediction result and the correct result. Thus, the neural network can not only learn the features of the support samples in a small sample task during the training process of a small sample task, but also learn the features of the M group support samples, that is, the neural network can not only learn the differences in feature dimensions between different samples in a small sample task, but also learn the differences in feature dimensions between multiple different categories of samples corresponding to multiple different small sample tasks in a small sample learning, thereby improving the accuracy of the output prediction result.

[0145] (2) The neural network trained is for regression

[0146] In the present application, please refer to Fig. 9 , Fig. 9 A flowchart of a neural network training method provided in an embodiment of the present application, the method may include:

[0147] 901. The training device creates a feature information library.

[0148] In the present application embodiment, Figure 3 Similar to step 301 in the corresponding embodiment, in the scenario where the trained neural network is used for regression, the training device will also create a feature information library before training the neural network. The feature information library is also called a meta-repository, and the M queues included in the feature information library correspond one-to-one to the M groups of support samples included in the sample set. Each of the M queues is used to store feature information corresponding to a group of support samples and annotation results corresponding to a group of support samples.

[0149] Each of the M queues also includes the identification information of the entire queue and the labeling results of each supporting sample in the queue. Figure 3 The difference between the corresponding embodiments is that, first, Figure 3 In the corresponding embodiment, an entire queue in the M queues may correspond to one annotation result, and multiple supporting samples in one queue may share one annotation result (ie, the correct category or label); Fig. 9In the corresponding embodiment, any one of the M queues includes the annotation results of each supporting sample, that is, the number of annotation results in a queue is the same as the number of supporting samples, and the annotation result of each supporting sample is the correct regression result of each supporting sample. As an example, for example, the function of the first neural network to be trained is to perform personalized management of battery charging, and the annotation results of the supporting samples can be charging time of 6 hours, charging time of 3 hours, charging time of 9 hours, etc. The examples here are only for the convenience of understanding this solution and are not used to limit this solution.

[0150] Second, in Figure 3 In the corresponding embodiment, the identification information of one of the M queues and the marking result of the entire queue may be the same information. Fig. 9 In the corresponding embodiment, the identification information of one of the M queues and the labeling result of each supporting sample in the one queue are different information. In this application scenario, the identification information of one of the M queues can be specifically expressed as a character code, which can be randomly generated or generated according to a certain rule.

[0151] 902. The training device obtains a first sample subset from the sample set, where the first sample subset includes a first support sample and a first query sample.

[0152] In the embodiment of the present application, the specific implementation of step 902 can be found in Figure 3 The description of step 302 in the corresponding embodiment is not repeated here. Figure 3 The difference between the corresponding embodiments is that Figure 3 In the corresponding embodiment, a support sample or a query sample can be an image, text or speech, and the annotation result of a support sample or a query sample is the correct category of the sample. Fig. 9 In the corresponding embodiment, the support samples and the query samples are specifically represented as discrete data to be regressed.

[0153] As an example, for example, a neural network is used to perform personalized management of battery charging. A support sample or a query sample may include a user's mobile phone model, battery model, charging location and charging time; correspondingly, the annotation result of a support sample or a query sample is the correct charging time. Since the mobile phone can control the charging speed, under the premise of charging the same amount of electricity, the longer the scheduled charging time, the slower the charging speed can be controlled by the mobile phone; the shorter the scheduled charging time, the faster the charging speed can be controlled by the mobile phone to protect the mobile phone battery and improve the battery life of the mobile phone. Further, for example, if the charging location is home and the charging time is 11 o'clock in the evening, then in general, the connection time between the mobile phone and the charger will be longer; for example, if the charging location is the office and the charging time is 10 o'clock in the morning, then the connection time between the mobile phone and the charger will be shorter, etc. Different users' personal habits, mobile phone models, battery models, etc. can also affect the output of the first neural network. It should be understood that the examples here are only for the convenience of understanding this application scenario, and the trained first neural network can also be applied to other regression scenarios, which are not limited here.

[0154] Further, in this application scenario, the grouping basis of the M group is one or more of the following: users, locations, time or other elements corresponding to the supporting samples. In this embodiment, at least one first supporting sample included in the first sample subset comes from the same group of the M group, and at least one first query sample included in the first sample subset comes from the same group of the M group. In the embodiment of the present application, multiple grouping bases of the M group supporting samples are provided in the application scenario of regression, which improves the implementation flexibility of the solution.

[0155] Specifically, in one case, take the grouping basis as an example. In one implementation, after obtaining the sample set, the training device can directly determine the support samples of each user as a group of support samples for the support sample set included in the sample set, thereby determining the support samples of M users as M groups of support samples. In another implementation, the training device can classify the support sample set according to the user, obtain the support sample of each user among multiple users, and then obtain the feature information of each user according to the support sample of each user, and perform a clustering operation according to the feature information of each user among the multiple users to divide all the support samples included in the sample set into M groups of support samples. The process of dividing all the query samples included in the sample set into M groups of query samples is similar to the above description and will not be repeated here.

[0156] In another case, take the case where the grouping basis is location as an example. In one implementation, after obtaining the sample set, the training device can directly determine the support samples of each location as a group of support samples for the support sample set included in the sample set, thereby determining the support samples of M locations as M groups of support samples. In another implementation, the training device can classify the support sample set according to the location, obtain the support samples corresponding to each location in the multiple locations, and then obtain the feature information of each location according to the support samples corresponding to each location, and perform a clustering operation based on the feature information of each location in the multiple locations to divide all the support samples included in the sample set into M groups of support samples. The process of dividing all the query samples included in the sample set into M groups of query samples is similar to the above description and will not be repeated here.

[0157] For the specific implementation method of classifying based on time, please refer to the description of the specific implementation method of classifying based on user or location, which will not be repeated here.

[0158] 903. The training device inputs the first sample subset into the first neural network, obtains the first feature information of the first query sample and the feature information of the first support sample generated by the first neural network, and obtains the first prediction result corresponding to the first query sample output by the first neural network, and the first neural network is used to regress the samples.

[0159] In the embodiment of the present application, the specific implementation of step 903 can be found in Figure 3 The description of step 303 in the corresponding embodiment is not repeated here. The first neural network is a neural network that performs regression processing on the sample; specifically, the first neural network can be a fully connected neural network. The first prediction result is specifically manifested as a prediction regression result.

[0160] 904. The training device adds the feature information of the first supporting sample and the annotation result of the first supporting sample to the first queue of the feature information library.

[0161] In the present application embodiment, Figure 3 Similar to step 304 in the corresponding embodiment, for any first supporting sample among the multiple first supporting samples, after the training device generates feature information of the first supporting sample through the first neural network, it will add the feature information of the first supporting sample to the first queue. Figure 3 The difference from step 304 in the corresponding embodiment is that in step 904, the training device also adds the annotation result of the first supporting sample to the first queue. The way in which the training device determines the correspondence between a first supporting sample and a first queue can be found in the description of step 304 and will not be repeated here.

[0162] 905. The training device obtains, according to the feature information library, second feature information corresponding to the M groups of support samples and first labeling results corresponding to the M groups of support samples.

[0163] In the present application embodiment, Figure 3 Similar to step 305 in the corresponding embodiment, the training device obtains the second feature information corresponding to one group of support samples in the M groups of support samples by performing an average processing. For details, please refer to Figure 3 This corresponds to the description in step 305 in the embodiment.

[0164] and Figure 3 The difference from step 305 in the corresponding embodiment is that in step 905, the training device will also generate M first annotation results corresponding to the M groups of support samples. Specifically, for a first annotation result corresponding to any group of support samples in the M groups of support samples. The training device obtains multiple annotation results corresponding to all support samples included in the second queue from the M queues included in the feature information library, averages the multiple annotation results corresponding to all support samples included in the second queue, and obtains a first annotation result corresponding to the second queue (that is, obtains a first annotation result corresponding to a group of support samples in the M groups of support samples).

[0165] 906. The training device generates a second prediction result corresponding to the first query sample according to the second feature information corresponding to the M groups of support samples, the first annotation result corresponding to the M groups of support samples, and the first feature information of the first query sample.

[0166] In the present application embodiment, Figure 3 Similar to step 306 in the corresponding embodiment, for any first query sample in one or more first query samples included in the first sample subset. After obtaining the M second feature information corresponding to the M groups of support samples and the M first annotation results corresponding to the M groups of support samples, the training device performs a similarity calculation operation based on the M second feature information and the first feature information of a first query sample to obtain the first similarity information. The first similarity information indicates the similarity between the first feature information of a first query sample and the M second feature information, that is, the similarity between the first query sample and each group of support samples in the M groups of support samples. The training device generates a second prediction result based on the first similarity information and the M first annotation results corresponding to the M groups of support samples.

[0167] Specifically, with Figure 3The difference from step 306 in the corresponding embodiment is that in this application scenario, the training device generates the weight of each of the M first annotation results based on the similarity between the first query sample and each group of support samples in the M groups of support samples, and performs weighted summation on the M first annotation results to generate the second prediction result of the first query result. Further, the training device can directly determine the similarity between the first query sample and a group of support samples as the weight of the first annotation result corresponding to the group of support samples; it can also perform secondary processing on the similarity between the first query sample and a group of support samples to obtain the weight of the first annotation result corresponding to the group of support samples, etc., which is not limited here.

[0168] As an example, for example, the value of M in the M first annotation results is 12, and the first similarity information indicates that the similarity between a first query sample and each group of support samples in the M groups of support samples is (0.01, 0.8, 0.01, 0.01, 0.02, 0.05, 0.01, 0.01, 0.01, 0.02, 0.03, 0.02), then the weight of each first annotation result corresponding to each group of support samples in the 12 groups of support samples is (0.01, 0.8, 0.01, 0.01, 0.02, 0.05, 0.01, 0.01, 0.01, 0.02, 0.03, 0.02). It should be understood that the examples given here are only for the convenience of understanding the present scheme and are not used to limit the present scheme.

[0169] 907. The training device iteratively trains the first neural network according to the first loss function and the second loss function until a preset condition is met, the first loss function indicates the similarity between the first prediction result and the second annotation result, the second loss function indicates the similarity between the first prediction result and the second prediction result, or the second loss function indicates the similarity between the second prediction result and the second annotation result.

[0170] In the embodiment of the present application, the specific implementation of step 907 can be found in Figure 3 The description of step 307 in the corresponding embodiment is not repeated here. Another example of the formula of the first loss function and the second loss function is disclosed as follows:

[0171]

[0172] Wherein, formula (4) represents the sum of the first loss function and the second loss function, represents the first sample subset corresponding to a small sample task, represents the first query sample in the first sample subset, represents the correct regression result of the first query sample (that is, the second annotation result), represents the predicted regression result of the first query sample (ie, the first predicted result), represents the first loss function, indicating the similarity between the first prediction result and the second annotation result, represents the second prediction result obtained by step 906, represents the second loss function, indicating the similarity between the second prediction result and the second annotation result, and λ represents the weight of the second loss function, which is a hyperparameter.

[0173] The training goal of formula (4) is to get smaller and smaller, that is, the training goal is to shorten the similarity between the first prediction result of each first query sample and the second annotation result of each first query sample, and shorten the similarity between the second prediction result of each first query sample and the second annotation result of each first query sample. It should be understood that formula (4) is only an example made to facilitate understanding of the first loss function and the second loss function, and is not used to limit this solution.

[0174] In the embodiment of the present application, the trained first neural network can be used not only to classify samples, but also to regress samples, which expands the application scenarios of the present solution.

[0175] In the embodiment of the present application, the first neural network can be a fully connected neural network, a convolutional neural network or a residual neural network, which improves the implementation flexibility of the present solution.

[0176] 2. Reasoning Stage

[0177] In the embodiment of the present application, the reasoning stage refers to the above Figure 2 The execution device 210 processes the sample using the trained target model / rule 201. Fig.10 , Fig.10 A flow chart of a sample processing method provided in an embodiment of the present application, the method may include:

[0178] 1001. The execution device obtains a third support sample and a third query sample.

[0179] In an embodiment of the present application, after the execution device obtains the trained first neural network, before each reasoning, it is necessary to first obtain N types of third support samples and n third query samples. The meaning of the third support samples is similar to that of the first support samples, and the meaning of the third query samples is similar to that of the first query samples. For details, please refer to the description in step 302 and step 902, which will not be repeated here.

[0180] 1002. The execution device inputs the third support sample and the third query sample into the first neural network to output a third prediction result corresponding to the third query sample through the first neural network, wherein the third prediction result is generated based on the similarity between the feature information of the third support sample and the feature information of the third query sample, and the first neural network is trained based on the first loss function and the second loss function.

[0181] In the embodiment of the present application, the specific implementation of step 1002 can be found in Figure 3 In the corresponding embodiment, steps 303 and Fig. 9 The description of step 903 in the corresponding embodiment is not repeated here.

[0182] Among them, the first loss function indicates the similarity between the prediction result output by the first neural network and the correct result, the second loss function indicates the similarity between the prediction result output by the first neural network and the second prediction result corresponding to the third query sample, or the second loss function indicates the similarity between the second prediction result and the correct result, the second prediction result is obtained based on the second feature information corresponding to the M groups of support samples, the correct result corresponding to the M groups of support samples and the feature information of the third query sample, the third support sample can belong to the support sample of the third group, the third query sample can belong to the query sample of the third group, and the third group is one of the M groups.

[0183] The third prediction result has a similar meaning to the second prediction result. The meanings of the second prediction result, the first loss function, and the second loss function can all be found in Figure 3 and Fig. 9 The description in the corresponding embodiment is not repeated here.

[0184] In the embodiment of the present application, since the neural network finally obtained learns too much about the differences in feature dimensions between different samples in the same small sample task, and ignores the differences in feature dimensions between multiple different categories of samples corresponding to multiple different small sample tasks, the accuracy of the prediction results output by the neural network is low. The first neural network is trained and generated according to the first loss function and the second loss function. The second loss function indicates the similarity between the first prediction result and the second prediction result, or indicates the similarity between the second prediction result and the correct result. The second prediction result is generated according to the second feature information corresponding to the M group support samples, the first annotation result corresponding to the M group support samples, and the feature information of the first query sample. The trained neural network not only learns the differences in feature dimensions between different samples in a small sample task, but also can learn the differences in feature dimensions between multiple different categories of samples corresponding to multiple small sample tasks, so that the accuracy of the results output by the neural network is higher.

[0185] In order to further understand the beneficial effects, the following is combined with data to demonstrate the effects brought by the embodiments of the present application. The results are shown in Tables 1 and 2 below, which are verified on the public image set MiniImageNet.

[0186]

[0187] Table 1

[0188] Among them, as shown in Table 1, 5-way 1-shot means that a small sample task includes 5 categories of first support samples, and each category of first support samples has 1 first support sample. 5-way 1-shot means that a small sample task includes 5 categories of first support samples, and each category of first support samples has 5 first support samples. Proto and FEAT (few-shot embedding adaptation w / transformer) are currently two meta-learning training methods. When the small sample task is 5-way 1-shot and the first neural network selects a convolutional neural network, the accuracy of the trained first neural network obtained by training in the Proto method is 49.42, the accuracy of the trained first neural network obtained by training in the FEAT method is 55.15, and the accuracy of the trained first neural network obtained by training in the method of the embodiment of the present application is 55.37. The other data in Table 1 can be understood by analogy and will not be repeated here. It is obvious that the accuracy of the trained first neural network is improved in the small sample scenario by using the training method provided in the embodiment of the present application.

[0189] 5-way 30-shot Convolutional Neural Networks Residual Neural Network Proto 77.01±0.14 87.64±0.40 FEAT 78.53±0.56 87.92±0.42 Embodiments of the present application 80.26±0.50 88.20±0.41

[0190] Table 2

[0191] Among them, as shown in Table 2, 5-way 30-shot means that a small sample task includes 5 categories of first support samples, and each category of first support samples has 30 first support samples. When the first neural network selects a convolutional neural network, the accuracy of the first neural network after training obtained by Proto is 77.01±0.14, the accuracy of the first neural network after training obtained by FEAT is 78.53±0.56, and the accuracy of the first neural network after training obtained by the method of the embodiment of the present application is 80.26±0.50. The other data in Table 1 can be understood by analogy and will not be repeated here. It is obvious that the accuracy of the first neural network after training is improved in the medium-volume sample scenario by using the training method provided in the embodiment of the present application.

[0192] exist Figures 1 to 10On the basis of the corresponding embodiments, in order to better implement the above solutions of the embodiments of the present application, the following also provides related devices for implementing the above solutions. Fig.11 , Fig.11 A schematic diagram of a structure of a neural network training device provided in an embodiment of the present application. The neural network training device 1100 may include an acquisition module 1101, an input module 1102, a generation module 1103 and a training module 1104. Among them, the acquisition module 1101 is used to obtain a first sample subset from a sample set, the sample set includes M groups of support samples and M groups of query samples, and the first sample subset includes a first support sample and a first query sample; the input module 1102 is used to input the first sample subset into the first neural network, the first neural network generates first feature information of the first query sample, and obtains a first prediction result corresponding to the first query sample output by the first neural network, and the first prediction result is generated according to the similarity between the feature information of the first support sample and the first feature information; the generation module 1103 is used to generate a second prediction result corresponding to the first query sample according to the second feature information corresponding to the M groups of support samples, the first annotation results corresponding to the M groups of support samples, and the first feature information of the first query sample, each of the first annotation results indicates a correct result corresponding to a group of support samples in the M groups of support samples; the training module 1104 is used to iteratively train the first neural network according to the first loss function and the second loss function until a preset condition is met. The first loss function indicates the similarity between the first prediction result and the second annotation result, and the second loss function indicates the similarity between the first prediction result and the second prediction result, or the second loss function indicates the similarity between the second prediction result and the second annotation result, and the second annotation result is the correct result of the first query sample.

[0193] In one possible design, see Fig.12 , Fig.12 A structural diagram of a neural network training device provided in an embodiment of the present application. The generation module 1103 is also used to generate feature information of a first support sample through a first neural network, and the first support sample is selected from a first group, and the first group is one of the M groups. The neural network training device 1100 also includes: an adding module 1105, which is used to add the feature information of the first support sample to the first queue of the feature information library, the feature information library includes M queues corresponding to the M groups of support samples one by one, the first queue is a queue corresponding to the first group among the M queues, and is used to store feature information corresponding to the support samples of the first group; the acquisition module 1101 is also used to obtain second feature information corresponding to the M groups of support samples according to the feature information library.

[0194] In one possible design, the second queue is any queue among the M queues, and the second queue includes characteristic information of at least one supporting sample; the acquisition module 1101 is specifically used to average the characteristic information of all supporting samples included in the second queue to obtain a second characteristic information corresponding to the second queue.

[0195] In one possible design, generation module 1103 is specifically used to: perform a similarity calculation operation based on the second feature information and the first feature information to obtain first similarity information, where the first similarity information indicates the similarity between the first query sample and each group of support samples in the M groups of support samples; and generate a second prediction result based on the first similarity information and the first annotation result.

[0196] In one possible design, the first neural network is a neural network for classifying samples, the first sample subset includes N categories of first support samples, and the first prediction result indicates the predicted category of the first query sample in the N categories; the generation module 1103 is specifically used to: generate a first classification category based on the second feature information corresponding to the M groups of support samples, the first annotation results corresponding to the M groups of support samples, and the feature information of the first query sample, the first classification category indicates the predicted category of the first query sample in the M categories; obtain a second prediction result from the first classification category, the second prediction result indicates the predicted category of the first query sample in the N categories.

[0197] In a possible design, the first neural network is a neural network that performs regression processing on samples.

[0198] In one possible design, the M groups are grouped based on one or more of the following: users, locations, or time corresponding to the support samples.

[0199] In a possible design, at least one first support sample included in the first sample subset comes from the same group of the M groups, and at least one first query sample included in the first sample subset comes from the same group of the M groups.

[0200] In one possible design, the first neural network is any one of the following neural networks: a fully connected neural network, a convolutional neural network, or a residual neural network.

[0201] It should be noted that the information interaction, execution process, etc. between the modules / units in the neural network training device 1100 are the same as those in the present application. Figures 3 to 9 The corresponding method embodiments are based on the same concept. For specific contents, please refer to the description in the method embodiments shown above in this application, which will not be repeated here.

[0202] The present application also provides a sample processing device, see Fig.13 , Fig.13A structural schematic diagram of a sample processing device provided in an embodiment of the present application. The sample processing device 1300 may include an acquisition module 1301 and an input module 1302. Among them, the acquisition module 1301 is used to acquire a third support sample and a third query sample; the input module 1302 is used to input the third support sample and the third query sample into the first neural network, so as to obtain a third prediction result corresponding to the third query sample output by the first neural network, and the third prediction result is generated according to the similarity between the feature information of the third support sample and the feature information of the third query sample. The first neural network is trained according to the first loss function and the second loss function, the first loss function indicates the similarity between the prediction result output by the first neural network and the correct result, the second loss function indicates the similarity between the prediction result output by the first neural network and the second prediction result corresponding to the third query sample, or the second loss function indicates the similarity between the second prediction result and the correct result, the second prediction result is obtained according to the second feature information corresponding to the M group support sample, the correct result corresponding to the M group support sample and the feature information of the third query sample, the third support sample can be attributed to the support sample of the third group, the third query sample can be attributed to the query sample of the third group, and the third group is one of the M groups.

[0203] It should be noted that the information interaction, execution process, etc. between the modules / units in the sample processing device 1300 are the same as those in the present application. Fig.10 The corresponding method embodiments are based on the same concept. For specific contents, please refer to the description in the method embodiments shown above in this application, which will not be repeated here.

[0204] The present application also provides a training device. Fig.14 , Fig.14 A schematic diagram of a structure of a training device provided in an embodiment of the present application. The training device 1400 may be deployed with Fig.11 and Fig.12 The neural network training device 1100 described in the corresponding embodiment is used to implement Figures 3 to 9Functions of the training device in the corresponding embodiment. Specifically, the training device 1400 is implemented by one or more servers. The training device 1400 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 1422 (for example, one or more processors) and memory 1432, and one or more storage media 1430 (for example, one or more mass storage devices) storing application programs 1442 or data 1444. Among them, the memory 1432 and the storage medium 1430 can be short-term storage or permanent storage. The program stored in the storage medium 1430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the training device. Furthermore, the central processing unit 1422 can be configured to communicate with the storage medium 1430 to execute a series of instruction operations in the storage medium 1430 on the training device 1400.

[0205] The training device 1400 may also include one or more power supplies 1426, one or more wired or wireless network interfaces 1450, one or more input and output interfaces 1458, and / or, one or more operating systems 1441, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0206] In the embodiment of the present application, the central processor 1422 is used to execute Figures 3 to 9In the case of the training method of the neural network executed by the training device in the corresponding embodiment, specifically, the central processor 1422 is used to obtain a first sample subset from the sample set, the sample set includes M groups of support samples and M groups of query samples, and the first sample subset includes a first support sample and a first query sample; the first sample subset is input to the first neural network, the first neural network generates first feature information of the first query sample, and obtains a first prediction result corresponding to the first query sample output by the first neural network, the first prediction result is generated according to the similarity between the feature information of the first support sample and the first feature information; according to the second feature information corresponding to the M groups of support samples and the second feature information corresponding to the M groups The first annotation result corresponding to the support sample and the first feature information of the first query sample are used to generate a second prediction result corresponding to the first query sample, each of the first annotation results indicates a correct result corresponding to a group of support samples in the M groups of support samples; according to the first loss function and the second loss function, the first neural network is iteratively trained until a preset condition is met; wherein the first loss function indicates the similarity between the first prediction result and the second annotation result, and the second loss function indicates the similarity between the first prediction result and the second prediction result, or the second loss function indicates the similarity between the second prediction result and the second annotation result, and the second annotation result is the correct result of the first query sample.

[0207] It should be noted that the CPU 1422 executes Figures 3 to 9 The specific implementation of the neural network training method in the corresponding embodiment and the beneficial effects brought about can be referred to Figures 3 to 9 The descriptions in the corresponding method embodiments will not be repeated here one by one.

[0208] The present application also provides an execution device. Fig.15 , Fig.15 A schematic diagram of the structure of an execution device provided in an embodiment of the present application. Among them, the execution device 1500 may be deployed with Fig.13 The sample processing device 1300 described in the corresponding embodiment is used to implement Fig.10 The functions of the execution device in the corresponding embodiment. Specifically, the execution device 1500 includes: a receiver 1501, a transmitter 1502, a processor 1503 and a memory 1504 (wherein the number of the processor 1503 in the execution device 1500 can be one or more, Fig.15 In the example of FIG. 1501 , the processor 1503 may include an application processor 15031 and a communication processor 15032. In some embodiments of the present application, the receiver 1501, the transmitter 1502, the processor 1503 and the memory 1504 may be connected via a bus or other means.

[0209] The memory 1504 may include a read-only memory and a random access memory, and provides instructions and data to the processor 1503. A portion of the memory 1504 may also include a non-volatile random access memory (NVRAM). The memory 1504 stores processor and operation instructions, executable modules or data structures, or subsets thereof, or extended sets thereof, wherein the operation instructions may include various operation instructions for implementing various operations.

[0210] The processor 1503 controls the operation of the execution device. In a specific application, the various components of the execution device are coupled together through a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus, and a status signal bus, etc. However, for the sake of clarity, various buses are referred to as bus systems in the figure.

[0211] The method disclosed in the above embodiment of the present application can be applied to the processor 1503, or implemented by the processor 1503. The processor 1503 can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 1503. The above processor 1503 can be a general processor, a digital signal processor (digital signal processing, DSP), a microprocessor or a microcontroller, and can further include an application specific integrated circuit (application specific integrated circuit, ASIC), a field programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The processor 1503 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to execute, or the hardware and software modules in the decoding processor can be combined and executed. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 1504, and the processor 1503 reads the information in the memory 1504 and completes the steps of the above method in combination with its hardware.

[0212] The receiver 1501 can be used to receive input digital or character information and generate signal input related to the relevant settings and function control of the execution device. The transmitter 1502 can be used to output digital or character information through the first interface; the transmitter 1502 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; the transmitter 1502 can also include a display device such as a display screen.

[0213] In the embodiment of the present application, the application processor 15031 is used to execute Fig.10 The corresponding embodiment executes the function of the device. It should be noted that the application processor 15031 executes Fig.10 For the specific implementation methods and beneficial effects of the functions of the execution device in the corresponding embodiments, please refer to Fig.10 The descriptions in the corresponding method embodiments will not be repeated here one by one.

[0214] The present application also provides a computer-readable storage medium in which a program is stored. When the program is run on a computer, the computer executes the above-mentioned Figures 3 to 9 The steps performed by the training device in the method described in the embodiment shown; or, causing the computer to perform the steps as described above Fig.10 The illustrated embodiment describes the steps performed by the device in the method.

[0215] The present application also provides a computer program product which, when executed on a computer, enables the computer to execute the above Figures 3 to 9 The steps performed by the training device in the method described in the embodiment shown, or the steps of causing the computer to perform the above Fig.10 The illustrated embodiment describes the steps performed by the device in the method.

[0216] The present application also provides a circuit system, which includes a processing circuit, wherein the processing circuit is configured to perform the above Figures 3 to 9 The steps performed by the training device in the method described in the embodiment shown, or the processing circuit is configured to perform the above Fig.10 The illustrated embodiment describes the steps performed by the device in the method.

[0217] The neural network training device or execution device provided in the embodiment of the present application can be specifically a chip, and the chip includes: a processing unit and a communication unit, the processing unit can be, for example, a processor, and the communication unit can be, for example, an input / output interface, a pin or a circuit. The processing unit can execute the computer execution instructions stored in the storage unit to enable the chip in the training device to execute the above Figures 3 to 9 The neural network training method described in the embodiment shown, or, to enable the chip in the training device to perform the above Fig.10 The processing method of the sample described in the illustrated embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc., and the storage unit can 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.

[0218] For details, please refer to Fig.16 , Fig.16 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 160, NPU 160 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 1603, which is controlled by the controller 1604 to extract matrix data from the memory and perform multiplication operations.

[0219] In some implementations, the operation circuit 1603 includes multiple processing units (Process Engine, PE) inside. In some implementations, the operation circuit 1603 is a two-dimensional systolic array. The operation circuit 1603 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 1603 is a general-purpose matrix processor.

[0220] 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 1602 and caches it on each PE in the operation circuit. The operation circuit takes the matrix A data from the input memory 1601 and performs matrix operation with matrix B, and the partial result or final result of the matrix is ​​stored in the accumulator 1608.

[0221] The unified memory 1606 is used to store input data and output data. The weight data is directly transferred to the weight memory 1602 through the direct memory access controller (DMAC) 1605. The input data is also transferred to the unified memory 1606 through the DMAC.

[0222] BIU stands for Bus Interface Unit 1610 , which is used for the interaction between the AXI bus and the DMAC and the instruction fetch buffer (IFB) 1609 .

[0223] The bus interface unit 1610 (Bus Interface Unit, BIU for short) is used for the instruction fetch memory 1609 to obtain instructions from the external memory, and is also used for the storage unit access controller 1605 to obtain the original data of the input matrix A or the weight matrix B from the external memory.

[0224] DMAC is mainly used to transfer input data in the external memory DDR to the unified memory 1606 or to transfer weight data to the weight memory 1602 or to transfer input data to the input memory 1601.

[0225] The vector calculation unit 1607 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.

[0226] In some implementations, the vector calculation unit 1607 can store the processed output vector to the unified memory 1606. For example, the vector calculation unit 1607 can apply a linear function and / or a nonlinear function to the output of the operation circuit 1603, 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 1607 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 1603, for example, for use in a subsequent layer in a neural network.

[0227] The controller 1604 is connected to an instruction fetch buffer 1609, which is used to store instructions used by the controller 1604; the unified memory 1606, the input memory 1601, the weight memory 1602 and the instruction fetch buffer 1609 are all on-chip memories. The external memory is private to the NPU hardware architecture.

[0228] Among them, the operations of each layer in the recurrent neural network can be performed by the operation circuit 1603 or the vector calculation unit 1607.

[0229] The processor mentioned in any of the above places may be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the program of the above-mentioned first aspect method.

[0230] 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.

[0231] Through the description of the above implementation mode, the technicians in the relevant 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 CLUs, 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, U disk, mobile hard disk, ROM, RAM, disk or 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.

[0232] 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.

[0233] 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.

Claims

1. A neural network training method, It is characterized in that The method comprises: Acquire a first sample subset from a sample set, the sample set including M groups of support samples, the first sample subset including a first support sample and a first query sample, the first support sample and the first query sample are both image samples, or the first support sample and the first query sample are both voice samples; Inputting the first sample subset into a first neural network, the first neural network generating first feature information of the first query sample, and obtaining a first prediction result corresponding to the first query sample output by the first neural network, wherein the first prediction result is generated according to a similarity between the feature information of the first support sample and the first feature information; Generate a second prediction result corresponding to the first query sample according to the second feature information corresponding to the M groups of support samples, the first annotation results corresponding to the M groups of support samples, and the first feature information of the first query sample, each of the first annotation results indicating a correct result corresponding to a group of support samples in the M groups of support samples; According to the first loss function and the second loss function, the first neural network is trained until a preset condition is met; Among them, the first loss function indicates the similarity between the first prediction result and the second annotation result, the second loss function indicates the similarity between the first prediction result and the second prediction result, or the second loss function indicates the similarity between the second prediction result and the second annotation result, and the second annotation result is the correct result of the first query sample.

2. The method according to claim 1, It is characterized in that After inputting the first sample subset into the first neural network, the method further includes: generating feature information of the first supporting sample by the first neural network, wherein the first supporting sample is selected from a first group, and the first group is one of the M groups; Adding the feature information of the first supporting sample to a first queue of a feature information library, the feature information library comprising M queues corresponding one-to-one to the M groups of supporting samples, the first queue being a queue corresponding to the first group among the M queues, and being used to store the feature information corresponding to the supporting samples of the first group; Before generating a second prediction result corresponding to the first query sample according to the second feature information corresponding to the M groups of support samples, the first annotation result corresponding to the M groups of support samples, and the first feature information, the method further includes: According to the feature information library, second feature information corresponding to the M groups of supporting samples is obtained.

3. The method according to claim 2, It is characterized in that The second queue is any queue among the M queues, the second queue includes feature information of at least one supporting sample, and acquiring second feature information corresponding to the M groups of supporting samples according to the feature information library includes: An average value is taken for the feature information of all supporting samples included in the second queue to obtain a second feature information corresponding to the second queue.

4. The method according to claim 1, It is characterized in that The generating a second prediction result corresponding to the first query sample according to the second feature information corresponding to the M groups of support samples, the first annotation result corresponding to the M groups of support samples, and the first feature information includes: Performing a similarity calculation operation according to the second feature information and the first feature information to obtain first similarity information, where the first similarity information indicates a similarity between the first query sample and each group of support samples in the M groups of support samples; The second prediction result is generated according to the first similarity information and the first annotation result.

5. The method according to any one of claims 1 to 4, It is characterized in that The first neural network is a neural network for classifying samples, the first sample subset includes N categories of first support samples, and the first prediction result indicates a predicted category of the first query sample in the N categories; The generating a second prediction result corresponding to the first query sample according to the second feature information corresponding to the M groups of support samples, the first annotation result corresponding to the M groups of support samples, and the feature information of the first query sample includes: generating a first classification category according to the second feature information corresponding to the M groups of support samples, the first annotation results corresponding to the M groups of support samples, and the feature information of the first query sample, wherein the first classification category indicates a predicted category of the first query sample in the M categories corresponding to the M groups; The second prediction result is obtained from the first classification category, where the second prediction result indicates the predicted category of the first query sample in the N categories.

6. The method according to any one of claims 1 to 4, It is characterized in that The first neural network is a neural network that performs regression processing on samples.

7. The method according to claim 6, It is characterized in that The M groups are grouped based on one or more of the following: users, locations or times corresponding to the supporting samples.

8. The method according to claim 6, It is characterized in that At least one first support sample included in the first sample subset comes from the same group as the M groups, and at least one first query sample included in the first sample subset comes from the same group as the M groups.

9. The method according to any one of claims 1 to 4, It is characterized in that The first neural network is any one of the following neural networks: a fully connected neural network, a convolutional neural network or a residual neural network.

10. A method for processing a sample, It is characterized in that The method comprises: Obtaining a third support sample and a third query sample; Inputting the third support sample and the third query sample into a first neural network, so as to output a third prediction result corresponding to the third query sample through the first neural network, wherein the third prediction result is generated according to the similarity between the feature information of the third support sample and the feature information of the third query sample; Among them, the first neural network is trained according to a first loss function and a second loss function, the first loss function indicates the similarity between the prediction result output by the first neural network and the correct result, the second loss function indicates the similarity between the prediction result output by the first neural network and the second prediction result corresponding to the third query sample, or, the second loss function indicates the similarity between the second prediction result and the correct result, the second prediction result is obtained according to the second feature information corresponding to the M groups of support samples, the correct result corresponding to the M groups of support samples and the feature information of the third query sample, the third support sample can be attributed to the support sample of the third group, the third query sample can be attributed to the query sample of the third group, the third group is one of the M groups, the third support sample and the third query sample are both image samples, or, the third support sample and the third query sample are both speech samples.

11. A neural network training device, It is characterized in that The device comprises: an acquisition module, configured to acquire a first sample subset from a sample set, the sample set comprising M groups of support samples, the first sample subset comprising a first support sample and a first query sample, the first support sample and the first query sample both being image samples, or the first support sample and the first query sample both being voice samples; an input module, configured to input the first sample subset into a first neural network, the first neural network generating first feature information of the first query sample, and obtaining a first prediction result corresponding to the first query sample output by the first neural network, wherein the first prediction result is generated according to a similarity between the feature information of the first support sample and the first feature information; a generating module, configured to generate a second prediction result corresponding to the first query sample according to the second feature information corresponding to the M groups of support samples, the first annotation results corresponding to the M groups of support samples, and the first feature information of the first query sample, wherein each of the first annotation results indicates a correct result corresponding to a group of support samples in the M groups of support samples; A training module, used for iteratively training the first neural network according to a first loss function and a second loss function until a preset condition is met; Among them, the first loss function indicates the similarity between the first prediction result and the second annotation result, the second loss function indicates the similarity between the first prediction result and the second prediction result, or the second loss function indicates the similarity between the second prediction result and the second annotation result, and the second annotation result is the correct result of the first query sample.

12. The device according to claim 11, It is characterized in that The generating module is further used to generate feature information of the first supporting sample through the first neural network, the first supporting sample is selected from a first group, and the first group is one of the M groups; The apparatus further includes: an adding module, configured to add the feature information of the first supporting sample to a first queue of a feature information library, the feature information library including M queues corresponding one-to-one to the M groups of supporting samples, the first queue being one of the M queues corresponding to the first group, configured to store feature information corresponding to the supporting samples of the first group; The acquisition module is further used to acquire second feature information corresponding to the M groups of supporting samples according to the feature information library.

13. The device according to claim 12, It is characterized in that The second queue is any queue among the M queues, and the second queue includes feature information of at least one supporting sample; The acquisition module is specifically used to average the feature information of all supporting samples included in the second queue to obtain a second feature information corresponding to the second queue.

14. The device according to claim 11, It is characterized in that The generation module is specifically used for: Performing a similarity calculation operation according to the second feature information and the first feature information to obtain first similarity information, where the first similarity information indicates a similarity between the first query sample and each group of support samples in the M groups of support samples; The second prediction result is generated according to the first similarity information and the first annotation result.

15. The device according to any one of claims 11 to 14, It is characterized in that The first neural network is a neural network for classifying samples, the first sample subset includes N categories of first support samples, and the first prediction result indicates a predicted category of the first query sample in the N categories; The generation module is specifically used for: generating a first classification category according to the second feature information corresponding to the M groups of support samples, the first annotation results corresponding to the M groups of support samples, and the feature information of the first query sample, wherein the first classification category indicates a predicted category of the first query sample in the M categories corresponding to the M groups; The second prediction result is obtained from the first classification category, where the second prediction result indicates the predicted category of the first query sample in the N categories.

16. The device according to any one of claims 11 to 14, It is characterized in that The first neural network is a neural network that performs regression processing on samples.

17. The device according to claim 16, It is characterized in that The M groups are grouped based on one or more of the following: users, locations or times corresponding to the supporting samples.

18. The device according to claim 16, It is characterized in that At least one first support sample included in the first sample subset comes from the same group as the M groups, and at least one first query sample included in the first sample subset comes from the same group as the M groups.

19. The device according to any one of claims 11 to 14, It is characterized in that The first neural network is any one of the following neural networks: a fully connected neural network, a convolutional neural network or a residual neural network.

20. A sample processing device, It is characterized in that The device comprises: An acquisition module, used for acquiring a third support sample and a third query sample; an input module, configured to input the third support sample and the third query sample into a first neural network, so as to output a third prediction result corresponding to the third query sample through the first neural network, wherein the third prediction result is generated according to a similarity between feature information of the third support sample and feature information of the third query sample; Among them, the first neural network is trained according to a first loss function and a second loss function, the first loss function indicates the similarity between the prediction result output by the first neural network and the correct result, the second loss function indicates the similarity between the prediction result output by the first neural network and the second prediction result corresponding to the third query sample, or, the second loss function indicates the similarity between the second prediction result and the correct result, the second prediction result is obtained according to the second feature information corresponding to the M groups of support samples, the correct result corresponding to the M groups of support samples and the feature information of the third query sample, the third support sample can be attributed to the support sample of the third group, the third query sample can be attributed to the query sample of the third group, the third group is one of the M groups, the third support sample and the third query sample are both image samples, or, the third support sample and the third query sample are both speech samples.

21. A training device, It is characterized in that The method comprises a processor, wherein the processor is coupled to a memory, wherein the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the method according to any one of claims 1 to 9 is implemented.

22. An execution device, It is characterized in that The method comprises a processor, wherein the processor is coupled to a memory, wherein the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the method according to claim 10 is implemented.

23. A computer-readable storage medium, It is characterized in that The invention comprises a program which, when being executed on a computer, causes the computer to execute the method according to any one of claims 1 to 9, or causes the computer to execute the method according to claim 10.

24. A circuit system, It is characterized in that The circuit system comprises a processing circuit configured to perform the method according to any one of claims 1 to 9 or the processing circuit configured to perform the method according to claim 10.

Citation Information

Cited By

  • Neural network training method and related device

    WO2022012407A1