rofunc.learning.RofuncML.hmm
#
1. Module Contents#
1.1. Classes#
1.2. API#
- class rofunc.learning.RofuncML.hmm.HMM(nb_states, nb_dim=2)[source]#
Bases:
rofunc.learning.RofuncML.gmm.GMM
- property init_priors#
- property trans#
- property Trans#
- viterbi(demo, reg=True)[source]#
Compute most likely sequence of state given observations
- Parameters:
demo – [np.array([nb_timestep, nb_dim])]
- Returns:
- online_forward_message(x, marginal=None, reset=False)[source]#
- Parameters:
x –
marginal – slice
reset –
- Returns:
- compute_messages(demo=None, dep=None, table=None, marginal=None, sample_size=200, demo_idx=None)[source]#
- Parameters:
demo – [np.array([nb_timestep, nb_dim])]
dep – [A x [B x [int]]] A list of list of dimensions Each list of dimensions indicates a dependence of variables in the covariance matrix E.g. [[0],[1],[2]] indicates a diagonal covariance matrix E.g. [[0, 1], [2]] indicates a full covariance matrix between [0, 1] and no covariance with dim [2]
table – np.array([nb_states, nb_demos]) - composed of 0 and 1 A mask that avoid some demos to be assigned to some states
marginal – [slice(dim_start, dim_end)] or [] If not None, compute messages with marginals probabilities If [] compute messages without observations, use size (can be used for time-series regression)
- Returns:
- init_params_random(data, left_to_right=False, self_trans=0.9)[source]#
- Parameters:
data –
left_to_right (bool) – if True, init with left to right. All observations pre_trained_models will be the same, and transition matrix will be set to l_t_r
self_trans (float) – if left_to_right, self transition value to fill
- Returns:
- em(demos, dep=None, reg=1e-08, table=None, end_cov=False, cov_type='full', dep_mask=None, reg_finish=None, left_to_right=False, nb_max_steps=40, loop=False, obs_fixed=False, trans_reg=None)[source]#
- Parameters:
demos – [list of np.array([nb_timestep, nb_dim])] or [lisf of dict({})]
dep – [A x [B x [int]]] A list of list of dimensions or slices Each list of dimensions indicates a dependence of variables in the covariance matrix !!! dimensions should not overlap eg : [[0], [0, 1]] should be [[0, 1]], [[0, 1], [1, 2]] should be [[0, 1, 2]] E.g. [[0],[1],[2]] indicates a diagonal covariance matrix E.g. [[0, 1], [2]] indicates a full covariance matrix between [0, 1] and no covariance with dim [2] E.g. [slice(0, 2), [2]] indicates a full covariance matrix between [0, 1] and no covariance with dim [2]
reg – [float] or list [nb_dim x float] for different regularization in different dimensions Regularization term used in M-step for covariance matrices
table – np.array([nb_states, nb_demos]) - composed of 0 and 1 A mask that avoid some demos to be assigned to some states
end_cov – [bool] If True, compute covariance matrix without regularization after convergence
cov_type – [string] in [‘full’, ‘diag’, ‘spherical’]
- Returns: