fasttext::ProductQuantizer Class Reference

`#include <productquantizer.h>`

## Public Member Functions

| ProductQuantizer ()
| ProductQuantizer (int32_t, int32_t)
real * | get_centroids (int32_t, uint8_t)
const real * | get_centroids (int32_t, uint8_t) const
real | assign_centroid (const real *, const real *, uint8_t *, int32_t) const
void | Estep (const real *, const real *, uint8_t *, int32_t, int32_t) const
void | MStep (const real *, real *, const uint8_t *, int32_t, int32_t)
void | kmeans (const real *, real *, int32_t, int32_t)
void | train (int, const real *)
real | mulcode (const Vector &, const uint8_t *, int32_t, real) const
void | addcode (Vector &, const uint8_t *, int32_t, real) const
void | compute_code (const real *, uint8_t *) const
void | compute_codes (const real *, uint8_t *, int32_t) const
void | save (std::ostream &)
void | load (std::istream &)

## Private Attributes

const int32_t | nbits_ = 8
const int32_t | ksub_ = 1 << nbits_
const int32_t | max_points_per_cluster_ = 256
const int32_t | max_points_ = max_points_per_cluster_ * ksub_
const int32_t | seed_ = 1234
const int32_t | niter_ = 25
const real | eps_ = 1e-7
int32_t | dim_
int32_t | nsubq_
int32_t | dsub_
int32_t | lastdsub_
std::vector< real > | centroids_
std::minstd_rand | rng

## Constructor & Destructor Documentation

## ProductQuantizer() [1/2]

fasttext::ProductQuantizer::ProductQuantizer | ( |  | ) |

inline

## ProductQuantizer() [2/2]

fasttext::ProductQuantizer::ProductQuantizer | ( | int32_t | dim,
|  | int32_t | dsub
| ) |  |

## Member Function Documentation

## addcode()

void fasttext::ProductQuantizer::addcode | ( | Vector & | x,
|  | const uint8_t * | codes,
|  | int32_t | t,
|  | real | alpha
| ) |  | const

## assign_centroid()

real fasttext::ProductQuantizer::assign_centroid | ( | const real * | x,
|  | const real * | c0,
|  | uint8_t * | code,
|  | int32_t | d
| ) |  | const

## compute_code()

void fasttext::ProductQuantizer::compute_code | ( | const real * | x,
|  | uint8_t * | code
| ) |  | const

## compute_codes()

void fasttext::ProductQuantizer::compute_codes | ( | const real * | x,
|  | uint8_t * | codes,
|  | int32_t | n
| ) |  | const

## Estep()

void fasttext::ProductQuantizer::Estep | ( | const real * | x,
|  | const real * | centroids,
|  | uint8_t * | codes,
|  | int32_t | d,
|  | int32_t | n
| ) |  | const

## get_centroids() [1/2]

real * fasttext::ProductQuantizer::get_centroids | ( | int32_t | m,
|  | uint8_t | i
| ) |  |

## get_centroids() [2/2]

const real * fasttext::ProductQuantizer::get_centroids | ( | int32_t | m,
|  | uint8_t | i
| ) |  | const

## kmeans()

void fasttext::ProductQuantizer::kmeans | ( | const real * | x,
|  | real * | c,
|  | int32_t | n,
|  | int32_t | d
| ) |  |

## load()

void fasttext::ProductQuantizer::load | ( | std::istream & | in | ) |

## MStep()

void fasttext::ProductQuantizer::MStep | ( | const real * | x0,
|  | real * | centroids,
|  | const uint8_t * | codes,
|  | int32_t | d,
|  | int32_t | n
| ) |  |

## mulcode()

real fasttext::ProductQuantizer::mulcode | ( | const Vector & | x,
|  | const uint8_t * | codes,
|  | int32_t | t,
|  | real | alpha
| ) |  | const

## save()

void fasttext::ProductQuantizer::save | ( | std::ostream & | out | ) |

## train()

void fasttext::ProductQuantizer::train | ( | int | ,
|  | const real * |
| ) |  |

## Member Data Documentation

## centroids_

std::vector<real> fasttext::ProductQuantizer::centroids_

private

## dim_

int32_t fasttext::ProductQuantizer::dim_

private

## dsub_

int32_t fasttext::ProductQuantizer::dsub_

private

## eps_

const real fasttext::ProductQuantizer::eps_ = 1e-7

private

## ksub_

const int32_t fasttext::ProductQuantizer::ksub_ = 1 << nbits_

private

## lastdsub_

int32_t fasttext::ProductQuantizer::lastdsub_

private

## max_points_

const int32_t fasttext::ProductQuantizer::max_points_ = max_points_per_cluster_ * ksub_

private

## max_points_per_cluster_

const int32_t fasttext::ProductQuantizer::max_points_per_cluster_ = 256

private

## nbits_

const int32_t fasttext::ProductQuantizer::nbits_ = 8

private

## niter_

const int32_t fasttext::ProductQuantizer::niter_ = 25

private

## nsubq_

int32_t fasttext::ProductQuantizer::nsubq_

private

## rng

std::minstd_rand fasttext::ProductQuantizer::rng

private

## seed_

const int32_t fasttext::ProductQuantizer::seed_ = 1234

private

The documentation for this class was generated from the following files:

- /data/users/cpuhrsch/fbsource/fbcode/deeplearning/fastText/src/productquantizer.h
- /data/users/cpuhrsch/fbsource/fbcode/deeplearning/fastText/src/productquantizer.cc