Training method, device and system for neural network model

By sharing network parameters of the source domain and target domain in the neural network model and using preset loss functions for loss processing, the problem of domain distribution cannot be accurately aligned is solved, and better generalization performance and the effect of reducing negative migration is achieved. .

CN113191478BActive Publication Date: 2025-02-14ALIBABA GROUP HOLDING LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010036613.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-01-14
Publication Date
2025-02-14
Estimated Expiration
2040-01-14

AI Technical Summary

Technical Problem

When training neural network models in the prior art, the domain distribution cannot be accurately aligned, resulting in degradation of generalization performance and negative migration.

Method used

By entering the labeled source domain sample data and unlabeled target domain sample data respectively, and sharing the same network parameters, the sample data is lost by using the preset loss function to update the network parameters , to achieve accurate alignment of domain distribution.

Benefits of technology

This method effectively constrains the consistency of feature structures of different domains, increases the discriminant nature of the source domain and the target domain characteristics, makes the domain distribution easier to align, reduces the occurrence of negative migration, and improves the generalization performance of neural network models in the target domain.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113191478B_ABST
    Figure CN113191478B_ABST
Patent Text Reader

Abstract

The present application discloses a training method, device and system for a neural network model. The neural network model includes: a source domain model and a target domain model, and the method includes: inputting a first type of sample data into the source domain model and inputting a second type of sample data into the target domain model, respectively, wherein the first type of sample data is source domain sample data with labels, and the second type of sample data is target domain sample data without labels, and the source domain model and the target domain model share the same network parameters; performing loss processing on the first type of sample data and the second type of sample data using a preset loss function to obtain a processing result; updating the network parameters according to the processing result, and training to obtain a neural network model. The present application solves the technical problem in the prior art that the domain distribution cannot be accurately aligned when training a neural network model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular, to a method, device and system for training a neural network model. Background Art

[0002] At present, people can use neural network models to achieve system identification, pattern recognition, intelligent control, etc. The use of neural network models has brought convenience to human scientific research and life. However, the training of neural network models usually requires a large amount of labeled data, but the cost of obtaining a large amount of labeled data is relatively high. In order to solve this problem, the existing technology simultaneously uses labeled data samples from other similar fields (i.e., source domains) and unlabeled samples from the field to be learned (i.e., target domains) to learn a model with good generalization in the target domain. This method is an unsupervised domain adaptation algorithm.

[0003] Classic domain adaptation algorithms include Deep Domain Confusion (DDC) network and Deep Adaptation Network (DAN). Both of the above methods learn the source domain and target domain models respectively through a two-stream convolutional neural network, and use the maximum mean difference to align the feature distributions of the source domain and the target domain. For DDC, the maximum mean difference is only used in the last fully connected layer, while DAN uses the kernelized maximum mean difference in all fully connected layers. Among them, Maximum Mean Discrepancy (MMD) is currently the most widely used method in the field of domain adaptation to measure the distance between two different distributions. This method can use the difference in the means of two feature distributions in the regenerated Hilbert space as the distance between the two distributions.

[0004] However, the above methods only consider global alignment and do not consider semantic information such as categories, which leads to partial alignment or even wrong alignment, which in turn reduces the generalization performance of the neural network model in the target domain. For example, in domain adaptation of handwritten digit recognition, the feature distribution of the number "2" in the target domain may be aligned to the feature distribution of the number "3" in the source domain, resulting in "negative transfer".

[0005] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0006] The embodiments of the present application provide a method, device and system for training a neural network model, so as to at least solve the technical problem in the prior art that domain distribution cannot be accurately aligned when training a neural network model.

[0007] According to one aspect of an embodiment of the present application, a training method for a neural network model is provided, comprising: inputting a first type of sample data into a source domain model and inputting a second type of sample data into a target domain model, wherein the first type of sample data is source domain sample data with labels, and the second type of sample data is target domain sample data without labels, and the source domain model and the target domain model share the same network parameters; performing loss processing on the first type of sample data and the second type of sample data using a preset loss function to obtain a processing result; updating the network parameters according to the processing result, and training to obtain a neural network model. The neural network model includes: a source domain model and a target domain model.

[0008] According to one aspect of an embodiment of the present application, there is provided a data processing method, comprising: obtaining an object to be identified; identifying the object to be identified using a neural network model, and outputting an identification result; wherein the neural network model comprises: a first granularity machine learning model and a second granularity machine learning model, the first granularity machine learning model is trained using a first category of sample data, and the second granularity machine learning model is trained using a second category of sample data, the first category of sample data is labeled sample data, and the second category of sample data is unlabeled sample data, and the first granularity machine learning model and the second granularity machine learning model share at least a portion of the same network parameters.

[0009] According to another aspect of the embodiment of the present application, a training device for a neural network model is also provided, including: an input module, used to input a first type of sample data into a source domain model and a second type of sample data into a target domain model, wherein the first type of sample data is labeled source domain sample data, and the second type of sample data is unlabeled target domain sample data, and the source domain model and the target domain model share the same network parameters; a processing module, used to perform loss processing on the first type of sample data and the second type of sample data using a preset loss function to obtain a processing result; an updating module, used to update the network parameters according to the processing result, and train to obtain a neural network model. The neural network model includes: a source domain model and a target domain model.

[0010] According to another aspect of an embodiment of the present application, a storage medium is also provided, which includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the above-mentioned neural network model training method or the above-mentioned data processing method.

[0011] According to another aspect of an embodiment of the present application, a processor is also provided, which is used to run a program, wherein the above-mentioned training method of the neural network model or the above-mentioned data processing method is executed when the program is running.

[0012] According to another aspect of the embodiment of the present application, a training system for a neural network model is also provided, including: a processor; and a memory connected to the processor, for providing the processor with instructions for processing the following processing steps: respectively inputting the first type of sample data into the source domain model and inputting the second type of sample data into the target domain model, wherein the first type of sample data is source domain sample data with labels, and the second type of sample data is target domain sample data without labels, and the source domain model and the target domain model share the same network parameters; performing loss processing on the first type of sample data and the second type of sample data using a preset loss function to obtain a processing result; updating the network parameters according to the processing result, and training to obtain a neural network model. Wherein, the neural network model includes: a source domain model and a target domain model.

[0013] According to another aspect of an embodiment of the present application, a method for determining shared network parameters is also provided, including: using a first category of sample data to train a first granularity machine learning model in a neural network model to obtain a first training result, wherein the first category of sample data is labeled sample data; using a second category of sample data to train a second granularity machine learning model in the neural network model to obtain a second training result, wherein the second category of sample data is unlabeled sample data; and determining the shared network parameters between the first granularity machine learning model and the second granularity machine learning model based on the first training result and the second training result.

