MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / ForwardAlgorithm

Method ForwardAlgorithm

external/sentencepiece/src/unigram_model.cc:200–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198}
199
200std::vector<float> Lattice::ForwardAlgorithm(float inv_theta) const {
201 const int len = size();
202 std::vector<float> alpha(node_allocator_.size(), 0.0);
203
204 for (int pos = 0; pos <= len; ++pos) {
205 for (Node *rnode : begin_nodes_[pos]) {
206 for (Node *lnode : end_nodes_[pos]) {
207 alpha[rnode->node_id] =
208 LogSumExp(alpha[rnode->node_id],
209 inv_theta * lnode->score + alpha[lnode->node_id],
210 lnode == end_nodes_[pos][0]);
211 }
212 }
213 }
214
215 return alpha;
216}
217
218std::vector<float> Lattice::BackwardAlgorithm(float inv_theta) const {
219 const int len = size();

Callers 2

TESTFunction · 0.80
SampleEncodeAndScoreMethod · 0.80

Calls 2

LogSumExpFunction · 0.85
sizeMethod · 0.45

Tested by 1

TESTFunction · 0.64