Model training method and system based on cross entropy triple loss function

By constructing a cross-entropy triplet loss function and integrating feature extraction and classification prediction networks, the problem of insufficient generalization ability of convolutional neural network models in complex scenarios is solved, and the model achieves efficient classification and feature differentiation in complex scenarios.

CN121746785APending Publication Date: 2026-03-27TIANJIN JINHANG COMP TECH RES INST
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-16
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing convolutional neural network models updated using the cross-entropy loss function suffer from insufficient generalization ability and classification reliability in complex scenarios, resulting in inadequate feature discrimination.

Method used

A cross-entropy triplet loss function is constructed, which integrates the feature extraction network and the classification prediction network. The parameters of the convolutional neural network model are updated by jointly updating the parameters of the cross-entropy loss function and the triplet loss function. The classification accuracy of the cross-entropy loss function and the feature discriminative power of the triplet loss function are combined to achieve dual constraints.

Benefits of technology

This improves the model's generalization ability and classification reliability in complex scenarios, ensuring performance improvement in scenarios with fine classification, noisy samples, and few samples.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121746785A_ABST
    Figure CN121746785A_ABST
Patent Text Reader

Abstract

The invention relates to a model training method and system based on a cross entropy triple loss function. The method comprises the following steps: constructing a feature extraction network and a classification prediction network; fusing the feature extraction network and the classification prediction network to obtain a convolutional neural network classification model; constructing a cross entropy loss function and a triple loss function; constructing a cross entropy triple loss function based on the cross entropy loss function and the triple loss function; and updating model parameters of the convolutional neural network classification model based on the cross entropy triple loss function, so as to solve the problem that the model learns the characteristic of'effective classification but insufficient discrimination 'due to the fact that the convolutional neural network model is updated through the cross entropy loss function in the prior art. And the generalization ability and the classification reliability of the model in complex scenes (such as subdivided categories, sample noise and few samples) are influenced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of deep learning, in particular to a model training method and system based on a cross-entropy triplet loss function. BACKGROUND

[0002] A convolutional neural network (CNN) is a core model for image classification tasks. It automatically extracts local features to global features through the combination of convolutional layers, pooling layers, and fully connected layers, and finally realizes class discrimination. Currently, the convolutional neural network model usually updates its model parameters using a cross-entropy loss function. However, updating the convolutional neural network model using the cross-entropy loss function can cause the model to learn the characteristic of "effective classification but insufficient discrimination", which in turn affects the generalization ability and classification reliability of the model in complex scenarios (such as fine classification, sample noise, and few samples). SUMMARY

[0003] The present application provides a model training method and system based on a cross-entropy triplet loss function, which can solve the problem that updating the convolutional neural network model using the cross-entropy loss function causes the model to learn the characteristic of "effective classification but insufficient discrimination", which in turn affects the generalization ability and classification reliability of the model in complex scenarios (such as fine classification, sample noise, and few samples).

[0004] In a first aspect, the present application provides a model training method based on a cross-entropy triplet loss function, comprising: constructing a feature extraction network and a classification prediction network; fusing the feature extraction network and the classification prediction network to obtain a convolutional neural network classification model; constructing a cross-entropy loss function and a triplet loss function; constructing a cross-entropy triplet loss function based on the cross-entropy loss function and the triplet loss function; updating the model parameters of the convolutional neural network classification model based on the cross-entropy triplet loss function.

[0005] In some embodiments, the updating of the model parameters of the convolutional neural network classification model based on the cross-entropy triplet loss function comprises: performing gradient derivation on the model parameters of the convolutional neural network classification model based on the cross-entropy triplet loss function to obtain a parameter correction gradient; updating the model parameters of the convolutional neural network classification model based on the parameter correction gradient.

[0006] In some embodiments, the model parameters include at least one of convolution kernel weights, convolution kernel biases, fully connected layer weights, and fully connected layer biases.