[0014] In an embodiment of the present application, the neural network model is trained by using self-similarity consistency and feature discriminability, by respectively inputting the first type of sample data into the source domain model and the second type of sample data into the target domain model, and then using a preset loss function to perform loss processing on the first type of sample data and the second type of sample data to obtain processing results, and finally the network parameters are updated according to the processing results to train the neural network model.

[0015] In the above process, the source domain model and the target domain model share the same network parameters, thereby constraining the feature structures of different domains to be consistent, thereby ensuring the correlation between the different features of the source domain model and the target domain model. In addition, the sample data is processed by the preset loss function, and the network parameters are updated based on the processing results, which increases the discriminability of the source domain and target domain features, making it easier to align the source domain and target domain, thereby reducing the occurrence of negative transfer.

[0016] From the above, it can be seen that the solution provided in the present application achieves the purpose of training the neural network model, thereby realizing the technical effect of ensuring the accurate alignment of the domain distribution when training the neural network model, and further solving the technical problem that the domain distribution cannot be accurately aligned when training the neural network model in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0018] Figure 1 is a hardware structure block diagram of a computing device for implementing a training method for a neural network model according to an embodiment of the present application;

[0019] FIG. 2( a ) is a diagram of an optional scene application of object recognition according to an embodiment of the present application;

[0020] FIG2( b) is a flow chart of a method for training a neural network model according to an embodiment of the present application;

[0021] Figure 3 is a flowchart of an optional training method of a neural network model according to an embodiment of the present application;

[0022] Figure 4 is a schematic diagram of an optional loss processing according to an embodiment of the present application;

[0023] Figure 5 is a schematic diagram of an optional loss processing according to an embodiment of the present application;

[0024] Figure 6 is a schematic diagram of a training device for a neural network model according to an embodiment of the present application;

[0025] Figure 7 is a structural block diagram of a computing device according to an embodiment of the present application; and

[0026] Figure 8 is a flow chart of a data processing method according to an embodiment of the present application;

[0027] Fig. 9 is a schematic diagram of an optional scenario based on a data processing method according to an embodiment of the present application;

[0028] Fig.10 It is a flowchart of a method for determining shared network parameters according to an embodiment of the present application. DETAILED DESCRIPTION

[0029] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0030] It should be noted that 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 data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0031] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:

[0032] The domain adaptation algorithm is an algorithm that can overcome the difference between the source domain distribution and the target domain distribution and achieve the learning task on the target domain. In traditional machine learning algorithms, it is usually assumed that the training samples and test samples come from the same probability distribution, and then the corresponding model and discrimination criteria are designed to predict the output of the sample to be tested. However, in many practical scenarios, the training set samples and the test set samples may come from data with different distributions. In this case, the performance of the model learned well on the training set will be severely degraded on the test set, and the domain adaptation algorithm can achieve learning when the probability distribution of the source domain and the target domain is inconsistent, that is, domain adaptive learning.

[0033] Unsupervised domain adaptation algorithm is a method that uses labeled source domain data and unlabeled target domain data to learn a model with good generalization performance in the target domain.

[0034] Self-similarity consistency refers to ensuring that the correlation between different features in the source domain feature space is consistent with the correlation between different features in the target domain feature space.

[0035] The discriminability of a feature refers to the distinguishability of the feature. The closer the feature distributions of samples of the same type are, the stronger the discriminability of the feature; the greater the difference in the feature distributions of samples of different types, the stronger the discriminability of the feature.

[0036] Example 1

[0037] According to an embodiment of the present application, an embodiment of a training method for a neural network model is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0038] The method embodiment provided in the first embodiment of the present application can be executed in a mobile terminal, a computing device or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computing device (or mobile device) for implementing a training method for a neural network model. Figure 1 As shown, the computing device 10 (or mobile device 10) may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (BUS) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is for illustration only and does not limit the structure of the electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.

[0039] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computing device 10 (or mobile device). As involved in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0040] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the training method of the neural network model in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the training method of the neural network model described above is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computing device 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0041] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computing device 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0042] The display may be, for example, a touch screen liquid crystal display (LCD) that may enable a user to interact with a user interface of computing device 10 (or mobile device).

[0043] It should be noted that, in some optional embodiments, the above Figure 1 The computer device (or mobile device) shown may include hardware elements (including circuits), software elements (including computer code stored on a computer-readable medium), or a combination of hardware elements and software elements. It should be noted that Figure 1 This is merely one example of a particular embodiment and is intended to illustrate the types of components that may be present in the above-described computer device (or mobile device).

[0044] Optionally, FIG2(a) shows a scene application diagram of object recognition based on the training method of the neural network model of the present application, wherein in FIG2(a), the object to be recognized is an image. Specifically, the user inputs the object to be recognized into a computing device, wherein the computing device may be, but is not limited to, a tablet, a PAD, a PC, etc. After obtaining the object to be recognized, the computing device inputs the object to be recognized into the neural network model provided in the present application, and the neural network model performs recognition processing on the object to be recognized to obtain a recognition result, and finally, outputs the recognition result to a display unit. For example, in FIG2(a), the output recognition result is "dog". The display unit may be integrated with the computing device, for example, the display unit is a display of the computing device; in addition, the display unit may also be other devices independent of the computing device.

[0045] It should be noted that the neural network model trained by the training method of the neural network model provided in this application can be applied not only in the object recognition field shown in Figure 2(a), but also in the fields of automatic control, pattern recognition, automatic control, robot control, and signal processing, etc.

[0046] In addition, it should be noted that the present application obtains the neural network model by updating the parameters of the convolution layer adjacent to the output layer in the neural network model in Figure 2(a).

[0047] Optional. The neural network model includes: a source domain model and a target domain model, wherein the source domain model and the target domain model can be trained using a two-stream neural network. The source domain model and the target domain model share the same network parameters, thereby constraining the feature structures of different domains to be consistent, thereby ensuring the correlation between different features of the source domain model and the target domain model.

[0048] Optionally, the execution subject of the training method of the neural network model of this embodiment can be a server or a client. In this application, the server is used as the main body for description. FIG2(b) shows a flow chart of the training method of the neural network model. It can be seen from the method flow chart shown in FIG2(b) that the training method of the neural network model provided in this application includes the following steps:

[0049] Step S202, respectively inputting the first type of sample data into the source domain model and the second type of sample data into the target domain model, wherein the first type of sample data is labeled source domain sample data, and the second type of sample data is unlabeled target domain sample data, and the source domain model and the target domain model share the same network parameters.

[0050] In step S202, the server uses a dual-stream deep convolutional neural network to process labeled source domain sample data and unlabeled target domain sample data respectively, that is, the source domain model and the target domain model use the same set of network parameters.

[0051] Optional, Figure 3 A flowchart of an optional training method for a neural network model is shown. Figure 3 It can be seen that the source domain model and the target domain model share the same network parameters, wherein the same network parameters at least include convolution layer parameters, fully connected layer parameters, and bias, etc. Optionally, the source domain model and the target domain model may adopt a ResNet (Residual Neural NetWord, residual network)-50 network model.

