osl_dynamics.models.base.MVNMixin#
- class osl_dynamics.models.base.MVNMixin#
Methods for models whose Keras model has an
MVNLayercalledobs_model.Must be listed before the model base class, e.g.
class Model(MVNMixin, MarkovModelBase).- set_regularizers(training_data)#
Set regularizers for the means and covariances from the data.
A multivariate normal prior is applied to the means with
mu=0,sigma=diag((range/2)**2). Ifconfig.diagonal_covariances=True, a log-normal prior is applied to the diagonal of the covariances withmu=0,sigma=sqrt(log(2*range)), otherwise an inverse Wishart prior is applied to the covariances withnu=n_channels-1+0.1andpsi=diag(range).rangeis the range of each channel in the data. For models with session-specific parameters, these priors are on the group parameters, and the KL divergence of the deviation magnitudes and the regularization of the deviation decoders are divided by the number of sequences in the data (and the sequence length ifconfig.loss_reduction='mean').- Parameters:
- training_dataosl_dynamics.data.Data or tf.data.Dataset
Training data.
- get_means()#
Get the means.
- Returns:
- meansnp.ndarray
Mean of each state or mode. Shape is (n_states, n_channels) or (n_modes, n_channels).
- get_covariances()#
Get the covariances.
- Returns:
- covariancesnp.ndarray
Covariance of each state or mode. Shape is (n_states, n_channels, n_channels) or (n_modes, n_channels, n_channels).
- get_observation_model_parameters()#
Get the means and covariances.
- Returns:
- meansnp.ndarray
Mean of each state or mode. Shape is (n_states, n_channels) or (n_modes, n_channels).
- covariancesnp.ndarray
Covariance of each state or mode. Shape is (n_states, n_channels, n_channels) or (n_modes, n_channels, n_channels).
- set_means(means, update_initializer=True)#
Set the means.
- Parameters:
- meansnp.ndarray
Mean of each state or mode. Shape is (n_states, n_channels) or (n_modes, n_channels).
- update_initializerbool, optional
Should we use this value when the model is reset?
- set_covariances(covariances, update_initializer=True)#
Set the covariances.
- Parameters:
- covariancesnp.ndarray
Covariance of each state or mode. Shape is (n_states, n_channels, n_channels) or (n_modes, n_channels, n_channels). If the model has diagonal covariances, the diagonal is used.
- update_initializerbool, optional
Should we use this value when the model is reset?
- set_observation_model_parameters(parameters, update_initializer=True)#
Set the means and covariances.
- Parameters:
- parameterstuple
Means and covariances, as returned by
get_observation_model_parameters.- update_initializerbool, optional
Should we use these values when the model is reset?