Network training method, visual retrieval method and device

By whitening the feature vectors of multiple teacher networks and adjusting the distillation loss, the problem of similarity distribution differences in multi-teacher network fusion is solved, and efficient visual retrieval results are achieved.

CN118734932BActive Publication Date: 2026-11-27ZHEJIANG GONGSHANG UNIVERSITY +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310379400.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-31
Publication Date
2026-11-27
Estimated Expiration
2043-03-31

AI Technical Summary

Technical Problem

Existing visual retrieval methods based on deep neural networks are computationally inefficient and cannot meet the needs of large-scale retrieval. Furthermore, the differences in similarity distribution among multiple pre-trained models lead to poor fusion results.

Method used

By whitening the feature vectors of multiple teacher networks to unify their similarity distribution, and using the distillation loss function to adjust the parameters of the student network, the knowledge of multiple teacher networks is distilled into the student network, achieving stable and effective multi-teacher network fusion.

Benefits of technology

It improves the computational efficiency and performance of visual retrieval, enables the comparability of similarity among multiple teacher networks, and enhances the retrieval performance of student networks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118734932B_ABST
    Figure CN118734932B_ABST
Patent Text Reader

Abstract

The specification provides a network training method, a visual retrieval method and device, the method comprising: inputting a plurality of sample image pairs to a plurality of teacher networks and a student network; performing whitening processing on the feature vectors of the first sample image and the feature vectors of the second sample image output by each teacher network, and obtaining a first similarity matrix according to the whitened feature matrix; fusing the first similarity matrices of the plurality of teacher networks to obtain a fused similarity matrix; and adjusting the network parameters of the student network according to the distillation loss between the fused similarity matrix and a second similarity matrix. By performing whitening-based similarity standardization on the output of the teacher network, the output distribution of the plurality of teacher networks can be unified, the similarity of the plurality of teacher networks can be compared, stable and effective multi-teacher network fusion is realized, and thus the plurality of teacher networks can be distilled into the student network, and the performance and computational efficiency are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to the field of artificial intelligence technology, and in particular to a network training method, a visual retrieval method, and an apparatus. Background Technology

[0002] The goal of visual retrieval is to search for the most relevant data to a given query from candidate data. Visual retrieval includes image retrieval, video retrieval, etc., and has a wide range of applications, including instance matching, fine-grained recognition, product recommendation, etc.

[0003] Retrieval methods based on deep neural networks (DNNs) have become the mainstream approach for visual retrieval in recent years. Although DNNs have brought significant performance improvements to visual retrieval problems, computational efficiency remains a significant issue. Summary of the Invention

[0004] In view of the above, this specification provides a network training method, a visual retrieval method, and an apparatus through one or more embodiments.

[0005] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions: According to a first aspect of one or more embodiments of this specification, a network training method is proposed, comprising: Multiple sample image pairs are input into multiple pre-trained teacher networks and into a student network. Each sample image pair is a positive sample pair, including a first sample image and a second sample image. The feature vectors of each first sample image and each second sample image output by each teacher network are whitened, and the first similarity matrix is ​​obtained based on the whitened feature vectors. The first similarity matrices of the multiple teacher networks are fused to obtain a fused similarity matrix; The network parameters of the student network are adjusted based on the distillation loss between the fusion similarity matrix and the second similarity matrix, wherein the second similarity matrix is ​​obtained based on the feature vectors of each first sample image and the feature vectors of the second sample image output by the student network.

[0006] In some embodiments, the whitening process for the feature vectors of each first sample image and each second sample image output by each teacher network includes: Linear transformations are performed on the feature vectors of the first sample image and the feature vectors of the second sample image, respectively, so that the covariance matrix of the transformed feature vectors is an identity matrix. The parameters for the linear transformation are determined by running the training set on the teacher network.

[0007] In some embodiments, the method further includes: Based on the average mean of the feature vectors obtained by the teacher network from feature extraction of all training samples in the set training set, a zero-mean vector is obtained. The zero-mean vector is used to zero-mean the feature matrix corresponding to all training samples. Obtain the eigenvector matrix of the covariance matrix of the zero-mean eigenmatrix; The parameters for the linear transformation are obtained based on the zero-mean vector and the eigenvector matrix.

[0008] In some embodiments, the linear transformation of the feature vectors of the first sample image and the feature vectors of the second sample image includes: Subtracting the zero-mean vector from the feature vector of the image to be processed yields a zero-mean feature vector. The image to be processed includes a first sample image and a second sample image. The whitened feature vector is obtained by multiplying the feature vector matrix with the zero-mean feature vector.

[0009] In some embodiments, obtaining the first similarity matrix based on the whitened feature vector includes: The feature matrix is ​​obtained based on the whitened feature vectors; The first similarity matrix is ​​obtained by multiplying the transpose of the feature matrix with the feature matrix.

[0010] In some embodiments, the method further includes: A full connection operation is performed on the feature vector of the first sample image output by the student network to obtain the first feature matrix; A fully connected operation is performed on the feature vector of the second sample image output by the student network to obtain the second feature matrix; The second similarity matrix is ​​obtained based on the first feature matrix and the second feature matrix.