[0052] It should be noted that Figure 3 It can be seen that there is similarity between any two features in the feature space of the source domain model and the target domain model, which shows that the alignment of the domain distribution can be ensured through step S202.

[0053] Step S204: Perform loss processing on the first type of sample data and the second type of sample data using a preset loss function to obtain a processing result.

[0054] In step S204, the preset loss function includes three parts, namely, the source domain classification loss function, the consistency constraint loss function of the source domain and the target domain, and the source domain and the target domain simultaneously apply feature discrimination loss function. Among them, the source domain classification loss function can calculate the loss value corresponding to the classifier, the consistency constraint loss function of the source domain and the target domain is used to increase the norm of the feature by constraining the distance between the norm of the feature and a given constant, and the target domain simultaneously applies feature discrimination loss function. Through self-similar consistency constraints, the feature space structure of the source domain model and the target domain model tends to be consistent.

[0055] It should be noted that by performing loss processing on the first type of sample data and the second type of sample data respectively through the above three loss functions, the corresponding processing results can be obtained, and then the three corresponding processing results can be summed to obtain the final processing result, that is, the processing result satisfies the following formula:

[0056] loss=loss s +loss ssc +loss d

[0057] In the above formula, loss is the final processing result, loss s is the processing result corresponding to the source domain classification loss function, loss ss is the processing result corresponding to the consistency constraint loss function of the source domain and the target domain, lossd The processing results corresponding to the feature discriminative loss function are applied to the target domain at the same time.

[0058] Step S206, updating the network parameters according to the processing results, and training to obtain a neural network model.

[0059] It should be noted that in step S206, the process of updating the network parameters according to the processing results is the process of minimizing the preset loss function, that is, determining the network parameters that minimize the preset loss function, and finally obtaining the neural network model based on the network parameters training.

[0060] Based on the scheme defined in the above steps S202 to S206, it can be known that the method of training the neural network model by using self-similarity consistency and feature discriminability is to input the first type of sample data into the source domain model and the second type of sample data into the target domain model respectively, and then use the preset loss function to perform loss processing on the first type of sample data and the second type of sample data to obtain the processing results, and finally update the network parameters according to the processing results to train the neural network model.

[0061] It is easy to notice that the source domain model and the target domain model share the same network parameters, thus constraining the feature structures of different domains to be consistent, thereby ensuring the correlation between different features of the source domain model and the target domain model. In addition, by performing loss processing on the sample data through a preset loss function and updating the network parameters based on the processing results, the discriminability of the source domain and target domain features is increased, making it easier to align the source domain and target domain, thereby reducing the occurrence of negative transfer.

[0062] From the above, it can be seen that the solution provided in the present application achieves the purpose of training the neural network model, thereby realizing the technical effect of ensuring the accurate alignment of the domain distribution when training the neural network model, and further solving the technical problem that the domain distribution cannot be accurately aligned when training the neural network model in the prior art.

[0063] In an optional embodiment, before inputting the first type of sample data into the source domain model and the second type of sample data into the target domain model, the server initializes the neural network model using a model pre-trained by an image dataset. Optionally, the image dataset may be, but is not limited to, an ImageNet dataset.

[0064] Specifically, the server first pre-trains the neural network model on the ImageNet dataset, uses the pre-trained model as the first initial model, and then further trains the first initial model on the dataset of actual application to obtain the second initial model, wherein in the process of training the first initial model, only the last three layers of the neural network model need to be trained.

[0065] Optionally, the preset loss function includes: a source domain classification loss function, and the server uses the preset loss function to perform loss processing on the first category of sample data. Specifically, the server inputs the first parameter and the second parameter into the source domain classification loss function to obtain the classification loss result corresponding to the source domain sample data, and calculates the mean of the classification loss result corresponding to the source domain sample data to obtain the source domain classification loss result. Among them, the first parameter is the output result obtained after the source domain sample data is input into the source domain model, and the second parameter is the label of the source domain sample data.

[0066] It should be noted that the above process can satisfy the following formula:

[0067]

[0068] In the above formula, loss s is the source domain classification loss result, J(·,·) is the standard source domain classification loss function, is the output result after the i-th source domain sample data is input into the source domain model, n s is the number of sample data in the source domain, is the label of the source domain sample data.

[0069] Optionally, the preset loss function includes: a consistency constraint loss function of the source domain and the target domain, and the server uses the preset loss function to perform loss processing on the first category of sample data and the second category of sample data. Specifically, the server obtains a first similarity matrix and a second similarity matrix, and then calculates the Euclidean distance between the first similarity matrix and the second similarity matrix to obtain the consistency constraint loss result of the source domain and the target domain. Among them, the first similarity matrix is ​​a similarity matrix between different features in the source domain, and the second similarity matrix is ​​a similarity matrix between different features in the target domain. The matrix elements in the first similarity matrix represent the similarity between two different features of the adaptive layer in the source domain, and the matrix elements in the second similarity matrix represent the similarity between two different features of the adaptive layer in the target domain.

[0070] It should be noted that the above process can satisfy the following formula:

[0071]

[0072] In the above formula, loss sscis the consistency constraint loss result of the source domain and the target domain, D s ∈R L×L , D t ∈R L×L are the similarity matrices between different features in the source domain and the target domain, respectively, where D s is the first similarity matrix, D t is the second similarity matrix, and L is the number of neurons in the adaptive layer.

[0073] Optional, Figure 4 A schematic diagram showing an optional loss processing of the first sample data and the second sample data based on the consistency constraint loss function of the source domain and the target domain is shown. Figure 4 The processing process can be obtained as follows:

[0074]

[0075] in, represents the similarity (or distance) between the i-th feature and the j-th feature of the adaptive layer in the source domain; sim(·,·) represents a similarity measure function, wherein the similarity measure function can be any one of the following: dot product similarity function, Euclidean distance function and cosine similarity function.

[0076] Optionally, the dot product similarity function satisfies the following formula:

[0077] sim(x,y)=x·y

[0078] The Euclidean distance function satisfies the following formula:

[0079] sin(x, y)=||x·y||2

[0080] The cosine similarity function satisfies the following formula:

[0081]

[0082] In this application, heat kernel similarity is used as the similarity measure, that is,

[0083]

[0084]

[0085] Optionally, the preset loss function includes: applying a feature discrimination loss function to the source domain and the target domain at the same time, wherein the server uses the preset loss function to perform loss processing on the first type of sample data and the second type of sample data. Specifically, the server uses the target norm value and the multidimensional features of the source domain sample data output in the adaptive layer to calculate the first intermediate result, and then uses the target norm value and the multidimensional features of the target domain sample data output in the adaptive layer to calculate the second intermediate result, and finally uses the first intermediate result and the second intermediate result to calculate the source domain and the target domain to apply feature discrimination loss results at the same time. Among them, the target norm value is greater than the sample feature norms of the source domain and the target domain.

