[fix] had taken out a previous optimization while debugging. Don't need to repeatedly update the backpointer array in viterbi to store an argmax when a stack variable will work. Because that's in the quadratic (only in L, the number o labels, which is small) section of the algorithm, even this small change can make a pretty sizeable difference. CRF training speed is now roughly on par with the greedy model
This commit is contained in:
@@ -611,7 +611,7 @@ double crf_context_viterbi(crf_context_t *self, uint32_t *labels) {
|
|||||||
/* Store this path if it has the maximum score. */
|
/* Store this path if it has the maximum score. */
|
||||||
if (max_score < score) {
|
if (max_score < score) {
|
||||||
max_score = score;
|
max_score = score;
|
||||||
back[j] = i;
|
argmax_score = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user