A dynamic routing network learning method based on relation

By introducing a relational dynamic routing structure and relationship diagram into the depth model, the dynamic network routing mechanism is optimized, and the problem of difficult image path modeling and regular correlation in the depth model is solved, and efficient image classification and computing resources are achieved.

CN113887723BActive Publication Date: 2025-04-08ZHEJIANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111171434.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-08
Publication Date
2025-04-08
Estimated Expiration
2041-10-08

AI Technical Summary

Technical Problem

In the image classification task of the existing depth model, although the increase in the number of layers improves the accuracy, the marginal improvement is reduced. For pictures with inconspicuous blur features, more network layer processing is required, and it is difficult for the prior art to model the regularity of image paths and the path correlation of similar images.

Method used

A dynamic routing network learning method based on relationship is proposed. By introducing dynamic routing structures and relationship diagrams into convolutional neural networks, the dynamic network routing mechanism is optimized, the path diversity operation and relationship constraints are realized, and the dynamic prediction model is trained.

Benefits of technology

It achieves the same performance with the lowest computational volume under the same model, improves the algorithm running speed, the accuracy and path interpretability of the dynamic routing network, and gets rid of the strategy of disorderly adjusting the network structure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113887723B_ABST
    Figure CN113887723B_ABST
Patent Text Reader

Abstract

The present invention discloses a relational-based dynamic routing network learning method, which is used to accelerate the corresponding network prediction algorithm in various tasks such as classification and segmentation. Specifically, the following steps are included: obtaining an image data set for training the task; establishing a basic network model based on routing selection; establishing a relational routing model for selecting paths in the model; establishing a relational model for paths between samples; training a prediction model based on the aforementioned modeling results; and accelerating the existing network using the learning framework. The present invention is based on a relational-based dynamic routing network learning method. Compared with the existing dynamic network learning method, the running speed that can be completed under the existing ResNet, DenseNet and other models is greatly improved, and has good application value.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of computer vision, and particularly designs a relationship-based dynamic routing network learning method. Technical Background

[0002] In pursuit of improved accuracy, the number of layers in deep models has been increasing, but the marginal improvement in accuracy brought by more layers is decreasing. Or for some input images, not so many neuron operations are actually required. Only some really blurry images with unclear features and difficult to distinguish even for humans require more network layers to process and finally obtain the expression features that can distinguish their categories. However, for a set of images, whether the path they pass through is irregular or cannot be modeled, for similar images and images of different difficulty, the paths they choose should have corresponding regularities. Against the above background, the prior art faces two key technical problems: First, how to model the path chosen by the image passing through the network. Second, for similar images and different images, how to constrain the natural association between the image and the selected path. Summary of the invention

[0003] In order to solve the problems existing in the prior art, the present invention mainly explores the relational dynamic network in the dynamic routing network, and proposes a relational dynamic routing network learning method. Through the diversity operation of the path in this method, the network model can be more fully utilized, and at the same time, through relational routing, the dynamic network routing mechanism can be better optimized. And under the same model, the same performance can be achieved with the lowest amount of calculation in the industry.

[0004] In order to achieve the above object, the technical solution specifically adopted by the present invention is as follows:

[0005] A relationship-based dynamic routing network learning method comprises the following steps:

[0006] S1. Obtain the image classification dataset for training and divide the dataset into several batches as network input;

[0007] S2. For the convolutional neural network used for image classification, it is divided into several substructures and a dynamic routing structure is added before the substructure to construct a dynamic routing network model based on path selection;

[0008] S3, for the dynamic routing structure added in S2, establish a relationship graph between the dynamic routing structures, and propagate routing features through the established relationship graph;

[0009] S4, input the data set in S1 into the dynamic routing network model constructed in S2 in batches, and train the model in combination with the relational constraints of the path;

[0010] S5. Based on the dynamic routing network model trained in S4, the dynamic routing structure output before each substructure is binarized and the binarization results represent the corresponding substructures to be skipped or executed, thereby obtaining a dynamic prediction model for classifying the input image.

[0011] Preferably, in S1, the image dataset used for training the target task includes an image set Among them I i is the i-th image, K is the number of images in the image group; the image group is divided into several batches, each batch contains L images.

[0012] Preferably, in S2, the process of establishing a basic network model based on routing selection is as follows:

[0013] The convolutional neural network for image classification is divided into N network substructures in units of Block, where F j (x j-1 ) represents the j-th substructure, and the input x of the j-th substructure j-1 The output of the previous substructure; before each substructure, add a dynamic routing structure R for selecting to skip or execute the current substructure j ;

[0014] The input of the dynamic routing structure is the output of the previous substructure, and the output of the jth dynamic routing structure is r j for:

[0015] r j = gumbel-softmax(fc(x j-1 )))[0]

[0016] Where fc is the fully connected layer model, r j is 0 or 1, gumbel-softmax is a softmax structure with gumbel sampling;

[0017] For the jth substructure with dynamic routing structure, the output is:

[0018] x j =r j F j (x j-1 )+(1-r j )x j-1 .

[0019] Preferably, the specific method of S3 is as follows:

[0020] S31. For the dynamic routing structures added before all substructures in S2, a relationship graph between the dynamic routing structures is established; in the relationship graph, the features between the dynamic routing structures can only be transmitted unidirectionally from the previous dynamic routing structure to the subsequent dynamic routing structure and the influence is attenuated layer by layer, and the weight of the previous layer of dynamic routing structure transmitted to the next one is γ∈[0,1]; each layer of dynamic routing structure is at most affected by the previous r layers of dynamic routing structure; the routing features are propagated between the dynamic routing structures through the adjacency matrix A of the relationship graph, and the elements of the mth row and nth column in the adjacency matrix A are as follows:

[0021]

[0022] S32, during the routing feature propagation process, for the nth dynamic routing structure currently propagated, the dynamic routing structure is the output x of the previous substructure n As input, the first routing feature of the current dynamic routing structure is obtained through an average pooling operation:

[0023]

[0024] Among them, H n is x n High, W n is x n The width, With x n The feature channels are the same. The dimension is 1×C n ;

[0025] Then the first routing feature obtained Alignment is performed through the first fully connected layer FC, and the activation function outputs the second routing feature with a dimension of 1×d.

[0026]

[0027] Where g represents the Rule activation function, w0 is the network parameter of the first fully connected layer FC;

[0028] S33, collecting the second routing features of the first r dynamic routing structures of the current dynamic routing structure Connect to get the fusion routing feature S n =(s n-r ,…s n ) ; then the fused routing features are passed through the GCN layer, and the activation function outputs the final routing features s that need to be propagated backward in the current dynamic routing structure n :

[0029] s n =g(GCN(S n;A;w1))[r,:]

[0030] Where w1 is the network parameter of the GCN layer;

[0031] S34, the final routing feature s of the current dynamic routing structure n After passing through the second fully connected layer FC, the execution decision of the current substructure is obtained through the relaxation function Gumbel-Softmax:

[0032] v n =softmax(log(FC(s n ;w n +G) / τ)[1]

[0033] Where G is gumbel sampling, τ is the temperature of the relaxation function, and the obtained v n is the probability of executing the current substructure output by the current dynamic routing structure;

[0034] S35. For the nth substructure with a dynamic routing structure, its input is x n , the output is:

[0035] x n+1 =v n F n+1 (x n )+(1-v n )x n .

[0036] Preferably, the specific method of S4 is as follows:

[0037] S41, take a batch from the data set of S1 and input it into the dynamic routing network model constructed by S2 for model training. In the training phase, for any i-th input sample, a dynamic network selection path is established as follows:

[0038] P i =[v1,v2,…,v N ]

[0039] S42, for the samples in the input training batch, first use a projection method H(.) to calculate the distance between any two samples X in the same batch i and X j The distance between them is obtained, and the distance matrix D is obtained. The element of the i-th row and j-th column in the distance matrix D is:

[0040] D i,j =||H(X I )-H(X j )||2,

[0041] Among them, ‖‖2 represents the L2 norm;

[0042] Then use the argsort function to sort the distance matrix D in descending order by row to obtain the index matrix M:

[0043] M=argsort(D)

[0044] The element in the i-th row and j-th column of the index matrix M is denoted by M i,j ;

[0045] S43, calculating the total loss function of the current input batch samples based on the index matrix M, and optimizing the parameters of the dynamic routing network model based on the total loss function to complete the training of the current batch, wherein the calculation formula of the total loss function is:

[0046] L total =L cls +L rank +L cost

[0047] Where: L cls is the classification constraint loss;

[0048] L rank is the triplet loss, and its calculation formula is:

[0049]

[0050] In the formula Indicates Margin parameter;

[0051] L cost is the computational loss of the path, and its calculation formula is:

[0052]

[0053] Where: c j represents the computational effort of the jth substructure;

[0054] S44. Repeat S41 to S43 continuously, input different batches of samples into the dynamic routing network model, and finally complete the model training.

[0055] Preferably, the specific method of S5 is as follows:

[0056] S51: Based on the dynamic routing network model trained in S4, the v output by the dynamic routing structure before each substructure n Binarization is performed, and the dynamic routing structure after binarization outputs r j for:

[0057]

[0058] After adding binarization processing to each dynamic routing structure of the dynamic routing network model, a dynamic prediction model is obtained;

[0059] S52: Input the image I to be classified and detected into the dynamic prediction model, and output the network prediction result, which is the classification result O.

[0060] Compared with the existing dynamic network learning methods, the relationship-based dynamic routing network learning method of the present invention has the following beneficial effects:

[0061] First, the relational dynamic routing method of the present invention defines a dynamic network learning model based on multiple relations. By introducing a dynamic routing mechanism, the network structure used by the input image can dynamically and selectively execute part of the network according to the different characteristics of the image during the prediction process, effectively reducing the computational consumption and greatly improving the algorithm operation speed.

[0062] Secondly, the present invention proposes a relationship model between the execution relationship between network units and the path between samples, which for the first time realizes the modeling of the execution relationship between different unit blocks of a single image and makes long-term decisions on the execution of each block. At the same time, the modeling of the execution path relationship of different images helps the prediction model to better learn the path selection of image samples, getting rid of the strategy of simply adjusting the network structure in an unordered manner, and effectively improving the accuracy of the dynamic routing network and the interpretability of the path.

[0063] Finally, the present invention can be directly applied to most existing networks through the improvement of the routing structure, and can achieve great acceleration without loss of accuracy or improvement.

[0064] The present invention is based on a relational dynamic routing network learning method. Compared with the existing dynamic network learning method, the running speed that can be completed under the existing ResNet, DenseNet and other models is greatly improved, and it has good application value. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] Figure 1 It is a schematic diagram of the process of the present invention;

[0066] Figure 2 It is a schematic diagram of the routing model structure of the present invention;

[0067] Figure 3 This is a schematic diagram of the path optimization of the present invention;

[0068] Figure 4 The following is a comparison chart of the effects of the present invention and the basic methods in the field, where (a) is the result on the CIFAR-10 general dataset, (b) is the result on the CIFAR-100 general dataset; (c) is compared with the result on the ImageNet general dataset;

[0069] Figure 5 The following is a comparison chart of the effects of the present invention and other leading methods in the industry, where (a) is the result on the CIFAR-10 general dataset, (b) is the result on the CIFAR-100 general dataset; (c) is the result on the ImageNet general dataset; DETAILED DESCRIPTION

[0070] The present invention will be further described and illustrated below in conjunction with the accompanying drawings and specific implementation methods.

[0071] like Figure 1 As shown, a relationship-based dynamic routing network learning method includes the following steps:

[0072] S1. Obtain the image classification dataset for training and divide the dataset into several batches as network input;

[0073] In this step, the image dataset used to train the target task includes the image group Among them I i is the i-th image, K is the number of images in the image group; the image group is divided into several batches, each batch contains L images.