[0011] In some embodiments, fusing the first similarity matrices of the plurality of teacher networks to obtain a fused similarity matrix includes: For the elements on the diagonal of the fused similarity matrix, the element value is obtained based on the maximum value of the corresponding elements in multiple first similarity matrices; For the off-diagonal elements of the fused similarity matrix, the element values ​​are obtained according to any of the following methods: It is obtained based on the minimum value of corresponding elements in multiple first similarity matrices; It is obtained by averaging the corresponding elements in multiple first similarity matrices; It is obtained from the corresponding element values ​​of the specified first similarity matrix among multiple first similarity matrices.

[0012] In some embodiments, the method further includes: The Gaussian kernel function is used to process each row of the similarity matrix to be processed to obtain a probability distribution matrix, and the similarity matrix to be processed is updated using the probability distribution matrix. The similarity matrix to be processed includes a first similarity matrix and a second similarity matrix.

[0013] In some embodiments, adjusting the network parameters of the student network based on the distillation loss between the fusion similarity matrix and the second similarity matrix includes: The distillation loss between the fusion similarity matrix and the second similarity matrix is ​​calculated using the KL divergence loss function.

[0014] According to a second aspect of one or more embodiments of this specification, a visual retrieval method is proposed, comprising: inputting an image to be retrieved into a visual retrieval network to obtain first feature information of the image to be retrieved, wherein the visual retrieval network is a student network trained in the above embodiments; The first feature information is compared with the second feature information of the images in the image library, and the images that meet the similarity requirements are used as the retrieval results. The second feature information is obtained by extracting features from the images in the image library using the visual retrieval network.

[0015] According to a third aspect of one or more embodiments of this specification, a network training apparatus is provided, comprising: The input unit is used to input multiple sample image pairs into multiple pre-trained teacher networks and into student networks. Each sample image pair is a positive sample pair, including a first sample image and a second sample image. The whitening unit is used to whiten the feature vectors of each first sample image and each second sample image output by each teacher network, and to obtain the first similarity matrix based on the whitened feature vectors. The fusion unit is used to fuse the first similarity matrices of the multiple teacher networks to obtain a fused similarity matrix; The adjustment unit is used to adjust the network parameters of the student network according to the distillation loss between the fusion similarity matrix and the second similarity matrix, wherein the second similarity matrix is ​​obtained based on the feature vectors of each first sample image and the feature vectors of the second sample image output by the student network.

[0016] In some embodiments, the whitening unit is specifically used for: Linear transformations are performed on the feature vectors of the first sample image and the feature vectors of the second sample image, respectively, so that the covariance matrix of the transformed feature vectors is an identity matrix. The parameters for the linear transformation are determined by running the training set on the teacher network.

[0017] In some embodiments, the apparatus further includes a parameter acquisition unit, configured to: Based on the average mean of the feature vectors obtained by the teacher network from feature extraction of all training samples in the set training set, a zero-mean vector is obtained. The zero-mean vector is used to zero-mean the feature matrix corresponding to all training samples. Obtain the eigenvector matrix of the covariance matrix of the zero-mean eigenmatrix; The parameters for the linear transformation are obtained based on the zero-mean vector and the eigenvector matrix.

[0018] In some embodiments, when the whitening unit performs linear transformations on the feature vectors of the first sample image and the feature vectors of the second sample image, it is specifically used for: Subtracting the zero-mean vector from the feature vector of the image to be processed yields a zero-mean feature vector. The image to be processed includes a first sample image and a second sample image. The whitened feature vector is obtained by multiplying the feature vector matrix with the zero-mean feature vector.

[0019] In some embodiments, when the whitening unit is used to obtain the first similarity matrix based on the whitened feature vector, it is specifically used for: The feature matrix is ​​obtained based on the whitened feature vectors; The first similarity matrix is ​​obtained by multiplying the transpose of the feature matrix with the feature matrix.

[0020] In some embodiments, the apparatus further includes a determining unit for: A full connection operation is performed on the feature vector of the first sample image output by the student network to obtain the first feature matrix; A fully connected operation is performed on the feature vector of the second sample image output by the student network to obtain the second feature matrix; The second similarity matrix is ​​obtained based on the first feature matrix and the second feature matrix.

[0021] In some embodiments, the fusion unit is specifically used for: For the elements on the diagonal of the fused similarity matrix, the element value is obtained based on the maximum value of the corresponding elements in multiple first similarity matrices; For the off-diagonal elements of the fused similarity matrix, the element values ​​are obtained according to any of the following methods: It is obtained based on the minimum value of corresponding elements in multiple first similarity matrices; It is obtained by averaging the corresponding elements in multiple first similarity matrices; It is obtained from the corresponding element values ​​of the specified first similarity matrix among multiple first similarity matrices.

[0022] In some embodiments, the apparatus further includes an updating unit for: The Gaussian kernel function is used to process each row of the similarity matrix to be processed to obtain a probability distribution matrix, and the similarity matrix to be processed is updated using the probability distribution matrix. The similarity matrix to be processed includes a first similarity matrix and a second similarity matrix.

[0023] In some embodiments, the adjustment unit is specifically used for: The distillation loss between the fusion similarity matrix and the second similarity matrix is ​​calculated using the KL divergence loss function.

[0024] According to a fourth aspect of one or more embodiments of this specification, a visual retrieval device is provided, comprising: An input unit is used to input the image to be retrieved into a visual retrieval network to obtain the first feature information of the image to be retrieved. The visual retrieval network is a student network trained in the above embodiments. The retrieval unit is used to compare the first feature information with the second feature information of images in the image library, and take the image with the similarity requirement as the retrieval result. The second feature information is obtained by extracting features from the images in the image library using the visual retrieval network.

