WO2016110125A1 - 高维向量的哈希方法、向量量化方法及装置 - Google Patents

高维向量的哈希方法、向量量化方法及装置 Download PDF

Info

Publication number
WO2016110125A1
WO2016110125A1 PCT/CN2015/089607 CN2015089607W WO2016110125A1 WO 2016110125 A1 WO2016110125 A1 WO 2016110125A1 CN 2015089607 W CN2015089607 W CN 2015089607W WO 2016110125 A1 WO2016110125 A1 WO 2016110125A1
Authority
WO
WIPO (PCT)
Prior art keywords
dimension
vector
interval
quantization
binary
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2015/089607
Other languages
English (en)
French (fr)
Inventor
段凌宇
王哲
王潇放
黄铁军
高文
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Peking University
Original Assignee
Peking University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority claimed from CN201510012075.6A external-priority patent/CN105824856A/zh
Priority claimed from CN201510013258.XA external-priority patent/CN105824858A/zh
Application filed by Peking University filed Critical Peking University
Publication of WO2016110125A1 publication Critical patent/WO2016110125A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor

Definitions

  • the present invention relates to computer technology, and in particular to a high-dimensional vector hash method, vector quantization method and device.
  • high-dimensional vector neighbor queries provide critical technical support in computer image search.
  • a neighbor query of a high-dimensional vector means that given a high-dimensional vector, several vectors closest to it are found from a set of vectors.
  • High-dimensional vector neighbor queries can be applied to artificial intelligence, machine learning, and computer vision.
  • the first method is to set up an index structure to bring together similar vectors offline. When online, the results are quickly read from the index, and the neighbors of the query vector are obtained.
  • the biggest disadvantage of the first method is that the memory consumption is large, and the memory usage of the index structure is larger than the memory usage of the original data, resulting in very low query efficiency.
  • the commonly used product quantization divides this 8-dimensional vector into two segments, ⁇ y 1 , y 2 , y 3 , y 4 ⁇ and ⁇ y 5 , y 6 , y 7 , y 8 ⁇ . Then the dimensions of each segment are unified and quantified together.
  • the disadvantage of this method is that it needs to split the high-dimensional vector into many segments, each segment uses an additional lookup table; when the vector dimension is high, it will destroy the spatial structure of the vector, and the memory usage is large, resulting in the use of quantized information in the image.
  • the retrieval accuracy in the search is reduced, and the retrieval speed is slow and the efficiency is low.
  • the present invention provides a high-dimensional vector hashing method and device, which can reduce the storage complexity in the prior neighbor query process, and improve the retrieval accuracy and retrieval efficiency.
  • the present invention provides a hashing method for a high dimensional vector, comprising:
  • the compressed high-dimensional vector is quantized by using a scalar quantization method to obtain quantization information of each element, wherein each element is an element of each dimension in the compressed high-dimensional vector;
  • the method before performing the quantization process on the compressed high-dimensional vector by using a scalar quantization method, the method further includes:
  • the processed high-dimensional vector is compressed to obtain a compressed high-dimensional vector.
  • the compressed high-dimensional vector is quantized by using a scalar quantization method to obtain quantitative information of each element, including:
  • the interval corresponding to each dimension is obtained according to a preset training data set.
  • the method further includes: before the interval corresponding to the dimension to which the element belongs, according to the interval corresponding to each dimension acquired in advance, the method further includes:
  • the section information includes: a section corresponding to each dimension of the dimension acquired in advance.
  • the method further includes: before the interval corresponding to the dimension to which the element belongs, according to the interval corresponding to each dimension acquired in advance, the method further includes:
  • intervals corresponding to each dimension are not overlapping.
  • the training corresponding to the training data set is used to obtain the interval corresponding to each dimension, including:
  • the element set of each dimension is divided into sections to obtain an interval corresponding to the dimension.
  • the element set of each dimension is divided into sections, and the interval corresponding to the dimension is obtained, including:
  • the boundary value of the extreme value of the objective function is selected to divide the dimension, and the interval corresponding to the dimension is obtained.
  • the elements of the interval corresponding to each dimension are encoded, and the elements quantized into a certain interval are encoded into the binary code corresponding to the interval.
  • the encoding method can adopt a natural binary code and a unary code.
  • all the binary codes are combined according to a preset rule to obtain a binary vector, including:
  • the high-dimensional vector to be processed is subjected to compression processing to obtain a compressed high-dimensional vector, including:
  • the high-dimensional vector to be processed is compressed by using a preset linear transformation matrix to obtain a compressed high-dimensional vector
  • the linear transformation matrix is obtained by pre-training through training samples.
  • the high-dimensional vector to be processed is subjected to compression processing to obtain a compressed high-dimensional vector, including:
  • the high-dimensional vector to be processed is compressed by using a preset nonlinear transformation function to obtain a compressed high-dimensional vector
  • the nonlinear transformation function is pre-trained by training samples.
  • the present invention further provides a high-dimensional vector neighbor query method, including:
  • the present invention also provides a high-dimensional vector hashing apparatus, including:
  • a quantization unit configured to perform quantization processing on the compressed high-dimensional vector by using a scalar quantization method, to obtain quantization information of each element, wherein each of the elements is an element of each dimension in the compressed high-dimensional vector;
  • a coding unit configured to encode the quantization information of each element into a binary code
  • a combination unit is configured to combine all the binary codes according to a preset rule to obtain a binary vector.
  • the device further includes:
  • a compression unit configured to perform compression processing on the high-dimensional vector to be processed before the quantization unit quantizes, to obtain the compressed high-dimensional vector.
  • the quantization unit is specifically used for
  • the interval corresponding to each dimension is obtained according to a preset training data set.
  • the quantization unit is specifically used for
  • the section information includes: a section corresponding to each dimension of the dimension acquired in advance;
  • the interval corresponding to each dimension is obtained according to a preset training data set.
  • the quantization unit is further used to determine whether the quantization unit is further used to determine whether the quantization unit is further used to determine whether the quantization unit is further used to determine whether the quantization unit is further used to determine
  • intervals corresponding to each dimension are not overlapping.
  • the quantization unit is specifically configured to be used
  • the element set of each dimension is divided into sections to obtain an interval corresponding to the dimension.
  • the quantization unit is specifically configured to be used
  • the boundary value of the extreme value of the objective function is selected to divide the dimension, and the interval corresponding to the dimension is obtained.
  • a combination unit specifically for
  • the coding unit is specifically configured to be used
  • the elements in the interval of each dimension are encoded into a binary code, and the encoding may be a natural binary code or a unary code.
  • the compression unit is specifically used for the compression unit
  • the high-dimensional vector to be processed is compressed by using a preset linear transformation matrix to obtain a compressed high-dimensional vector
  • the linear transformation matrix is obtained by pre-training through training samples.
  • the compression unit is specifically used for the compression unit
  • the high-dimensional vector to be processed is compressed by using a preset nonlinear transformation function to obtain a compressed high-dimensional vector
  • the nonlinear transformation function is obtained by pre-training through training samples.
  • the present invention provides a high-dimensional vector neighbor query device, including:
  • a binary vector obtaining unit configured to acquire a binary vector of a high-dimensional vector to be processed by using any one of the foregoing devices
  • a hash binary value obtaining unit configured to obtain a hash binary code of the binary vector
  • a similarity measure unit configured to select a metric distance corresponding to the coding mode according to the coding manner of the hash binary code, and measure the binary vector corresponding to the other high-dimensional vector by using the metric distance Similarity.
  • the present invention provides a vector quantization method, including:
  • the interval corresponding to each dimension is obtained according to a preset training data set.
  • the method further includes: before the interval corresponding to the dimension to which the element belongs, according to the interval corresponding to each dimension acquired in advance, the method further includes:
  • the section information includes: a section corresponding to each dimension of the dimension acquired in advance.
  • the method further includes: before the interval corresponding to the dimension to which the element belongs, according to the interval corresponding to each dimension acquired in advance, the method further includes:
  • intervals corresponding to each dimension are not overlapping.
  • the training corresponding to the training data set is used to obtain the interval corresponding to each dimension, including:
  • the element set of each dimension is divided into sections to obtain an interval corresponding to the dimension.
  • the element set of each dimension is divided into sections, and the interval corresponding to the dimension is obtained, including:
  • the boundary value of the extreme value of the objective function is selected to divide the dimension, and the interval corresponding to the dimension is obtained.
  • the present invention also provides a vector quantization apparatus, including:
  • An element obtaining unit configured to acquire an element of each dimension in the vector to be quantized
  • a quantization unit configured to quantize the element to an interval corresponding to a dimension to which the element belongs according to an interval corresponding to each dimension acquired in advance, to obtain quantization information of the vector to be quantized
  • the interval corresponding to each dimension is obtained according to a preset training data set.
  • the device further includes:
  • a dimension determining unit configured to acquire a dimension of the to-be-quantized vector, and obtain, according to the dimension, interval information corresponding to the dimension, where the section information includes: a section corresponding to each dimension in the dimension acquired in advance.
  • the device further includes:
  • a dimension dividing unit configured to acquire, according to a preset training data set, a section corresponding to each dimension, where each dimension is each dimension in the to-be quantized vector;
  • intervals corresponding to each dimension are not overlapping.
  • the dimension dividing unit is specifically used for
  • the element set of each dimension is divided into sections to obtain an interval corresponding to the dimension.
  • the dimension dividing unit is specifically used for
  • the boundary value of the extreme value of the objective function is selected to divide the dimension, and the interval corresponding to the dimension is obtained.
  • the high-dimensional vector hash method and apparatus of the present invention can obtain the quantized information of each element in the high-dimensional vector, and then encode the quantized information into a binary code, thereby combining the binary code.
  • the binary vector of the high-dimensional vector is obtained, which can reduce the storage complexity in the prior-neighbor query process in the prior art, and improve the retrieval accuracy and retrieval efficiency.
  • the vector quantization method and device of the present invention obtains the quantized information of the vector to be quantized by obtaining the element of each dimension in the vector to be quantized, and then quantizing the element to the interval corresponding to the dimension to which the element belongs, thereby realizing The high-dimensional vector is quantized, and the quantized information can improve the retrieval accuracy in image retrieval.
  • FIG. 1 is a schematic flowchart of a hashing method for a high-dimensional vector according to an embodiment of the present invention
  • FIG. 2 is a schematic flowchart of a hashing method for a high-dimensional vector according to an embodiment of the present invention
  • FIG. 3 is a schematic flowchart diagram of a high-dimensional vector neighbor query method according to an embodiment of the present invention.
  • FIG. 4 is a schematic structural diagram of a high-dimensional vector hash device according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of a high-dimensional vector neighbor query apparatus according to an embodiment of the present invention.
  • FIG. 6 is a schematic flowchart of a vector quantization method according to an embodiment of the present invention.
  • FIG. 7 is a schematic flowchart diagram of a vector quantization method according to another embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of a vector quantization apparatus according to an embodiment of the present invention.
  • the technical solution is a hash method for reducing a dimension of a high-dimensional vector by compressing a high-dimensional vector and then quantizing the reduced-dimensional vector into a binary code.
  • the hash method in the technical solution usually does not require an additional index, and directly utilizes the distance between the quantized binary codes. The similarity between the decision vectors.
  • the technical solution of the neighbor query is simply to quantize each element of the compressed vector to a single bit with a preset threshold, which introduces a large quantization error.
  • FIG. 1 is a schematic flowchart diagram of a hashing method for a high-dimensional vector according to an embodiment of the present invention. As shown in FIG. 1, the hashing method of the high-dimensional vector in this embodiment is as follows.
  • the quantized information after x i is Q(x) i ), where Q represents a quantization function.
  • the interval coded element of each dimension is the code of the element.
  • the element x i of each dimension is divided into intervals, and the interval S ij , 1 ⁇ i ⁇ m, 1 ⁇ j ⁇ u, which is divided by the elements of each dimension, is encoded into two values.
  • u is a non-zero natural number
  • the binary code includes but is not limited to a natural binary code, including:
  • the distance metric used is the difference between the values of the binary code. For example, the distance between 00 and 01
  • 3.
  • the distance metric used can be Hamming distance. The Hamming distance is defined as follows: Given two binary codes, the Hamming distance is equal to the number of bits whose value is 1 after XOR. For example, if 010 and 011 are equal to or equal to 001, then the Hamming distance between 010 and 011 is 1.
  • all the binary codes may be spliced in the order of the dimension numbers corresponding to each binary code to obtain a binary vector.
  • the dimension number corresponding to each binary code is the subscript of the binary code
  • the binary vector can be obtained by splicing according to the subscript order of all the binary codes.
  • the dimension number is the subscript
  • the subscript is essentially the sequence numbers 1 , 2 , and 3 .
  • y 1 is quantized to 00
  • y 2 is quantized to 01
  • y 3 is quantized to 11
  • spliced together to obtain a binary vector is 000111. To do this, you can stitch together from left to right by dimension number.
  • the binary code encoded by the quantization information of each element is arranged in order.
  • the binary code B(Q(x 1 )), B(Q(x 2 )), ..., B(Q(x m )) encoded by the quantization information of each element in the X is arranged in the following order.
  • the binary vector is the result of high-dimensional vector hashing.
  • the hash method of the high-dimensional vector of this embodiment can obtain the quantized information of each element in the high-dimensional vector, and then encode the quantized information into a binary code.
  • the binary code can be combined to obtain the high-dimensional vector.
  • the value vector can further reduce the storage complexity in the prior neighbor query process and improve the retrieval efficiency.
  • FIG. 2 is a schematic flowchart diagram of a hashing method for a high-dimensional vector according to an embodiment of the present invention. As shown in FIG. 2, the hashing method of the high-dimensional vector in this embodiment is as follows.
  • the high-dimensional vector to be processed is compressed by using a preset linear transformation matrix to obtain a compressed high-dimensional vector
  • the linear transformation matrix is obtained by pre-training through training samples.
  • step 201 the specific implementation process of step 201 is as follows:
  • A01. Collect an offline training data set to form a training sample S Z .
  • collect an n-dimensional vector set S Z ⁇ Z 1 , Z 2 , . . . , Z t ⁇ , Z 1 , Z 2 , . . . , Z t Is the element in S Z.
  • Z i is an n-dimensional vector, 1 ⁇ i ⁇ t, and t is a natural number.
  • a Principal Component Analysis can be used to learn from the vector set S Z to obtain a linear transformation matrix A having a dimension of n*m and m being a compressed high dimension.
  • the dimension of the vector can be used to learn from the vector set S Z to obtain a linear transformation matrix A having a dimension of n*m and m being a compressed high dimension. The dimension of the vector.
  • A03. Multiply the high-dimensional vector to be processed by a linear transformation matrix to obtain a compressed high-dimensional vector.
  • the high-dimensional vector to be processed can also be nonlinearly transformed to obtain a compressed high-dimensional vector.
  • ) [cos(y 1 s 1 ), cos(y 2 s 2 ), ..., cos(y m s m )], m is a natural number, and K is a nonlinear transformation.
  • the nonlinear function is obtained in advance through the training sample.
  • the high-dimensional vectors to be processed may be compressed in other manners, and the steps A01 to A03 of the above examples are not limited.
  • the quantized information after x i is Q(x i ), where Q represents a quantization function.
  • each element is quantized to the interval corresponding to the dimension to which the element belongs.
  • the interval corresponding to each dimension is obtained according to a preset training data set.
  • the dimension of the compressed high-dimensional vector may be obtained in advance, and the section information corresponding to the dimension may be acquired according to the dimension, where the section information includes: each dimension of the dimension acquired in advance
  • the interval is further performed in step 203.
  • the interval information of each dimension corresponding to 128-dimensional can be obtained.
  • the interval information for different dimensions may be different.
  • the quantized information Q(x i ) is encoded as a binary code B(Q(x i )), and B represents an encoding function.
  • (x 1 )), B(Q(x 2 )), ..., B(Q(x m ))]] H is a binary vector.
  • H in this embodiment is a compact binary vector.
  • the hashing method of the high-dimensional vector of the embodiment can reduce the storage complexity in the prior-neighbor query process in the prior art, and improve the retrieval efficiency.
  • This embodiment can effectively solve the performance loss problem of single bit quantization in the existing hash method.
  • Most of the existing hashing methods simply quantize each element of the compressed vector to a single bit with a preset threshold, which introduces a large quantization error.
  • the present embodiment provides a more scientific and multi-bit quantization quantization mechanism, which can greatly reduce the quantization error and solve the problem of single-bit quantization in the existing hash method.
  • step 203 will be described in detail as follows:
  • the interval corresponding to each dimension is obtained according to a preset training data set, where each dimension is each dimension in the high-dimensional vector; and the intervals corresponding to each dimension are not overlapping.
  • B02 Quantify the element to an interval corresponding to the dimension to which the element belongs according to the interval corresponding to each dimension acquired in advance.
  • step B02 The specific implementation process of step B02 is as follows:
  • B0231 enumerates a boundary value of the interval division in the set of elements, and uses a boundary value of each of the interval divisions as a parameter value of the objective function, and determines and records a value corresponding to the target function;
  • B0232 Select a boundary value that makes the target function obtain an extreme value (such as a minimum value) to divide the dimension, and obtain a section corresponding to the dimension.
  • the objective function may also be a non-continuous and non-conductible function.
  • there is an extremum that cannot directly obtain the target function that is, the objective function cannot be directly judged at a certain fetch. Whether the value is a maximum or a minimum value.
  • a sufficient number of boundary values can be pre-enumerated, and a boundary value that makes the objective function relatively largest (or smallest) can be selected to divide the interval.
  • the method of obtaining the maximum value or the minimum value of the target function may be selected according to actual needs.
  • This embodiment is illustrative and not limited.
  • FIG. 3 is a schematic flowchart diagram of a high-dimensional vector neighbor query method according to an embodiment of the present invention. As shown in FIG. 3, the high-dimensional vector neighbor query method in this embodiment is as follows.
  • the method described in any of the above embodiments may be used to obtain a binary vector of a high-dimensional vector to be processed.
  • the distance D matching the binary code used is selected to measure the similarity between the binary vectors.
  • the metric of the similarity may be a Hamming distance or a Manhattan example metric. Other example metrics are not limited in this embodiment.
  • the above neighbor query method can reduce the high storage complexity in the prior art and greatly improve the retrieval efficiency.
  • FIG. 4 is a schematic structural diagram of a high-dimensional vector hashing apparatus according to an embodiment of the present invention.
  • the high-dimensional vector hashing apparatus of this embodiment includes: a quantization unit 41, an encoding unit 42, and Combination unit 43;
  • the quantization unit 41 is configured to perform quantization processing on the compressed high-dimensional vector by using a scalar quantization method to obtain quantization information of each element, where each element is an element of each dimension in the compressed high-dimensional vector. ;
  • the encoding unit 42 is configured to encode the quantization information of each element into a binary code
  • the combining unit 43 is configured to combine all the binary codes according to a preset rule to obtain a binary vector.
  • the foregoing apparatus may further include a compression unit 40 not shown in the figure, and the compression unit 40 is configured to perform compression processing on the high-dimensional vector to be processed before the quantization unit 41 quantizes, and obtain the compressed high-dimensional vector.
  • the high-dimensional vector to be processed is compressed by using a preset linear transformation matrix to obtain a compressed high-dimensional vector; the linear transformation matrix is obtained by pre-training through training samples.
  • the quantization unit 41 may be specifically configured to obtain an element of each dimension in the compressed high-dimensional vector
  • the interval corresponding to each dimension is obtained according to a preset training data set.
  • the quantization unit 41 may be specifically configured to obtain an element of each dimension in the compressed high-dimensional vector
  • the section information includes: a section corresponding to each dimension of the dimension acquired in advance;
  • the interval corresponding to each dimension is obtained according to a preset training data set.
  • the quantization unit 41 is further configured to: acquire, according to a preset training data set, an interval corresponding to each dimension, where each dimension is each dimension in the high-dimensional vector;
  • obtaining a set of elements for each dimension of all vectors in the training data set the set of elements including elements of all vectors in the dimension, the dimensions of all vectors in the training data set being the same;
  • the element set of each dimension is divided into sections to obtain an interval corresponding to the dimension.
  • the intervals corresponding to each dimension are not overlapping.
  • the element set of each dimension is divided into sections, which may be: enumerating the boundary values of the interval division in the set of the elements, and using the boundary value of each section of the set as the Determining and recording a value corresponding to the objective function;
  • the boundary value of the extreme value of the objective function is selected to divide the dimension, and the interval corresponding to the dimension is obtained.
  • the combining unit 43 may be specifically configured to splicing all the binary codes in order of the dimension numbers corresponding to each binary code to obtain a binary vector.
  • the high-dimensional vector hashing device of this embodiment can reduce the storage complexity in the prior art neighboring query process and improve the retrieval efficiency.
  • FIG. 5 is a schematic structural diagram of a high-dimensional vector neighbor query apparatus according to an embodiment of the present invention.
  • the high-dimensional vector neighbor query apparatus of this embodiment includes: a binary vector acquisition unit 51, a binary binary code obtaining unit 52 and a similarity measuring unit 53;
  • the binary vector obtaining unit 51 is configured to obtain a binary vector of the high-dimensional vector to be processed; for example, the hash device of the high-dimensional vector described in any of the foregoing embodiments may be used to obtain the binary vector;
  • the hash binary code obtaining unit 52 is configured to obtain a hash binary code of the binary vector
  • the similarity measure unit 53 is configured to select a metric distance corresponding to the coding mode according to the coding manner of the hash binary code, and measure the binary vector corresponding to the other high-dimensional vectors by using the metric distance Similarity.
  • the above neighbor query device can reduce the high storage complexity in the prior art and greatly improve the efficiency of retrieval.
  • the hash device and the neighbor query device in this embodiment are all implemented in a computing device, such as a terminal, a mobile terminal, or a server to implement vector query or retrieval, and can be applied to image retrieval, or vector learning, machine learning. etc.
  • FIG. 6 is a schematic flowchart diagram of a vector quantization method according to an embodiment of the present invention. As shown in FIG. 6, the vector quantization method in this embodiment is as follows.
  • the interval corresponding to each dimension is obtained according to a preset training data set.
  • the element x i in the set of elements of each dimension all elements in the set of elements are quantized to the u independent intervals S i1 , S i2 , . . . , S iu corresponding to the dimension.
  • the u intervals do not overlap (ie, the intervals are independent, and for any two intervals of one dimension, their intersection is an empty set). That is, if the element x i belongs to the interval S ij , the element x i is quantized into the interval S ij .
  • step 602 the method shown in FIG. 6 may further include the following step 601a;
  • the section information includes: a section corresponding to each dimension in the dimension acquired in advance.
  • the section information corresponding to the 64 dimension may be acquired according to the 64-dimensional; or the dimension of the vector to be quantized is 128-dimensional, and the section information corresponding to the 128 dimension may be acquired according to the 128-dimensional.
  • the vector quantization method of the embodiment obtains the quantization information of the vector to be quantized by obtaining the element of each dimension in the vector to be quantized, and then quantizing the element to the interval corresponding to the dimension to which the element belongs, thereby achieving high
  • the dimensional vector is quantized, and the quantized information can improve the retrieval accuracy in image retrieval.
  • FIG. 7 is a schematic flowchart diagram of a vector quantization method according to an embodiment of the present invention. As shown in FIG. 7, the vector quantization method in this embodiment is as follows.
  • the intervals corresponding to each dimension are not overlapping.
  • step 701 can include sub-steps not shown in the following figures:
  • t n-dimensional vectors X 1 , X 2 , . . . , X t are selected as training data sets.
  • the boundary value of the interval division in the set of elements is enumerated, and the boundary value of each of the interval divisions is used as a parameter value of the objective function, and the value corresponding to the objective function is determined and recorded;
  • the objective function may also be a non-continuous and non-conductible function.
  • there is an extremum that cannot directly obtain the target function that is, the objective function cannot be directly judged at a certain fetch. Whether the value is a maximum or a minimum value.
  • a sufficient number of boundary values can be pre-enumerated, and a boundary value that makes the objective function relatively largest (or smallest) can be selected to divide the interval.
  • the method of obtaining the maximum value or the minimum value of the target function may be selected according to actual needs.
  • This embodiment is illustrative and not limited.
  • an objective function is used to determine the interval division of the element set A of the dimension.
  • the element set A is divided into three sections.
  • a 1 ⁇ a 1 ,a 2 ,...,a(l 1 ) ⁇
  • a 2 ⁇ a(l 1+1 ), a(l 1+2 ),...,a(l 2 ) ⁇
  • a 3 ⁇ a(l 2+1 ),...,a t ⁇ .
  • an objective function F is used to determine the quality of the interval division in the dimension.
  • the information of the objective function is as follows:
  • the distance difference is defined as:
  • the mean of the interval to which a i is quantized is Q(a i ). That is, if the interval corresponding to a i is A j , Q(a i ) represents the average of all elements in A j .
  • t is a scaling factor that adjusts the absolute value of the difference between d(Q(a i ), Q(a j )) and d(V(a i ), V(a j )).
  • the objective function consists of a combination of MSDE and MSE, namely:
  • the division of the dimension is determined by using the above-described division scheme in which the objective function obtains the extreme value.
  • the dimensions are divided into 3 segments using a(s 1 ) and a(s 2 ) described above.
  • a 2 ⁇ a (l1+1) , a (l1+2) ,...,a (l2) ⁇
  • a 3 ⁇ a (l2+1) ,...,a t ⁇ .
  • the objective function is calculated to calculate the function value. After l1 and l2 are determined, the value of the corresponding F is calculated.
  • a 1 ⁇ a 1 ,a 2 ,...,a p ⁇
  • a 2 ⁇ a (p+1) , a (p+2) ,...,a q ⁇
  • a 3 ⁇ a (q+1) , a (q+2) ,..., a t ⁇ .
  • the quantization in this embodiment can be understood as a grouping, and after quantization, it means that it is assigned to a specific group, and the quantization information is the number of the group to which it belongs or the symbol used to represent the group.
  • the element i of the i-th dimension is quantized, and the elements of the i-th dimension are divided into three groups, (- ⁇ , -1], (-1, 1], (1, ⁇ ), and each group number is 1, 2, 3.
  • a yi 0.5, it is assigned to (-1, 1), the process is quantization. It is encoded as 2, which is the quantitative information.
  • the correlation between the original vectors is reflected in the objective function. In this part. When searching for the extremum of the objective function, it not only depends on the distribution of the elements in the element set of the corresponding dimension, but also uses the distance relationship between the vectors corresponding to the dimension. For this reason, in this embodiment, it can be called between the original vectors. Correlation.
  • the vector quantization method in this embodiment can combine the correlation between the original vectors, and then quantize each element of each dimension, so that the spatial structure of the vector is not destroyed when the dimension of the vector is high.
  • the accuracy of the search in the image search is improved by using the quantized information.
  • an embodiment of the present invention further provides a method for using the vector quantization method shown in FIG. 6 or FIG. 7 in image retrieval as follows:
  • M01 acquire an image, and extract a high-dimensional vector describing the visual characteristics of the image.
  • the numerical distribution of each dimension of the statistical high-dimensional vector is quantized for each dimension based on the distribution information.
  • M03 Perform binary coding on the quantized information of each dimension to obtain quantized information of the high-dimensional vector.
  • the above method can improve the retrieval accuracy in image retrieval in the image retrieval process.
  • FIG. 8 is a schematic structural diagram of a vector quantization apparatus according to an embodiment of the present invention.
  • the vector quantization apparatus of this embodiment includes: an element obtaining unit 81 and a quantization unit 82;
  • the element obtaining unit 81 is configured to acquire an element of each dimension in the vector to be quantized
  • the quantization unit 82 is configured to quantize the element to the interval corresponding to the dimension to which the element belongs according to the interval corresponding to each dimension acquired in advance, and obtain the quantization information of the vector to be quantized;
  • the interval corresponding to each dimension is obtained according to a preset training data set.
  • the vector quantization apparatus may further include a dimension determining unit not shown in the following figure, the dimension determining unit is configured to acquire a dimension of the to-be-quantized vector, according to the dimension, acquiring and The section information corresponding to the dimension, the section information includes: a section corresponding to each dimension in the dimension acquired in advance.
  • the vector quantization apparatus may further include a dimension division unit not shown in the following figure, and the dimension division unit may be an offline completion process for training each acquisition according to a preset training data set. Intervals corresponding to the dimensions, each of the dimensions being each of the dimensions to be quantized;
  • intervals corresponding to each dimension are not overlapping.
  • the dimension dividing unit is specifically configured to acquire a set of elements of each dimension of all the vectors in the training data set, where the set of elements includes elements of all the vectors in the dimension, and the dimensions of all the vectors in the training data set are the same, and The dimensions of the quantized vectors are the same;
  • the element set of each dimension is divided into sections to obtain an interval corresponding to the dimension.
  • the dimension dividing unit is specifically configured to: acquire an element set of each dimension of all the vectors in the training data set, where the element set includes elements of all the vectors in the dimension, and all the vectors in the training data set have the same dimension, and The dimensions of the quantization vector are the same;
  • the boundary value of the extreme value of the objective function is selected to divide the dimension, and the interval corresponding to the dimension is obtained.
  • the vector quantization apparatus of this embodiment can implement quantization processing on high-dimensional vectors, and the quantized information can improve the retrieval accuracy in image retrieval.
  • modules in the devices in the embodiments can be adaptively changed and placed in one or more devices different from the embodiment.
  • the modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components.
  • any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed or All processes or units of the device are combined.
  • Each feature disclosed in this specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

