Method and system for quantifying semantic difference between neural network representations
By learning the weight of the Net2VEC method on the reference dataset and calculating the data set and the difference, the problem that the difference between semantic information differences between neural network expressions is difficult to measure, and the semantic analysis of the internal mechanism of the neural network is realized.
Patent Information
- Application Number
- PCT/CN2024/090949
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-07-26
- Filing Date
- 2024-04-30
- Publication Date
- 2025-01-30
AI Technical Summary
The prior art is difficult to accurately measure semantic information differences between neural network representations, resulting in a lack of effective semantic differences measurement methods when analyzing the internal mechanisms of neural networks.
Use the Net2VEC method to learn the weight of each semantic concept on each semantic concept on the reference data set, calculate the dataset of each characteristic concept of each semantic concept. The difference between the ratio is the semantic difference between neural networking.
The accurate measurement of semantic information differences between neural network signs can be used to analyze the internal mechanism of neural networks in semantics, and the semantic differences between different intermediate tables can be used.
Smart Images

Figure CN2024090949_30012025_PF_FP_ABST
Abstract
Description
A method and system for quantifying semantic differences between neural network representations Technical Field
[0001] The present invention belongs to the field of computer vision and interpretability technology, and specifically relates to a method and system for quantifying semantic differences between neural network representations. Background Art
[0002] While deep neural networks have achieved remarkable results in various tasks in recent years, they remain difficult to understand as "black boxes." Visualizing the semantic concepts encoded in the intermediate layers of neural networks is a natural way to interpret them. The activation maximization method seeks to find a representative feature that maximizes the activation of a neuron, channel, or layer. Visualizations can be used to roughly decode the semantic concepts contained in the intermediate layers of a neural network. For example, low-layer filters typically encode basic concepts such as edges and textures, while high-layer filters tend to encode high-level objects and patterns. Beyond visualization, some researchers have focused on exploring the relationship between intermediate-layer filters and semantic concepts. The paper "David Bau, Bolei Zhou, Aditya Khosla, Aude Oliva, and Antonio Torralba. Network dissection: Quantifying interpretability of deep visual representations. In Proc. CVPR, 2017" collects a new dataset, BRODEN, that provides pixel-level labels for visual concepts and discovers alignments between individual filters and specific concepts. The paper "Ruth Fong and Andrea Vedaldi. Net2vec: Quantifying and explaining how concepts are encoded by filters in deep neural networks. In Proc. CVPR, 2018." demonstrates how DNNs use multiple filters to represent specific semantic concepts and investigates concept embedding through combinations of multiple filters. However, existing research has mostly focused on visualizing or statistically distributing the semantic concepts implied by neural network representations. Specifically, this involves statistically analyzing the number of filters or IoU values corresponding to each semantic concept in the representation. This makes it difficult to measure the semantic information differences between two neural network representations. Analyzing the internal mechanisms of neural networks often requires analyzing various differences between the two neural network representations, such as differences in semantic information. Therefore, addressing this issue is urgent.
[0003] Summary of the Invention
[0004] The present invention addresses the problems existing in the prior art and provides a method and system for quantifying the semantic differences between neural network representations. The method first extracts the two neural network representations to be compared, then uses the Net2Vec method to learn the weights of each semantic concept for each filter in the intermediate layer on a reference dataset. The method then calculates the dataset intersection-over-union (IoU) of each representation for all semantic concepts in the reference dataset. Finally, the difference between the IoUs of the two representations for all semantic concepts is integrated to obtain the semantic difference between the two neural network representations. This method solves the problem of the lack of accurate measurement of differences between neural network representations at the semantic information level, achieving accurate measurement results.
[0005] To achieve the above object, the present invention adopts a technical solution: a method for quantifying semantic differences between neural network representations, comprising the following steps:
[0006] S1, Extract Representation: The two neural networks that need to extract features are predicted on the reference dataset. During the prediction process, the intermediate layer output of the neural network when predicting each sample is retained;
[0007] S2, learn weights: use the Net2Vec method to learn the weight of each filter in the middle layer corresponding to each semantic concept on the reference dataset;
[0008] S3, calculate the intersection-over-union ratio of the dataset: linearly superimpose the activation value of each filter in the intermediate layer output retained in step S1 using the weights learned in step S2 to obtain the total activation value corresponding to each semantic concept. Then, binarize the total activation value to obtain the mask of each sample corresponding to each semantic concept, and then calculate the intersection-over-union ratio of each representation corresponding to each semantic concept.
[0009] S4, difference integration: Calculate the difference between the two neural network representations for the dataset of all semantic concepts, and integrate the difference to obtain the semantic difference between the two neural network representations.
[0010] As an improvement of the present invention, the Net2Vec method in step S2 is specifically as follows:
[0011] The predicted segmentation mask M(x; w) is calculated using the Sigmoid function σ according to the following formula:
[0012] Where W∈R K is the weight to be learned, K is the total number of filters in the middle layer, and A k (x) is the activation map of the k-th filter for input x;
[0013] The weight w for concept c is learned by minimizing the following binary cross entropy loss function:
[0014] Among them, N c is the number of samples containing concept c, x∈X c represents samples containing concept c, and where |L c (x)| is the number of foreground pixels of concept c in the ground-truth mask of sample x, S = h s w s is the total number of pixels in the true mask.
[0015] As another improvement of the present invention, in step S3, for the concept c, the set intersection over union (Set IoU) is:
[0016] Among them, L c is the ground-truth segmentation mask.
[0017] As another improvement of the present invention, in step S4, the difference between the intersection-over-union ratios of the two neural network representations for the datasets of all semantic concepts is integrated as follows:
[0018] Among them, α=I(min(IoU set (c j ; R2), IoU set (c j ; R1))>0) judge concept c j Is it a common concept between the two representations? If it is a common concept, α = 1; otherwise α = 0; I(·) is the indicator function, X R is the reference dataset, |L j (x)| is concept c j The number of foreground pixels in the ground-truth mask of sample x, |X R | is the total number of samples in the reference dataset, S = h s w s is the total number of pixels in the true mask, is the semantic concept shared by the representations R1 and R2 of the two neural networks, is the semantic concept that is not shared between the two representations, and λ is the weight of the concept that appears or disappears in the R2 representation compared to the R1 representation.
[0019] As another improvement of the present invention, the semantic difference of R2 relative to R1 is obtained by calculating the shared semantic concepts between the representations R1 and R2 of the two neural networks according to the following formula:
[0020] Among them, IoUset (c j ; R i ) j=1…c Is the representation of R i The intersection-over-union ratio of the dataset corresponding to each semantic concept, C is the total number of concepts;
[0021] The semantic difference between R2 and R1 is obtained by calculating the non-shared semantic concepts between the two representations according to the following formula:
[0022] As another improvement of the present invention, the value of λ is 2.
[0023] In order to achieve the above-mentioned purpose, the present invention also adopts a technical solution: a system for quantifying semantic differences between neural network representations, including a computer program, which implements the steps of any of the above-mentioned methods when executed by a processor.
[0024] Compared with the existing technology, the present invention has the following technical advantages and effects: The present invention designs a method and system for quantifying the semantic differences between neural network representations. The method calculates the intersection-over-union (IoU) of the datasets corresponding to each semantic concept and integrates the differences between the datasets of the representations for all semantic concepts to obtain the semantic difference between the two representations. The present invention solves the problem of being unable to measure the semantic information differences between neural network representations and provides a method for accurately measuring the differences between neural network representations at the semantic information level in the field of interpretability. By using the Net2Vec method to learn the weights of each semantic concept for each filter in the intermediate layer using a reference dataset and assigning different weights based on the learning difficulty of shared and unshared semantic concepts between the two representations, the measurement results are accurate and consistent with experimental experience. The present invention can be used to compare the semantic differences between representations in different intermediate layers of a neural network, thereby semantically analyzing the internal mechanisms of the neural network. The present invention can also be used to measure the semantic differences between representations in different modalities in the form of activation maps, such as RGB, depth, and infrared modalities, providing a semantic measurement method for analyzing the differences between representations in different modalities of multimodal neural networks. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] FIG1 is a flow chart of the steps of a method for quantifying semantic differences between neural network representations according to the present invention. DETAILED DESCRIPTION
[0026] The present invention will be further explained below with reference to the accompanying drawings and specific embodiments. It should be understood that the following specific embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention.
[0027] Example 1
[0028] As shown in Figure 1, a method for quantifying the semantic differences between neural network representations is implemented as follows:
[0029] Step S1, extract the representations of the two neural networks (such as ResNet50) that need to be compared: predict the neural network whose features need to be extracted on the reference dataset (such as the BRODEN dataset). During the prediction process, retain the intermediate layer output when the neural network predicts each sample.
[0030] Step S2: Use the Net2Vec method to learn the weight of each filter in the middle layer corresponding to each semantic concept on the reference dataset:
[0031] First, we need to learn the weights w∈R K Represented as , where K is the total number of filters in the middle layer, and the predicted segmentation mask M(x; w) is calculated using the Sigmoid function σ as follows:
[0032] Among them, A k (x) is the activation map of the k-th filter for input x;
[0033] Then, we learn the weight w for concept c by minimizing the binary cross entropy loss function as follows:
[0034] Among them, N c is the number of samples containing concept c, x∈X c represents samples containing concept c, and where |L c (x)| is the number of foreground pixels of concept c in the ground-truth mask of sample x, S = h s w s is the total number of pixels in the true value mask;
[0035] Then, on the reference dataset, the SGD optimizer is used with the learning rate set to 0.0001, the momentum set to 0.9, the batch size set to 64, and training is performed for 30 epochs to obtain the weights corresponding to each semantic concept.
[0036] Step S3, calculating the dataset intersection-over-union ratio of each representation to each semantic concept: first use the Net2Ve method to learn the weight of each filter in the intermediate layer corresponding to each semantic concept, then use the learned weight to linearly superimpose the activation value of each filter in the intermediate layer output retained in the previous step to obtain the total activation value corresponding to each semantic concept, then binarize the total activation value to obtain the mask of each sample corresponding to each semantic concept, and then calculate the dataset intersection-over-union ratio of each representation to each semantic concept;
[0037] The specific steps are as follows:
[0038] The set intersection over union (Set IoU) of concept c is calculated as follows:
[0039] This formula calculates the segmentation mask M after the total activation value is binarized by linearly superimposing the activation value of each filter by the weight w of the concept c, and the true value segmentation mask L c The intersection-over-union ratio (Jakkard coefficient);
[0040] Then calculate the corresponding dataset intersection-union ratio for each semantic concept.
[0041] Step S4, integrating the difference between the intersection and union ratios of the two representations for all semantic concepts in the dataset;
[0042] The steps for integrating the difference between the intersection of the two representations for all semantic concepts in the dataset are as follows:
[0043] First, we use R1 and R2 to represent the representation of the two neural networks, and use IoU set (c j ; R i ) j=1…C Representation R i The intersection-over-union (IoU) of the datasets corresponding to each semantic concept, where C is the total number of concepts, is then used to calculate the semantic difference between the two representations, R2, relative to R1, using the following formula:
[0044] Then, the semantic difference of R2 relative to R1 is calculated based on the non-shared semantic concepts between the two representations according to the following formula:
[0045] Finally, we integrate all semantic concepts from the above two equations according to the following formula to calculate the semantic difference between the two neural network representations:
[0046] Among them, α=I(min(IoU set (c j ; R2), IoU set (c j ; R1))>0) judge concept c j Is it a common concept between the two representations? If it is a common concept, α=1, otherwise α=0. I(·) is the indicator function, X R is the reference dataset, |L j (x)| is concept c j The number of foreground pixels in the ground-truth mask of sample x, |X R| is the total number of samples in the reference dataset, S = h s w s is the total number of pixels in the true mask.
[0047] We set λ = 2 to emphasize the semantic differences brought about by non-shared concepts between the two representations, that is, the semantic differences between R2 and R1. For concept c j The semantic difference of each semantic concept is divided by the ratio of pixels in the entire reference dataset to eliminate the semantic concept ratio bias in the reference dataset.
[0048] When the above semantic difference S.Var(R2; R1) is positive, it means that R2 has richer semantic information than R1, and vice versa.
[0049] It should be noted that the above content merely illustrates the technical idea of the present invention and cannot be used to limit the scope of protection of the present invention. For ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications all fall within the scope of protection of the claims of the present invention.
Claims
1. A method for quantifying semantic differences between neural network representations, characterized in that The steps include: S1, extract representation: predict the two neural networks that need to extract features on the reference data set. During the prediction process, retain the intermediate layer output of the neural network when predicting each sample; S2, learn weights: use the Net2Vec method to learn the weight of each filter in the middle layer corresponding to each semantic concept on the reference data set; S3, calculate the intersection-and-union ratio of the data set: linearly superimpose the activation value of each filter in the intermediate layer output retained in step S1 with the weights learned in step S2 to obtain the total activation value corresponding to each semantic concept, then binarize the total activation value to obtain the mask of each sample corresponding to each semantic concept, and then calculate the intersection-and-union ratio of the data set corresponding to each semantic concept for each representation; S4, difference integration: calculate the difference of the intersection and union ratio of the two neural network representations for all semantic concepts in the data set, and integrate the difference to obtain the semantic difference between the two neural network representations.
2. A method for quantifying semantic differences between neural network representations as claimed in claim 1, characterized in that: The Net2Vec method in step S2 is specifically: The predicted segmentation mask M(x; w) is calculated using the Sigmoid function σ according to the following formula: Where w∈R K is the weight to be learned, K is the total number of filters in the middle layer, A k (X) is the activation map of the kth filter for input x; The weight w for concept c is learned by minimizing the following binary cross entropy loss function: Among them, N c is the number of samples containing concept c, x∈X c represents samples containing concept c, and Where |L c (x)| is the number of foreground pixels of concept c in the ground-truth mask of sample x, S = h s ·w s is the total number of pixels in the true value mask.
3. A method for quantifying semantic differences between neural network representations as claimed in claim 2, characterized in that: In step S3, for the concept c, the set intersection over union (Set IoU) is: Among them, L c is the true segmentation mask.
4. A method for quantifying semantic differences between neural network representations according to claim 2 or 3, characterized in that: In step S4, the difference between the intersection and union ratios of the representations of the two neural networks for the data sets of all semantic concepts is integrated in the following manner: Among them, α=I(min(IoU set (c j ;R2),IoU set (c j ; R1))>0) judge concept c j Is it a common concept between the two representations? If it is a common concept, α = 1; otherwise α = 0; I(·) is the indicator function, X R is the reference data set, |L j (x)| is the concept c j The number of foreground pixels in the ground-truth mask of sample x, |X R | is the total number of samples in the reference data set, S = h s ·w s is the total number of pixels in the true value mask, is the semantic concept shared by the representations R1 and R2 of the two neural networks, is a semantic concept that is not shared between the two representations, and λ is the difference between the R1 representation and The weight of the newly appearing or disappearing concept in the R2 representation.
5. A method for quantifying semantic differences between neural network representations as claimed in claim 4, characterized in that: The semantic difference between R1 and R2 in the representation of the two neural networks is calculated according to the following formula: Among them, IoU set (c j ; R i ) j=1…C It is the representation of R i The intersection-over-union ratio of the datasets corresponding to each semantic concept, C is the total number of concepts; The semantic difference between R2 and R1 is obtained by calculating the non-shared semantic concepts between the two representations according to the following formula:
6. A method for quantifying semantic differences between neural network representations as claimed in claim 5, characterized in that: The value of λ is 2.
7. A system for quantifying semantic differences between neural network representations, comprising a computer program, characterized in that: When the computer program is executed by a processor, the steps of any of the above methods are implemented.
Citation Information
Patent Citations
Convolutional neural network training method, image recognition method and corresponding devices
CN110647992A
Semantic segmentation method based on data set distribution and context information
CN114549832A
Deep neural network interpretable method based on semantic alignment
CN114970820A
Method and system for quantifying semantic difference between neural network representations
CN116992930A
Semantic segmentation network model uncertainty quantification method based on evidence inference
US20230084910A1