[0025] According to a fifth aspect of one or more embodiments of this specification, an electronic device is provided, comprising: processor; Memory used to store processor-executable instructions; The processor implements the method proposed in the above embodiments by running the executable instructions.

[0026] According to a sixth aspect of one or more embodiments of this specification, a computer-readable storage medium is provided that stores computer instructions thereon, which, when executed by a processor, implement the steps of the method proposed in the above embodiments.

[0027] In the embodiments of this specification, multiple pre-trained teacher networks extract features from multiple sample image pairs. The feature vectors of the first and second sample images output by each teacher network are whitened, and a first similarity matrix is ​​obtained based on the whitened feature matrix. The first similarity matrices of the multiple teacher networks are then fused to obtain a fused similarity matrix. A student network extracts features from the multiple sample image pairs, and a second similarity matrix is ​​obtained based on the feature vectors of the first and second sample images output by the student network. Subsequently, the network parameters of the student network are adjusted according to the distillation loss between the fused similarity matrix and the second similarity matrix. By performing whitening-based similarity normalization on the outputs of the teacher networks, the output distribution of multiple teacher networks can be unified, making the similarity of multiple teacher networks comparable. This achieves stable and effective multi-teacher network fusion, enabling the distillation of multiple teacher networks into the student network, thereby improving performance and computational efficiency. Attached Figure Description

[0028] Figure 1 This is a flowchart of a network training method provided in an exemplary embodiment.

[0029] Figure 2 This is a schematic diagram of a network training method provided in an exemplary embodiment.

[0030] Figure 3A and Figure 3B These are schematic diagrams showing the similarity distribution of multiple neural network outputs without whitening and with whitening, respectively.

[0031] Figure 4 This is a flowchart of a method for whitening a feature matrix, provided in an exemplary embodiment.

[0032] Figure 5 This is a schematic diagram of another network training method provided in an exemplary embodiment.

[0033] Figure 6 This is a flowchart of a visual retrieval method provided in an exemplary embodiment.

[0034] Figure 7 This is a block diagram of a network training apparatus provided in an exemplary embodiment.

[0035] Figure 8This is a block diagram of a visual retrieval device provided in an exemplary embodiment.

[0036] Figure 9 This is a schematic diagram of the structure of a device provided in an exemplary embodiment. Detailed Implementation

[0037] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.

[0038] It should be noted that the steps of the corresponding methods are not necessarily performed in the order shown and described in this specification in other embodiments. In some other embodiments, the methods may include more or fewer steps than described in this specification. Furthermore, a single step described in this specification may be broken down into multiple steps in other embodiments; and multiple steps described in this specification may be combined into a single step in other embodiments.

[0039] The goal of visual retrieval is to search for the most relevant data to a given query from candidate data. Visual retrieval includes image retrieval, video retrieval, etc., and has a wide range of applications, including instance matching, fine-grained recognition, product recommendation, etc.

[0040] Retrieval methods based on deep neural networks (DNNs) have become the mainstream approach for visual retrieval recently. Although DNNs have brought significant performance improvements to visual retrieval problems, the computational efficiency of pre-trained models in related technologies is relatively low. For large-scale retrieval scenarios, more compact and efficient retrieval models are needed.

[0041] In view of this, the embodiments of this specification propose a network training method that integrates multiple cumbersome pre-trained visual retrieval networks into a single, more efficient, and lightweight visual retrieval network. Specifically, knowledge distillation technology is used to distill the knowledge of multiple large models (teacher networks) into a small model (student network), reducing computational costs without sacrificing performance.

[0042] Since visual retrieval is a ranking problem and focuses on the relationships between samples, this specification employs a relationship-based distillation method in its embodiments, utilizing the correlation and degree between samples as knowledge transferred between teachers and students. The following description uses image retrieval as an example to specifically describe this network training method; those skilled in the art should understand that this method is also applicable to other types of visual retrieval.

[0043] Figure 1 This is a flowchart of a network training method provided in an exemplary embodiment, the method comprising: Step 101: Input multiple sample image pairs into multiple pre-trained teacher networks and into student networks.

[0044] Each sample image pair is a positive sample pair, including a first sample image and a second sample image.

[0045] Figure 2 This is a schematic diagram of multiple sample image pairs provided in an exemplary embodiment. The diagram contains N sample image pairs, each of which includes a first sample image and a second sample image.

[0046] If the first and second sample images in a sample image pair meet the set requirements, such as similarity greater than or equal to a set threshold, originating from the same image and containing overlapping parts, or containing the same target object, then the first and second sample images can be considered similar and can be called a positive sample pair. Conversely, if the similarity between the first and second sample images in a sample image pair does not meet the set requirements, then the two can be considered unrelated and can be called a negative sample pair.

[0047] by Figure 2 Taking the input image in the landmark image retrieval scenario shown as an example, Figure 2 If the first and second sample images in each sample image pair contain the same building, then each sample image pair is considered a positive sample pair.

[0048] In the embodiments of this specification, each of the multiple teacher networks is a pre-trained visual retrieval network; the student network is a visual retrieval network to be trained. The visual retrieval network is mainly used to extract features from the input image, compare the extracted features with the features of each image in the image database, and obtain the visual retrieval result based on the similarity ranking result.

