Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
/data/users/hoss/faiss/IndexIVFSpectralHash.h
1 /**
2 * Copyright (c) Facebook, Inc. and its affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8 // -*- c++ -*-
9
10 #ifndef FAISS_INDEX_IVFSH_H
11 #define FAISS_INDEX_IVFSH_H
12
13
14 #include <vector>
15
16 #include "IndexIVF.h"
17
18
19 namespace faiss {
20
21 struct VectorTransform;
22
23 /** Inverted list that stores binary codes of size nbit. Before the
24 * binary conversion, the dimension of the vectors is transformed from
25 * dim d into dim nbit by vt (a random rotation by default).
26 *
27 * Each coordinate is subtracted from a value determined by
28 * threshold_type, and split into intervals of size period. Half of
29 * the interval is a 0 bit, the other half a 1.
30 */
31 struct IndexIVFSpectralHash: IndexIVF {
32
33 VectorTransform *vt; // transformation from d to nbit dim
34 bool own_fields;
35
36 int nbit;
37 float period;
38
39 enum ThresholdType {
40 Thresh_global,
41 Thresh_centroid,
42 Thresh_centroid_half,
43 Thresh_median
44 };
45 ThresholdType threshold_type;
46
47 // size nlist * nbit or 0 if Thresh_global
48 std::vector<float> trained;
49
50 IndexIVFSpectralHash (Index * quantizer, size_t d, size_t nlist,
51 int nbit, float period);
52
53 IndexIVFSpectralHash ();
54
55 void train_residual(idx_t n, const float* x) override;
56
57 void encode_vectors(idx_t n, const float* x,
58 const idx_t *list_nos,
59 uint8_t * codes) const override;
60
61 InvertedListScanner *get_InvertedListScanner (bool store_pairs)
62 const override;
63
64 ~IndexIVFSpectralHash () override;
65
66 };
67
68
69
70
71 }; // namespace faiss
72
73
74 #endif
faiss::IndexIVF
Definition: IndexIVF.h:90
faiss::IndexIVFSpectralHash
Definition: IndexIVFSpectralHash.h:31
faiss::IndexIVFSpectralHash::get_InvertedListScanner
InvertedListScanner * get_InvertedListScanner(bool store_pairs) const override
get a scanner for this index (store_pairs means ignore labels)
Definition: IndexIVFSpectralHash.cpp:300
faiss::Index::d
int d
vector dimension
Definition: Index.h:66
faiss::Index::idx_t
long idx_t
all indices are this type
Definition: Index.h:62
faiss::IndexIVFSpectralHash::train_residual
void train_residual(idx_t n, const float *x) override
Definition: IndexIVFSpectralHash.cpp:66
faiss::VectorTransform
Definition: VectorTransform.h:26
faiss::InvertedListScanner
Definition: IndexIVF.h:272
faiss::IndexIVFSpectralHash::encode_vectors
void encode_vectors(idx_t n, const float *x, const idx_t *list_nos, uint8_t *codes) const override
Definition: IndexIVFSpectralHash.cpp:161
faiss::Index
Definition: Index.h:61
faiss::Level1Quantizer::quantizer
Index * quantizer
quantizer that maps vectors to inverted lists
Definition: IndexIVF.h:32
faiss::Level1Quantizer::nlist
size_t nlist
number of possible key values
Definition: IndexIVF.h:33