[0086] It should be noted that the above process can satisfy the following formula:

[0087]

[0088] In the above formula, loss d Apply feature discriminative loss to both source and target domains, n s and n t are the number of sample data in the source domain and the target domain, respectively, tn is the target norm value, such as Figure 5 A schematic diagram of an optional loss handling is shown in Figure 5 In the process, the source domain sample data and the target domain sample data are classified by the classifier respectively, and the target norm value needs to be larger than the sample feature norm of the source domain and the target domain. It is the L-dimensional feature output by the adaptive layer.

[0089] In an optional embodiment, after updating the network parameters according to the processing results and training the neural network model, the server also uses an adaptive moment estimation optimizer to update the network parameters to obtain an optimized neural network model. Optionally, the server can use Adam Optimizer in TensorFlow (i.e., the above-mentioned adaptive moment estimation optimizer) to update the parameters according to a preset loss function, wherein TensorFlow is a symbolic data system based on data flow programming, which is widely used in the programming implementation of various machine learning algorithms.

[0090] It should be noted that the ResNet-50 network has 5 stages, of which the fifth stage has three blocks. We only update the network parameters of the last block. The other network parameters remain unchanged, that is, the parameters pre-trained on ImageNet.

[0091] Based on the above content, it can be seen that the method provided by this application is based on the self-similarity consistency criterion, and ensures the alignment of distribution by aligning the similarity relationship between any two features in the feature space of the source domain and the target domain. At the same time, this method also uses more discriminative deep features to alleviate the adverse effects that may be caused by global feature alignment, and increases the distance between samples of different categories by increasing the norm of each sample. Compared with the traditional maximum mean difference, the method provided by this application greatly improves the performance of the domain adaptation algorithm.

[0092] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0093] Through the description of the above implementation methods, those skilled in the art can clearly understand that the training method of the neural network model according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0094] Example 2

[0095] According to an embodiment of the present application, a data processing method is also provided, wherein: Figure 8 A flow chart of a data processing method is shown, comprising Figure 8 It can be seen that the method includes the following steps:

[0096] Step S802: obtaining an object to be identified.

[0097] In step S802, the object to be identified may be an object in the image to be identified. For example, in the field of image recognition, a user inputs the image to be identified into a computing device, and the computing device performs recognition processing on the image to be identified and outputs a recognition result. The recognition result represents the identifier corresponding to the object in the image to be identified, for example, the object in the image to be identified is identified as a lost pet, etc. In addition, in the field of product detection, the above-mentioned object to be identified may be an image or related parameters of a product to be identified. By detecting the object to be identified, it can be determined whether the object to be identified is an abnormal object or whether it includes abnormal objects.

[0098] In an optional embodiment, if Fig. 9 In the schematic diagram of an optional scenario based on a data processing method, a user inputs an object to be identified into a computing device, so that the computing device can identify and / or detect the object to be identified. In another optional embodiment, the computing device can also automatically obtain the object to be identified based on a big data algorithm or a web crawler technology, and identify and / or detect the object to be identified. For example, the computing device actively detects whether there is any illegal web page content in a web page link in the network.

[0099] Step S804: Use a neural network model to identify the object to be identified and output the identification result.

[0100] In step S804, the neural network model includes: a first granularity machine learning model and a second granularity machine learning model, the first granularity machine learning model is trained using the first category of sample data, and the second granularity machine learning model is trained using the second category of sample data, the first category of sample data is labeled sample data, and the second category of sample data is unlabeled sample data, the first granularity machine learning model and the second granularity machine learning model share at least a part of the same network parameters, optionally, the first granularity machine learning model may be but not limited to a source domain model, the second granularity machine learning model may be but not limited to a target domain model, and the first granularity machine learning model and the second granularity machine learning model may share the same network parameters.

[0101] In addition, the first type of sample data and the second type of sample data can be processed by a preset loss function, and the parameters of the convolution layer adjacent to the output layer in the neural network model can be updated.

[0102] It should be noted that, in this embodiment, the preset loss function includes three parts, namely, the first granularity classification loss function, the consistency constraint loss function of the first granularity and the second granularity, and the feature discrimination loss function of the first granularity and the second granularity. Among them, the first granularity classification loss function can calculate the loss value corresponding to the classifier, the consistency constraint loss function of the first granularity and the second granularity is used to increase the norm of the feature by constraining the distance between the norm of the feature and a given constant, and the first granularity and the second granularity simultaneously applying the feature discrimination loss function can make the feature space structure of the first granularity machine learning model and the second granularity machine learning model tend to be consistent through self-similar consistency constraints.

[0103] In addition, by performing loss processing on the first type of sample data and the second type of sample data respectively through the above three loss functions, corresponding processing results can be obtained, and then the three corresponding processing results can be summed to obtain the final processing result. After obtaining the processing result, the parameters of the convolution layer adjacent to the output layer in the neural network model are further updated to train the neural network model.