[0049] Step 102: Whiten the feature vectors of each first sample image and each second sample image output by each teacher network, and obtain the first similarity matrix based on the whitened feature vectors.

[0050] In the embodiments of this specification, multiple teacher networks may have different network structures, be trained using different training methods, or be trained using different training sets. In this case, the similarity distribution of the outputs of the multiple teacher networks may have significant differences.

[0051] Figure 3A The diagram shows the similarity (cosine similarity) distribution of the outputs of five pre-trained visual retrieval networks. The horizontal axis represents the similarity value, and the vertical axis represents the frequency of similarity occurrences. In the leftmost section, the two curves with similar peaks represent the similarity distribution of the GeM (Generalized-Mean) network output on the left and the SOLAR (Second-Order Loss and Attention for Image Retrieval) network output on the right. The curve with a relatively lower peak represents the DELG (Deep Local and Global features) network output, and the curve with the lowest peak represents the DOLG (Deep Orthogonal Local and Global features) network output. The curve with the highest peak on the right represents the AP (Average Precision)-GeM network output similarity distribution. Figure 3A It is evident that the similarity distributions of the various teacher networks differ significantly. If we ignore these differences and employ strategies such as averaging, weighting, and multiple teacher selection, the fusion result is likely to be biased towards the distribution of a particular teacher network.

[0052] In the embodiments of this specification, a method is proposed to whiten the output features of each teacher network in order to eliminate the differences in the similarity distribution of multiple teacher networks.

[0053] Specifically, each pre-trained teacher network extracts features from each first sample image in multiple sample image pairs to obtain a feature vector for the first sample image, and then whitens this feature vector. Simultaneously, features are extracted from each second sample image in multiple sample image pairs to obtain a feature vector for the second sample image, and this feature vector is also whitened. Next, based on the whitened feature vectors of the first and second sample images, a first similarity matrix corresponding to the teacher network is obtained.

[0054] Whitening an eigenvector involves a linear transformation, converting it from an eigenvector with a known covariance matrix to one with an identity covariance matrix. This transforms the eigenvector into multiple uncorrelated white noise distributions, allowing the similarity calculated from features under these white noise distributions to be consistently aligned. See also... Figure 3B After whitening treatment, Figure 3A The five similarity curves in the model basically overlap, with no obvious differences. Therefore, the process of whitening the feature vectors output by multiple teacher networks can also be regarded as a process of standardizing the similarity of the outputs of multiple teacher networks.

[0055] Step 103: Fuse the first similarity matrices of the multiple teacher networks to obtain a fused similarity matrix.

[0056] After the whitening process in step 102, the first similarity of multiple teacher networks can be compared. Therefore, by taking the average of the first similarity outputs of all teacher networks, the fusion similarity matrix of multiple teacher networks can be obtained, thus realizing the fusion of multiple teacher networks.

[0057] Step 104: Adjust the network parameters of the student network based on the distillation loss between the fusion similarity matrix and the second similarity matrix.

[0058] In the embodiments of this specification, the student network to be trained can be used to extract features from multiple sample image pairs. Specifically, feature extraction is performed on each first sample image to obtain a feature vector of the first sample image; feature extraction is performed on each second sample image to obtain a feature vector of the second sample image; and a second similarity matrix is ​​obtained based on the feature vectors of the first and second sample images.

[0059] In one example, a full connection operation can be performed on the feature vector of the first sample image output by the student network to obtain a first feature matrix; a full connection operation can be performed on the feature vector of the second sample image output by the student network to obtain a second feature matrix; and a second similarity matrix can be obtained based on the first feature matrix and the second feature matrix.

[0060] After obtaining the second similarity matrix, the distillation loss between the fusion similarity matrix corresponding to multiple teacher networks and the second similarity matrix is ​​calculated. That is, the difference between the similarity distribution of the output of multiple teacher networks and the similarity distribution of the output of student networks is obtained. By minimizing this difference, the network parameters of student networks are adjusted to achieve the training of student networks.

[0061] In the embodiments of this specification, multiple pre-trained teacher networks extract features from multiple sample image pairs. The feature vectors of the first and second sample images output by each teacher network are whitened, and a first similarity matrix is ​​obtained based on the whitened feature vectors. The first similarity matrices of the multiple teacher networks are then fused to obtain a fused similarity matrix. A student network extracts features from the multiple sample image pairs, and a second similarity matrix is ​​obtained based on the feature vectors of the first and second sample images output by the student network. Subsequently, the network parameters of the student network are adjusted according to the distillation loss between the fused similarity matrix and the second similarity matrix. By performing whitening-based similarity normalization on the outputs of the teacher networks, the output distribution of multiple teacher networks can be unified, making the similarity of multiple teacher networks comparable. This achieves stable and effective multi-teacher network fusion, enabling the distillation of multiple teacher networks into the student network, thereby improving performance and computational efficiency.

[0062] In the embodiments of this specification, the parameters for performing a linear transformation (whitening) on ​​the feature vectors of the first sample image and the feature vectors of the second sample image are determined using the results of running the training set on the teacher network. The process of obtaining the whitening parameters can be performed after training the teacher network and before distilling the student network.

[0063] See Figure 4 The parameters for whitening treatment can be obtained through the following steps.

[0064] Step 401: Obtain the zero mean vector by taking the average value of the feature vectors obtained by the teacher network from feature extraction of all training samples in the set training set.