[0007] In some embodiments, the updating the model parameters of the convolutional neural network classification model based on the cross-entropy triplet loss function further comprises: calculating a cross-entropy triplet loss of the convolutional neural network classification model based on the cross-entropy triplet loss function; if the cross-entropy triplet loss is less than a preset loss threshold, stopping updating the model parameters of the convolutional neural network classification model to obtain a target neural network classification model; performing classification inference on to-be-classified data using the target neural network classification model.

[0008] In some embodiments, the cross-entropy loss function is wherein M is the number of categories, is a true label (1 or 0), is the probability of a predicted category.

[0009] In some embodiments, the triplet loss function is wherein, is an anchor sample, is a positive sample, is a negative sample.

[0010] In some embodiments, the constructing a cross-entropy triplet loss function based on the cross-entropy loss function and the triplet loss function comprises: substituting the anchor sample into the cross-entropy loss function to obtain an anchor sample cross-entropy function; substituting the positive sample into the cross-entropy loss function to obtain a positive sample cross-entropy function; substituting the negative sample into the cross-entropy loss function to obtain a negative sample cross-entropy function; fusing the anchor sample cross-entropy function, the positive sample cross-entropy function, and the negative sample cross-entropy function and the triplet loss function to obtain the cross-entropy triplet function.

[0011] In some embodiments, the cross-entropy triplet loss function is wherein, is a triplet loss function, is an anchor sample cross-entropy function, is a positive sample cross-entropy function. negative sample cross-entropy function.

[0012] In a second aspect, the embodiments of the present application provide a model training system based on a cross-entropy triplet loss function, applied to the model training method based on the cross-entropy triplet loss function as any one of the first aspect, comprising: a network construction module, configured to construct a feature extraction network and a classification prediction network; a network fusion module, configured to fuse the feature extraction network and the classification prediction network to obtain a convolutional neural network classification model; a function construction module, configured to construct a cross-entropy loss function and a triplet loss function; a function fusion module, configured to construct a cross-entropy triplet loss function based on the cross-entropy loss function and the triplet loss function; a model updating module, configured to update model parameters of the convolutional neural network classification model based on the cross-entropy triplet loss function.

[0013] In a third aspect, the embodiments of the present application provide a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the model training method based on the cross-entropy triplet loss function as any one of the first aspect when executing the program.

[0014] The above technical solutions provided by the embodiments of the present application have the following advantages compared with the prior art: The model training method and system based on the cross-entropy triplet loss function provided by the embodiments of the present application, by constructing a feature extraction network and a classification prediction network, fusing the feature extraction network and the classification prediction network to obtain a convolutional neural network classification model, constructing a cross-entropy loss function and a triplet loss function, constructing a cross-entropy triplet loss function based on the cross-entropy loss function and the triplet loss function, and updating model parameters of the convolutional neural network classification model based on the cross-entropy triplet loss function, can simultaneously realize the dual constraints of "classification accuracy" and "feature discrimination" by using the cross-entropy triplet loss function, which not only ensures that the model learns an effective classification decision boundary matching the class label, guarantees the correctness of the basic classification task, but also narrows the feature distance of similar samples and widens the feature distance of different samples, thereby solving the problem that the existing convolutional neural network model is updated by the cross-entropy loss function, resulting in the model learning "classification is effective but the discrimination is insufficient", which further affects the generalization ability and classification reliability of the model in complex scenarios (such as fine classification, sample noise, and few samples). BRIEF DESCRIPTION OF DRAWINGS

[0015] The accompanying drawings, which are incorporated herein and constitute part of the specification, illustrate embodiments consistent with the present application and, together with the description, further serve to explain the principles of the application.

