Repository navigation
Fit shared latent covariance models with joint EM - #30
Merged
Merged
Conversation
# Conflicts: # docs/src/fitting.md # src/em.jl
# Conflicts: # docs/src/fitting.md # src/covariancefit.jl # src/fit.jl # test/runtests.jl
This was referenced Oct 20, 2026
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.
Fit
LatentCovariancewith standard latent-variableCovarianceEM, either as a weighted single Gaussian or insideEMwith exactlyTied(:F,:D). Mixture components learn shared loadings F and residual variances D, their own full or diagonal A_k, and unrestricted means: Σ_k=F A_k F′+Diagonal(D). PCAEM remains the separate fixed-projection pipeline.For fixed responsibilities and updated means, a small posterior-moment helper uses latent-space Cholesky solves. The joint M-step pools mass-weighted cross/second moments to update F, updates each A_k, and pools expected squared residuals to update D.
variance_floorconstrains D. One joint inner report describes this covariance optimization.The implementation follows the direct matrix-equation style of existing LRD
CovarianceEM, reuses_varianceand_objective, and shares one core between single-Gaussian and mixture fitting. It uses the existing public workspaces and outer EM dispatch. No custom buffer struct or optimizer framework is introduced.fit!continues from current parameters; docs explain initialization, identifiability, local convergence and the inner sweep budget.Workspace validation checks F/D ties, latent shape and positive-definite A. Zero responsibilities are omitted before arithmetic, and component arrays remain independently owned. Includes the shared empty-observation mixture prediction fix also in #31. Other partial-sharing patterns remain deferred. No new dependencies or version bump.
Validation
b363efd.Performance follow-up
Reusable buffers, blocked accumulation and shared LRD/latent posterior kernels are deferred to #34, which preserves the prototype and its benchmark evidence. This PR retains sample-sized intermediate arrays and centers one component at a time.
A cached MNIST check (10k train / 10k validation, p=784, K=10, rank 30, seed 1, Gaussian dequantization σ=0.01) uses three outer iterations and three inner sweeps, Julia 1.11.5 / BLAS1, and two fresh fits after a small dispatch warm-up. Median fit time is 17.23 s, cumulative allocations 60.69 GB, and mean validation log likelihood 966.2014811920. Covariances, means, weights, training history and per-image validation scores match the original direct implementation exactly. Timings include initialization and in-fit GC; loading, validation scoring and I/O are excluded. Cumulative allocations are not peak RAM; this checks a fixed iteration budget, not convergence. Benchmark assets remain outside the repository.