[0065] Assume the training set is represented as , This is the number of training samples. For each teacher network... Zero-mean vector It can be represented as: (1) in, It is the number of training samples. Indicates training samples, Indicating teacher network Extracted feature vectors.

[0066] Step 402: Use the zero-mean vector to zero-mean the feature matrix corresponding to all training samples.

[0067] Specifically, the zero-mean feature vector is obtained by subtracting the feature vector of each training sample from the zero-mean value. And based on the corresponding training samples This yields the zero-mean feature matrix corresponding to all training samples. It can be represented as: (2) in, Indicating teacher network Extracted feature vectors This represents a vector with zero mean.

[0068] Step 403: Obtain the eigenvector matrix of the covariance matrix of the zero-mean eigenmatrix.

[0069] covariance matrix Each element represents the covariance between the different components of the eigenvector matrix, and the eigenvector matrix satisfies The eigenvector matrix can be calculated using this formula. .

[0070] Step 404: Obtain the parameters for the linear transformation based on the zero mean vector and the eigenvector matrix.

[0071] Based on the zero-mean vector obtained in steps 401-403 and eigenvector matrix It can be used to whiten feature vectors that have undergone equivalent processing, thus obtaining the whitened result.

[0072] The whitening process in step 102 can be achieved through the following steps.

[0073] First, subtract the zero-mean vector obtained in step 402 from the feature vector of the first sample image to obtain the zero-mean feature vector corresponding to the first sample image; subtract the zero-mean vector from the feature vector of the second sample image to obtain the zero-mean feature vector corresponding to the second sample image. Next, based on the product of the zero-mean eigenvector corresponding to the first sample image and the eigenvector matrix obtained in step 403, the whitened eigenvector corresponding to the first sample image is obtained; based on the product of the zero-mean eigenvector corresponding to the second sample image and the eigenvector matrix, the whitened eigenvector corresponding to the second sample image is obtained.

[0074] The following describes in detail the whitening process during the training of student networks.

[0075] Multiple sample image pairs are input into multiple pre-trained teacher networks. ,in, This represents the first sample image. This represents the second sample image. , It is the number of sample image pairs.

[0076] In the embodiments of this specification, both the teacher network and the student network can be viewed as encoders from the input space to the feature space. Assume the teacher network can be represented as... Where m is the size of the input space and n is the size of the feature space. The number of teacher networks. Through teacher networks Feature extraction is performed on each pair of sample images to obtain the feature vector of the first sample image. , and the feature vector of the second sample image Correspondingly, The feature matrix corresponding to the first sample image in a pair of sample images The feature matrix corresponding to the second sample image ,in, It is Dimensional column vector.

[0077] For each teacher network The process of whitening the feature vectors of the first and second sample images can be represented by the following linear transformation formula: (3) in, It is the covariance matrix of the eigenmatrix with zero mean. eigenvector matrix, It is a zero-mean vector. and For the method of obtaining the information, please refer to steps 401-404; Indicating teacher network For the features extracted from the input sample image pair This indicates zero mean.

[0078] Accordingly, after whitening treatment, The feature matrix corresponding to the first sample image in a pair of sample images can be represented as follows: The feature matrix corresponding to the second sample image can be represented as: .

[0079] In the embodiments of this specification, cosine similarity can be used to measure the relationship between images. After obtaining the whitened feature matrix, the first similarity matrix can be obtained by multiplying the transpose of the feature matrix with the feature matrix itself. (This is relevant to teacher networks.) The first similarity matrix can be represented by, for example, the following formula: (4) In this matrix, the i-th row represents the similarity value between any image j and image i. This represents the feature matrix of the first sample image after whitening. This represents the feature matrix of the second sample image after whitening.

[0080] In some embodiments, the similarity matrix may be further converted into a probability matrix, including converting the first similarity matrix output by the teacher network into a probability matrix and the second similarity matrix output by the student network into a probability matrix.

[0081] Specifically, a Gaussian kernel function can be used to standardize each row of the similarity matrix to be processed, and the standardization result can be used to update the similarity matrix. This process can be represented by, for example, the following formula: (5) in, It is an image and images Similarity between them It is a temperature factor, which can be set according to the specific task at hand.

[0082] After converting the similarity matrix into a probability matrix, the distillation loss between the fused similarity matrix and the second similarity matrix can be calculated using the Kullback-Lerbler (KL) divergence loss function. This loss function can be expressed, for example, by the following formula: (6) in, Let be the number of sample image pairs, and  and  be the similarity matrices of the teacher network and student network, respectively, expressed as probability matrices.

[0083] The distillation loss is calculated based on the KL divergence loss function, which takes into account the asymmetry of the difference between the two probability distributions and can improve the training effect.

[0084] The following describes the processing procedure for the student network.

[0085] Suppose the student network can be represented as Where m is the size of the input space and n is the size of the feature space. (Through student network) right Feature extraction is performed on each pair of sample images to obtain the feature matrix corresponding to the first sample image. and the feature matrix corresponding to the second sample image. ,in, It is A column vector representing the features extracted by the student network.

[0086] Accordingly, the second similarity matrix of the student network can be represented, for example, by the following formula: (7) In this matrix, the i-th row represents the similarity value between any image j and image i. This represents the feature matrix corresponding to the first sample image. This represents the feature matrix corresponding to the first sample image.