[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the accompanying drawings required to be used in the embodiments or prior art description will be briefly introduced below. Obviously, for those of ordinary skill in the art, other drawings can also be obtained based on these drawings without any creative effort.

[0017] One or more embodiments are illustrated by the drawings in the accompanying drawings, which do not constitute a limitation on the embodiments, and elements with the same reference numerals in the drawings represent similar elements, unless otherwise specified. The drawings in the drawings do not constitute a proportional limit.

[0018] Figure 1 A model training method flowchart based on a cross-entropy triplet loss function is provided for an embodiment of the present application. Figure 2 A convolutional neural network classification model schematic diagram is provided for an embodiment of the present application. Figure 3 An anchor point sample schematic diagram is provided for an embodiment of the present application. Figure 4 A positive sample schematic diagram is provided for an embodiment of the present application. Figure 5 A negative sample schematic diagram is provided for an embodiment of the present application. Figure 6 A cross-entropy triplet loss function schematic diagram is provided for an embodiment of the present application. Figure 7 A model training system schematic diagram based on a cross-entropy triplet loss function is provided for an embodiment of the present application. DETAILED DESCRIPTION

[0019] In order to make the purposes, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without any creative effort fall within the scope of protection of the present application.

[0020] The following disclosure provides a number of different embodiments or examples for implementing different aspects of the present application. In order to simplify the disclosure of the present application, the components and arrangements of the specific examples below are described. Of course, they are merely examples and are not intended to limit the present application. Furthermore, the present application can be repeated with different examples and / or in different arrangements. Such repetition is expressly avoided unless otherwise specifically noted.

[0021] Convolutional Neural Network (CNN) is the core model of image classification task, which automatically extracts local features to global features through the combination of convolutional layer, pooling layer and fully connected layer, and finally realizes class discrimination.

[0022] In the field of machine learning and deep learning, the loss function is a core tool for measuring model prediction performance and driving parameter optimization. The cross-entropy loss function is a key to achieving accurate prediction in classification tasks. Its core value lies in quantifying the difference between the "predicted probability distribution of model output" and the "true probability distribution of sample", so as to directly reflect the accuracy of the model classification result. In the neural network training process, the cross-entropy loss function is set as the core optimization target, and the model will continuously adjust the parameters through the gradient descent algorithm to minimize the loss, so that the prediction result gradually aligns with the true label, and finally improves the accuracy of the classification task. Compared with the mean square error and other loss functions, the cross-entropy loss is more suitable for the essential needs of the classification scenario. It can naturally adapt to the discrete characteristics of class labels and avoid the problems of gradient disappearance and slow convergence that may occur when dealing with classification tasks. Therefore, it performs better in typical classification tasks such as image classification and text semantic recognition.

[0023] Metric learning is another technical path that focuses on "optimizing sample feature relationships". Its core goal is to learn a distance / similarity metric criterion that adapts to a specific task, so that samples of the same class show "intra-class aggregation" (minimum distance) and samples of different classes show "inter-class separation" (maximum distance) in the feature space. The triplet loss function is a classic optimization tool for metric learning. By constructing a "anchor sample-positive sample (same class)-negative sample (different class)" triplet, it constrains the model to "minimize the distance between anchor and positive samples and maximize the distance between anchor and negative samples" to learn more discriminative feature representations. Because metric learning can strengthen the intra-class consistency and inter-class discriminativeness of features, it can be combined with a classifier: through the optimized distance metric, the classifier can obtain more reliable feature input, thereby solving the performance bottleneck of traditional classification models in scenarios with high sample feature overlap and fuzzy class boundaries, and significantly improving the reliability and accuracy of the classification result.

[0024] However, in existing technologies, classification models dominated by cross-entropy loss and metric learning models dominated by triplet loss are mostly used independently. Classification models that rely solely on cross-entropy loss are prone to performance bottlenecks due to insufficient feature discriminativeness; while metric learning models that rely solely on triplet loss lack direct constraints on class labels, which may lead to the problem of "feature clustering but unclear classification boundaries".

[0025] Firstly, such as Figures 1-6 As shown, to address the aforementioned technical problems, this application provides a model training method based on the cross-entropy triplet loss function, including: S101: Construct a feature extraction network and a classification prediction network; S102: The feature extraction network and the classification prediction network are fused to obtain a convolutional neural network classification model; S103: Construct the cross-entropy loss function and the triplet loss function; S104: Construct a cross-entropy triplet loss function based on the cross-entropy loss function and the triplet loss function; S105: Update the model parameters of the convolutional neural network classification model based on the cross-entropy triplet loss function.

[0026] It should be noted that by introducing the cross-entropy loss function into the cross-entropy triplet loss function, the probability distribution of the model output can be directly constrained to align with the true class label, ensuring the basic accuracy of the classification task. By introducing the triplet loss function into the cross-entropy triplet loss function, in scenarios with overlapping sample features and blurred class boundaries (such as fine classification and few-sample classification), the feature vector optimized by the triplet loss has stronger intra-class clustering and inter-class discriminative power, which can help the classification prediction network to more clearly identify class boundaries and reduce the probability of misclassification.

[0027] It should be noted that the triplet loss, through the constraint of "anchor point-positive sample-negative sample", forces the feature vector output by the feature extraction network to present a distribution of "similar types are close and dissimilar types are far", which solves the problem of "insufficient feature discrimination" under the single cross-entropy loss. Moreover, the enhanced features not only adapt to the current training data, but also better capture the essential attributes of the samples, and can still maintain stable discrimination ability on unseen test data, reducing the risk of model overfitting.

[0028] It should be noted that by constructing the cross-entropy triplet loss function based on the cross-entropy loss function and the triplet loss function, the problem of "classification bottleneck caused by feature overlap when using only cross-entropy loss" is solved, and the defects of "lack of direct constraints from class labels and unclear classification boundaries when using only triplet loss" are also overcome. This makes the "class constraint" of cross-entropy loss and the "feature constraint" of triplet loss complementary, so that the model can simultaneously take into account "correct classification" and "high-quality features" during parameter update. The training efficiency and final performance are better than the training method of single loss. Moreover, the method provided in this application is not limited to conventional classification tasks, but can also effectively support complex scenarios, such as few-sample classification (relying on strong feature discriminative power), fine-grained classification (relying on features with clear class boundaries), and cross-domain classification (relying on features with strong generalization), all of which can achieve performance improvement through this method.

[0029] In some embodiments, updating the model parameters of the convolutional neural network classification model based on the cross-entropy triplet loss function includes: The parameter correction gradient is obtained by taking the gradient derivative of the model parameters of the convolutional neural network classification model based on the cross-entropy triplet loss function. The model parameters of the convolutional neural network classification model are updated based on the gradient correction of the parameters.

[0030] It should be noted that the parameter correction gradient obtained by differentiating the cross-entropy triplet loss function simultaneously integrates the optimization requirements of "classification accuracy" and "feature discriminability": that is, the gradient includes both the "class prediction bias correction signal" brought by the cross-entropy loss (driving the parameters to make the classification results more accurate) and the "feature distance constraint correction signal" brought by the triplet loss (driving the parameters to make the features more discriminative). Compared with the step-by-step update of "training the classification first and then training the features", this method achieves simultaneous optimization of the two requirements, avoids repeated adjustment of parameters under a single objective, and can significantly improve training efficiency.

[0031] It's important to note that gradients from a single loss function can easily lead to parameters tilting towards "local optima": using only the gradient of cross-entropy loss might optimize parameters towards "accurate classification but weak feature discrimination" (prone to overfitting in complex scenarios); using only the gradient of triplet loss might optimize parameters towards "strong feature discrimination but ambiguous classification boundaries" (unreliable classification results); while gradients from fused loss functions can balance the weights of both types of requirements (controlled by the fusion coefficient λ of the loss function), allowing parameter adjustments to simultaneously consider "correct classification" and "high-quality features," avoiding optimization bias under a single objective, and ultimately converging to a better global parameter state; moreover, the gradients of the two types of losses complement each other, meaning that if the gradient signal of one type of loss is weak (e.g., classification is already accurate but features still need optimization), the gradient of the other type of loss can continuously provide effective correction signals, ensuring the continuity and stability of parameter updates and accelerating model convergence.

[0032] In some embodiments, the model parameters include at least one of convolution kernel weights, convolution kernel biases, fully connected layer weights, and fully connected layer biases.

[0033] It should be noted that the convolutional kernel weights and biases are core parameters of the feature extraction network (determining the quality of the mapping from the original data to the feature vector), while the fully connected layer weights and biases are core parameters of the classification prediction network (determining the quality of the mapping from the feature vector to the class probability). By explicitly defining these parameters as optimization targets, the gradient signal of the cross-entropy triplet loss can be precisely applied to the model's dual core modules of "feature extraction + classification prediction": that is, for the convolutional kernel parameters, the gradient will drive them to extract features of "intra-class aggregation and inter-class separation" (responding to the triplet loss); for the fully connected layer parameters, the gradient will drive them to output accurate class probabilities based on high-quality features (responding to the cross-entropy loss), ultimately achieving synchronous optimization of the two modules and avoiding the shortcomings of one module's parameters not being effectively adjusted.

[0034] In some embodiments, updating the model parameters of the convolutional neural network classification model based on the cross-entropy triplet loss function further includes: The cross-entropy triplet loss of the convolutional neural network classification model is calculated based on the cross-entropy triplet loss function. If the cross-entropy triplet loss is less than a preset loss threshold, then the model parameters of the convolutional neural network classification model are stopped from being updated, and the target neural network classification model is obtained. The target neural network classification model is used to perform classification inference on the data to be classified.

[0035] It should be noted that using "the cross-entropy triplet loss is less than the preset loss threshold" as the training termination condition can accurately determine whether the model has reached the dual-excellence state of "accurate classification + strong feature discrimination": when the loss is lower than the threshold, it means that the model's predicted probability has closely matched the true label, and the feature vector has achieved the distribution requirement of "same class clustering and different class separation". Continuing training will result in invalid iterations and increase computational costs. At the same time, this mechanism can terminate training in a timely manner to avoid the model fitting the noise of the training data due to excessive iteration, effectively reduce the risk of overfitting, and ensure the model's generalization performance on the test set.

[0036] In some embodiments, the cross-entropy loss function is Where M is the number of categories, For true labels (1 or 0). To predict the probability of the category.

[0037] It should be noted that the cross-entropy loss function is based on the "true label". With predicted probability The sum of the logarithmic products of the models directly measures the difference between the model's predicted probability distribution and the true class distribution: if the model predicts the true class ( The probability of (=1) Approaching 1, log( When the deviation approaches 0, the loss approaches 0 (the deviation is extremely small); if Approaching 0, log( As the bias approaches -∞, the loss increases significantly (forcing the model to correct its parameters and improve the prediction probability of the true class). Through this characteristic of "strong correlation between bias and loss", the model can be precisely driven to optimize in the direction of "correct classification", ensuring the basic accuracy of the classification task.

[0038] In some embodiments, the triplet loss function is: ,in, For anchor point samples, For positive samples This is a negative sample.

[0039] It should be noted that this loss function directly constrains the distance relationship of feature vectors through the triple structure of "anchor point - positive sample (same class) - negative sample (different class)", making the "distance D(a,p) between the anchor point and the positive sample as small as possible (intra-class clustering) and the "distance D(a,n) between the anchor point and the negative sample as large as possible (inter-class separation). The loss will only take effect and drive parameter adjustment when D(a,p)>D(a,n)-a (i.e. the constraint of "same class is close, different class is far") is not satisfied, ensuring that the feature vectors present clear class boundaries in the metric space, which can solve the problem of "feature overlap and weak discriminativeness" under single classification loss.

[0040] It should be noted that in scenarios such as fine classification and few-sample classification, the features of the samples themselves have a high degree of overlap, and it is difficult to distinguish them by classification loss alone. However, triplet loss directly optimizes the relative distance of features. Even if the features of the original data are similar, this loss can make the features of the same type of samples cluster closely and the features of the different types of samples significantly separated, providing more discriminative feature input for subsequent classification. For example, in the face fine classification task, this loss can make the features of different photos of the same person more similar and the features of photos of different people more distant, greatly reducing the probability of misclassification.

[0041] In some embodiments, constructing the cross-entropy triplet loss function based on the cross-entropy loss function and the triplet loss function includes: The anchor point sample Substituting the cross-entropy loss function, we obtain the anchor samples. Cross-entropy function; The positive sample Substituting the cross-entropy loss function, we obtain the positive samples. Cross-entropy function; The negative sample Substituting into the cross-entropy loss function, we obtain the negative samples. Cross-entropy function; Fusion of the anchor point samples Cross-entropy function, the positive sample Cross-entropy function, the negative sample The cross-entropy triplet function is obtained by combining the cross-entropy function and the triplet loss function.

[0042] It should be noted that traditional triplet loss only constrains the "feature distance" and does not directly require the classification result of each sample within the triplet to be accurate. However, the method provided in this application embodiment uses anchor samples. Positive samples negative samples Substituting each sample into the cross-entropy loss function, the anchor samples... The cross-entropy function can constrain the classification result of the anchor point to align with its true label; through the positive samples The cross-entropy function can constrain the classification results of positive samples (of the same type as the anchor points) to align with the true labels; through the negative samples... The cross-entropy function can constrain the classification results of negative samples (different from the anchor point) to align with the true label; ultimately, it ensures that each sample in the triplet simultaneously meets the dual requirements of "accurate classification" and "reasonable feature distance", achieving a deep binding between "category label" and "feature distribution" and avoiding the contradictory situation of "feature distance meets the constraint but classification is wrong".

[0043] It should be noted that the method provided in this application integrates the constraints of "3 cross-entropy functions + 1 triplet loss function". Compared with the fusion method of "1 cross-entropy + 1 triplet", the constraint dimensions are more comprehensive. That is, the classification bias and feature distance bias of each sample are quantified as loss. The gradient signal of model parameter update is richer and more accurate. Even if the constraint of a certain dimension (such as feature distance) is close to meeting the standard, the constraints of other dimensions (such as the classification bias of a sample) can still drive parameter optimization, avoid the model from entering the "pseudo-convergence" state in advance, and accelerate the model to converge to the optimal state of "accurate classification + excellent features".

[0044] In some embodiments, the cross-entropy triplet loss function is: ,in, The triplet loss function, For anchor point samples Cross-entropy function, Positive sample Cross-entropy function, negative samples Cross-entropy function.

[0045] It should be noted that, as Figure 6 As shown, the cross-entropy triplet loss function simultaneously constrains both the "feature distance" and the "classification result of each sample": that is, the triplet loss part... Ensure that "anchor point-positive sample (same class) features are similar, anchor point-negative sample (different class) features are dissimilar"; the three cross-entropy loss components (anchor point / positive / negative sample) (etc.) Ensure that the classification results of anchor samples, positive samples, and negative samples are aligned with the true labels; through the dual constraint of "feature distance + classification of each sample", the problem of "feature distance meets the requirements but a sample is classified incorrectly" in traditional fusion loss can be avoided, so that "feature optimization" and "classification accuracy" are deeply bound together, ensuring that the features are effective features that serve classification.

[0046] It should be noted that, especially in scenarios with fine-grained classification and high sample overlap, a single constraint is insufficient to distinguish samples. The multi-dimensional constraints of the cross-entropy triplet loss function, however, cover more details: for anchor samples, it constrains both their own classification accuracy and their feature distance from positive / negative samples; for positive samples, it constrains both their own classification accuracy and their feature clustering with the anchor; for negative samples, it constrains both their own classification accuracy and their feature separation from the anchor. Ultimately, this allows the model to capture the "essential category features" of samples, even if samples have similar appearances / features (such as different products within the same category), enabling accurate classification through the dual constraints of "classification + features." This approach distinguishes and improves classification performance in complex scenarios. Furthermore, the cross-entropy triplet loss function integrates the gradients of four independent loss terms. Compared to the fusion method of "one cross-entropy + one triplet," the gradient signal simultaneously includes both "feature distance bias" and "classification bias of each sample," providing more precise guidance for parameter updates. When a certain loss term approaches convergence (e.g., feature distance reaches the target), other loss terms (e.g., classification bias of a sample) can still provide effective gradients, preventing the model from entering a "pseudo-convergence" state. This allows the model to converge more efficiently to the optimal parameters of "accurate classification + excellent features," while reducing parameter oscillations during training and improving the stability of model training.

[0047] It should be noted that, for example, such as Figure 2 As shown, the convolutional neural network classification model includes 5 categories: dog, fox, horse, eagle, and squirrel. When the model outputs an image of a dog, the true result is [1 0 0 0 0], and the output probability is [0.4 0.3 0.05 0.05 0.2]. This classification indicates that the first image has a 40% probability of being a dog, a 30% probability of being a fox, a 5% probability of being a horse, a 5% probability of being an eagle, and a 20% probability of being a squirrel. The cross-entropy loss is calculated as follows:

[0048] The loss function is much greater than 0, indicating that the model's prediction performance is poor. The derivative of the cross-entropy loss function is calculated, the model is trained, and the weights and bias parameters of the convolutional neural network classification model are updated. The output probability of the trained classification model is [0.98 0.01 0 0 0.01].

[0049] The cross-entropy loss is recalculated as follows:

[0050] The cross-entropy loss is reduced, and the model's classification performance is improved.

[0051] It should be noted that, for example, such as Figure 3 , 4 As shown in Figure 5, a triple is defined. Figure 3Anchor samples ; Figure 4 Positive samples are ( Figure 3 Images of the same category are denoted as ; Figure 5 negative samples ( Figure 3 Different categories of images), denoted as The mathematical model for metric learning is (It represents the process of retrieving an image from space) metric space mapped to feature vectors It requires that feature vectors of similar images mapped to the metric space be close in distance. Metric learning is essentially the construction of... Model and optimize its parameters .

[0052] Define the metric function (representing the distance between two images in the metric space), where, The calculation is the Euclidean distance between the feature vectors x and y, i.e., the distance between the image and the feature vectors x and y. and pictures The distance in the metric space is Let the feature representation of image x be denoted as Then the distance It should be smaller, and the distance... If the value is relatively large, then the eigenvectors of the triples need to satisfy the following formula: ,in, Define the margin (which represents the distance that needs to be maintained between samples of the same class and samples of different classes), and define the triplet loss function: When the triple loss satisfies When, define loss The value is 0. If this condition is not met, the loss is... = .

[0053] Secondly, such as Figure 7 As shown, this application provides a model training system based on the cross-entropy triplet loss function, applied to the model training method based on the cross-entropy triplet loss function as described in any of the first aspects, including: The network building module is used to build feature extraction networks and classification prediction networks; The network fusion module is used to fuse the feature extraction network and the classification prediction network to obtain a convolutional neural network classification model; The function building module is used to construct the cross-entropy loss function and the triplet loss function; The function fusion module is used to construct a cross-entropy triplet loss function based on the cross-entropy loss function and the triplet loss function. The model update module is used to update the model parameters of the convolutional neural network classification model based on the cross-entropy triplet loss function.

[0054] Thirdly, embodiments of this application provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the model training method based on the cross-entropy triplet loss function as described in any one of the first aspects.

[0055] The device / system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0056] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0057] It should be understood that the terminology used herein is for the purpose of describing particular exemplary embodiments only and is not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms “a,” “an,” and “described” as used herein may also mean including the plural forms. The terms “comprising,” “including,” “containing,” and “having” are inclusive and therefore indicate the presence of stated features, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not to be construed as requiring them to be performed in a particular order described or illustrated unless the order of execution is explicitly indicated. It should also be understood that additional or alternative steps may be used. The above description is merely a specific embodiment of the invention to enable those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A model training method based on the cross-entropy triplet loss function, characterized in that, include: Construct feature extraction networks and classification prediction networks; The feature extraction network and the classification prediction network are fused to obtain a convolutional neural network classification model; Construct the cross-entropy loss function and the triplet loss function; Construct a cross-entropy triplet loss function based on the cross-entropy loss function and the triplet loss function; The model parameters of the convolutional neural network classification model are updated based on the cross-entropy triplet loss function.

