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_multFunction
my_mult(A, B)

Contract matrix A with array B over the last dimension of A and the first dimension of B.

source
HMMRBM.stack_vector_matrixFunction
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.

source
HMMRBM.unstack_vector_matrixFunction
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.

source

RBM Utilities

HMMRBM.log_P_v_given_hFunction
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 as energy(rbm.visible, v).
  • Wᵀv should be precomputed as rbm.w' * v.
source
HMMRBM.∂ₕlog_P_v_given_hFunction
∂ₕ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.

source
HMMRBM.∂ₕ²log_P_v_given_hFunction
∂ₕ²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.

source
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.

source

Algorithm Extensions

HiddenMarkovModels.baum_welchMethod
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 algorithm
  • loglikelihood_increasing: whether to throw an error if the loglikelihood decreases
source
DensityInterface.logdensityofMethod
logdensityof(hmm::SingleSeqHMM)

Log-density regularisation term for SingleSeqHMM instances whose emissions are RBMEmission.

HMMs using RBMEmission must have hyperparameter l2 for regularization.

source