Internal API
The following helpers are documented but not exported. They remain available as HMMRBM internals for advanced workflows and extension hooks.
Utilities
HMMRBM.my_mult — Function
my_mult(A, B)Contract matrix A with array B over the last dimension of A and the first dimension of B.
HMMRBM.stack_vector_matrix — Function
stack_vector_matrix(v, mat)Stack a vector v and a matrix mat into a single matrix where the first column is v and the remaining columns are mat. The first dimensions of v must match all but the last dimension of mat.
HMMRBM.unstack_vector_matrix — Function
unstack_vector_matrix(θ)Unstack a matrix θ into a vector and a matrix where the first column of θ is the vector and the remaining columns are the matrix. The returned vector has all but the last dimension of θ, and the returned matrix has the same first dimensions as θ but with the last dimension reduced by one.
RBM Utilities
HMMRBM.log_P_v_given_h — Function
log_P_v_given_h(rbm, v, h)
log_P_v_given_h(rbm, Eᵥ, Wᵀv, h)Log probability of the visible units given the hidden units of the RBM.
Optimisation
Use log_P_v_given_h(rbm, Eᵥ, Wᵀv, h) when repeatedly evaluating for the same visible vector v.
Eᵥshould be precomputed asenergy(rbm.visible, v).Wᵀvshould be precomputed asrbm.w' * v.
HMMRBM.∂ₕlog_P_v_given_h — Function
∂ₕlog_P_v_given_h(rbm, Wᵀv, h)Gradient of the log probability of the visible units given the hidden units of the RBM.
Wᵀv should be precomputed as rbm.w' * v.
HMMRBM.∂ₕ²log_P_v_given_h — Function
∂ₕ²log_P_v_given_h(rbm, h)Diagonal of the Hessian of the log probability of the visible units given the hidden units of the RBM.
HMMRBM.cgfs! — Function
cgfs!(out, x, y)
cgfs!(out, visible, inputs)
cgfs!(out, rbm, h)In place cumulant generating function (CGF) evaluations for RBM components.
Algorithm Extensions
HiddenMarkovModels.baum_welch — Method
baum_welch(hmm_guess, obs_seq; atol, max_iterations, loglikelihood_increasing)Apply the Baum-Welch algorithm to estimate the parameters of an HMM on obs_seq, starting from hmm_guess.
Return a tuple (hmm_est, loglikelihood_evolution) where hmm_est is the estimated HMM and loglikelihood_evolution is a vector of loglikelihood values, one per iteration of the algorithm.
Keyword arguments
atol: minimum loglikelihood increase at an iteration of the algorithm (otherwise the algorithm is deemed to have converged)max_iterations: maximum number of iterations of the algorithmloglikelihood_increasing: whether to throw an error if the loglikelihood decreases
DensityInterface.logdensityof — Method
logdensityof(hmm::SingleSeqHMM)Log-density regularisation term for SingleSeqHMM instances whose emissions are RBMEmission.
HMMs using RBMEmission must have hyperparameter l2 for regularization.
DensityInterface.logdensityof — Method
HMMs using RBMMultiEmission must have hyperparameter l2 for regularization.