[0087] During the training of the student network, each iteration sequentially inputs multiple sample image pairs into both the teacher and student networks. The network parameters of the student network are adjusted based on the distillation loss between the fusion similarity matrices of the teacher networks and the second similarity matrix of the student network. After each iteration, the next batch of multiple sample image pairs is input for the next iteration. The sample image pairs input in each iteration are at least partially different. Training of the student network is complete when a predetermined termination condition is met, such as the distillation loss value decreasing to a certain threshold or a predetermined number of iterations being reached.

[0088] In the embodiments of this specification, the input multiple sample image pairs are all positive sample pairs. The elements on the diagonal of the first similarity matrix corresponding to each teacher network represent the similarity between positive sample pairs, which can be used to evaluate the alignment of the teacher network with samples within the same class. The off-diagonal region describes the structure of the corresponding feature space, which can reflect the arrangement of sample images in space.

[0089] The fusion of the first similarity matrices corresponding to the K teacher networks can be expressed by the following formula: (8) in, Represents the fusion function. Let represent the first similarity matrix of the k-th teacher network.

[0090] In some embodiments, the first similarity matrices of multiple teacher networks can be fused using any of the following fusion strategies: 1. For elements on the diagonal, take the maximum value of the corresponding elements in multiple first similarity matrices as the element value; for elements off the diagonal, take the minimum value of the corresponding elements in multiple first similarity matrices as the element value.

[0091] This strategy favors a more compact within-class distribution and pushes all negative samples as far away as possible to achieve a more uniform distribution.

[0092] 2. For elements on the diagonal, take the maximum value of the corresponding elements in multiple first similarity matrices as the element value; for elements off the diagonal, take the average value of the corresponding elements in multiple first similarity matrices as the element value.

[0093] This strategy favors a more compact within-class distribution and considers the average distribution of multiple distributions.

[0094] 3. For elements on the diagonal, take the maximum value of the corresponding elements in multiple similarity matrices as the element value; for elements off the diagonal, take the corresponding element value in the specified first similarity matrix from multiple first similarity matrices.

[0095] In this strategy, there is a bias towards a more compact intra-class distribution, and the average distribution of multiple distributions is considered, with learning fixed to a certain teacher network.

[0096] The fusion strategy proposed in the embodiments of this specification can achieve better fusion results based on the actual training situation of multiple teacher networks.

[0097] Figure 5 This is a schematic diagram illustrating another network training method provided in an exemplary embodiment. For example... Figure 5 As shown, N sample image pairs are input into K pre-trained teacher networks. , and the student network S to be trained, wherein all N sample image pairs are positive sample pairs, and the first and second sample images in each positive sample pair contain the same building.

[0098] The following is based on teacher networks The following description uses the processing procedure as an example: Teacher Network Feature extraction is performed on N sample image pairs to obtain feature vectors for each first sample image. The feature matrices corresponding to the N first sample images in the N sample image pairs are shown in Figure 501. Similarly, feature vectors for each second sample image are obtained, and the feature matrices corresponding to the N second sample images in the N sample image pairs are shown in Figure 502. Whitening processing is then applied to feature matrices 501 and 502 to obtain whitened feature matrices 503 and 504. A first similarity matrix 505 is obtained based on feature matrices 503 and 504. For example, the first similarity matrix 505 can be obtained by multiplying the transpose of feature matrix 503 with feature matrix 504. This first similarity matrix 505 can then be updated to a probability matrix.

[0099] Other teacher networks can adopt the same approach. The same processing procedure is used to obtain the corresponding first similarity matrix; and the first similarity matrices corresponding to multiple teacher networks are fused to obtain the fused similarity matrix 506.

[0100] The student network S also extracts features from N sample image pairs, obtaining feature vectors for each first sample image. The feature matrices corresponding to the N first sample images in the N sample image pairs are shown in Figure 511. It also obtains feature vectors for each second sample image, with the feature matrices corresponding to the N second sample images in the N sample image pairs shown in Figure 512. Fully connected operations are performed on feature matrices 511 and 512 respectively, resulting in feature matrices 513 and 514. A second similarity matrix 515 is obtained based on feature matrices 513 and 514, for example, by multiplying the transpose of feature matrix 513 with feature matrix 514. This second similarity matrix 515 can be updated as a probability matrix.

[0101] Based on the distillation loss between the fusion similarity matrix 506 and the second similarity matrix 515, the network parameters of the student network S are adjusted to achieve training of the student network S.

[0102] Figure 6 This is a flowchart illustrating a visual retrieval method provided in an exemplary embodiment. The method includes the following steps: Step 601: Input the image to be retrieved into the visual retrieval network to obtain the first feature information of the image to be retrieved. The visual retrieval network is trained by the above embodiment.

[0103] Step 602: Compare the first feature information with the second feature information of the images in the image library, and take the images that meet the similarity requirements as the retrieval results. The second feature information is obtained by extracting features from the images in the image library using the visual retrieval network.

[0104] See Figure 7 , Figure 7 This is a block diagram of a network training apparatus provided in an exemplary embodiment, the apparatus comprising: The input unit 701 is used to input multiple sample image pairs into multiple pre-trained teacher networks and into a student network. Each sample image pair is a positive sample pair, including a first sample image and a second sample image. Whitening unit 702 is used to whiten the feature vectors of each first sample image and each second sample image output by each teacher network, and to obtain the first similarity matrix based on the whitened feature vectors. The fusion unit 703 is used to fuse the first similarity matrices of the multiple teacher networks to obtain a fused similarity matrix; The adjustment unit 704 is used to adjust the network parameters of the student network according to the distillation loss between the fusion similarity matrix and the second similarity matrix, wherein the second similarity matrix is ​​obtained based on the feature vectors of each first sample image and the feature vectors of the second sample image output by the student network.