[0074] The algorithm goal is defined as: obtaining the classification result O of the image I to be detected.

[0075] S2. For the convolutional neural network used for image classification, it is divided into several substructures and a dynamic routing structure is added in front of the substructure to construct a dynamic routing network model based on path selection.

[0076] The target convolutional neural network here refers to the existing convolutional neural networks (CNNs) that can be used for image classification, such as ResNet, DenseNet, etc.

[0077] In this step, the process of establishing a basic network model based on routing selection is as follows:

[0078] The convolutional neural network used for image classification is divided into N network substructures in units of Block, and each substructure contains one Block. j (x j-1 ) represents the j-th substructure, and the input x of the j-th substructure j-1 The output of the previous substructure is used to obtain the basic network structure. A dynamic routing structure R is added before each substructure of the basic network structure to select whether to skip or execute the current substructure. j ;

[0079] When the input is x j-1 , if the dynamic routing structure chooses to skip the current substructure, the output of the current substructure is its input; if the dynamic routing structure chooses to execute the current substructure, the output of the current substructure is the output of its input after passing through the Block. The expression is as follows:

[0080]

[0081] In order to facilitate the execution of this selection operation, its form is adjusted and the routing model of the path is set. In this model, the input of the dynamic routing structure is the output of the previous substructure, and the output r of the jth dynamic routing structure is j for:

[0082] r j = gumbel-softmax(fc(x j-1 )))[0]

[0083] Where fc is the fully connected layer model, r j is 0 or 1, gumbel-softmax is a softmax structure with gumbel sampling; [0] [] means taking the vector gumbel-softmax(fc(x j-1 )))'s 0th dimension, that is, the first scalar in the vector.

[0084] For the jth substructure with dynamic routing structure, the output is:

[0085] x j =r j F j (x j-1 )+(1-r j )x j-1 .

[0086] In this representation, r j is a binary 0 or 1. However, during the training phase, r j It is actually output as a continuous value, and its corresponding continuous variable can be recorded as v j . In the subsequent testing or actual use stage, v j After binarization, the output is r j Thus, after S2, the original CNN network can be constructed into a dynamic routing network model for subsequent training.

[0087] S3. For the dynamic routing structure added in S2, a relationship graph between the dynamic routing structures is established, and routing features are propagated through the established relationship graph.

[0088] In this step, the specific method of establishing a relationship diagram between dynamic routing structures to propagate routing features is as follows:

[0089] S31. For the dynamic routing structures added before all substructures in S2, a relationship graph between the dynamic routing structures is established; in the relationship graph, the features between the dynamic routing structures can only be transmitted unidirectionally from the previous dynamic routing structure to the subsequent dynamic routing structure and the influence is attenuated layer by layer, and the weight of the previous layer of dynamic routing structure transmitted to the next one is γ∈[0,1]; each layer of dynamic routing structure is at most affected by the previous r layers of dynamic routing structure; the routing features are propagated between the dynamic routing structures through the adjacency matrix A of the relationship graph, and the elements of the mth row and nth column in the adjacency matrix A are as follows:

[0090]

[0091] A framework for propagating routing features across dynamic routing structures is available at Figure 2 As shown, the specific process is as S32~S35, and the process is described in detail below.

[0092] S32, during the routing feature propagation process, assume that the current propagation is the nth dynamic routing structure, recorded as the current dynamic routing structure, and the corresponding CNN network substructure is recorded as the current substructure. The current dynamic routing structure is the output x of the previous substructure block. n As input, the first routing feature of the current dynamic routing structure is obtained through an average pooling operation:

[0093]

[0094] Among them, H n is x n High, W n is x n The width, With x n The feature channels are the same. The dimension is 1×C n ; [h,w,:] represents x n Dimension operation;

[0095] In order to propagate the routing features on the above relationship graph, the first routing feature Aligned through the first fully connected layer, the activation function outputs the second routing feature with a dimension of 1×d

[0096]

[0097] Where g represents the Rule activation function, w0 is the network parameter of the first fully connected layer FC;

