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

Method BackwardAlgorithm

external/sentencepiece/src/unigram_model.cc:218–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218std::vector<float> Lattice::BackwardAlgorithm(float inv_theta) const {
219 const int len = size();
220 std::vector<float> beta(node_allocator_.size(), 0.0);
221
222 for (int pos = len; pos >= 0; --pos) {
223 for (Node *lnode : end_nodes_[pos]) {
224 for (Node *rnode : begin_nodes_[pos]) {
225 beta[lnode->node_id] =
226 LogSumExp(beta[lnode->node_id], rnode->score + beta[rnode->node_id],
227 rnode == begin_nodes_[pos][0]);
228 }
229 }
230 }
231
232 return beta;
233}
234
235float Lattice::PopulateMarginal(float freq,
236 std::vector<float> *expected) const {

Callers

nothing calls this directly

Calls 2

LogSumExpFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected