Method and device for spatial modeling of image class relationships based on prototype network
By modeling the image class relationship space based on the prototype network, the problem of linear classifiers' poor performance in capturing new sample position relationships is solved, achieving tighter clustering and robustness improvement, and optimizing fine-grained data sets. performance.
Patent Information
- Application Number
- CN202410904566.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-08
AI Technical Summary
In the existing technology, linear classifiers perform poorly in capturing the positional relationship of new samples relative to known categories, resulting in CNN's insufficient robustness in natural and complex environments, especially in fine-grained data sets.
A method of spatial modeling of image class relationships based on prototype networks is adopted. By constructing a prototype network and a supervised pre-training module, the similarity between image samples and prototype vectors is calculated, the image class spatial relationships are obtained, and transferred through KL divergence. to the discovery learning module to form tighter clusters.
It enhances the model's robustness to clustered samples of unknown categories, improves the interpretability of the classification process and performance on fine-grained data sets, and optimizes the model's classification performance balance.
Smart Images

Figure CN118447340B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image recognition, and in particular relates to a method and device for spatial modeling of image class relationships based on a prototype network. Background Art
[0002] Novel Class Discovery (NCD) is an important learning paradigm in open-world tasks. It allows machine learning models to classify unknown samples into appropriate semantic clusters with the help of prior knowledge without supervision. NCD focuses on the extraction and sorting of cluster semantic information to ensure that the final clustering results are consistent with the actual visual semantics, so as to better adapt to the complex scenes of the real world. At present, the mainstream NCD research methods mainly focus on transferring knowledge from labeled data to support the learning of new categories. This process is usually divided into two stages: supervised learning and discovery training. In the supervised learning stage, only labeled data is used to initialize the feature representation of known categories. At the same time, some studies also try to use self-supervised learning methods to obtain more general feature expressions to provide strong support for subsequent new category discovery; in discovery learning, the data set includes labeled data and unlabeled data. The model uses prior knowledge to guide the clustering of new categories through a shared latent feature space.
[0003] Recent studies have shown that although knowledge transfer from latent space in NCD has achieved certain success, it still has limitations and fails to fully reveal the intrinsic connection between known classes and new classes. According to our experimental results, traditional linear layer classifiers perform poorly in capturing the positional relationship of new samples relative to known classes. From the perspective of representation learning, the addition of a linear classification head to a convolutional neural network (CNN) essentially partitions the entire feature space and maps new class samples to specific regions. Despite this partitioning, CNNs often misclassify unknown classes into known classes with extremely high confidence. This representation sometimes results in inter-class distances being smaller than intra-class distances, significantly weakening the robustness of CNNs in natural complex environments. This phenomenon is particularly prominent in fine-grained datasets. Summary of the invention
[0004] In view of the defects in the above-mentioned prior art, the present invention provides a method for spatial modeling of image class relationships based on a prototype network, the method comprising:
[0005] Step S1: Construct a prototype network, which includes a prototype network P T and prototype network P S , the prototype network P T and prototype network P SBy calculating the similarity between the input image sample and each prototype vector, the image sample is mapped to the corresponding category;
[0006] Step S2: construct a supervised pre-training module, which pre-trains the image data set with known labels to obtain the distribution of known classes, and for each new class image sample with unknown labels, calculates the relationship between each new class image sample and the known class, thereby obtaining the image class space relationship, and transfers the image class space relationship to the discovery learning module through KL divergence;
[0007] Wherein, the supervised pre-training module includes an encoder Ω T , prototype network P T and the first softmax layer;
[0008] Step S3: constructing a discovery learning module, wherein the discovery learning module takes known label image data and unknown label image data as input and predicts the image category;
[0009] Wherein, the discovery learning module includes an encoder Ω S , prototype network P S and the second softmax layer;
[0010] Step S4: The supervised pre-training module and the discovery learning module constitute an image-like spatial relationship model, and the image-like spatial relationship model is used to classify images.
[0011] Preferably, in step S1, constructing a prototype network specifically includes:
[0012] S11: Set a prototype vector for each image category ;
[0013] S12: Calculate image samples With the corresponding prototype vector The similarity distance between
[0014] S13: Calculate image samples Belongs to the prototype vector The probability of
[0015] in, , Represents the number of image categories in the known image category space.
[0016] Preferably, in step S12, the image samples are calculated With the corresponding prototype vector The similarity distance between them is:
[0017] ;
[0018] ;
[0019] ;
[0020] Among them, Ω(·) is the encoder before the prototype network, which is used to extract image features; Sim e and Sim c They represent the normalized Euclidean distance and cosine distance respectively; the square of the Euclidean distance is divided by the dimension d of the feature space to obtain the normalized Euclidean distance.
[0021] Preferably, in step S13, the image samples are calculated Belongs to the prototype vector The probability is:
[0022] ;
[0023] in, Represents the adjustment factor.
[0024] Preferably, the supervised pre-training module serves as a teacher model for knowledge distillation, and the discovery learning module serves as a student model for knowledge distillation, and a balance in image classification performance is achieved by performing knowledge distillation on known label categories and unknown label categories.
[0025] Preferably, in step S2, for each new image class sample of unknown label, calculating the relationship between each new image class sample and the known class, so as to obtain the image class spatial relationship, specifically includes:
[0026] Input each new class sample of the image into the supervised pre-training module, and calculate the relationship between the new class and the known class according to the following formula:
[0027] ;
[0028] in, softmax represents the normalized exponential function, Represents new class samples of images of unknown categories, The prototype network P T The previous encoder is used to extract image features. Represents the prototype network P T Calculate image samples Belongs to category l The probability of t is the temperature coefficient, is the feature vector space of known image categories.
[0029] Preferably, in step S3, the discovery learning module simultaneously takes known label image data and unknown label image data as input, and predicts the image category, including: obtaining the predicted probability of the new image category as the final prediction result according to the following formula:
[0030] ;
[0031] in, softmax represents the normalized exponential function, Represents new class samples of images of unknown categories, The prototype network P S The previous encoder is used to extract image features. Represents the prototype network P S Calculate image samples Belongs to category l The probability of t is the temperature coefficient, is the feature vector space of known image categories.
[0032] Preferably, the loss function of the prototype network is cross entropy loss:
[0033] ;
[0034] in, Represents the loss function of the prototype network.
[0035] Preferably, in the knowledge distillation process, the difference between the output distribution of the supervised pre-training module and the output distribution of the discovery learning module is measured by KL divergence, so as to transfer the image class spatial relationship obtained by the supervised pre-training module to the discovery learning module.
[0036] The present invention also discloses a device for spatially modeling image class relationships based on a prototype network, comprising a memory and a processor, wherein the memory stores computer program code, and the processor is used to execute the computer program code to implement the aforementioned method for spatially modeling image class relationships based on a prototype network.
[0037] The present invention uses a prototype network to replace the linear classification model, and performs spatial modeling of image class relationships based on the prototype network. The obtained image class spatial relationship model can map similar samples to the adjacent area of the corresponding prototype, and can use the supervisory signal to minimize the distance between the sample and the prototype, thereby forming a tighter clustering. This design not only enhances the robustness of the model for clustered samples from unknown categories, but also improves the interpretability of the classification process through class relationship modeling, and ultimately optimizes the performance of the model on fine-grained data sets. In addition, the present invention also performs knowledge distillation on known classes and unknown classes to achieve a balance in model classification performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] By reading the detailed description below with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of the present disclosure will become readily understood. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0039] Figure 1 It is a framework for new category discovery tasks in the existing technology.
[0040] Figure 2 is a flow chart showing a method for spatially modeling image class relationships based on a prototype network according to an embodiment of the present invention.
[0041] Figure 3 FIG. 2 is a diagram illustrating an image class spatial relationship model according to an embodiment of the present invention. DETAILED DESCRIPTION
[0042] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0043] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings, and "multiple" generally includes at least two.
[0044] It should be understood that although the terms first, second, third, etc. may be used to describe ... in the embodiments of the present invention, these ... should not be limited to these terms. These terms are only used to distinguish .... For example, without departing from the scope of the embodiments of the present invention, the first ... may also be referred to as the second ..., and similarly, the second ... may also be referred to as the first ....
[0045] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0046] As used herein, the words "if" and "if" may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.
[0047] It should also be noted that the term "includes", "comprising" or any other variation thereof is intended to cover non-exclusive inclusion, so that a commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprising a ..." do not exclude the existence of other identical elements in the commodity or device including the elements.
[0048] like Figure 1 As shown in the figure, in the prior art, the new category discovery task is usually divided into two stages: supervised learning and discovery training. Before exploring the new category discovery task in depth, the following two key points need to be clarified: 1. The sample spaces corresponding to the known categories of known label image data and the unknown categories of unknown label image data are independent of each other and do not have any intersection. 2. The known categories of known label image data and the unknown categories of unknown label image data are similar but different.
[0049] Since image samples of certain known label categories are limited, the new category discovery task model needs to automatically separate new category images of unknown labels through supervised learning and training, so as to simultaneously identify old image categories and new image categories in the test image set.
[0050] When using a linear classification model for new category discovery tasks, the linear classification head performs poorly in capturing the positional relationship of new samples relative to known categories. Since CNN often misclassifies unknown categories into known categories with extremely high confidence, this representation sometimes causes the inter-class distance to be smaller than the intra-class distance, which significantly weakens the robustness of CNN in natural and complex environments. This phenomenon is particularly prominent in fine-grained datasets.
[0051] To solve the problem that linear classification models perform poorly in fine-grained datasets in new category discovery tasks, such as Figure 2 As shown, the present invention discloses a method for spatial modeling of image class relationships based on a prototype network, the method comprising:
[0052] Step S1: Construct a prototype network, which includes a prototype network P T and prototype network P S , the prototype network P T and prototype network P S By calculating the similarity between the input image sample and each prototype vector, the image sample is mapped to the corresponding category;
[0053] The prototype network is a cutting-edge deep learning network whose core purpose is to learn and extract prototype vectors that can represent samples of different categories. These vectors play the role of category centers in the model, and the mapping of samples to corresponding categories is achieved by calculating the similarity between the input samples and each prototype vector. During the training phase, the prototype network uses a carefully designed loss function to continuously update and optimize the prototype vectors to improve the model's recognition accuracy and generalization ability for categories. Compared with traditional linear classifiers, the prototype network has a more powerful feature representation capability, and is particularly suitable for processing complex and changing sample spaces.
[0054] Considering the strong robustness and interpretability of the prototype network, the embodiment of the present invention uses the prototype network to model the class space relationship, thereby constructing an image class space relationship model.
[0055] Step S2: construct a supervised pre-training module, which pre-trains the image data set with known labels to obtain the distribution of known classes, and for each new class image sample with unknown labels, calculates the relationship between each new class image sample and the known class, thereby obtaining the image class space relationship, and transfers the image class space relationship to the discovery learning module through KL divergence;
[0056] Wherein, the supervised pre-training module includes an encoder Ω T , prototype network P T and the first softmax layer;
[0057] Step S3: constructing a discovery learning module, wherein the discovery learning module takes known label image data and unknown label image data as input and predicts the image category;
[0058] Wherein, the discovery learning module includes an encoder Ω S , prototype network P S and the second softmax layer;
[0059] Step S4: The supervised pre-training module and the discovery learning module constitute an image-like spatial relationship model, and the image-like spatial relationship model is used to classify images.
[0060] The present invention adopts a prototype network to replace the linear classification model, and performs spatial modeling of image class relationships based on the prototype network. The obtained image class spatial relationship model can map similar samples to the neighboring areas of the corresponding prototype, and can use supervisory signals to minimize the distance between samples and prototypes, thereby forming a tighter clustering.
[0061] According to a further embodiment of the present invention, it is described how to use a classification head based on a prototype network (hereinafter referred to as a prototype classification head) to replace the existing linear classification head, that is, how to construct a prototype network.
[0062] Previous studies have shown that having multiple prototypes for each image category may not help to form a tighter sample distribution in the feature space. Therefore, this embodiment chooses to set only one prototype vector for each image category. In this framework, the embodiment of the present invention uses distance to measure the similarity between the sample and the prototype. The soft assignment of each image sample (x, y) to the prototype vector μ is calculated, and the distance between them can be expressed as Belongs to the prototype vector For each image sample instance in the classification head , this embodiment measures With the corresponding prototype vector The similarity distance between them is:
[0063] ;
[0064] ;
[0065] ;
[0066] Among them, Ω(·) is the encoder before the prototype network, which is used to extract image features; Sim e and Sim cThey represent the normalized Euclidean distance and cosine distance respectively; in the above formula, the square of the Euclidean distance is divided by the dimension d of the feature space in order to obtain the normalized Euclidean distance to avoid the influence of this distance on the model in high-dimensional space.
[0067] Next, calculate each image sample instance Belongs to the prototype vector The probability is:
[0068] ;
[0069] in, Represents the adjustment factor.
[0070] Then, the cross entropy (CE) loss can be defined as the loss of the prototype network framework:
[0071] ;
[0072] After the optimization of the above formula, similar embedded features are attracted to the prototype center, forming a trend of mutual convergence; while heterogeneous features show the characteristics of mutual repulsion. Therefore, the distribution characteristics of the feature embedding obtained by the prototype network in the latent space are more distinct, which is specifically manifested in that the intra-class distribution is more compact and the inter-class distribution is more sparse.
[0073] In a specific embodiment of the present invention, the supervised pre-training module serves as a teacher model for knowledge distillation, and the discovery learning module serves as a student model for knowledge distillation, thereby achieving a balance in image classification performance by performing knowledge distillation on known label categories and unknown label categories.
[0074] Knowledge distillation is a key technology that aims to efficiently transfer the knowledge of the teacher model to the student model, thereby achieving model compactness and performance improvement. This technology usually involves extracting knowledge from a larger teacher model and using a forced learning strategy to ensure that the output or representation of the student model is highly consistent with the teacher model.
[0075] In addition, mutual learning is a related technique that simultaneously trains two models with the same structure but different initializations to encourage them to learn cooperatively. The advantage of this approach is that different initializations cause the models to focus on features in different input regions, thereby better capturing the overall structure of the data.
[0076] However, traditional knowledge distillation methods require labels during training and are therefore limited in discovering new categories. In an embodiment, knowledge distillation techniques are used to transfer the distribution of category relations into a new shared feature space to regularize the new category discovery process.
[0077] Specifically, the supervised pre-training module pre-trains the image dataset with known labels to obtain the distribution of known classes. In order to determine the spatial relationship between known class samples, each new class image sample with unknown labels is input into the supervised pre-training module, and the relationship between each new class image sample and the known class is calculated to obtain the image class spatial relationship, and the image class spatial relationship is transferred to the discovery learning module through KL divergence.
[0078] Specifically, the relationship between the new class and the known class is calculated by the following formula:
[0079] ;
[0080] in, softmax represents the normalized exponential function, Represents new class samples of images of unknown categories, The prototype network P T The previous encoder is used to extract image features. Represents the prototype network P T Calculate image samples Belongs to category l The probability of t is the temperature coefficient, is the feature vector space of known image categories.
[0081] The discovery learning module takes both known label image data and unknown label image data as input and predicts the image category by mapping the input sample image to the latent space and calculating the distance between each input image sample and its corresponding prototype vector. Then, the distance is converted into probability distribution through softmax to obtain the final prediction result.
[0082] As a student model of knowledge distillation, the discovery learning module predicts new image categories in a similar way to the supervised pre-training module, specifically including: obtaining the prediction probability of the new image category as the final prediction result according to the following formula:
[0083] ;
[0084] in, softmax represents the normalized exponential function, Represents new class samples of images of unknown categories, The prototype network P S The previous encoder is used to extract image features. Represents the prototype network P S Calculate image samples Belongs to category l The probability of t is the temperature coefficient, is the feature vector space of known image categories.
[0085] In knowledge distillation, the knowledge distillation loss is defined as:
[0086] ;
[0087] During the knowledge distillation process, the KL divergence is used to measure the difference in output distribution between the supervised pre-training module (teacher model) and the discovery learning module (student model), so that the output distribution of the student model is as close as possible to the teacher model, thereby realizing the transfer of the image class spatial relationship obtained by the supervised pre-training module to the discovery learning module.
[0088] In this embodiment, the goal of knowledge distillation is to ensure that the output distribution of the student model is consistent with the output distribution of the teacher model. Therefore, when a new category sample is input into the classifier head of a known category, what is actually obtained is the overfitting score of the sample within the known category. The key to distillation is to capture the distribution of these overfitting scores, thereby promoting the learning of unknown categories. Then, during the training process, the model is more inclined to learn the knowledge of new categories, which may lead to ignoring the classification performance of known categories. In this embodiment, the knowledge of known classes is extracted in the discovery training phase to solve this problem:
[0089] ;
[0090] On this basis, the overall form of knowledge distillation loss can be written as:
[0091] ;
[0092] in, is the factor used to adjust for known and unknown distillation losses. With the choice of , the model can perfectly balance the performance of discovering new categories and detecting known categories.
[0093] In the above formulas, B represents the batch size of image samples. and They respectively represent the KL divergence corresponding to the unknown category image samples and the known category image samples in the knowledge distillation process.
[0094] According to a specific embodiment of the present invention, after constructing a prototype network, a supervised pre-training module and a discovery learning module, an image class spatial relationship model can be obtained, and the image class spatial relationship model is used for image classification to perform a new image category discovery task. Figure 3 As shown, the image-based spatial relationship model includes two parts: a supervised pre-training module and a discovery learning module, wherein the supervised pre-training module includes an encoder Ω T, prototype network P T and the first softmax layer; the discovery learning module includes an encoder Ω S , prototype network P S and the second softmax layer.
[0095] like Figure 3 As shown, the discovery learning module has a two-head network structure, including a known category classification head and a new category discovery header , Connect to the prototype network P S To receive image-like spatial relationship information; The self-labeling method is used to cluster new categories. The discovery learning module takes both known category label image data and unknown category label image data as input, and respectively passes the known category classification head and a new category discovery header After that, we get and Logarithm, the and Logarithmic fusion obtains the final image classification result. is the number of image categories with known labels, is the number of image categories with unknown labels, L ce is the cross-entropy loss function.
[0096] like Figure 3 As shown in the figure, the path of the known label data flow represents the processing process of the known label image data, and the path of the unknown label data flow represents the processing process of the unknown label image data. The mixed logarithmic score represents the mixed logarithmic score obtained after passing through the two classification heads, and finally merged for joint cross entropy (CE) loss calculation. The prototype network serves as the prototype head of the supervised pre-training module and the discovery learning module. Figure 3 The upper middle part is the supervised pre-training module, which serves as the teacher model for knowledge distillation. Figure 3 The lower middle part serves as a student model.
[0097] In order to evaluate the effectiveness and robustness of the method in this paper, the embodiment of the present invention conducted experiments on the CIFAR100 dataset, which is a standard benchmark dataset in computer vision. The embodiment of the present invention divides CIFAR100 into two subsets:
[0098] CIFAR100-80 (where 80% of the classes are known and 20% are new) and CIFAR100-50 (with less supervised information, where the ratio of known classes to new classes is 50:50). The embodiment of the present invention excludes the CIFAR10 and ImageNet datasets from the evaluation because the performance of existing methods on these datasets has reached saturation, which makes it difficult to identify the difference in algorithm performance. In addition, the method of the embodiment of the present invention is evaluated on three challenging fine-grained datasets: StanfordCars, CUB-200-2011, and FGVC-Aircraft. For each dataset, the embodiment of the present invention divides it into two parts, one containing known categories and the other containing new categories. The details of the dataset segmentation are as follows:
[0099] Table 1: Dataset segmentation information;
[0100]
[0101] The embodiment of the present invention adopts two evaluation protocols to comprehensively evaluate the image class spatial relationship model, namely task-aware and task-unaware. Under the framework of task-aware evaluation, the technical solution adopted by the present invention has achieved competitive performance on the standard datasets CIFAR100-50 and CIFAR100-80. On the three more challenging fine-grained datasets (Stanford Cars, CUB and Aircraft), the technical solution of the present invention has shown significant advantages, reflecting its superior performance in processing complex datasets. Under the framework of task-unaware evaluation, the technical solution adopted by the present invention outperforms existing methods in both known and new classes.
[0102] In addition, in the ablation experiment, the embodiment of the present invention also evaluated the effects of different distance modeling methods in the prototype network and conducted an in-depth study on the selection of distance modeling methods in the prototype network. As shown below, although some studies have pointed out that using only Euclidean distance is superior to using only cosine similarity or a combination of the two, the experimental results of the embodiment of the present invention show that the best effect can be achieved through a carefully designed combination of the two measurement methods.
[0103] Table 2: Effects of different distance modeling on different datasets;
[0104]
[0105] Specifically, the closeness between a sample and the prototype corresponds to a smaller Euclidean distance and a larger cosine similarity, which results in a significant degree of differentiation. Therefore, the measurement method we use not only accelerates the convergence process, but also the generated disparity can be easily converted into a probability distribution through the softmax function, thus avoiding the tedious step of reciprocal distance calculation.
[0106] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0107] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0108] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0109] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0110] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.
[0111] The above introduces the preferred embodiments of the present invention, which is intended to make the spirit of the present invention clearer and easier to understand, but is not intended to limit the present invention. All modifications, substitutions, and improvements made within the spirit and principles of the present invention should be included in the scope of protection outlined by the claims attached to the present invention.
Claims
1. A method for spatial modeling of image class relationships based on a prototype network, characterized in that: The method comprises: Step S1: Construct a prototype network, the prototype network includes a prototype network and prototype network , the prototype network and prototype network By calculating the similarity between the input image sample and each prototype vector, the image sample is mapped to the corresponding category; Step S2: construct a supervised pre-training module, which pre-trains the image data set with known labels to obtain the distribution of known classes, and for each new class image sample with unknown labels, calculates the relationship between each new class image sample and the known class, thereby obtaining the image class space relationship, and transfers the image class space relationship to the discovery learning module through KL divergence; The supervised pre-training module includes an encoder , Prototype Network and the first softmax layer; Step S3: constructing a discovery learning module, wherein the discovery learning module takes known label image data and unknown label image data as input and predicts the image category; The discovery learning module includes an encoder , Prototype Network and the second softmax layer; Step S4: the supervised pre-training module and the discovery learning module constitute an image-like spatial relationship model, and the image-like spatial relationship model is used to classify images; Wherein, in step S1, constructing a prototype network specifically includes: Step S11: Set a prototype vector for each image category ; Step S12: Calculate image samples With the corresponding prototype vector The similarity distance between Step S13: Calculate image samples Belongs to the prototype vector The probability of in, , Represents the number of image categories in the known image category space; In step S12, the image samples are calculated With the corresponding prototype vector The similarity distance between them is: ; ; ; in, It is the encoder before the prototype network, which is used to extract image features; and They represent the normalized Euclidean distance and cosine distance respectively; the square of the Euclidean distance is divided by the dimension d of the feature space to obtain the normalized Euclidean distance; In step S13, the image samples are calculated Belongs to the prototype vector The probability is: ; in, represents the regulating factor; Wherein, in the step S2, for each new class sample of an image with an unknown label, the relationship between each new class sample of the image and the known class is calculated to obtain the image class spatial relationship, which specifically includes: Input each new class sample of the image into the supervised pre-training module, and calculate the relationship between the new class and the known class according to the following formula: ; in, softmax represents the normalized exponential function, Represents new class samples of images of unknown categories, Prototype Network The previous encoder is used to extract image features. Representation Prototype Network Calculate image samples Belongs to category The probability of is the temperature coefficient, is the feature vector space of known image categories.
2. The method for spatial modeling of image class relationships based on a prototype network as claimed in claim 1, characterized in that: The supervised pre-training module is used as a teacher model for knowledge distillation, and the discovery learning module is used as a student model for knowledge distillation. By performing knowledge distillation on known label categories and unknown label categories, a balance of image classification performance is achieved.
3. The method for spatial modeling of image class relationships based on a prototype network as claimed in claim 1, characterized in that: In step S3, the discovery learning module simultaneously takes the known label image data and the unknown label image data as input, and predicts the image category, including: obtaining the predicted probability of the new image category as the final prediction result according to the following formula: ; in, softmax represents the normalized exponential function, Represents new class samples of images of unknown categories, Prototype Network The previous encoder is used to extract image features. Representation Prototype Network Calculate image samples Belongs to category The probability of is the temperature coefficient, is the feature vector space of known image categories.
4. The method for spatial modeling of image class relationships based on a prototype network as claimed in claim 1, characterized in that: The loss function of the prototype network is the cross entropy loss: ; in, Represents the loss function of the prototype network.
5. The method for spatial modeling of image class relationships based on a prototype network as claimed in claim 2, characterized in that: In the knowledge distillation process, the difference between the output distribution of the supervised pre-training module and the output distribution of the discovery learning module is measured by KL divergence, so as to transfer the image class spatial relationship obtained by the supervised pre-training module to the discovery learning module.
6. A device for spatially modeling image class relationships based on a prototype network, comprising a memory and a processor, characterized in that: The memory stores computer program code, and the processor is used to execute the computer program code to implement the method for spatial modeling of image class relationships based on a prototype network as described in any one of claims 1 to 5.
