From a6eaf5ebc57fbca025eb4f0908a0084523f1e0d4 Mon Sep 17 00:00:00 2001 From: Al Date: Sat, 11 Mar 2017 02:31:52 -0500 Subject: [PATCH] [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 --- src/crf_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crf_context.c b/src/crf_context.c index 17a07b25..275454ee 100644 --- a/src/crf_context.c +++ b/src/crf_context.c @@ -611,7 +611,7 @@ double crf_context_viterbi(crf_context_t *self, uint32_t *labels) { /* Store this path if it has the maximum score. */ if (max_score < score) { max_score = score; - back[j] = i; + argmax_score = i; } }