[0105] In some embodiments, the whitening unit is specifically used for: Linear transformations are performed on the feature vectors of the first sample image and the feature vectors of the second sample image, respectively, so that the covariance matrix of the transformed feature vectors is an identity matrix. The parameters for the linear transformation are determined by running the training set on the teacher network.

[0106] In some embodiments, the apparatus further includes a parameter acquisition unit, configured to: Based on the average mean of the feature vectors obtained by the teacher network from feature extraction of all training samples in the set training set, a zero-mean vector is obtained. The zero-mean vector is used to zero-mean the feature matrix corresponding to all training samples. Obtain the eigenvector matrix of the covariance matrix of the zero-mean eigenmatrix; The parameters for the linear transformation are obtained based on the zero-mean vector and the eigenvector matrix.

[0107] In some embodiments, when the whitening unit performs linear transformations on the feature vectors of the first sample image and the feature vectors of the second sample image, it is specifically used for: Subtracting the zero-mean vector from the feature vector of the image to be processed yields a zero-mean feature vector. The image to be processed includes a first sample image and a second sample image. The whitened feature vector is obtained by multiplying the feature vector matrix with the zero-mean feature vector.

[0108] In some embodiments, when the whitening unit is used to obtain the first similarity matrix based on the whitened feature vector, it is specifically used for: The feature matrix is ​​obtained based on the whitened feature vectors; The first similarity matrix is ​​obtained by multiplying the transpose of the feature matrix with the feature matrix.

[0109] In some embodiments, the apparatus further includes a determining unit for: A full connection operation is performed on the feature vector of the first sample image output by the student network to obtain the first feature matrix; A fully connected operation is performed on the feature vector of the second sample image output by the student network to obtain the second feature matrix; The second similarity matrix is ​​obtained based on the first feature matrix and the second feature matrix.

[0110] In some embodiments, the fusion unit is specifically used for: For the elements on the diagonal of the fused similarity matrix, the element value is obtained based on the maximum value of the corresponding elements in multiple first similarity matrices; For the off-diagonal elements of the fused similarity matrix, the element values ​​are obtained according to any of the following methods: It is obtained based on the minimum value of corresponding elements in multiple first similarity matrices; It is obtained by averaging the corresponding elements in multiple first similarity matrices; It is obtained from the corresponding element values ​​of the specified first similarity matrix among multiple first similarity matrices.

[0111] In some embodiments, the apparatus further includes an updating unit for: The Gaussian kernel function is used to process each row of the similarity matrix to be processed to obtain a probability distribution matrix, and the similarity matrix to be processed is updated using the probability distribution matrix. The similarity matrix to be processed includes a first similarity matrix and a second similarity matrix.

[0112] In some embodiments, the adjustment unit is specifically used for: The distillation loss between the fusion similarity matrix and the second similarity matrix is ​​calculated using the KL divergence loss function.

[0113] Figure 8 This is a block diagram of a visual retrieval device provided in an exemplary embodiment. The device includes: The input unit 801 is used to input the image to be retrieved into the visual retrieval network to obtain the first feature information of the image to be retrieved. The visual retrieval network is a student network trained in the above embodiment. The retrieval unit 802 is used to compare the first feature information with the second feature information of the images in the image library, and take the image with the similarity requirement as the retrieval result. The second feature information is obtained by extracting features from the images in the image library using the visual retrieval network.

[0114] Figure 9 This is a schematic structural diagram of a device provided in an exemplary embodiment. Please refer to... Figure 9At the hardware level, the device includes a processor 902, an internal bus 904, a network interface 906, memory 908, and non-volatile memory 910, and may also include other hardware required for tasks. One or more embodiments of this specification can be implemented in software, such as the processor 902 reading the corresponding computer program from the non-volatile memory 910 into memory 908 and then running it. Of course, in addition to software implementation, one or more embodiments of this specification do not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0115] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which can take the form of a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email sending and receiving device, game console, tablet computer, wearable device, or any combination of these devices.

[0116] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0117] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0118] Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0119] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0120] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0121] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of one or more embodiments of this specification. The singular forms “a,” “described,” and “the” used in one or more embodiments of this specification and in the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0122] It should be understood that although the terms first, second, third, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first information may also be referred to as second information without departing from the scope of one or more embodiments of this specification, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "in response to a determination," or "when," or "in the event of a determination."

[0123] The above description is merely a preferred embodiment of one or more embodiments of this specification and is not intended to limit the scope of one or more embodiments of this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of one or more embodiments of this specification should be included within the protection scope of one or more embodiments of this specification.

Claims