[0104] Furthermore, if Fig. 9 As shown, after obtaining the neural network model, the computing device uses the neural network model to perform recognition processing on the object to be recognized and obtains the recognition result. Specifically, the computing device uses the first granularity machine learning model (such as Fig. 9 Net1 in the figure identifies the first part of the features (such as Fig. 9 1), and the second granularity machine learning model (such as Fig. 9 Net2 in the above example identifies the second part of the features (such as Fig. 9 Output 2), then perform weighted fusion processing on the first part of features and the second part of features to obtain multiple candidate classification results, and finally select the classification result with the highest probability from the multiple candidate classification results to obtain the recognition result, where Fig. 9 The computing module in is used to implement weighted fusion processing of the first part of features and the second part of features, and to select the classification result with the highest probability from multiple candidate classification results. Further, after obtaining the recognition result, the computing device can also output the recognition result.

[0105] For example, the object to be identified is a dog image. After the image to be identified is input into the neural network model, the first granularity machine learning model and the second granularity machine learning model respectively perform feature recognition on the dog image to obtain the first part of features and the second part of features. Optionally, the first part of features and the second part of features may contain multiple features, for example, the first part of features includes three features A, B and C, and the second part of features includes two features C and D. After obtaining the first part of features and the second part of features, the computing device further performs weighted fusion on the first part of features and the second part of features, for example, weighted fusion of at least one feature in the first part of features and at least one feature in the second part, respectively, to obtain an alternative classification result, for example, feature A in the first part of features and feature C and D in the second part of features can be weighted fused to obtain a classification result. It is easy to notice that since there are multiple combinations of weighted fusion of the first part of features and the second part of features, multiple alternative classification results can be obtained after the weighted fusion of the first part of features and the second part of features. Furthermore, the computing device selects the classification result with the highest probability from multiple alternative classification results as the recognition result. Since the probability of the classification result can represent the possibility that the object to be recognized belongs to the classification result, the greater the probability, the greater the possibility that the object to be recognized belongs to the classification result. Therefore, using the classification result with the highest probability as the recognition result can improve the accuracy of the recognition result.

[0106] In addition, it should be noted that the method for training the neural network model in this embodiment is the same as the method in Example 1. The relevant content has been explained in Example 1 and will not be repeated here.

[0107] As can be seen from the above, in this implementation, the first granularity machine learning model and the second granularity machine learning model share the same network parameters, thereby constraining the feature structures of different domains to be consistent, thereby ensuring the correlation between the different features of the first granularity machine learning model and the second granularity machine learning model. In addition, by performing loss processing on the sample data through a preset loss function, and updating the network parameters based on the processing results, the discriminability of the features of the first granularity machine learning model and the second granularity machine learning model is increased, making it easier to align the first granularity machine learning model and the second granularity machine learning model, thereby reducing the occurrence of negative migration.

[0108] From the above, it can be seen that the solution provided in the present application achieves the purpose of training the neural network model, thereby realizing the technical effect of ensuring the accurate alignment of the domain distribution when training the neural network model, and further solving the technical problem that the domain distribution cannot be accurately aligned when training the neural network model in the prior art.

[0109] Example 3

[0110] According to an embodiment of the present application, a method for determining a shared network parameter is also provided, wherein: Fig.10 A flow chart showing a method for determining shared network parameters is shown. Fig.10 It can be seen that the method includes the following steps:

[0111] Step S1002: Use the first category of sample data to train the first granularity machine learning model in the neural network model to obtain a first training result, wherein the first category of sample data is labeled sample data.

[0112] In step S1002, the first training result may be a first network parameter corresponding to the first granularity machine learning model, wherein the first network parameter includes at least a convolution layer parameter, a fully connected layer parameter, and a bias corresponding to the first granularity machine learning model. Optionally, the first granularity machine learning model may be, but is not limited to, a source domain model.

[0113] In an optional embodiment, the computing device first initializes the neural network model using a model pre-trained by an image data set, wherein the image data set may be, but is not limited to, an ImageNet data set. Specifically, the computing device first pre-trains the neural network model on the ImageNet data set, uses the pre-trained model as the first initial model, and then further trains the first initial model on a data set of actual application to obtain a second initial model, wherein in the process of training the first initial model, only the last three layers of the neural network model need to be trained. Furthermore, after completing the initialization of the neural network model, the computing device trains the first granularity machine learning model using a first preset loss function and a first type of sample data to obtain a first training result.

[0114] Step S1004, using the second category of sample data to train the second granularity machine learning model in the neural network model to obtain a second training result, wherein the second category of sample data is sample data without labels.

[0115] In step S1004, the second training result may be a second network parameter corresponding to the second granularity machine learning model, wherein the second network parameter includes at least a convolution layer parameter, a fully connected layer parameter, and a bias corresponding to the second granularity machine learning model. Optionally, the second granularity machine learning model may be, but is not limited to, a target domain model.

[0116] In an optional embodiment, similar to step S1002, after completing the initialization operation of the neural network model, the second granularity machine learning model is trained by a second preset loss function and the second type of sample data to obtain a second training result. The second preset loss function may be the same as the first preset loss function, or may be a function different from the first preset loss function.

[0117] Step S1006, determining shared network parameters between the first granularity machine learning model and the second granularity machine learning model based on the first training result and the second training result.

[0118] It should be noted that, through step S1002, multiple network parameters corresponding to the first granularity machine learning model can be obtained, and through step S1004, multiple network parameters corresponding to the second granularity machine learning model can be obtained, and then shared network parameters are selected from the above multiple network parameters. Among them, the shared network parameters can be selected by the user through the computing device, and in addition, the shared network parameters can also be selected by the computing device from multiple network parameters through a preset algorithm.

[0119] From the above, it can be seen that in this implementation, the first granularity machine learning model and the second granularity machine learning model share the same network parameters, thereby constraining the feature structures of different domains to be consistent, thereby ensuring the correlation between different features of the first granularity machine learning model and the second granularity machine learning model.

[0120] From the above, it can be seen that the solution provided in the present application achieves the purpose of training the neural network model, thereby realizing the technical effect of ensuring the accurate alignment of the domain distribution when training the neural network model, and further solving the technical problem that the domain distribution cannot be accurately aligned when training the neural network model in the prior art.

[0121] In an optional embodiment, it can be known from step S1006 that the user can select the shared network parameters between the first granularity machine learning model and the second granularity machine learning model from multiple network parameters through a computing device. Specifically, the computing device first determines multiple candidate network parameters based on the first training result and the second training result, then displays the multiple candidate network parameters through a visualization interface, and finally determines the shared network parameters between the first granularity machine learning model and the second granularity machine learning model from the multiple candidate network parameters in response to the control operation received by the visualization interface.

[0122] Optionally, the computing device has a display screen that can display a visualization interface. After training the first granularity machine learning model and obtaining the first training result, the visualization interface can display the first network parameter corresponding to the first training result, and after training the second granularity machine learning model and obtaining the second training result, the second network parameter corresponding to the second training result is displayed, so that the user can intuitively observe which network parameters the first granularity machine learning model and the second granularity machine learning model have respectively. The computing device then further processes the first network parameter and the second network parameter to obtain a plurality of candidate network parameters. At this point, a plurality of candidate network parameters can be displayed in the visualization interface, and the user obtains a shared network parameter by selecting a plurality of candidate network parameters in the visualization interface. Optionally, the user can select a shared network parameter from a plurality of candidate network parameters based on experience or usage requirements.

[0123] In an optional embodiment, the neural network model also includes: a third granularity machine learning model. Optionally, in the present application, the shared network parameters between machine learning models of different granularities may also be transitive. Specifically, if the shared network parameters between the first granularity machine learning model and the second granularity machine learning model and the shared network parameters between the second granularity machine learning model and the third granularity machine learning model are at least partially the same, the first granularity machine learning model and the third granularity machine learning model are trained to determine the shared network parameters between the first granularity machine learning model and the third granularity machine learning model. For example, the first shared network parameters between the first granularity machine learning model and the second granularity machine learning model include: A, B and C, and the second shared network parameters between the second granularity machine learning model and the third granularity machine learning model include: B, D and E, then the same network parameter in the two shared network parameters is B, then when the first granularity machine learning model and the third granularity machine learning model are trained, the same shared network parameters can be directly used as one of the third shared network parameters between the first granularity machine learning model and the third granularity machine learning model.

[0124] In another optional embodiment, if the first shared network parameters between the first granularity machine learning model and the second granularity machine learning model and the second shared network parameters between the second granularity machine learning model and the third granularity machine learning model are at least partially the same, the first granularity machine learning model and the third granularity machine learning model are trained to determine that the third shared network parameters between the first granularity machine learning model and the third granularity machine learning model are the union of the first shared network parameters and the second shared network parameters. For example, the first shared network parameters include: A, B and C, and the second shared network parameters include: B, D and E, then the third shared network parameters may include: A, B, C, D and E.

[0125] It should be noted that, since the shared network parameters are transitive, when training the neural network model, the network parameters of the neural network model can be directly determined based on the transitivity of the shared network parameters, thereby improving the training rate of the neural network model.

[0126] Example 4

[0127] According to an embodiment of the present application, a training device for a neural network model for implementing the training method of the neural network model is also provided, wherein the neural network model includes: a source domain model and a target domain model, such as Figure 6 As shown, the device 60 includes: an input module 601 , a processing module 603 and an updating module 605 .

[0128] Among them, the input module 601 is used to input the first type of sample data into the source domain model and the second type of sample data into the target domain model respectively, wherein the first type of sample data is labeled source domain sample data, and the second type of sample data is unlabeled target domain sample data, and the source domain model and the target domain model share the same network parameters; the processing module 603 is used to use a preset loss function to perform loss processing on the first type of sample data and the second type of sample data to obtain processing results; the updating module 605 is used to update the network parameters according to the processing results and train to obtain a neural network model.

[0129] It should be noted that the above input module 601, processing module 603 and update module 605 correspond to steps S202 to S206 in Example 1, and the three modules and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in the above Example 1. It should be noted that the above modules, as part of the apparatus, can be run in the computing device 10 provided in Example 1.

[0130] In an optional embodiment, the training device for the neural network model also includes: a first processing module, used to initialize the neural network model using a model pre-trained by an image data set before inputting the first type of sample data into the source domain model and before inputting the second type of sample data into the target domain model.

[0131] In an optional embodiment, the preset loss function includes: a source domain classification loss function, and the processing module includes: a first input module and a first calculation module. The first input module is used to input the first parameter and the second parameter into the source domain classification loss function to obtain the classification loss result corresponding to the source domain sample data, wherein the first parameter is the output result obtained after the source domain sample data is input into the source domain model, and the second parameter is the label of the source domain sample data; the first calculation module is used to calculate the mean of the classification loss result corresponding to the source domain sample data to obtain the source domain classification loss result.

[0132] In an optional embodiment, the preset loss function includes: a consistency constraint loss function of the source domain and the target domain, and the processing module includes: an acquisition module and a second calculation module. The acquisition module is used to obtain a first similarity matrix and a second similarity matrix, wherein the first similarity matrix is ​​a similarity matrix between different features in the source domain, and the second similarity matrix is ​​a similarity matrix between different features in the target domain. The matrix elements in the first similarity matrix represent the similarity between two different features of the adaptive layer in the source domain, and the matrix elements in the second similarity matrix represent the similarity between two different features of the adaptive layer in the target domain; the second calculation module is used to calculate the Euclidean distance between the first similarity matrix and the second similarity matrix to obtain the consistency constraint loss result of the source domain and the target domain.

[0133] In an optional embodiment, the preset loss function includes: applying feature discrimination loss function to the source domain and the target domain at the same time, and the processing module includes: a third calculation module, a fourth calculation module and a fifth calculation module. Among them, the third calculation module is used to calculate the first intermediate result using the target norm value and the multidimensional features output by the source domain sample data in the adaptive layer, wherein the target norm value is greater than the sample feature norm of the source domain and the target domain; the fourth calculation module is used to calculate the second intermediate result using the target norm value and the multidimensional features output by the target domain sample data in the adaptive layer; the fifth calculation module is used to calculate the result of applying feature discrimination loss to the source domain and the target domain at the same time using the first intermediate result and the second intermediate result.

[0134] In an optional embodiment, the training device for the neural network model also includes: an optimization module, which is used to update the network parameters according to the processing results, and after the neural network model is trained, use an adaptive moment estimation optimizer to update the network parameters to obtain an optimized neural network model.

[0135] Example 5

[0136] According to an embodiment of the present application, a neural network model training system for implementing the above-mentioned neural network model training method is also provided, and the system includes: a processor and a memory.

[0137] The memory is connected to the processor and is used to provide the processor with instructions for processing the following processing steps: respectively inputting the first type of sample data into the source domain model and inputting the second type of sample data into the target domain model, wherein the first type of sample data is labeled source domain sample data, and the second type of sample data is unlabeled target domain sample data, and the source domain model and the target domain model share the same network parameters; using a preset loss function to perform loss processing on the first type of sample data and the second type of sample data to obtain processing results; updating the network parameters according to the processing results, and training to obtain a neural network model.

[0138] It can be seen that the method of training the neural network model by using self-similarity consistency and feature discriminability is to input the first type of sample data into the source domain model and the second type of sample data into the target domain model respectively, and then use the preset loss function to perform loss processing on the first type of sample data and the second type of sample data to obtain the processing result, and finally update the network parameters according to the processing result to train the neural network model.

[0139] It is easy to notice that the source domain model and the target domain model share the same network parameters, thus constraining the feature structures of different domains to be consistent, thereby ensuring the correlation between different features of the source domain model and the target domain model. In addition, by performing loss processing on the sample data through a preset loss function and updating the network parameters based on the processing results, the discriminability of the source domain and target domain features is increased, making it easier to align the source domain and target domain, thereby reducing the occurrence of negative transfer.

[0140] From the above, it can be seen that the solution provided in the present application achieves the purpose of training the neural network model, thereby realizing the technical effect of ensuring the accurate alignment of the domain distribution when training the neural network model, and further solving the technical problem that the domain distribution cannot be accurately aligned when training the neural network model in the prior art.

[0141] It should be noted that the training system of the neural network model in this embodiment can execute the training method of the neural network model in Example 1. The relevant content has been explained in Example 1 and will not be repeated here.

[0142] Example 6

[0143] The embodiment of the present application may provide a computing device, which may be any computing device in a computing device group. Optionally, in this embodiment, the computing device may also be replaced by a terminal device such as a mobile terminal.

[0144] Optionally, in this embodiment, the computing device may be located in at least one network device among a plurality of network devices of a computer network.

[0145] In this embodiment, the computing device can execute the program code of the following steps in the training method of the neural network model: inputting the first type of sample data into the source domain model and the second type of sample data into the target domain model, respectively, wherein the first type of sample data is source domain sample data with labels, and the second type of sample data is target domain sample data without labels, and the source domain model and the target domain model share the same network parameters; using a preset loss function to perform loss processing on the first type of sample data and the second type of sample data to obtain a processing result; updating the network parameters according to the processing result, and training to obtain a neural network model. Wherein, the neural network model includes: a source domain model and a target domain model.

[0146] Optionally, Figure 7 is a structural block diagram of a computing device according to an embodiment of the present application. Figure 7 As shown, the computing device 10 may include: one or more (only one is shown in the figure) processors 702 , a memory 704 , and a peripheral interface 706 .

[0147] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the training method and device of the neural network model in the embodiment of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, realizing the training method of the neural network model mentioned above. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories can be connected to the computing device 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0148] The processor can call the information and application program stored in the memory through the transmission device to perform the following steps: input the first type of sample data into the source domain model and input the second type of sample data into the target domain model respectively, wherein the first type of sample data is the source domain sample data with labels, and the second type of sample data is the target domain sample data without labels, and the source domain model and the target domain model share the same network parameters; use the preset loss function to perform loss processing on the first type of sample data and the second type of sample data to obtain processing results; update the network parameters according to the processing results, and train to obtain a neural network model. The neural network model includes: a source domain model and a target domain model.

[0149] Optionally, the processor may also execute program code of the following steps: before inputting the first type of sample data into the source domain model and before inputting the second type of sample data into the target domain model, respectively, initializing the neural network model using a model pre-trained by an image data set.

[0150] Optionally, the processor may also execute the following steps of program code: inputting the first parameter and the second parameter into the source domain classification loss function to obtain a classification loss result corresponding to the source domain sample data, wherein the first parameter is the output result obtained after inputting the source domain sample data into the source domain model, and the second parameter is the label of the source domain sample data; calculating the mean of the classification loss results corresponding to the source domain sample data to obtain the source domain classification loss result.

[0151] Optionally, the processor may also execute the following steps of program code: obtaining a first similarity matrix and a second similarity matrix, wherein the first similarity matrix is ​​a similarity matrix between different features in the source domain, and the second similarity matrix is ​​a similarity matrix between different features in the target domain, and the matrix elements in the first similarity matrix represent the similarity between two different features of the adaptive layer in the source domain, and the matrix elements in the second similarity matrix represent the similarity between two different features of the adaptive layer in the target domain; calculating the Euclidean distance between the first similarity matrix and the second similarity matrix to obtain the consistency constraint loss results of the source domain and the target domain. The preset loss function includes: the consistency constraint loss function of the source domain and the target domain.

[0152] Optionally, the processor may also execute the following steps of program code: using the target norm value and the multidimensional features of the source domain sample data outputted in the adaptive layer to obtain a first intermediate result, wherein the target norm value is greater than the sample feature norms of the source domain and the target domain; using the target norm value and the multidimensional features of the target domain sample data outputted in the adaptive layer to obtain a second intermediate result; using the first intermediate result and the second intermediate result to calculate the source domain and the target domain to apply feature discrimination loss results at the same time. Wherein, the preset loss function includes: applying feature discrimination loss functions to the source domain and the target domain at the same time.

[0153] Optionally, the processor may also execute the program code of the following steps: after updating the network parameters according to the processing results and training the neural network model, an adaptive moment estimation optimizer is used to update the network parameters to obtain an optimized neural network model.

[0154] It can be understood by those skilled in the art that Figure 7The structure shown is for illustration only, and the computing device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a handheld computer, a mobile Internet device (Mobile Internet Devices, MID), a PAD, and other terminal devices. Figure 7 The structure of the electronic device is not limited. For example, the computing device 10 may also include Figure 7 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 7 Different configurations shown.

[0155] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0156] Example 7