2. The model training method based on the cross-entropy triplet loss function according to claim 1, characterized in that, The process of updating the model parameters of the convolutional neural network classification model based on the cross-entropy triplet loss function includes: The parameter correction gradient is obtained by taking the gradient derivative of the model parameters of the convolutional neural network classification model based on the cross-entropy triplet loss function. The model parameters of the convolutional neural network classification model are updated based on the gradient correction of the parameters.

3. The model training method based on the cross-entropy triplet loss function according to claim 1, characterized in that, The model parameters include at least one of the following: convolution kernel weights, convolution kernel biases, fully connected layer weights, and fully connected layer biases.

4. The model training method based on the cross-entropy triplet loss function according to claim 1, characterized in that, The step of updating the model parameters of the convolutional neural network classification model based on the cross-entropy triplet loss function further includes: The cross-entropy triplet loss of the convolutional neural network classification model is calculated based on the cross-entropy triplet loss function. If the cross-entropy triplet loss is less than a preset loss threshold, then the model parameters of the convolutional neural network classification model are stopped from being updated, and the target neural network classification model is obtained. The target neural network classification model is used to perform classification inference on the data to be classified.

5. The model training method based on the cross-entropy triplet loss function according to claim 1, characterized in that, The cross-entropy loss function is: Where M is the number of categories, For true labels (1 or 0). To predict the probability of the category.