1. A network training method, comprising: Multiple sample image pairs are input into multiple pre-trained teacher networks and into a student network. Each sample image pair is a positive sample pair, including a first sample image and a second sample image. The feature vectors of each first sample image and each second sample image output by each teacher network are whitened, and the first similarity matrix is ​​obtained based on the whitened feature vectors. The first similarity matrices of the multiple teacher networks are fused to obtain a fused similarity matrix; The network parameters of the student network are adjusted based on the distillation loss between the fused similarity matrix and the second similarity matrix. The second similarity matrix is ​​obtained based on the feature vectors of each first sample image and the feature vectors of the second sample images output by the student network. The whitening process for the feature vectors of each first sample image and each second sample image output by each teacher network includes: performing a linear transformation on the feature vectors of the first sample image and the feature vectors of the second sample image respectively, so that the covariance matrix of the transformed feature vector is an identity matrix. The parameters for performing the linear transformation are determined by running the training set on the teacher network.

2. The method according to claim 1, further comprising: Based on the average mean of the feature vectors obtained by the teacher network from feature extraction of all training samples in the set training set, a zero-mean vector is obtained. The zero-mean vector is used to zero-mean the feature matrix corresponding to all training samples. Obtain the eigenvector matrix of the covariance matrix of the zero-mean eigenmatrix; The parameters for the linear transformation are obtained based on the zero-mean vector and the eigenvector matrix.

3. The method according to claim 2, wherein performing linear transformations on the feature vectors of the first sample image and the feature vectors of the second sample image respectively comprises: Subtracting the zero-mean vector from the feature vector of the image to be processed yields a zero-mean feature vector. The image to be processed includes a first sample image and a second sample image. The whitened feature vector is obtained by multiplying the feature vector matrix with the zero-mean feature vector.

4. The method according to any one of claims 1-3, wherein obtaining the first similarity matrix based on the whitened feature vector comprises: The feature matrix is ​​obtained based on the whitened feature vectors; The first similarity matrix is ​​obtained by multiplying the transpose of the feature matrix with the feature matrix.

5. The method according to any one of claims 1-3, further comprising: A full connection operation is performed on the feature vector of the first sample image output by the student network to obtain the first feature matrix; A fully connected operation is performed on the feature vector of the second sample image output by the student network to obtain the second feature matrix; The second similarity matrix is ​​obtained based on the first feature matrix and the second feature matrix.

6. The method according to any one of claims 1-3, wherein fusing the first similarity matrices of the plurality of teacher networks to obtain a fused similarity matrix comprises: For the elements on the diagonal of the fused similarity matrix, the element value is obtained based on the maximum value of the corresponding elements in multiple first similarity matrices; For the off-diagonal elements of the fused similarity matrix, the element values ​​are obtained according to any of the following methods: It is obtained based on the minimum value of corresponding elements in multiple first similarity matrices; It is obtained by averaging the corresponding elements in multiple first similarity matrices; It is obtained from the corresponding element values ​​of the specified first similarity matrix among multiple first similarity matrices.

7. The method according to any one of claims 1-3, further comprising: The Gaussian kernel function is used to process each row of the similarity matrix to be processed to obtain a probability distribution matrix, and the similarity matrix to be processed is updated using the probability distribution matrix. The similarity matrix to be processed includes a first similarity matrix and a second similarity matrix.

8. The method according to claim 7, wherein adjusting the network parameters of the student network based on the distillation loss between the fusion similarity matrix and the second similarity matrix comprises: The distillation loss between the fusion similarity matrix and the second similarity matrix is ​​calculated using the KL divergence loss function.

9. A visual retrieval method, comprising: The image to be retrieved is input into the visual retrieval network to obtain the first feature information of the image to be retrieved. The visual retrieval network is a student network trained according to any one of claims 1-8. The first feature information is compared with the second feature information of the images in the image library, and the images that meet the similarity requirements are used as the retrieval results. The second feature information is obtained by extracting features from the images in the image library using the visual retrieval network.

10. A network training device, comprising: The input unit is used to input multiple sample image pairs into multiple pre-trained teacher networks and into student networks. Each sample image pair is a positive sample pair, including a first sample image and a second sample image. The whitening unit is used to whiten the feature vectors of each first sample image and each second sample image output by each teacher network, and to obtain a first similarity matrix based on the whitened feature vectors; wherein, the whitening process of the feature vectors of each first sample image and each second sample image output by each teacher network includes: performing linear transformations on the feature vectors of the first sample image and the feature vectors of the second sample image respectively, so that the covariance matrix of the transformed feature vectors is an identity matrix, wherein the parameters for performing the linear transformation are determined by running the training set on the teacher network; The fusion unit is used to fuse the first similarity matrices of the multiple teacher networks to obtain a fused similarity matrix; The adjustment unit is used to adjust the network parameters of the student network according to the distillation loss between the fusion similarity matrix and the second similarity matrix, wherein the second similarity matrix is ​​obtained based on the feature vectors of each first sample image and the feature vectors of the second sample image output by the student network.

11. A visual retrieval device, comprising: An input unit is used to input the image to be retrieved into a visual retrieval network to obtain the first feature information of the image to be retrieved, wherein the visual retrieval network is a student network trained according to any one of claims 1-8; The retrieval unit is used to compare the first feature information with the second feature information of images in the image library, and take the image with the similarity requirement as the retrieval result. The second feature information is obtained by extracting features from the images in the image library using the visual retrieval network.

12. An electronic device, comprising: processor; Memory used to store processor-executable instructions; The processor executes the executable instructions to implement the method as described in any one of claims 1-8 or claim 9.

13. A computer-readable storage medium having stored thereon computer instructions that, when executed by a processor, implement the steps of the method as described in any one of claims 1-8 or claim 9.