[0157] The embodiment of the present application further provides a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the training method of the neural network model provided in the first embodiment.

[0158] Optionally, in this embodiment, the above storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.

[0159] Optionally, in this embodiment, the storage medium is configured to store program codes for executing the following steps: respectively inputting the first type of sample data into the source domain model and the second type of sample data into the target domain model, wherein the first type of sample data is source domain sample data with labels, and the second type of sample data is target domain sample data without labels, and the source domain model and the target domain model share the same network parameters; performing loss processing on the first type of sample data and the second type of sample data using a preset loss function to obtain processing results; updating the network parameters according to the processing results, and training to obtain a neural network model. The neural network model includes: a source domain model and a target domain model.

[0160] Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps: before inputting the first type of sample data into the source domain model and before inputting the second type of sample data into the target domain model, respectively, initializing the neural network model using a model pre-trained by an image data set.

[0161] Optionally, in this embodiment, the storage medium is configured to store program code for executing the following steps: inputting a first parameter and a second parameter into a source domain classification loss function to obtain a classification loss result corresponding to the source domain sample data, wherein the first parameter is the output result obtained after inputting the source domain sample data into a source domain model, and the second parameter is the label of the source domain sample data; calculating the mean of the classification loss results corresponding to the source domain sample data to obtain the source domain classification loss result.