[0098] S33, collecting the second routing features of the first r dynamic routing structures of the current dynamic routing structure Connect to get the fusion routing feature S n =(s n-r ,…s n ) ; then the fused routing features are passed through the GCN layer, and the activation function outputs the final routing features s that need to be propagated backward in the current dynamic routing structure n :

[0099] s n =g(GCN(S n ;A;w1))[r,:]

[0100] Where w1 is the network parameter of the GCN layer; [r,:] represents g(GCN(S n ; A; w1)) dimension operation;

[0101] Therefore, through the above-mentioned adjacency matrix A of the relationship graph between routes, we propagate the routing features between routes, and pass the obtained current layer features to the subsequent routes.

[0102] S34, the final routing feature s of the current dynamic routing structure n After passing through the second fully connected layer FC, the execution decision of the current substructure is obtained through the relaxation function Gumbel-Softmax:

[0103] v n =softmax(log(FC(s n ;w n +G) / τ)[1]

[0104] Where G is gumbel sampling, τ is the temperature of the relaxation function, and the obtained v n is the probability of executing the current substructure output by the current dynamic routing structure;

[0105] S35. For the nth substructure with a dynamic routing structure, its input is x n , the output is:

[0106] x n+1 =v n F n+1 (x n )+(1-v n )x n .

[0107] S4: Input the data set in S1 into the dynamic routing network model constructed in S2 in batches, and train the model in combination with the relational constraints of the path.

[0108] In this step, the specific method of training the dynamic routing network model is as follows:

[0109] S41, take a batch from the data set of S1 and input it into the dynamic routing network model constructed by S2 for model training. In the training phase, for any i-th input sample, a dynamic network selection path is established as follows:

[0110] P i =[v1,v2,…,v N ]

[0111] where v n The selection result of the path representing the nth substructure is obtained by S3.

[0112] S42, for the samples in the input training batch, first use a projection method H(.) to calculate the distance between any two samples X in the same batch i and X j The distance between them is obtained, and the distance matrix D is obtained. The element of the i-th row and j-th column in the distance matrix D is:

[0113] D i,j =||H(X i )-H(X j )||2,

[0114] Among them, ‖‖2 represents the L2 norm;

[0115] Then use the argsort function to sort the distance matrix D in descending order by row to obtain the index matrix M:

[0116] M=argsort(D)

[0117] The element in the i-th row and j-th column of the index matrix M is denoted by M i,j D determines the distance between every two samples in a training batch.

[0118] S43, calculating the total loss function of the current input batch samples based on the index matrix M, and optimizing the parameters of the dynamic routing network model based on the total loss function to complete the training of the current batch, wherein the calculation formula of the total loss function is:

[0119] L total =L cls +L rank +L cost

[0120] Where: L cls is the classification constraint loss; L rank It is the triplet loss.

[0121] Based on the above path index, the present invention designs a special triplet sampling method, which treats every two adjacent samples as a positive sample and a negative sample. i,j is the sample X i The jth most recent sample, therefore, P Mi,j It is M i,j The present invention designs a triplet optimization method, and the calculation formula of the triplet loss is:

[0122]

[0123] In the formula Indicates Margin parameter;

[0124] L cost is the computational loss of the path, and its calculation formula is:

[0125]

[0126] Where: c j represents the computational effort of the jth substructure;

[0127] S44. Repeat S41 to S43 continuously, input different batches of samples into the dynamic routing network model, and finally complete the model training.

[0128] S5. Based on the dynamic routing network model trained in S4, the dynamic routing structure output before each substructure is binarized and the binarization results represent the corresponding substructures to be skipped or executed, thereby obtaining a dynamic prediction model for classifying the input image.

[0129] In this step, the specific method of constructing a dynamic prediction model is as follows:

[0130] Since the dynamic routing structure output in the original model is a continuous probability value in the range of [0,1], but in the actual application of the model, the dynamic routing structure should play a role in controlling whether to skip the substructure. Therefore, in this step, the purpose of binarization is to convert the original v j Binarize to 0 or 1.

[0131] S51: Based on the dynamic routing network model trained in S4, the v output by the dynamic routing structure before each substructure n Binarization is performed, and the dynamic routing structure after binarization outputs r j for:

[0132]

[0133] After adding binarization processing to each dynamic routing structure of the dynamic routing network model, the dynamic routing network model is adjusted into a dynamic prediction model that can be used for actual classification.

[0134] S52: Input the image I to be classified and detected into the dynamic prediction model, and output the network prediction result, which is the classification result O.

[0135] The above methods S1 to S5 are applied to a specific embodiment below to demonstrate their technical effects.

[0136] Example

[0137] The implementation method of this embodiment is as described above, and the steps are not described here. The following only shows the effect based on the case data.

[0138] This example is based on two widely used open source datasets, Cifar10 / 100 and ImageNet:

[0139] Cifar10 / 100: includes 60,000 natural object images, divided into 10 categories, of which 50,000 are train data and 10,000 are test data. ImageNet: includes 125,0000 training samples and 50,000 validation samples.

[0140] In the above methods S1 to S5, the target convolutional neural network uses ResNet110 on the CIFAR dataset and ResNet50 on the ImageNet dataset. The optimization method of the loss function uses the stochastic gradient descent method SGD.

[0141] By adjusting the hyperparameters, we can obtain models with different performance.

[0142] Finally, the test results of the method of this embodiment on the data set are compared with the basic ResNet results, as shown in Figure 4 shown. Figure 4 In the figure, Accuracy represents the prediction accuracy, and FLOPs represents the computational effort of the model. It can be seen that the present invention can be directly applied on the existing network by improving the routing structure, and can achieve great acceleration without loss or improvement of accuracy.

[0143] This invention realizes the establishment of a relational dynamic routing network for the first time, which helps the prediction model to better learn the path selection of image samples, gets rid of the strategy of simply adjusting the network structure in an unordered manner, and effectively improves the accuracy of the dynamic routing network (see Figure 5 Comparison chart of the effects of the present invention compared with other industry-leading methods).

Claims

1. A dynamic routing network learning method based on a relational model, characterized in that: The following steps are involved: S1. Obtain the image classification dataset for training and divide the dataset into several batches as network input; S2. For the convolutional neural network used for image classification, it is divided into several substructures and a dynamic routing structure is added before the substructure to construct a dynamic routing network model based on path selection; S3, for the dynamic routing structure added in S2, establish a relationship graph between the dynamic routing structures, and propagate routing features through the established relationship graph; S4, input the data set in S1 into the dynamic routing network model constructed in S2 in batches, and train the model in combination with the relational constraints of the path; S5, based on the dynamic routing network model trained in S4, the dynamic routing structure output before each substructure is binarized, and the binarization results represent the corresponding substructures to be skipped or executed, thereby obtaining a dynamic prediction model for classifying the input image; In S2, the process of establishing a basic network model based on routing selection is as follows: The convolutional neural network for image classification is divided into N network substructures in units of Block, where F j (x j-1 ) represents the j-th substructure, and the input x of the j-th substructure j-1 The output of the previous substructure; before each substructure, add a dynamic routing structure R for selecting to skip or execute the current substructure j ; The input of the dynamic routing structure is the output of the previous substructure, and the output of the jth dynamic routing structure is r j for: r j =gumbel-softmax(fc(x j-1 )))[0] Where fc is the fully connected layer model, r j is 0 or 1, gumbel-softmax is a softmax structure with gumbel sampling; For the jth substructure with dynamic routing structure, the output is: x j =r j F j (x j-1 )+(1-r j )x j-1 ; The specific method of S3 is as follows: S31. For the dynamic routing structures added before all substructures in S2, a relationship graph between the dynamic routing structures is established; in the relationship graph, the features between the dynamic routing structures can only be transmitted unidirectionally from the previous dynamic routing structure to the subsequent dynamic routing structure and the influence is attenuated layer by layer, and the weight of the previous layer of dynamic routing structure transmitted to the next one is γ∈[0,1]; each layer of dynamic routing structure is at most affected by the previous r layers of dynamic routing structure; the routing features are propagated between the dynamic routing structures through the adjacency matrix A of the relationship graph, and the elements of the mth row and nth column in the adjacency matrix A are as follows: S32, during the routing feature propagation process, for the nth dynamic routing structure currently propagated, the dynamic routing structure is the output x of the previous substructure n As input, the first routing feature of the current dynamic routing structure is obtained through an average pooling operation: Among them, H n is x n High, W n is x n The width, With x n The feature channels are the same. The dimension is 1×C n ; Then the first routing feature obtained Alignment is performed through the first fully connected layer FC, and the activation function outputs the second routing feature with a dimension of 1×d. Where g represents the Rule activation function, w0 is the network parameter of the first fully connected layer FC; S33, collecting the second routing features of the first r dynamic routing structures of the current dynamic routing structure Connect to get the fusion routing feature S n =(s n-r ,…s n ) ; then the fused routing features are passed through the GCN layer, and the activation function outputs the final routing features s that need to be propagated backward in the current dynamic routing structure n : s n =g(GCN(S n ;A;w1))[r,:] Where w1 is the network parameter of the GCN layer; S34, the final routing feature s of the current dynamic routing structure n After passing through the second fully connected layer FC, the execution decision of the current substructure is obtained through the relaxation function Gumbel-Softmax: v n =softmax(log(FC(s n ;w n +G) / τ)[1] Where G is gumbel sampling, τ is the temperature of the relaxation function, and the obtained v n is the probability of executing the current substructure output by the current dynamic routing structure; S35. For the nth substructure with a dynamic routing structure, its input is x n , the output is: x n+1 =v n F n+1 (x n )+(1-v n )x n ; The specific method of S4 is as follows: S41, take a batch from the data set of S1 and input it into the dynamic routing network model constructed by S2 for model training. In the training phase, for any i-th input sample, a dynamic network selection path is established as follows: P i =[v1,v2,…,v N ] S42, for the samples in the input training batch, first use a projection method H(.) to calculate the distance between any two samples X in the same batch i and X j The distance between them is obtained, and the distance matrix D is obtained. The element of the i-th row and j-th column in the distance matrix D is: D i,j =‖H(X i )-H(X j )‖2, Among them, ‖‖2 represents the L2 norm; Then use the argsort function to sort the distance matrix D in descending order by row to obtain the index matrix M: M=argsort(D) The element in the i-th row and j-th column of the index matrix M is denoted by M i,j ; S43, calculating the total loss function of the current input batch samples based on the index matrix M, and optimizing the parameters of the dynamic routing network model based on the total loss function to complete the training of the current batch, wherein the calculation formula of the total loss function is: L total =L cls +L rank +L cost Where: L cls is the classification constraint loss; L rank is the triplet loss, and its calculation formula is: In the formula Indicates Margin parameter; L cost is the computational loss of the path, and its calculation formula is: Where: c j represents the computational effort of the jth substructure; S44. Repeat S41 to S43 continuously, input different batches of samples into the dynamic routing network model, and finally complete the model training.

2. The relationship-based dynamic routing network learning method according to claim 1, characterized in that: In S1, the image dataset used for training the target task includes an image group Among them I i is the i-th image, K is the number of images in the image group; the image group is divided into several batches, each batch contains L images.

3. The relationship-based dynamic routing network learning method according to claim 1, characterized in that: The specific method of S5 is as follows: S51: Based on the dynamic routing network model trained in S4, the v output by the dynamic routing structure before each substructure n Binarization is performed, and the dynamic routing structure after binarization outputs r j for: After adding binarization processing to each dynamic routing structure of the dynamic routing network model, a dynamic prediction model is obtained; S52: Input the image I to be classified and detected into the dynamic prediction model, and output the network prediction result, which is the classification result O.

Citation Information

Patent Citations

  • Policy-routing system based on grid service and dynamic policy-generating method

    CN101667961A

  • Rectal cancer pathology image classification method based on multi-channel collaborative capsule network

    CN111191660A