一种高维向量的哈希方法、向量量化方法及装置,所述哈希方法包括:采用标量量化方式对压缩后的高维向量进行量化处理,获取每个元素的量化信息,其中,所述每个元素为压缩后的高维向量中每个维度的元素(S101);将所述每个元素的量化信息编码成二值码(S102);按照预设规则将所有二值码进行组合,获得二值向量(S103)。上述方法能够对降低现有技术中近邻查询过程中的存储复杂度,以及提升检索准确率和检索效率。

Description

高维向量的哈希方法、向量量化方法及装置 技术领域
本发明涉及计算机技术,具体涉及一种高维向量的哈希方法、向量量化方法及装置。
背景技术
当前,高维向量的近邻查询在计算机的图像搜索中提供着关键性的技术支撑。高维向量的近邻查询是指:给定一个高维向量,从一个向量集中找出与其最近的若干个向量。高维向量的近邻查询可应用于人工智能、机器学习以及计算机视觉等方面。
为此,越来越多的业内人士研究高维向量的近邻查询的相关技术。现有技术中,解决近邻查询的方法主要分为两类。第一类方法是通过建立索引结构,离线将相似的向量集中到一起,在线查询时,从索引中快速的读取结果,从而获得查询向量的近邻。然而,该第一类方法最大的缺点是内存消耗大,该索引结构的内存占用量比原始数据的内存占用量还大,导致查询效率非常低。
第二类方法是通过乘积量化的方式将高维向量分成多段,每段单独量化,并建立索引。以一个维度为8的向量为例Y={y1,y2,y3,y4,y5,y6,y7,y8}。常用的乘积量化会将这个8维向量划分成两段,分别是{y1,y2,y3,y4}以及{y5,y6,y7,y8}。然后每段的维度统一共同量化。该方法的缺点是需要将高维向量拆分成许多段,每段使用额外的查找表;当向量维度较高时,会破坏向量的空间结构,内存占用大,导致采用量化后的信息在图像检索中检索准确率降低,且检索速度慢,效率低。
为此,如何降低近邻查询过程中的存储复杂度,并提升检索准确率和检索效率成为当前需要解决的技术问题。
发明内容
针对现有技术中的缺陷,本发明提供了一种高维向量的哈希方法及装置,能够降低现有技术中近邻查询过程中的存储复杂度,以及提升检索准确率和检索效率。
第一方面,本发明提供一种高维向量的哈希方法,包括:
采用标量量化方式对压缩后的高维向量进行量化处理,获取每个元素的量化信息,其中,所述每个元素为压缩后的高维向量中每个维度的元素;
将所述每个元素的量化信息编码成二值码;
按照预设规则将所有二值码进行组合,获得二值向量。
可选地,采用标量量化方式对压缩后的高维向量进行量化处理之前,所述方法还包括:
对待处理的高维向量进行压缩处理,获取压缩后的高维向量。
可选地,采用标量量化方式对压缩后的高维向量进行量化处理,获取每个元素的量化信息,包括:
获取压缩后的高维向量中每个维度的元素;
根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间,获得每个元素的量化信息;
所述每个维度对应的区间是根据预设的训练数据集训练获取的。
可选地,根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间之前,所述方法还包括:
获取所述压缩后高维向量的维度,根据所述维度获取与所述维度对应的区间信息,所述区间信息包括:预先获取的所述维度中每个维度对应的区间。
可选地,根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间之前,所述方法还包括:
根据预设的训练数据集训练获取每个维度对应的区间,所述每个维度为所述高维向量中的每个维度;
每一维度对应的区间均是不重叠的。
可选地,根据预设的训练数据集训练获取每个维度对应的区间,包括:
获取训练数据集中所有向量的每一维度的元素集合,所述元素集合包括该维度上所有向量的元素,所述训练数据集中所有向量的维度相同;
根据预设距离差和量化误差,获取用于划分区间的目标函数;
根据所述目标函数,将每一维度的元素集合进行区间划分,获得该维度对应的区间。
可选地,根据所述目标函数,将每一维度的元素集合进行区间划分,获得该维度对应的区间,包括:
枚举所述元素集合中区间划分的边界值,将每组所述区间划分的边界值 作为所述目标函数的参数值,确定并记录所述目标函数对应的取值;
选择使目标函数取得极值的边界值划分该维度,获得该维度对应的区间。
可选地,给每个维度对应的区间的元素进行编码,被量化到某个区间的元素将编码成该区间对应的二值码。编码的方式可以采用自然二进制码和一元码。
可选地,按照预设规则将所有二值码进行组合,获得二值向量,包括:
将所有二值码按照每一二值码对应的维度序号顺序拼接,获得二值向量。
可选地,所述对待处理的高维向量进行压缩处理,获取压缩后的高维向量,包括:
采用预设的线性变换矩阵对待处理的高维向量进行压缩处理,获得压缩后的高维向量;
所述线性变换矩阵为通过训练样本预先训练获取的。
可选地,所述对待处理的高维向量进行压缩处理,获取压缩后的高维向量,包括:
采用预设的非线性变换函数对待处理的高维向量进行压缩处理,获得压缩后的高维向量;
所述非线性变换函数通过训练样本预先训练获取的。
第二方面,本发明还提供一种高维向量的近邻查询方法,包括:
采用如上任一所述的方法获取待处理的高维向量的二值向量;
获取所述二值向量的哈希二值码;
根据所述哈希二值码的编码方式,选择与该编码方式对应的度量距离,采用所述度量距离度量所述二值向量与其他高维向量对应的二值向量的相似度。利用二值向量的相似性/相似度表达高维向量之间的相似性。
第三方面,本发明还提供一种高维向量的哈希装置,包括:
量化单元,用于采用标量量化方式对压缩后的高维向量进行量化处理,获取每个元素的量化信息,其中,所述每个元素为压缩后的高维向量中每个维度的元素;
编码单元,用于将所述每个元素的量化信息编码成二值码;
组合单元,用于按照预设规则将所有二值码进行组合,获得二值向量。
可选地,所述装置还包括:
压缩单元,用于在量化单元量化之前对待处理的高维向量进行压缩处理,获取压缩后的高维向量。
可选地,量化单元,具体用于
获取压缩后的高维向量中每个维度的元素;
根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间,获得每个元素的量化信息;
所述每个维度对应的区间是根据预设的训练数据集训练获取的。
可选地,量化单元,具体用于
获取压缩后的高维向量中每个维度的元素;
获取所述压缩后高维向量的维度,根据所述维度,获取与所述维度对应的区间信息,所述区间信息包括:预先获取的所述维度中每个维度对应的区间;
根据获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间,获得每个元素的量化信息;
所述每个维度对应的区间是根据预设的训练数据集训练获取的。
可选地,所述量化单元,还用于
根据预设的训练数据集训练获取每个维度对应的区间,所述每个维度为所述高维向量中的每个维度;
每一维度对应的区间均是不重叠的。
可选地,所述量化单元,具体用于
获取训练数据集中所有向量的每一维度的元素集合,所述元素集合包括该维度上所有向量的元素,所述训练数据集中所有向量的维度相同;
根据预设距离差和量化误差,获取用于划分区间的目标函数;
根据所述目标函数,将每一维度的元素集合进行区间划分,获得该维度对应的区间。
可选地,所述量化单元,具体用于
枚举所述元素集合中区间划分的边界值,将每组所述区间划分的边界值作为所述目标函数的参数值,确定并记录所述目标函数对应的取值;
选择使目标函数取得极值的边界值划分该维度,获得该维度对应的区间。
可选地,组合单元,具体用于
将所有二值码按照每一二值码对应的维度序号顺序拼接,获得二值向量。
可选地,所述编码单元,具体用于
对每一维度的区间(即量化后的区间)中的元素编码成二值码,编码的方式可以是自然二进制码也可以是一元码。
可选地,压缩单元,具体用于
采用预设的线性变换矩阵对待处理的高维向量进行压缩处理,获得压缩后的高维向量;
所述线性变换矩阵为通过训练样本预先训练获取的。
可选地,压缩单元,具体用于
采用预设的非线性变换函数对待处理的高维向量进行压缩处理,获得压缩后的高维向量;
所述非线性变换函数为通过训练样本预先训练获取的。
第四方面,本发明提供一种高维向量的近邻查询装置,包括:
二值向量获取单元,用于采用上述任一所述的装置获取待处理的高维向量的二值向量;
哈希二值码获取单元,用于获取所述二值向量的哈希二值码;
相似度度量单元,用于根据所述哈希二值码的编码方式,选择与该编码方式对应的度量距离,采用所述度量距离度量所述二值向量与其他高维向量对应的二值向量的相似度。
第五方面,本发明提供一种向量量化方法,包括:
获取待量化的向量中每个维度的元素;
根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间,获得所述待量化的向量的量化信息;
所述每个维度对应的区间是根据预设的训练数据集训练获取的。
可选地,所述根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间之前,所述方法还包括:
获取所述待量化向量的维度,根据所述维度获取与所述维度对应的区间信息,所述区间信息包括:预先获取的所述维度中每个维度对应的区间。
可选地,所述根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间之前,所述方法还包括:
根据预设的训练数据集训练获取每个维度对应的区间,所述每个维度为所述待量化向量中的每个维度;
每一维度对应的区间均是不重叠的。
可选地,根据预设的训练数据集训练获取每个维度对应的区间,包括:
获取训练数据集中所有向量的每一维度的元素集合,所述元素集合包括该维度上所有向量的元素,所述训练数据集中所有向量的维度相同,且与待 量化向量的维度相同;
根据预设距离差和量化误差,获取用于划分区间的目标函数;
根据所述目标函数,将每一维度的元素集合进行区间划分,获得该维度对应的区间。
可选地,根据所述目标函数,将每一维度的元素集合进行区间划分,获得该维度对应的区间,包括:
枚举所述元素集合中区间划分的边界值,将每组所述区间划分的边界值作为所述目标函数的参数值,确定并记录所述目标函数对应的取值;
选择使目标函数取得极值的边界值划分该维度,获得该维度对应的区间。
第六方面,本发明还提供一种向量量化装置,包括:
元素获取单元,用于获取待量化的向量中每个维度的元素;
量化单元,用于根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间,获得所述待量化的向量的量化信息;
其中,所述每个维度对应的区间是根据预设的训练数据集训练获取的。
可选地,所述装置还包括:
维度确定单元,用于获取所述待量化向量的维度,根据所述维度,获取与所述维度对应的区间信息,所述区间信息包括:预先获取的所述维度中每个维度对应的区间。
可选地,所述装置还包括:
维度划分单元,用于根据预设的训练数据集训练获取每个维度对应的区间,所述每个维度为所述待量化向量中的每个维度;
每一维度对应的区间均是不重叠的。
可选地,维度划分单元,具体用于
获取训练数据集中所有向量的每一维度的元素集合,所述元素集合包括该维度上所有向量的元素,所述训练数据集中所有向量的维度相同,且与待量化向量的维度相同;
根据预设距离差和量化误差,获取用于划分区间的目标函数;
根据所述目标函数,将每一维度的元素集合进行区间划分,获得该维度对应的区间。
可选地,维度划分单元,具体用于
获取训练数据集中所有向量的每一维度的元素集合,所述元素集合包括该维度上所有向量的元素,所述训练数据集中所有向量的维度相同,且与待 量化向量的维度相同;
根据预设距离差和量化误差,获取用于划分区间的目标函数;
枚举所述元素集合中区间划分的边界值,将每组所述区间划分的边界值作为所述目标函数的参数值,确定并记录所述目标函数对应的取值;
选择使目标函数取得极值的边界值划分该维度,获得该维度对应的区间。
由上述技术方案可知,本发明的高维向量的哈希方法及装置,通过获取高维向量中每个元素的量化信息,进而将量化信息编码成二值码,由此,可组合二值码,获得高维向量的二值向量,进而能够对降低现有技术中近邻查询过程中的存储复杂度,以及提升检索准确率和检索效率。
本发明的向量量化方法及装置,通过获取待量化的向量中每个维度的元素,进而将元素量化到该元素所属维度对应的区间,获得待量化的向量的量化信息,由此,可实现对高维向量进行量化处理,且采用量化后的信息能够提高图像检索中的检索准确率。
附图说明
图1为本发明一实施例提供的高维向量的哈希方法的流程示意图;
图2为本发明一实施例提供的高维向量的哈希方法的流程示意图;
图3为本发明一实施例提供的高维向量的近邻查询方法的流程示意图;
图4为本发明一实施例提供的高维向量的哈希装置的结构示意图;
图5为本发明一实施例提供的高维向量的近邻查询装置的结构示意图;
图6为本发明一实施例提供的向量量化方法的流程示意图;
图7为本发明另一实施例提供的向量量化方法的流程示意图;
图8为本发明一实施例提供的向量量化装置的结构示意图。
具体实施方式
下面结合附图,对发明的具体实施方式作进一步描述。以下实施例仅用于更加清楚地说明本发明的技术方案,而不能以此来限制本发明的保护范围。本发明实施例中所使用的“第一”、“第二”仅为更清楚的说明本申请的内容,不具有特定含义,也不限定任何内容。
当前,业内还出现一种近邻查询的技术方案,例如,该技术方案是通过压缩高维向量降低高维向量的维度然后再将降维后的向量量化成二值码的哈希方法。不同于现有技术中提及的第一类和第二类方法,该技术方案中的哈希方法通常不需要额外的索引,直接利用量化后的二值码之间的距 离判定向量之间的相似性。
然而,该近邻查询的技术方案还仅仅是简单地将压缩后向量的每个元素用一个预设的阈值量化成单个比特,这个过程会引入较大的量化误差。
为此,如何降低近邻查询过程中的存储复杂度,提升检索效率;以及解决上述方案中单个比特量化的误差问题,本发明实施例中引入更精确的量化的机制(比如多比特量化)进而可减少量化误差。
图1示出了本发明一实施例提供的高维向量的哈希方法的流程示意图,如图1所示,本实施例中的高维向量的哈希方法如下所述。
101、采用标量量化方式对压缩后的高维向量进行量化处理,获取每个元素的量化信息,其中,所述每个元素为压缩后的高维向量中每个维度的元素。
举例来说,对于压缩后的高维向量X=[x1,x2,…xm]中的任何一个元素xi(1≤i≤m),xi量化后的量化信息为Q(xi),其中,Q表示量化函数。
102、将所述每个元素的量化信息编码成二值码;
在具体应用中,每个维度的元素量化后的区间编码即为该元素的编码。对于元素xi,若Q(xi)=Sij,那么xi将被编码成B(Sij)。
举例来说,可在应用中,将每个维度的元素xi划分到区间,将每个维度的元素划分后的区间Sij,1≤i≤m,1≤j≤u,编码成二值码B(Sij)。
其中,m为压缩后的高维向量的维度,u为非零自然数,u表示的是每个维度划分的区间数,比如u=4,那么就是将每个维度划分成4个区间,此时若采用二进制编码,可以分别将每个区间段依次编码成00,01,10,11等。
具体的,二值码包括但不限于自然二进制码,包括:
举例来说,设u=4,如果将Sij编码成2个比特,那么Si1,Si2,Si3,Si4对应的自然二进制码为00,01,10,11。对于二进制编码,采用的距离度量为二值码对应数值的差。比如00与01的距离|(00)2-(11)2|=|0-3|=3。
当然,在实际应用中,二值码包括但不限于上述的二进制码,还可为一元码,例如:设u=4,如果将Sij编码成3个比特,那么Si1,Si2,Si3,Si4对应的一元码为000,001,011,111。对于一元码,采用的距离度量可以为汉明距离。汉明距离的定义如下:给定两个二值码,其汉明距离等于异或以后数值为1的比特位的数目。比如010与011的抑或以后等于001,那么010与011的汉 明距离为1.
其它编码方式在本实施例中也可使用,本实施例仅为举例说明,并不是限定性的内容。
103、按照预设规则将所有二值码进行组合,获得二值向量。
例如,可将所有二值码按照每一二值码对应的维度序号顺序拼接,获得二值向量。
通常,每一二值码对应的维度序号即为该二值码的下标,进而可按照所有二值码的下标顺序拼接获得二值向量。举例来说,对于一个向量(y1,y2,y3),维度序号就是下标,该下标实质上就是1,2,3这些序号。其中y1量化成00,y2量化成01,y3量化成11,那么拼接到一起获得二值向量就是000111。为此,可按维度序号从左至右拼接到一起。
首先,按顺序排列每个元素的量化信息编码后的二值码。对于X,按下标顺序排列X中各个元素的量化信息编码后的二值码B(Q(x1)),B(Q(x2)),…,B(Q(xm))。
接着,把各个元素的量化信息编码后的二值码组合到一起,构成二值向量。例如,将B(Q(x1)),B(Q(x2)),…,B(Q(xm))组合,得到二值向量H,H=[B(Q(x1)),B(Q(x2)),…,B(Q(xm))]。
在本实施例中二值向量即为高维向量哈希后的结果。
本实施例的高维向量的哈希方法可通过获取高维向量中每个元素的量化信息,进而将量化信息编码成二值码,由此,可组合二值码,获得高维向量的二值向量,进而能够对降低现有技术中近邻查询过程中的存储复杂度,以及提升检索效率。
图2示出了本发明一实施例提供的高维向量的哈希方法的流程示意图,如图2所示,本实施例中的高维向量的哈希方法如下所述。
201、对待处理的高维向量进行压缩处理,获取压缩后的高维向量。
例如,采用预设的线性变换矩阵对待处理的高维向量进行压缩处理,获得压缩后的高维向量;
所述线性变换矩阵为通过训练样本预先训练获取的。
举例来说,步骤201的具体实现过程如下:
A01、采集一个离线训练的数据集,组成训练样本SZ,例如,采集一个n维向量集合SZ={Z1,Z2,…,Zt},Z1,Z2,…,Zt为SZ中的元素。
其中,Zi为n维向量,1≤i≤t,t为自然数。
A02、从训练样本SZ中训练获取一个线性变换矩阵A。
即,可采用主要成分分析方法((Principal Component Analysis,简称PCA)从向量集合SZ中学习获得一个线性变换矩阵A,该线性变换矩阵A的维度为n*m,m为压缩后的高维向量的维度。
A03、将待处理的高维向量乘以线性变换矩阵,得到压缩后的高维向量。
例如,可对于待处理的高维向量Y=[y1,y2,…,yn],乘以线性变换矩阵A,得到压缩后的高维向量X=F(Y)=(YTA)T=[x1,x2,…,xm],m为自然数,F代表压缩处理。
也可以将待处理的高维向量进行非线性变换,得到压缩后的高维向量。
例如可对于待处理的高维向量Y=[y1,y2,…,yn],进行非线性函数cos()变换,得到压缩后的高维向量X=K(Y)=cos(YS)=[cos(y1s1),cos(y2s2),…,cos(ym sm)],m为自然数,K为非线性变换。非线性函数为预先通过训练样本获取的。
当然,在实际应用中,还可采用其他方式对待处理的高维向量进行压缩处理,不限定上述举例的步骤A01至步骤A03。
202、获取压缩后的高维向量中每个维度的元素。
203、根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间,获得每个元素的量化信息。
例如,对于X中的任何一个元素xi(1≤i≤m),xi量化后的量化信息为Q(xi),其中,Q表示量化函数。
在具体实现过程中,预先将每个维度的元素取值范围划分成几个独立的区间。设X中每个维度的元素xi取值范围为Li=[li,ri]。将Li划分成u个独立的区间,Si1,Si2,…,Siu
其中,区间之间不重叠。且Li=Si1∪Si2∪…∪Siu
其次,把每个元素量化到该元素所属维度对应的区间。
若元素xi属于Sij,那么xi将被量化到Sij=Q(xi)。
其中,每个维度对应的区间是根据预设的训练数据集训练获取的。
举例来说,可预先离线获取所述压缩后高维向量的维度,根据所述维度获取与所述维度对应的区间信息,所述区间信息包括:预先获取的所述维度中每个维度对应的区间,进而再进一步执行步骤203。
例如,高维向量可为128维,则可获取与128维对应的每一维度的区间信息。在部分实施例中,不同维度的区间信息可不同。
204、将所述每个元素的量化信息编码成二值码。
例如,对于量化信息Q(xi)编码成二值码B(Q(xi)),B表示编码函数。
205、按照预设规则将所有二值码进行组合,获得二值向量。
例如,将编码后的二值码按照下标顺序拼接B(Q(x1)),B(Q(x2)),…,B(Q(xm)),得到H=[B(Q(x1)),B(Q(x2)),…,B(Q(xm))],H为二值向量。
本实施例中的H为紧凑的二值向量。
本实施例的高维向量的哈希方法能够对降低现有技术中近邻查询过程中的存储复杂度,以及提升检索效率。
本实施例能够有效解决现有哈希方法中的单比特量化的性能损失问题。现有的哈希方法大多是简单地将压缩后向量的每个元素用一个预设的阈值量化成单个比特,这个过程会引入较大的量化误差。而本实施例则提供了一种更科学并且支持多比特量化的量化机制,能够大大降低量化误差,解决现有哈希方法中单比特量化的问题。
下面对上述步骤203进行详细说明如下:
B01、根据预设的训练数据集训练获取每个维度对应的区间,所述每个维度为所述高维向量中的每个维度;每一维度对应的区间均是不重叠的。
B02、根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间。
该步骤B02的具体实现过程如下:
B021、获取训练数据集中所有向量的每一维度的元素集合,所述元素集合包括该维度上所有向量的元素,所述训练数据集中所有向量的维度相同;
B022、根据预设距离差和量化误差,获取用于划分区间的目标函数;
B023、根据所述目标函数,将每一维度的元素集合进行区间划分,获得该维度对应的区间。
具体地,B0231、枚举所述元素集合中区间划分的边界值,将每组所述区间划分的边界值作为所述目标函数的参数值,确定并记录所述目标函数对应的取值;
B0232、选择使目标函数取得极值(如最小值)的边界值划分该维度,获得该维度对应的区间。
可理解的是,在具体应用中,目标函数还可能是非连续而且不可导的函数,在应用中存在无法直接获取该目标函数的极值,也就是说,无法直接判断该目标函数在某个取值下是否是极大或者极小值。为此,可预先枚举足够多的边界值,从中选择使目标函数相对最大(或者最小)的边界值来划分区间。
当然,可根据实际需要选择使目标函数取得最大值或最小值的方式,本实施例均为举例说明,不对其进行限定。
图3示出了本发明一实施例提供的高维向量的近邻查询方法的流程示意图,如图3所示,本实施例中的高维向量的近邻查询方法如下所述。
301、获取待处理的高维向量的二值向量。
在本实施例中可采用上述任一实施例所述的方法获取待处理的高维向量的二值向量。
302、获取所述二值向量的哈希二值码;
303、根据所述哈希二值码的编码方式,选择与该编码方式对应的度量距离,采用所述度量距离度量所述二值向量与其他高维向量对应的二值向量的相似度。
例如,对于两个紧凑的二值向量H1和H2,选择与所用二值码相匹配的距离D,来度量二值向量之间的相似性。
即两个二值向量H1和H2的相似性用D(H1,H2)来表示。
对于两个二值向量H1和H2,其相似性的度量举例可以为汉明距离,也可以为曼哈顿举例度量,其他举例度量方法本实施例不对其进行限定。
上述近邻查询方法可降低现有技术中高额的存储复杂度,并且大幅度地提升检索的效率。
图4示出了本发明一实施例提供的高维向量的哈希装置的结构示意图,如图4所示,本实施例的高维向量的哈希装置包括:量化单元41、编码单元42和组合单元43;
其中,量化单元41用于采用标量量化方式对压缩后的高维向量进行量化处理,获取每个元素的量化信息,其中,所述每个元素为压缩后的高维向量中每个维度的元素;
编码单元42用于将所述每个元素的量化信息编码成二值码;
组合单元43用于按照预设规则将所有二值码进行组合,获得二值向量。
在具体应用中,前述的装置还可包括图中未示出的压缩单元40,该压缩单元40用于在量化单元41量化之前对待处理的高维向量进行压缩处理,获取压缩后的高维向量。例如,采用预设的线性变换矩阵对待处理的高维向量进行压缩处理,获得压缩后的高维向量;所述线性变换矩阵为通过训练样本预先训练获取的。
在一种可能的应用中,量化单元41可具体用于,获取压缩后的高维向量中每个维度的元素;
根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间,获得每个元素的量化信息;
所述每个维度对应的区间是根据预设的训练数据集训练获取的。
在另一种具体的应用中,量化单元41可具体用于,获取压缩后的高维向量中每个维度的元素;
获取所述压缩后高维向量的维度,根据所述维度,获取与所述维度对应的区间信息,所述区间信息包括:预先获取的所述维度中每个维度对应的区间;
根据获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间,获得每个元素的量化信息;
所述每个维度对应的区间是根据预设的训练数据集训练获取的。
举例来说,所述量化单元41还可用于,根据预设的训练数据集训练获取每个维度对应的区间,所述每个维度为所述高维向量中的每个维度;
例如,获取训练数据集中所有向量的每一维度的元素集合,所述元素集合包括该维度上所有向量的元素,所述训练数据集中所有向量的维度相同;
根据预设距离差和量化误差,获取用于划分区间的目标函数;
根据所述目标函数,将每一维度的元素集合进行区间划分,获得该维度对应的区间。每一维度对应的区间均是不重叠的。
在实际应用中,根据所述目标函数,将每一维度的元素集合进行区间划分,可为:枚举所述元素集合中区间划分的边界值,将每组所述区间划分的边界值作为所述目标函数的参数值,确定并记录所述目标函数对应的取值;
选择使目标函数取得极值的边界值划分该维度,获得该维度对应的区间。
在更具体的例子中,组合单元43可具体用于,将所有二值码按照每一二值码对应的维度序号顺序拼接,获得二值向量。
本实施例的高维向量的哈希装置能够对降低现有技术中近邻查询过程中的存储复杂度,以及提升检索效率。
图5示出了本发明一实施例提供的高维向量的近邻查询装置的结构示意图,如图5所示,本实施例的高维向量的近邻查询装置包括:二值向量获取单元51、哈希二值码获取单元52和相似度度量单元53;
其中,二值向量获取单元51,用于获取待处理的高维向量的二值向量;例如,可采用上述任意实施例所述的高维向量的哈希装置来获取二值向量;
哈希二值码获取单元52用于获取所述二值向量的哈希二值码;
相似度度量单元53用于根据所述哈希二值码的编码方式,选择与该编码方式对应的度量距离,采用所述度量距离度量所述二值向量与其他高维向量对应的二值向量的相似度。
上述近邻查询装置可降低现有技术中高额的存储复杂度,并且大幅度地提升检索的效率。
可理解的是,本实施例中的哈希装置和近邻查询装置均在计算设备中实现,如终端、移动终端或服务器等实现向量查询或检索,可应用于图像检索,或向量学习、机器学习等方面。
下面结合附图,对发明的向量量化方法及装置进行详细说明。
图6示出了本发明一实施例提供的向量量化方法的流程示意图,如图6所示,本实施例的向量量化方法如下所述。
601、获取待量化的向量中每个维度的元素。
举例来说,待量化的n维向量为X=[x1,x2,…,xn],获取待量化的向量中每个维度的元素xi,其中,1≤i≤n。
602、根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间,获得所述待量化的向量的量化信息。
其中,所述每个维度对应的区间是根据预设的训练数据集训练获取的。
对于每个维度的元素集合中的元素xi,将元素集合中的所有元素量化到该维度对应的u个独立的区间Si1,Si2,…,Siu。其中,该u个区间之间不重叠(即区间是独立的,对于一个维度的任意两个区间,它们的交集是空集)。即,若 元素xi属于区间Sij,则将元素xi量化到区间Sij
其中,u表示的是每个维度划分的区间数,比如u=4,那么就是将该维度划分成4个区间。
举例来说,在步骤602之前,图6所示的方法还可包括下述的步骤601a;
601a、获取所述待量化向量的维度,根据所述维度获取与所述维度对应的区间信息,所述区间信息包括:预先获取的所述维度中每个维度对应的区间。
例如,待量化向量的维度为64维,则可根据64维获取与64维度对应的区间信息;或者,待量化向量的维度为128维,则可根据128维获取与128维度对应的区间信息。
本实施例的向量量化方法,通过获取待量化的向量中每个维度的元素,进而将元素量化到该元素所属维度对应的区间,获得待量化的向量的量化信息,由此,可实现对高维向量进行量化处理,且采用量化后的信息能够提高图像检索中的检索准确率。
图7示出了本发明一实施例提供的向量量化方法的流程示意图,如图7所示,本实施例的向量量化方法如下所述。
701、获取待量化的向量中每个维度的元素。
举例来说,待量化的n维向量为X=[x1,x2,…,xn],获取待量化的向量中每个维度的元素xi,其中,1≤i≤n。
702、根据预设的训练数据集训练获取每个维度对应的区间,所述每个维度为所述待量化向量中的每个维度。
在本实施例中,每一维度对应的区间均是不重叠的。
举例来说,步骤701可包括下述的图中未示出的子步骤:
7021、获取训练数据集中所有向量的每一维度的元素集合,所述元素集合包括该维度上所有向量的元素,所述训练数据集中所有向量的维度相同,且与待量化的向量的维度相同。
例如,选t个n维向量X1,X2,…,Xt作为训练数据集。对于第i个维度,统计这t个向量在此维度上所有的取值,不妨设为,A={a1,a2,…,at}。其中, a1≤a2≤…≤at
7022、根据预设距离差和量化误差,获取用于划分区间的目标函数。
7023、根据所述目标函数,将每一维度的元素集合进行区间划分,获得该维度对应的区间。
具体地,枚举所述元素集合中区间划分的边界值,将每组所述区间划分的边界值作为所述目标函数的参数值,确定并记录所述目标函数对应的取值;
选择使目标函数取得极值(如最小值)的边界值划分该维度,获得该维度对应的区间。
可理解的是,在具体应用中,目标函数还可能是非连续而且不可导的函数,在应用中存在无法直接获取该目标函数的极值,也就是说,无法直接判断该目标函数在某个取值下是否是极大或者极小值。为此,可预先枚举足够多的边界值,从中选择使目标函数相对最大(或者最小)的边界值来划分区间。
当然,可根据实际需要选择使目标函数取得最大值或最小值的方式,本实施例均为举例说明,不对其进行限定。
在一个具体的例子中,对于一个维度的元素集合A的区间划分,用一个目标函数来判定该维度的元素集合A的区间划分的好坏。
具体中,假定将元素集合A划分成3个区间。
对于区间划分如下说明:
A1={a1,a2,…,a(l1)}
A2={a(l1+1),a(l1+2),…,a(l2)}
A3={a(l2+1),…,at}。
本实施例中采用一个目标函数F判定维度中区间划分质量的好坏。
目标函数的信息如下:
当前,
距离差定义成:
Figure PCTCN2015089607-appb-000001
量化误差定义成:MSE=Σi(ai-Q(ai))2
其中,ai被量化到的区间的均值为Q(ai)。即,如果ai对应的区间为Aj,Q(ai)代表Aj中所有元素的平均值。
t是一个放缩因子,调整d(Q(ai),Q(aj))和d(V(ai),V(aj))的差值的绝对值大小。
V(ai)代表元素ai所属的向量。即,如果ai属于Xj,那么V(ai)=Xj
最后,目标函数由MSDE和MSE的一个组合构成,即:
F=λ*MSDE+μ*MSE
λ和μ的取值可根据实际需要选择。举例来说,(λ=1,μ=0),(λ=0,μ=1),(λ=0.5,μ=0.5)等。
寻找能够使上述定义的目标函数取得极值的区间的边界值。即,寻找一个使F取得极小值的划分方式。
实际中,如果A1={a1,a2,…,a(s1)},A2={a(s1+1),a(s1+2),…,a(s2)},A3={a(s2+1),…,at}对应的F最小,那么选a(s1)和a(s2)对应的划分方式。
选用上述使目标函数取得极值的划分方案来确定维度的区间。
使用上述的a(s1)和a(s2)将维度划分成3段。
在本实施例中,查找所述元素集合中区间划分的边界值,将所述区间划分的边界值作为所述目标函数的参数值,确定所述目标函数的取值是否为极值;如果所述目标函数的取值为极值,则采用该区间划分的边界值划分该维度的元素集合中的元素,获得该维度对应的区间,举例如下:
可枚举每个划分边界的取值,具体中,假定将A={a1,a2,…,at}划分成3个区间A1={a1,a2,…,a(l1)}
A2={a(l1+1),a(l1+2),…,a(l2)}
A3={a(l2+1),…,at}。
那么,枚举l1和l2的取值。1≤l1≤t,l1<l2≤t。
对于每一组取值,带入目标函数计算函数值。当l1和l2确定后,计算对应F的取值。
枚举过程中,记录下所有l1和l2组合对应的F的取值。
选所有取值中最优的一组来划分维度。假如某组l1=p,l2=q使F最小。 那么选用p和q将维度划分成三部分,
A1={a1,a2,…,ap}
A2={a(p+1),a(p+2),…,aq}
A3={a(q+1),a(q+2),…,at}。
703、根据获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间,获得所述待量化的向量的量化信息。
本实施例中的量化可理解为是一种分组,量化后也就是意味着被分到了特定的组,而量化信息就是所属组的编号或者用来表示该组的符号。
例如,假设是量化第i维的元素yi,将第i维的元素分为三组,(-∞,-1],(-1,1],(1,∞),每个组编号分别是1,2,3。对于一个yi=0.5,它被分到(-1,1],这个过程是量化。它被编码成2,这就是量化信息。
另外,需要说明的是,原始向量之间的相关性体现在目标函数中的
Figure PCTCN2015089607-appb-000002
这一部分中。在寻找目标函数的极值时,不仅仅依赖对应维度的元素集合中元素的分布,还会利用维度对应的向量之间的距离关系,为此本实施例中可称之为原始向量之间的相关性。
由此,本实施例中的向量量化方法能够结合原始向量之间的相关性,进而对每一维度的每一元素进行量化,进而在向量的维度很高时也不会破坏向量的空间结构,由此,采用量化后的信息在图像检索中检索准确率提高。
另外,本发明实施例还提供一种使用上述图6或图7所示的向量量化方法在图像检索中使用的方法如下:
M01、获取一幅图像,并提取一个描述图像视觉特性的高维向量。
M02、统计高维向量每个维度的数值分布,基于分布信息给每个维度量化。
M03、将每个维度量化后的信息进行二值编码,从而得到高维向量的量化信息。
M04、选择与二值编码对应的距离度量方法度量量化后的向量之间的相 似性。
上述方法在图像检索过程中可提高图像检索中的检索准确率。
图8示出了本发明一实施例提供的向量量化装置的结构示意图,如图8所示,本实施例的向量量化装置包括:元素获取单元81、量化单元82;
元素获取单元81用于获取待量化的向量中每个维度的元素;
量化单元82用于根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间,获得所述待量化的向量的量化信息;
其中,所述每个维度对应的区间是根据预设的训练数据集训练获取的。
在一种具体的例子中,上述向量量化装置还可包括下述的图中未示出的维度确定单元,该维度确定单元用于获取所述待量化向量的维度,根据所述维度,获取与所述维度对应的区间信息,所述区间信息包括:预先获取的所述维度中每个维度对应的区间。
在另一种具体的例子中,向量量化装置还可包括下述的图中未示出的维度划分单元,该维度划分单元可为离线完成过程,用于根据预设的训练数据集训练获取每个维度对应的区间,所述每个维度为所述待量化向量中的每个维度;
每一维度对应的区间均是不重叠的。
例如,维度划分单元具体用于,获取训练数据集中所有向量的每一维度的元素集合,所述元素集合包括该维度上所有向量的元素,所述训练数据集中所有向量的维度相同,且与待量化的向量的维度相同;
根据预设距离差和量化误差,获取用于划分区间的目标函数;
根据所述目标函数,将每一维度的元素集合进行区间划分,获得该维度对应的区间。
或者,维度划分单元具体用于,获取训练数据集中所有向量的每一维度的元素集合,所述元素集合包括该维度上所有向量的元素,所述训练数据集中所有向量的维度相同,且与待量化向量的维度相同;
根据预设距离差和量化误差,获取用于划分区间的目标函数;
枚举所述元素集合中区间划分的边界值,将每组所述区间划分的边界值 作为所述目标函数的参数值,确定并记录所述目标函数对应的取值;
选择使目标函数取得极值的边界值划分该维度,获得该维度对应的区间。
本实施例的向量量化装置,可实现对高维向量进行量化处理,且采用量化后的信息能够提高图像检索中的检索准确率。
本发明的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。
类似地,应当理解,为了精简本发明公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释呈反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。
本领域技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在于该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是互相排斥之处,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。
此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使 用。
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围,其均应涵盖在本发明的权利要求和说明书的范围当中。

Claims (20)

  1. 一种高维向量的哈希方法,其特征在于,包括:
    采用标量量化方式对压缩后的高维向量进行量化处理,获取每个元素的量化信息,其中,所述每个元素为压缩后的高维向量中每个维度的元素;
    将所述每个元素的量化信息编码成二值码;
    按照预设规则将所有二值码进行组合,获得二值向量。
  2. 根据权利要求1所述的方法,其特征在于,采用标量量化方式对压缩后的高维向量进行量化处理,获取每个元素的量化信息,包括:
    获取压缩后的高维向量中每个维度的元素;
    根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间,获得每个元素的量化信息;
    所述每个维度对应的区间是根据预设的训练数据集训练获取的。
  3. 根据权利要求2所述的方法,其特征在于,根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间之前,所述方法还包括:
    获取所述压缩后高维向量的维度,根据所述维度获取与所述维度对应的区间信息,所述区间信息包括:预先获取的所述维度中每个维度对应的区间。
  4. 根据权利要求2或3所述的方法,其特征在于,根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间之前,所述方法还包括:
    根据预设的训练数据集训练获取每个维度对应的区间,所述每个维度为所述高维向量中的每个维度;
    每一维度对应的区间均是不重叠的。
  5. 根据权利要求4所述的方法,其特征在于,根据预设的训练数据集训练获取每个维度对应的区间,包括:
    获取训练数据集中所有向量的每一维度的元素集合,所述元素集合包括该维度上所有向量的元素,所述训练数据集中所有向量的维度相同,均等于 所述压缩后的高维向量的维度;
    根据预设距离差和量化误差,获取用于划分区间的目标函数;
    根据所述目标函数,将每一维度的元素集合进行区间划分,获得该维度对应的区间。
  6. 根据权利要求5所述的方法,其特征在于,根据所述目标函数,将每一维度的元素集合进行区间划分,获得该维度对应的区间,包括:
    枚举所述元素集合中区间划分的边界值,将每组所述区间划分的边界值作为所述目标函数的参数值,确定并记录所述目标函数对应的取值;
    选择使目标函数取得极值的边界值划分该维度,获得该维度对应的区间。
  7. 根据权利要求1至6任一所述的方法,其特征在于,按照预设规则将所有二值码进行组合,获得二值向量,包括:
    将所有二值码按照每一二值码对应的维度序号顺序拼接,获得二值向量。
  8. 一种高维向量的近邻查询方法,其特征在于,包括:
    采用权利要求1至7任一所述的方法获取待处理的高维向量的二值向量;
    获取所述二值向量的哈希二值码;
    根据所述哈希二值码的编码方式,选择与该编码方式对应的度量距离,采用所述度量距离度量所述二值向量与其他高维向量对应的二值向量的相似度。
  9. 一种高维向量的哈希装置,其特征在于,包括:
    量化单元,用于采用标量量化方式对压缩后的高维向量进行量化处理,获取每个元素的量化信息,其中,所述每个元素为压缩后的高维向量中每个维度的元素;
    编码单元,用于将所述每个元素的量化信息编码成二值码;
    组合单元,用于按照预设规则将所有二值码进行组合,获得二值向量。
  10. 一种高维向量的近邻查询装置,其特征在于,包括:
    二值向量获取单元,用于采用上述权利要求9所述的装置获取待处理的高维向量的二值向量;
    哈希二值码获取单元,用于获取所述二值向量的哈希二值码;
    相似度度量单元,用于根据所述哈希二值码的编码方式,选择与该编码方式对应的度量距离,采用所述度量距离度量所述二值向量与其他高维向量对应的二值向量的相似度。
  11. 一种向量量化方法,其特征在于,包括:
    获取待量化的向量中每个维度的元素;
    根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间,获得所述待量化的向量的量化信息;
    其中,所述每个维度对应的区间是根据预设的训练数据集训练获取的。
  12. 根据权利要求11所述的方法,其特征在于,所述根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间之前,所述方法还包括:
    获取所述待量化向量的维度,根据所述维度,获取与所述维度对应的区间信息,所述区间信息包括:预先获取的所述维度中每个维度对应的区间。
  13. 根据权利要求11或12所述的方法,其特征在于,所述根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间之前,所述方法还包括:
    根据预设的训练数据集训练获取每个维度对应的区间,所述每个维度为所述待量化向量中的每个维度;
    每一维度对应的区间均是不重叠的。
  14. 根据权利要求13所述的方法,其特征在于,根据预设的训练数据集训练获取每个维度对应的区间,包括:
    获取训练数据集中所有向量的每一维度的元素集合,所述元素集合包括该维度上所有向量的元素,所述训练数据集中所有向量的维度相同,且与待量化向量的维度相同;
    根据预设距离差和量化误差,获取用于划分区间的目标函数;
    根据所述目标函数,将每一维度的元素集合进行区间划分,获得该维度对应的区间。
  15. 根据权利要求14所述的方法,其特征在于,根据所述目标函数,将 每一维度的元素集合进行区间划分,获得该维度对应的区间,包括:
    枚举所述元素集合中区间划分的边界值,将每组所述区间划分的边界值作为所述目标函数的参数值,确定并记录所述目标函数对应的取值;
    选择使目标函数取得极值的边界值划分该维度,获得该维度对应的区间。
  16. 一种向量量化装置,其特征在于,包括:
    元素获取单元,用于获取待量化的向量中每个维度的元素;
    量化单元,用于根据预先获取的每个维度对应的区间,将所述元素量化到该元素所属维度对应的区间,获得所述待量化的向量的量化信息;
    其中,所述每个维度对应的区间是根据预设的训练数据集训练获取的。
  17. 根据权利要求16所述的装置,其特征在于,所述装置还包括:
    维度确定单元,用于获取所述待量化向量的维度,根据所述维度,获取与所述维度对应的区间信息,所述区间信息包括:预先获取的所述维度中每个维度对应的区间。
  18. 根据权利要求16或17所述的装置,其特征在于,所述装置还包括:
    维度划分单元,用于根据预设的训练数据集训练获取每个维度对应的区间,所述每个维度为所述待量化向量中的每个维度;
    每一维度对应的区间均是不重叠的。
  19. 根据权利要求18所述的装置,其特征在于,维度划分单元,具体用于
    获取训练数据集中所有向量的每一维度的元素集合,所述元素集合包括该维度上所有向量的元素,所述训练数据集中所有向量的维度相同,且与待量化向量的维度相同;
    根据预设距离差和量化误差,获取用于划分区间的目标函数;
    根据所述目标函数,将每一维度的元素集合进行区间划分,获得该维度对应的区间。
  20. 根据权利要求18所述的装置,其特征在于,维度划分单元,具体用于
    获取训练数据集中所有向量的每一维度的元素集合,所述元素集合包括该维度上所有向量的元素,所述训练数据集中所有向量的维度相同,且与待量化向量的维度相同;
    根据预设距离差和量化误差,获取用于划分区间的目标函数;
    枚举所述元素集合中区间划分的边界值,将每组所述区间划分的边界值作为所述目标函数的参数值,确定并记录所述目标函数对应的取值;
    选择使目标函数取得极值的边界值划分该维度,获得该维度对应的区间。
PCT/CN2015/089607 2015-01-09 2015-09-15 高维向量的哈希方法、向量量化方法及装置 Ceased WO2016110125A1 (zh)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN201510012075.6 2015-01-09
CN201510013258.X 2015-01-09
CN201510012075.6A CN105824856A (zh) 2015-01-09 2015-01-09 一种向量量化方法及装置
CN201510013258.XA CN105824858A (zh) 2015-01-09 2015-01-09 一种高维向量的哈希方法及装置

Publications (1)

Publication Number Publication Date
WO2016110125A1 true WO2016110125A1 (zh) 2016-07-14

Family

ID=56355481

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/089607 Ceased WO2016110125A1 (zh) 2015-01-09 2015-09-15 高维向量的哈希方法、向量量化方法及装置

Country Status (1)

Country Link
WO (1) WO2016110125A1 (zh)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110275881A (zh) * 2019-04-15 2019-09-24 阿里巴巴集团控股有限公司 基于哈希嵌入向量向用户推送对象的方法和装置
CN111988614A (zh) * 2020-08-14 2020-11-24 深圳前海微众银行股份有限公司 哈希编码优化方法、设备及可读存储介质
CN112560942A (zh) * 2020-12-14 2021-03-26 央视国际网络无锡有限公司 一种训练和计算相似性哈希码的神经网络方法
CN117294313A (zh) * 2023-09-26 2023-12-26 海南益林智能科技有限公司 一种教育机器人数据智能采集存储方法及系统
CN118468345A (zh) * 2024-07-12 2024-08-09 成都金科玉律科技有限公司 一种基于档案安全管理的档案存储管控方法

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1858773A (zh) * 2005-04-30 2006-11-08 中国科学院计算技术研究所 一种基于Gabor相位模式的图像识别方法
CN101430709A (zh) * 2008-09-24 2009-05-13 腾讯科技(深圳)有限公司 近邻查找方法和装置
CN102819582A (zh) * 2012-07-26 2012-12-12 华数传媒网络有限公司 一种海量图片快速检索方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1858773A (zh) * 2005-04-30 2006-11-08 中国科学院计算技术研究所 一种基于Gabor相位模式的图像识别方法
CN101430709A (zh) * 2008-09-24 2009-05-13 腾讯科技(深圳)有限公司 近邻查找方法和装置
CN102819582A (zh) * 2012-07-26 2012-12-12 华数传媒网络有限公司 一种海量图片快速检索方法

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110275881A (zh) * 2019-04-15 2019-09-24 阿里巴巴集团控股有限公司 基于哈希嵌入向量向用户推送对象的方法和装置
CN110275881B (zh) * 2019-04-15 2023-01-17 创新先进技术有限公司 基于哈希嵌入向量向用户推送对象的方法和装置
CN111988614A (zh) * 2020-08-14 2020-11-24 深圳前海微众银行股份有限公司 哈希编码优化方法、设备及可读存储介质
CN111988614B (zh) * 2020-08-14 2022-09-13 深圳前海微众银行股份有限公司 哈希编码优化方法、设备及可读存储介质
CN112560942A (zh) * 2020-12-14 2021-03-26 央视国际网络无锡有限公司 一种训练和计算相似性哈希码的神经网络方法
CN117294313A (zh) * 2023-09-26 2023-12-26 海南益林智能科技有限公司 一种教育机器人数据智能采集存储方法及系统
CN118468345A (zh) * 2024-07-12 2024-08-09 成都金科玉律科技有限公司 一种基于档案安全管理的档案存储管控方法

Similar Documents

Publication Publication Date Title
CN110188223B (zh) 图像处理方法、装置及计算机设备
CN105912611B (zh) 一种基于cnn的快速图像检索方法
JP5926291B2 (ja) 類似画像を識別する方法および装置
Zhou et al. Towards codebook-free: Scalable cascaded hashing for mobile image search
CN105718502B (zh) 用于高效特征匹配的方法和设备
CN107944046B (zh) 大规模高维数据快速检索方法及系统
CN109783691B (zh) 一种深度学习和哈希编码的视频检索方法
Wei et al. Projected residual vector quantization for ANN search
US20140229473A1 (en) Determining documents that match a query
CN111651668B (zh) 用户画像的标签生成方法及装置、存储介质、终端
CN110990596B (zh) 一种基于自适应量化多模态哈希检索方法及系统
WO2016110125A1 (zh) 高维向量的哈希方法、向量量化方法及装置
CN104217222B (zh) 一种基于随机采样哈希表示的图像匹配方法
CN107992611A (zh) 基于柯西分布哈希方法的高维数据检索方法与系统
CN105740428B (zh) 一种基于b+树的高维磁盘索引结构和图像检索方法
CN117131228A (zh) 一种向量检索方法及装置
CN112418298B (zh) 数据检索方法、装置以及计算机可读存储介质
CN114911958B (zh) 一种基于语义偏好的快速图像检索方法
CN105740916B (zh) 图像特征编码方法及装置
CN115881211B (zh) 蛋白质序列比对方法、装置、计算机设备以及存储介质
EP3115909A1 (en) Method and apparatus for multimedia content indexing and retrieval based on product quantization
CN116883740A (zh) 相似图片识别方法、装置、电子设备和存储介质
CN119416097B (zh) 一种ai模型服务平台数据集标注方法及系统
CN112200275B (zh) 人工神经网络的量化方法及装置
CN105824858A (zh) 一种高维向量的哈希方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15876626

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15876626

Country of ref document: EP

Kind code of ref document: A1