[0162] Optionally, in this embodiment, the storage medium is configured to store program codes for executing the following steps: obtaining a first similarity matrix and a second similarity matrix, wherein the first similarity matrix is ​​a similarity matrix between different features in the source domain, and the second similarity matrix is ​​a similarity matrix between different features in the target domain, and the matrix elements in the first similarity matrix represent the similarity between two different features of the adaptive layer in the source domain, and the matrix elements in the second similarity matrix represent the similarity between two different features of the adaptive layer in the target domain; calculating the Euclidean distance between the first similarity matrix and the second similarity matrix, and obtaining the consistency constraint loss results of the source domain and the target domain. The preset loss function includes: the consistency constraint loss function of the source domain and the target domain.

[0163] Optionally, in this embodiment, the storage medium is configured to store program codes for executing the following steps: obtaining a first intermediate result by calculating the multidimensional features outputted by the adaptive layer using the target norm value and the source domain sample data, wherein the target norm value is greater than the sample feature norms of the source domain and the target domain; obtaining a second intermediate result by calculating the multidimensional features outputted by the adaptive layer using the target norm value and the target domain sample data; obtaining a result of applying feature discrimination loss to the source domain and the target domain simultaneously using the first intermediate result and the second intermediate result. The preset loss function includes: applying feature discrimination loss function to the source domain and the target domain simultaneously.

[0164] Optionally, in this embodiment, the storage medium is configured to store program code for executing the following steps: after updating the network parameters according to the processing results and training the neural network model, an adaptive moment estimation optimizer is used to update the network parameters to obtain an optimized neural network model.

[0165] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0166] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0167] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0168] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0169] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0170] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0171] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A training method for a neural network model, characterized in that: The neural network model includes: a source domain model and a target domain model, and the method includes: Inputting first-category sample data into the source domain model and second-category sample data into the target domain model respectively, wherein the first-category sample data is labeled source domain image sample data, the second-category sample data is unlabeled target domain image sample data, and the source domain model and the target domain model share the same network parameters; Performing loss processing on the first category of sample data and the second category of sample data using a preset loss function to obtain a processing result, wherein the preset loss function includes a source domain classification loss function, a consistency constraint loss function of the source domain and the target domain, and a feature discrimination loss function applied to both the source domain and the target domain; The network parameters are updated according to the processing results, and the neural network model is obtained through training, wherein the neural network model is used to process image data.

