10 #ifndef FASTTEXT_MODEL_H 11 #define FASTTEXT_MODEL_H 24 #define SIGMOID_TABLE_SIZE 512 26 #define LOG_TABLE_SIZE 512 40 std::shared_ptr<Matrix>
wi_;
41 std::shared_ptr<Matrix>
wo_;
42 std::shared_ptr<QMatrix>
qwi_;
43 std::shared_ptr<QMatrix>
qwo_;
58 std::vector< std::vector<int32_t> >
paths;
59 std::vector< std::vector<bool> >
codes;
62 static bool comparePairs(
const std::pair<real, int32_t>&,
63 const std::pair<real, int32_t>&);
65 int32_t getNegative(int32_t target);
69 static const int32_t NEGATIVE_TABLE_SIZE = 10000000;
72 Model(std::shared_ptr<Matrix>, std::shared_ptr<Matrix>,
73 std::shared_ptr<Args>, int32_t);
76 real binaryLogistic(int32_t,
bool,
real);
77 real negativeSampling(int32_t,
real);
78 real hierarchicalSoftmax(int32_t,
real);
81 void predict(
const std::vector<int32_t>&, int32_t,
82 std::vector<std::pair<real, int32_t>>&,
84 void predict(
const std::vector<int32_t>&, int32_t,
85 std::vector<std::pair<real, int32_t>>&);
86 void dfs(int32_t, int32_t,
real,
87 std::vector<std::pair<real, int32_t>>&,
89 void findKBest(int32_t, std::vector<std::pair<real, int32_t>>&,
91 void update(
const std::vector<int32_t>&, int32_t,
real);
92 void computeHidden(
const std::vector<int32_t>&,
Vector&)
const;
94 void computeOutputSoftmax();
96 void setTargetCounts(
const std::vector<int64_t>&);
97 void initTableNegatives(
const std::vector<int64_t>&);
98 void buildTree(
const std::vector<int64_t>&);
105 void setQuantizePointer(std::shared_ptr<QMatrix>, std::shared_ptr<QMatrix>,
bool);
real * t_sigmoid
Definition: model.h:52
real loss_
Definition: model.h:50
int32_t parent
Definition: model.h:31
std::shared_ptr< QMatrix > qwo_
Definition: model.h:43
std::minstd_rand rng
Definition: model.h:103
int32_t right
Definition: model.h:33
std::vector< Node > tree
Definition: model.h:60
int64_t count
Definition: model.h:34
real * t_log
Definition: model.h:53
void predict(int argc, char **argv)
Definition: main.cc:138
std::vector< std::vector< bool > > codes
Definition: model.h:59
int32_t hsz_
Definition: model.h:48
bool quant_
Definition: model.h:104
Vector grad_
Definition: model.h:47
std::shared_ptr< QMatrix > qwi_
Definition: model.h:42
size_t negpos
Definition: model.h:56
std::vector< std::vector< int32_t > > paths
Definition: model.h:58
bool binary
Definition: model.h:35
std::shared_ptr< Matrix > wo_
Definition: model.h:41
std::shared_ptr< Matrix > wi_
Definition: model.h:40
Vector output_
Definition: model.h:46
float real
Definition: real.h:15
int64_t nexamples_
Definition: model.h:51
int32_t left
Definition: model.h:32
std::shared_ptr< Args > args_
Definition: model.h:44
std::vector< int32_t > negatives
Definition: model.h:55
Vector hidden_
Definition: model.h:45
int32_t osz_
Definition: model.h:49