fix: add getLastLogProbability() to BasicMapBaumWelchTrainer — parity with BasicBaumWelchTrainer (closes #55)#56
Merged
Conversation
) Parity fix with BasicBaumWelchTrainer. Changes: - accum_one_sequence now returns double (logP) instead of bool - train() accumulates totalLogProb and stores it as lastLogProb_ - getLastLogProbability() exposes the pre-M-step total E-step log-prob (reset to -inf before each train() call) Three new tests: initial -inf, finite-and-negative after train(), and pre-train model equality (same semantics as BaumWelchTrainer). Co-Authored-By: Oz <oz-agent@warp.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #55.
What changed
BasicMapBaumWelchTrainer::accum_one_sequencealready computedlogP = fbc.getLogProbability()but discarded it (returnedbool). This PR:accum_one_sequenceto returndouble(the sequence log-probability, or-∞if skipped)totalLogProbintrain()and stores it aslastLogProb_getLastLogProbability() const noexcept— identical semantics toBasicBaumWelchTrainerSemantics: stores the pre-M-step E-step log P(O|λ), reset to
-∞before eachtrain()call.Tests
3 new tests in
test_map_baum_welch.cpp:LastLogProbabilityIsNegInfBeforeTrain— initial stateLastLogProbabilityFiniteAfterTrain— finite and negative after one passLastLogProbabilityMatchesManualSum— equalstotal_logLon the pre-train model (correct semantics)47/47 pass.
Co-Authored-By: Oz oz-agent@warp.dev