2. The method according to claim 1, characterized in that Before respectively inputting the first type of sample data into the source domain model and inputting the second type of sample data into the target domain model, the method further includes: The neural network model is initialized using a model pre-trained by an image dataset.

3. The method according to claim 1, characterized in that The preset loss function includes: a source domain classification loss function, and using the preset loss function to perform loss processing on the first type of sample data includes: Inputting a first parameter and a second parameter into the source domain classification loss function to obtain a classification loss result corresponding to the source domain image sample data, wherein the first parameter is an output result obtained after inputting the source domain image sample data into the source domain model, and the second parameter is a label of the source domain image sample data; The mean of the classification loss results corresponding to the source domain image sample data is calculated to obtain the source domain classification loss result.

4. The method according to claim 1, characterized in that: The preset loss function includes: a consistency constraint loss function of the source domain and the target domain, and using the preset loss function to perform loss processing on the first type of sample data and the second type of sample data includes: Obtaining a first similarity matrix and a second similarity matrix, wherein the first similarity matrix is ​​a similarity matrix between different features in a source domain, the second similarity matrix is ​​a similarity matrix between different features in a target domain, the matrix elements in the first similarity matrix represent the similarity between two different features of an adaptive layer in the source domain, and the matrix elements in the second similarity matrix represent the similarity between two different features of an adaptive layer in the target domain; The Euclidean distance between the first similarity matrix and the second similarity matrix is ​​calculated to obtain consistency constraint loss results of the source domain and the target domain.

5. The method according to claim 1, characterized in that The preset loss function includes: applying a feature discrimination loss function to the source domain and the target domain at the same time, and using the preset loss function to perform loss processing on the first type of sample data and the second type of sample data includes: A first intermediate result is obtained by calculating the target norm value and the multidimensional features outputted by the source domain image sample data at the adaptive layer, wherein the target norm value is greater than the sample feature norms of the source domain and the target domain; Obtain a second intermediate result by calculating the multidimensional features output by the adaptive layer using the target norm value and the target domain image sample data; The first intermediate result and the second intermediate result are used to calculate the result of applying feature discriminative loss to the source domain and the target domain at the same time.

6. The method according to claim 1, characterized in that After the network parameters are updated according to the processing results and the neural network model is obtained through training, the method further includes: The network parameters are updated using an adaptive moment estimation optimizer to obtain an optimized neural network model.

7. A data processing method, characterized in that: include: Acquire an object to be identified, wherein the object to be identified is image data; Using a neural network model to identify the object to be identified, and outputting an identification result; Among them, the neural network model includes: a first granularity machine learning model and a second granularity machine learning model, the first granularity machine learning model is trained using a first category of sample data, and the second granularity machine learning model is trained using a second category of sample data, the first category of sample data is labeled image sample data, and the second category of sample data is unlabeled image sample data, and the first granularity machine learning model and the second granularity machine learning model share at least some of the same network parameters.

8. The method according to claim 7, characterized in that The first category of sample data and the second category of sample data are subjected to loss processing by using a preset loss function, and the parameters of the convolutional layer adjacent to the output layer in the neural network model are updated.

9. The method according to claim 7, characterized in that: The neural network model is used to identify the object to be identified, and the output identification result includes: Using the first granularity machine learning model to identify a first portion of features from the object to be identified, and using the second granularity machine learning model to identify a second portion of features from the object to be identified; Performing weighted fusion processing on the first part of features and the second part of features to obtain multiple candidate classification results; A classification result with the highest probability is selected from the multiple candidate classification results to obtain the recognition result.

10. A training device for a neural network model, characterized in that: The neural network model includes: a source domain model and a target domain model, and the device includes: An input module, used to input first-category sample data into the source domain model and second-category sample data into the target domain model, wherein the first-category sample data is labeled source domain image sample data, the second-category sample data is unlabeled target domain image sample data, and the source domain model and the target domain model share the same network parameters; A processing module, used to perform loss processing on the first category sample data and the second category sample data using a preset loss function to obtain a processing result, wherein the preset loss function includes a source domain classification loss function, a consistency constraint loss function of the source domain and the target domain, and a feature discrimination loss function applied to both the source domain and the target domain; An updating module is used to update the network parameters according to the processing results and train the neural network model, wherein the neural network model is used to process image data.

11. A storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the training method of the neural network model described in any one of claims 1 to 6 or the data processing method described in any one of claims 7 to 9.

12. A processor, characterized in that: The processor is used to run a program, wherein when the program is run, the training method of the neural network model described in any one of claims 1 to 6 or the data processing method described in any one of claims 7 to 9 is executed.

13. A training system for a neural network model, characterized in that: The neural network model includes: a source domain model and a target domain model, and the system includes: Processor; and A memory, connected to the processor, configured to provide the processor with instructions for processing the following processing steps: The first type of sample data is input into the source domain model and the second type of sample data is input into the target domain model respectively, wherein the first type of sample data is labeled source domain image sample data, and the second type of sample data is unlabeled target domain image sample data, and the source domain model and the target domain model share the same network parameters; the first type of sample data and the second type of sample data are subjected to loss processing by using a preset loss function to obtain a processing result, wherein the preset loss function includes a source domain classification loss function, a consistency constraint loss function of the source domain and the target domain, and a feature discrimination loss function applied to both the source domain and the target domain; the network parameters are updated according to the processing result, and the neural network model is obtained by training, wherein the neural network model is used to process image data.

14. A method for determining shared network parameters, characterized in that: include: Using the first type of sample data to train a first granularity machine learning model in the neural network model to obtain a first training result, wherein the first type of sample data is labeled image sample data; Using the second type of sample data to train the second granularity machine learning model in the neural network model to obtain a second training result, wherein the second type of sample data is unlabeled image sample data; Determine shared network parameters between the first granularity machine learning model and the second granularity machine learning model based on the first training result and the second training result.

15. The method according to claim 14, characterized in that Determining a shared network parameter between the first granularity machine learning model and the second granularity machine learning model based on the first training result and the second training result includes: Determine a plurality of candidate network parameters based on the first training result and the second training result; Displaying the multiple candidate network parameters through a visual interface; In response to a control operation received by the visualization interface, a shared network parameter between the first granularity machine learning model and the second granularity machine learning model is determined from the multiple candidate network parameters.

16. The method according to claim 14, characterized in that The neural network model further includes: a third granularity machine learning model, and the method further includes: If the shared network parameters between the first granularity machine learning model and the second granularity machine learning model and the shared network parameters between the second granularity machine learning model and the third granularity machine learning model are at least partially the same, the first granularity machine learning model and the third granularity machine learning model are trained to determine the shared network parameters between the first granularity machine learning model and the third granularity machine learning model.

Citation Information

Patent Citations

  • Training method of convolutional neural network (CNN) and face identification method and device

    CN108182394A

  • Neural network model training method and device, and computer device

    CN108898218A