6. The model training method based on the cross-entropy triplet loss function according to claim 5, characterized in that, The triplet loss function is: ,in, For anchor point samples, For positive samples This is a negative sample.

7. The model training method based on the cross-entropy triplet loss function according to claim 6, characterized in that, The construction of the cross-entropy triplet loss function based on the cross-entropy loss function and the triplet loss function includes: The anchor point sample Substituting the cross-entropy loss function, we obtain the anchor samples. Cross-entropy function; The positive sample Substituting the cross-entropy loss function, we obtain the positive samples. Cross-entropy function; The negative sample Substituting into the cross-entropy loss function, we obtain the negative samples. Cross-entropy function; Fusion of the anchor point samples Cross-entropy function, the positive sample Cross-entropy function, the negative sample The cross-entropy triplet function is obtained by combining the cross-entropy function and the triplet loss function.

8. The model training method based on the cross-entropy triplet loss function according to claim 7, characterized in that, The cross-entropy triplet loss function is: ,in, The triplet loss function, For anchor point samples Cross-entropy function, Positive sample Cross-entropy function, negative samples Cross-entropy function.

9. A model training system based on the cross-entropy triplet loss function, characterized in that, The model training method based on the cross-entropy triplet loss function as described in any one of claims 1-8 includes: The network building module is used to build feature extraction networks and classification prediction networks; The network fusion module is used to fuse the feature extraction network and the classification prediction network to obtain a convolutional neural network classification model; The function building module is used to construct the cross-entropy loss function and the triplet loss function; The function fusion module is used to construct a cross-entropy triplet loss function based on the cross-entropy loss function and the triplet loss function. The model update module is used to update the model parameters of the convolutional neural network classification model based on the cross-entropy triplet loss function.

10. A computer device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the model training method based on the cross-entropy triplet loss function as described in any one of claims 1-8.