Depth variable-length Hash retrieval method for adaptive bit selection
Through the deep variable-length hash retrieval method of adaptive bit selection, combined with alternating iterative bit pool generation and bit selection steps, the resource waste problem caused by multi-model training in the prior art is solved, and efficient image retrieval and adaptive bit selection are achieved.
Patent Information
- Application Number
- CN202411568417.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2044-11-05
AI Technical Summary
In image retrieval, the prior art requires training multiple depth models for different search scenarios, resulting in waste of memory resources and excessive computing resource consumption. At the same time, the optimization goal of existing bit selection methods is usually to maintain pairwise similarity, and lack a comprehensive consideration of retrieval performance and bit attributes.
A deep variable-length hash retrieval method for adaptive bit selection is proposed. Through alternating iterative bit pool generation and adaptive bit selection steps, an optimization measure that takes into account both search performance and bit attributes is designed to realize variable-length compact feature expression.
It improves the accuracy of image retrieval, reduces the consumption of memory and computing resources, can adapt to application scenarios of different computing resource configurations, and output binary codes of different lengths.
Smart Images

Figure CN119597946A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image retrieval technology, and in particular to a deep variable-length hash retrieval method with adaptive bit selection. Background Art
[0002] In large-scale image retrieval systems, compact feature expression learning can retain the distinctiveness of the original high-dimensional image representation and reduce memory consumption and online retrieval time. Existing compact feature expression methods mainly include two categories, namely quantization method and binary hashing method. The quantization method first learns a codebook, and then quantizes the original features to the codebook words with the closest distance in the codebook. Only the corresponding codebook word index needs to be saved in the database, which can greatly reduce memory overhead and significantly reduce online retrieval time by pre-calculating the distance lookup table between two codebook words. On the other hand, the binary hashing method projects the original features into a low-dimensional space by learning a hash function, and then directly binarizes the projected features to obtain a binary code. Using binary codes as feature expressions can significantly reduce memory consumption, and the Hamming distance between binary codes can be calculated at high speed by the existing CPU architecture, significantly reducing the online retrieval time overhead.
[0003] In recent years, with the rise of deep learning technology, deep learning technology has been introduced into compact feature expression learning to achieve better semantic distinguishability. Although existing deep learning-based quantization and binary hashing methods have achieved promising retrieval performance, different deep models are usually required to be trained separately for different retrieval scenarios (including different computing and memory resources). In other words, multiple deep models need to be trained separately to generate compact representations of different lengths. This approach requires the storage of multiple deep models and corresponding database image representations, resulting in a huge waste of memory resources. In addition, training multiple deep models also consumes a lot of time and computing resources. In order to solve the above problems, the variable-length compact feature expression method proposes to use a model to output a set of compact representations of different lengths, where the longer representation contains the shorter representation.
[0004] Existing variable-length deep hashing methods are less studied, and generally select bits of different lengths by weighting the bit importance. The optimization target is generally quantization loss or pairwise discrimination, which is still far from the ultimate goal of image retrieval (i.e., optimizing retrieval performance).
[0005] On the other hand, traditional hash bit selection methods usually output binary codes with fixed bit lengths, and the bit selection models need to be trained separately for application scenarios with different computing resource configurations. In addition, the optimization goal of existing bit selection methods is usually to maintain pairwise similarity, which lacks comprehensive consideration of retrieval performance and bit attributes, so the retrieval performance during testing is usually limited. Summary of the invention
[0006] Based on the technical problems existing in the background technology, the present invention proposes a deep variable-length hash retrieval method with adaptive bit selection to achieve variable-length compact feature expression and improve retrieval accuracy.
[0007] The present invention proposes a deep variable-length hash retrieval method with adaptive bit selection, which generates a query image binary code by passing the image through a trained retrieval model, calculates the Hamming distance between the query image binary code and the image binary code in the image database, and returns the database image as the retrieval result in the order of the distance from the smallest to the largest.
[0008] The training process of the retrieval model is as follows:
[0009] Step 1: bit pool generation: input each image in the constructed image training set into the deep hash network in turn to output the binary code corresponding to each image, train the deep hash network by optimizing the metric, and thus generate a bit pool, wherein the bit pool is composed of all the binary codes;
[0010] Step 2, adaptive bit selection: input the bit pool into the bit selection agent for bit selection, and use the same optimization metric as step 1 as the environment reward. When the preset bit length is reached, the bit selection agent obtains the environment reward, and uses the environment reward, environment state and action as training data to train the bit selection agent. Based on the interaction between the bit selection agent and the environment, the bit selection state is updated, and the bit selection state is fed back to the bit pool to obtain the selected bit. Based on the selected bit, the deep hash network in step 1 continues to be trained;
[0011] Step 3: Alternately iterate step 1 and step 2 until the retrieval model converges. After training, use a bit selection agent as a bit selector set after the deep hash network to perform bit selection on the binary code output by the deep hash network for storage in the image database.
[0012] Furthermore, the deep hash network is based on a deep convolutional neural network, the classification layer of the deep convolutional neural network is removed, and a linear layer is added as a hash layer in sequence, and a hyperbolic tangent activation layer and a classification layer are added in parallel after the hash layer. The hash layer outputs an L-dimensional vector x, and the hyperbolic tangent activation layer outputs a binary code b∈{-1,1} L .
[0013] Furthermore, the environmental state s at time t t Defined as the indicator of the current selected bit, that is, s t ∈{0,1} L , if the kth bit is selected as the final binary code, s t,k =1, otherwise s t,k=0,s t,k is the indicator of the kth bit at time t;
[0014] The bit selection agent includes a policy network and a value network, each of which includes two linear layers, and each linear layer is followed by a ReLU activation layer;
[0015] In the policy network, a linear layer and a softmax layer are set in sequence after the ReLU activation layer to output the action probability;
[0016] In the value network, a ReLU activation layer sets a linear layer to map the state representation to a real-number state value estimate.
[0017] Furthermore, there are two forms of optimization metrics: the first form comprehensively considers the retrieval performance and bit attributes, which is defined as the RPBP metric, and the second form directly uses the loss function of the existing hashing method as the optimization metric;
[0018] In the first form, the RPBP metric M rpbp The definition is as follows:
[0019] M rpbp (W,{Θ,Φ})=-L map (B)+αL q (B)+βL d (B);
[0020] Among them, L map (.) is the average precision mean metric loss, L q (.) and L d (.) represent binary quantization loss and independence measure loss respectively, α, β represent corresponding hyper parameters respectively, and B represents bit pool.
[0021] Furthermore, the overall optimization goal of the retrieval model is:
[0022] minL(W,{Θ,Φ})=minL C (W)+M(W,{Θ,Φ});
[0023] Where W represents the deep hashing network parameters in step 1, L C (.) is the classification loss, M(.) is the optimization metric, {Θ,Φ} represents the policy network Θ and value network Φ parameters of the bit selection agent in step 2, and L(W,{Θ,Φ}) is the loss of the network parameters W,{Θ,Φ} to be learned.
[0024] Furthermore, in the optimization of the bit pool generation process in step 1, the bit selection agent is fixed, and the overall optimization objective is expressed as follows:
[0025] minL(W)=minL c (W)+M(W);
[0026] In the adaptive bit selection optimization of step 2, the deep hash network is fixed and the overall optimization objective is expressed as follows:
[0027] minL({Θ,Φ})=max-M({Θ,Φ});
[0028] Among them, L(W) is the loss of W; L({Θ,Φ}) is the loss of {Θ,Φ}, and max is the reverse operation of min, which means finding the maximum value of -M({Θ,Φ}), that is, it is used to calculate the maximum reward.
[0029] Furthermore, in the bit pool generation process optimization of step 1, the optimization metric M adopts the RPBP metric M rpbp When L q (B),L d (B),L c The gradients of the loss function (W) are directly calculated and the retrieval model is updated through back-propagation;
[0030] L map (B) The policy gradient algorithm is used for optimization, where the policy gradient algorithm is as follows:
[0031] For the i-th input image, the hash layer output vector x of the deep hash network is i The probability of converting to output bit "1"
[0032] The binarization process is regarded as action u i , then the probability distribution of the output bit "1" is P W ,u i is the i-th vector x i Actions:
[0033]
[0034] Perform R Monte Carlo sampling based on probability, strategy gradient The calculation is as follows:
[0035]
[0036] Among them, u i,k is the i-th vector x i The action of the kth bit in is the i-th vector x i In the rth Monte Carlo sampling action, r takes values from 1 to R.
[0037] Furthermore, in step 2, when the preset bit length is reached, the bit selection agent obtains the environment reward specifically as follows:
[0038] The reward r obtained by the agent at time t t (Θ) calculated by accumulating discount rewards, r t+l is the environmental reward at the t+lth moment, r t+l Non-zero value on a user-specified variable-length bit length setting set, otherwise, r t+l =0, Θ is the policy network, t and l are the time.
[0039] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned retrieval method when executing the computer program.
[0040] A computer-readable storage medium stores a plurality of classification programs, and the plurality of classification programs are used to be called by a processor and execute the above-mentioned retrieval method.
[0041] The advantages of the deep variable-length hash retrieval method with adaptive bit selection provided by the present invention are: the deep variable-length hash retrieval method with adaptive bit selection provided in the structure of the present invention designs a novel variable-length adaptive deep hash bit selection framework technology, alternately and iteratively performs bit pool generation and adaptive bit selection, and by designing an optimization metric that takes into account both retrieval performance and bit attributes, the metric is simultaneously optimized in two alternating iterative steps during the training process, thereby achieving variable-length hash bit selection that takes into account both retrieval performance and bit attributes, thereby improving the retrieval accuracy during testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 It is a schematic diagram of the structure flow of the present invention;
[0043] Figure 2 Flowchart of the architecture for adaptive bit selection. DETAILED DESCRIPTION
[0044] Below, the technical solution of the present invention is described in detail through specific embodiments. Many specific details are set forth in the following description to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific implementation disclosed below.
[0045] In this embodiment, the network framework is optimized by alternating two steps of iterative training:
[0046] The variable-length adaptive deep hash bit selection framework proposed in this embodiment includes two alternating iterative training steps, namely bit pool generation and adaptive bit selection. The first step is to generate a large bit pool for the training set images, and the second step is to select the most effective bit set from the bit pool.
[0047] like Figures 1 to 2 As shown, the present invention proposes a deep variable-length hash retrieval method with adaptive bit selection, which generates a query image binary code by passing the image through a trained retrieval model, calculates the Hamming distance between the query image binary code and the image binary code in the image database, and returns the database image as the retrieval result in the order of the distance from small to large;
[0048] The training process of the retrieval model is as follows:
[0049] Step 1: bit pool generation: input each image in the constructed image training set into the deep hash network in turn to output the binary code corresponding to each image, train the deep hash network by optimizing the metric, and thus generate a bit pool, wherein the bit pool is composed of all the binary codes;
[0050] Step 2, adaptive bit selection: input the bit pool into the bit selection agent for bit selection, and use the same optimization metric as step 1 as the environment reward. When the preset bit length is reached, the bit selection agent obtains the environment reward, and uses the environment reward, environment state and action as training data to train the bit selection agent. Based on the interaction between the bit selection agent and the environment, the bit selection state is updated, and the bit selection state is fed back to the bit pool to obtain the selected bit. Based on the selected bit, the deep hash network in step 1 continues to be trained;
[0051] Step 3: Alternately iterate steps 1 and 2 until the retrieval model converges. After training, use a bit selection agent as a bit selector set after the deep hash network to perform bit selection on the binary code output by the deep hash network for storage in the image database.
[0052] The intelligent agent involved in this embodiment is specifically composed of two networks, namely a strategy network and a value network, which are described in detail below in (B) Adaptive Bit Selection.
[0053] In response to the problems existing in the existing binary hashing methods, this embodiment designs a novel variable-length adaptive deep hash bit selection framework technology, which performs bit pool generation and adaptive bit selection in an iterative manner. By designing an optimization metric that takes into account both retrieval performance and bit attributes, the metric is simultaneously optimized in two alternating iterative steps during the training process, thereby achieving variable-length hash bit selection that takes into account both retrieval performance and bit attributes, thereby improving the retrieval accuracy during testing.
[0054] That is, in response to the problems existing in the existing methods, this embodiment proposes a novel and universal variable-length deep hash bit selection framework technology, which realizes variable-length compact feature expression through adaptive bit selection. In particular, the framework includes two alternating iterative steps, namely bit pool generation and adaptive bit selection. To ensure the consistency of the variable-length compact expression optimization process, these two steps use the same optimization metric. This embodiment proposes a novel RPBP metric, which takes into account both explicit retrieval performance and bit attributes. By alternately optimizing the RPBP metric in two steps, the framework is instantiated as a new variable-length binary hash method, which can significantly improve the retrieval accuracy of existing variable-length hash methods. In addition, the framework can be instantiated as a universal variable-length expansion tool, which uses the optimization target of the existing hash method as the optimization metric, and optimizes the optimization metric through two steps of alternating iterations, so as to convert the existing hash method into the corresponding variable-length hash method, thereby reducing the training time.
[0055] While reducing time and storage consumption, it does not cause obvious retrieval performance loss.
[0056] A bit pool generation
[0057] The deep convolutional neural network is used as a deep hash network to generate a long binary code for each input image. Specifically, this embodiment removes the classification layer of the existing deep convolutional neural network and adds a linear layer as a hash layer, which contains L output units. Then a hyperbolic tangent activation layer is added to constrain the output of the deep convolutional neural network to be in the numerical range of [-1,1]. For each input image I, the deep hash network directly outputs an L-dimensional vector Then directly binarize it into a binary code b∈{-1,1} L For the training set The deep hashing network outputs a binary code for each image, which in turn forms a large bit pool. N is the number of images in the image training set. To further constrain the semantic distinction of the bit pool, a classification layer W is added after the hash layer of the deep hash network. c , and construct the classification loss L C (W).
[0058] B adaptive bit selection
[0059] In step 2, this embodiment models the bit selection problem as a Markov decision process and then solves it through a reinforcement learning algorithm. In particular, this embodiment uses the bit pool generated in step 1 as the environment and learns an agent by interacting with the environment to achieve hash bit selection. The state of the environment at time t is s t is defined as the indicator of the currently selected bit, i.e., s t∈{0,1} L , if the kth bit is selected as the final binary code, s t,k =1, otherwise s t,k =0,s t,k is the indicator of the kth bit at time t.
[0060] like Figure 2 As shown in FIG. 1 , the bit selection agent constructed in this embodiment includes two networks, namely, a strategy network and a value network. The strategy network Θ takes the environment state s t As input, the output probability of different actions is π(a t =a|s t ,Θ)=Θ(s t ), action a t =a indicates that the ath bit is selected at time t. Furthermore, set the environment state s when the ath bit is selected at time t+1 t+1,a = 1. The value network Φ is based on state s t is the input, and the output state value is estimated v = Φ(s t ). Both networks contain two linear layers, each followed by a ReLU activation layer. In the policy network, a linear layer and a softmax layer are still required to output action probabilities. In the value network, a linear layer is attached to the network to map the state representation to a real-number state value estimate.
[0061] In each sequence bit selection (action) process, once the preset bit length is reached, the agent can obtain the environment reward. In other words, the reward r t obtained by the agent at time t t (Θ) calculated by accumulating discount rewards, r t+l is the environmental reward at the t+lth moment, r t+l A non-zero value on a user-specified variable-length bit length setting set (e.g., when the variable-length bit length set is t+l={12,24,32,48}, r 12 ,r 24 ,r 32 ,r 48 is a non-zero value), otherwise, r t+l =0, t and l are time. Specifically, the specific form of the reward can be calculated by two optimization metrics, and different optimization metrics realize different instantiations of the variable-length adaptive deep hash bit selection framework proposed in this embodiment. By optimizing rewards of different bit lengths at the same time, the hash bit selection framework of this embodiment becomes a variable-length hash method that can output binary codes of different bit lengths at the same time.
[0062] This embodiment proposes a two-step alternating iterative optimization algorithm for optimizing the proposed adaptive bit selection framework. First, a deep hash network is trained to generate a large bit pool by minimizing the classification loss and optimizing the optimization metric proposed in this embodiment. Then, based on the bit pool generated by training, the same optimization metric is used as the environment reward to learn the bit selection agent by interacting with the environment. Next, the agent outputs the final state vector representing the selected bit position, and the corresponding selected bit can be further optimized in the deep hash network. These two steps are performed alternately and iteratively until convergence. The overall optimization goal of the retrieval model is:
[0063] minL(W,{Θ,Φ})=minL C (W)+M(W,{Θ,Φ}); (1)
[0064] Where W represents the deep hashing network parameters in step 1, L C (.) is the classification loss, M(.) is the optimization metric, {Θ,Φ} represents the policy network Θ and value network Φ parameters of the bit selection agent in step 2, and L(W,{Θ,Φ}) is the loss of the network parameters W,{Θ,Φ} to be learned.
[0065] b1) Optimization metrics
[0066] The optimization metric M(·) in the adaptive hash bit selection framework proposed in this embodiment has two different forms, corresponding to two different instantiation methods of the proposed framework. The first form of optimization metric comprehensively considers retrieval performance and bit attributes, and is named RPBP metric. The second form of optimization metric directly uses the loss function of the existing hash method as the optimization metric. This embodiment is instantiated as a general conversion tool that can convert the existing hash method into the corresponding variable-length hash method.
[0067] In the first form of the optimization metric, the retrieval performance is measured by the mean average precision, which takes into account both the precision and recall of the retrieval. The bit attributes include the binary quantization loss and the bit independence loss, while ensuring the compactness and information content of the binary code. Therefore, the proposed RPBP metric can be defined as:
[0068] M rpbp (W,{Θ,Φ})=-L map (B)+αL q (B)+βL d (B); (2)
[0069] Among them, L map (.) is the average precision mean metric loss, L q (.) and L d(.) represent binary quantization loss and independence metric loss respectively, α, β represent corresponding hyperparameters respectively, B represents bit pool, q, d is just an identifier to distinguish the two loss functions; where, X=[x1,x2,…,x N ] and B=[b1,b2,…,b N ] represent the continuous features and binary codes of the image training set, respectively, x N is the L-dimensional vector output by the deep hashing network for the Nth image, b N is the binary code corresponding to the Nth image, ‖·‖ F is the norm calculation, and F indicates that the Frobenius norm is used.
[0070] In order to speed up the average precision mean metric L map (·) is calculated. During the training process, a subset of the image training set can be randomly sampled as the retrieval database, that is:
[0071]
[0072] Among them, B s Represents a subset of the image training dataset selected as the retrieval database. Indicated by b i As a query to retrieve database B s The average precision obtained, P i,j Indicates the accuracy of the jth returned position, rel i,j ∈{0,1} represents the true correlation between the jth returned image and the query image, N r is the total number of images related to the query image in the retrieval database of the selected image training set, N s is the total number of images in the retrieved database.
[0073] Taking the RPBP metric as the optimization metric, the adaptive bit selection framework proposed in this embodiment becomes a variable-length hashing method, which achieves better compact representation and online retrieval performance by directly optimizing the RPBP metric.
[0074] In the second optimization metric, the framework proposed in this embodiment directly uses the loss function of the existing hash method as the optimization metric to convert the existing hash method into a corresponding variable-length hash method. Therefore, under the definition of the second optimization metric, the framework proposed in this embodiment is instantiated as a general variable-length conversion tool.
[0075] b2) In the optimization of the bit pool generation process in step 1, the bit selection agent is fixed, and the overall optimization objective of formula (1) is expressed as follows:
[0076] minL(W)=minLc (W)+M(W); (4)
[0077] When the existing hashing method objective function is used as the optimization metric M(·), formula (4) can update the retrieval model through back propagation. rpbp (·), in formula (4), except L map The gradient of the loss function outside (·) can be directly calculated and then the network is updated through back propagation. map (·) metric, which can be optimized using the policy gradient algorithm.
[0078] L map (B) When the policy gradient algorithm is used for optimization, the policy gradient algorithm is as follows:
[0079] The hash layer output vector x of the deep hashing network i The probability of converting to output bit "1"
[0080]
[0081] The binarization process is regarded as action u i , then the probability distribution of the output bit "1" is P W ,u i is the i-th vector x i Actions:
[0082]
[0083] Perform R Monte Carlo sampling based on probability, strategy gradient The calculation is as follows:
[0084]
[0085] Among them, u i,k is the i-th vector x i The action of the kth bit in is the i-th vector x i In the rth Monte Carlo sampling action, r takes values from 1 to R.
[0086] The log probability is calculated by the binary cross entropy of the Bernoulli distribution. The policy gradient is then combined with the gradients of other loss functions in formula (4) and used for backpropagation to update the deep hashing network. After the adaptive bit selection step is optimized, the optimization metric M(·) is further optimized on the selected bits.
[0087] b3) In the adaptive bit selection optimization of step 2, the deep hash network is fixed and the overall optimization objective is expressed as follows:
[0088] minL({Θ,Φ})=max-M({Θ,Φ}); (7)
[0089] Among them, L(W) is the loss of W; L({Θ,Φ}) is the loss of {Θ,Φ}, and max is the reverse operation of min, which means finding the maximum value of -M({Θ,Φ}), that is, it is used to calculate the maximum reward.
[0090] The objective function of formula (7) contains only the optimization metric, which is also used as the reward of the Markov decision process. When the RPBP metric is used, maximizing the reward -M(·) is equivalent to maximizing the mean average precision and minimizing the quantization error and independence constraints at the same time. When the loss function of the existing hashing method is used as the optimization metric, maximizing the reward -M(·) is equivalent to minimizing the target loss function of the existing hashing method. By continuously interacting with the environment, the obtained states, actions, and rewards are placed in the training data cache, and then the approximate policy optimization algorithm is used to iteratively train the policy network and the value network.
[0091] C. Online retrieval process after retrieval model training is completed
[0092] After training, the bit selection agent is used to generate the final state vector, which represents the selected bit position. Figure 1 As shown in the dashed box, for each database image, a deep hash network is used to generate its binary code, but only the bits selected by the bit selection agent are stored in the image database. In particular, the binary code with the longest bit length is stored to support variable-length online retrieval. For different online retrieval scenarios, the user selects the required bit length and uses the deep hash network to generate the corresponding query image binary code. Then, the Hamming distance between the query image binary code and the database image binary code is calculated, and the database images are returned in ascending order of distance as retrieval results.
[0093] Through A to C above, this embodiment proposes a variable-length deep hash framework, which realizes variable-length hash coding through adaptive bit selection. The framework includes two alternating iterative steps, namely bit pool generation and adaptive bit selection. The two steps are trained using the same optimization metric. Through different optimization metrics, the proposed framework can be instantiated in two different ways. In the first instantiation, a novel RPBP metric is defined, which takes into account both retrieval performance and bit attributes, so that the proposed framework is instantiated as a novel variable-length hash method. Due to the direct optimization of retrieval performance and bit attributes, the online retrieval performance is significantly improved, and the method has the advantages of a variable-length hash method, that is, training a model can be adapted to a variety of different computing resource application scenarios of users, and outputting binary codes of different lengths to compactly represent images, significantly reducing storage and training time.
[0094] In the second instantiation method, the proposed framework directly uses the objective function of the existing hash method as the optimization metric, which can convert the existing hash method into the corresponding variable-length hash method. Therefore, in this instantiation, the proposed framework becomes a universal variable-length converter, which converts the existing hash method into the corresponding variable-length hash method. Due to the alternating bit pool generation and bit selection agent learning, this instantiation method can reduce the training time and storage overhead of the existing hash method, and maintain the retrieval performance of the original hash method, which greatly improves the scene adaptability and training efficiency of the existing hash method.
[0095] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A deep variable-length hash retrieval method with adaptive bit selection, characterized in that: The image is passed through the trained retrieval model to generate a binary code for the query image, the Hamming distance between the binary code of the query image and the binary code of the image in the image database is calculated, and the database images are returned in ascending order of distance as the retrieval result; The training process of the retrieval model is as follows: Step 1: bit pool generation: input each image in the constructed image training set into the deep hash network in turn to output the binary code corresponding to each image, train the deep hash network by optimizing the metric, and thus generate a bit pool, wherein the bit pool is composed of all the binary codes; Step 2, adaptive bit selection: input the bit pool into the bit selection agent for bit selection, and use the same optimization metric as step 1 as the environment reward. When the preset bit length is reached, the bit selection agent obtains the environment reward, and uses the environment reward, environment state and action as training data to train the bit selection agent. Based on the interaction between the bit selection agent and the environment, the bit selection state is updated, and the bit selection state is fed back to the bit pool to obtain the selected bit. Based on the selected bit, the deep hash network in step 1 continues to be trained; Step 3: Alternately iterate step 1 and step 2 until the retrieval model converges. After training, use a bit selection agent as a bit selector set after the deep hash network to perform bit selection on the binary code output by the deep hash network for storage in the image database.
2. The deep variable-length hash retrieval method with adaptive bit selection according to claim 1, characterized in that: The deep hash network is based on a deep convolutional neural network. The classification layer of the deep convolutional neural network is removed, and a linear layer is added as a hash layer in sequence. A hyperbolic tangent activation layer and a classification layer are added in parallel after the hash layer. The hash layer outputs an L-dimensional vector x, and the hyperbolic tangent activation layer outputs a binary code b∈{-1,1} L .
3. The deep variable-length hash retrieval method with adaptive bit selection according to claim 1, characterized in that: The environmental state s at time t t Defined as the indicator of the current selected bit, that is, s t ∈{0, 1} L , if the kth bit is selected as the final binary code, s t,k =1, otherwise s t,k =0,s t,k is the indicator of the kth bit at time t; The bit selection agent includes a policy network and a value network, each of which includes two linear layers, and each linear layer is followed by a ReLU activation layer; In the policy network, a linear layer and a softmax layer are set in sequence after the ReLU activation layer to output the action probability; In the value network, a ReLU activation layer sets a linear layer to map the state representation to a real-number state value estimate.
4. The deep variable-length hash retrieval method with adaptive bit selection according to claim 2, characterized in that: There are two forms of optimization metrics. The first form comprehensively considers the retrieval performance and bit attributes, which is defined as the RPBP metric. The second form directly uses the loss function of the existing hashing method as the optimization metric. In the first form, the RPBP metric M rpbp The definition is as follows: M rpbp (W, {Θ, Φ})=-L map (B)+αL q (B)+βL d (B) Among them, L map (.) is the average precision mean metric loss, L q (.) and L d (.) represent binary quantization loss and independence measure loss respectively, α, β represent the corresponding hyper parameters respectively, and B represents the bit pool.
5. The deep variable-length hash retrieval method with adaptive bit selection according to claim 4 is characterized in that: The overall optimization goal of the retrieval model is: min L(W, {Θ, Φ})=minL c (W)+M(W,{Θ,Φ}) Where W represents the deep hashing network parameters in step 1, L c (.) is the classification loss, M(.) is the optimization metric, {Θ, Φ} represents the policy network Θ and value network Φ parameters of the bit selection agent in step 2, and L(W, {Θ, Φ}) is the loss of the network parameters W, {Θ, Φ} to be learned.
6. The deep variable-length hash retrieval method with adaptive bit selection according to claim 5, characterized in that: In the optimization of the bit pool generation process in step 1, the bit selection agent is fixed and the overall optimization objective is expressed as follows: min L(W)=min L c (W)+M(W); In the adaptive bit selection optimization of step 2, the deep hash network is fixed and the overall optimization objective is expressed as follows: min L({Θ,Φ})=max-M({Θ,Φ}); Among them, L(W) is the loss of W; L({Θ,Φ}) is the loss of {Θ,Φ}, and max is the reverse operation of min, which means finding the maximum value of -M({Θ,Φ}), that is, it is used to calculate the maximum reward.
7. The deep variable-length hash retrieval method with adaptive bit selection according to claim 6, characterized in that: In the bit pool generation process optimization of step 1, the optimization metric M adopts the RPBP metric M rpbp When L q (B),L d (B),L c The gradients of the loss function (W) are directly calculated and the retrieval model is updated through back-propagation; L map (B) The policy gradient algorithm is used for optimization, where the policy gradient algorithm is as follows: For the i-th input image, the hash layer output vector x of the deep hash network is i The probability of converting to output bit "1" The binarization process is regarded as action u i , then the probability distribution of the output bit "1" is P W ,u i is the i-th vector x i Actions: Perform R Monte Carlo sampling based on probability, strategy gradient The calculation is as follows: Among them, u i,k is the i-th vector x i The action of the kth bit in is the i-th vector x i In the rth Monte Carlo sampling action, r takes values from 1 to R.
8. The deep variable-length hash retrieval method with adaptive bit selection according to claim 3, characterized in that: In step 2, when the preset bit length is reached, the bit selection agent obtains the environment reward as follows: The reward r obtained by the agent at time t t (Θ) calculated by accumulating discount rewards, r t+l is the environmental reward at the t+lth moment, r t+l Non-zero value on a user-specified variable-length bit length setting set, otherwise, r t+l =0, Θ is the policy network, t and l are the time.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the retrieval method described above is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of classification programs, and the plurality of classification programs are used to be called by the processor and execute the retrieval method as described above.
Citation Information
Patent Citations
Image retrieval method based on deep learning and hash coding
CN107330074A
Depth supervised Hash retrieval method and system based on greedy asymmetric loss
CN114676275A
Image retrieval method based on weighted deep convolutional hash
CN117828117A
Cross-modal hash retrieval method based on long and short mapping
CN118051633A
Image Retrieval Method Based on Variable-Length Deep Hash Learning
US20180276528A1