osl_dynamics.inference.layers.MVNLayer#
- class osl_dynamics.inference.layers.MVNLayer(n_states, n_channels, *, learn_means, learn_covariances, initial_means=None, initial_covariances=None, covariances_epsilon=0.0, diagonal_covariances=False, means_regularizer=None, covariances_regularizer=None, covariances_layer=None, **kwargs)#
Bases:
tensorflow.keras.layers.LayerMultivariate normal observation model with a mean and covariance for each state.
- Parameters:
- n_statesint
Number of states.
- n_channelsint
Number of channels.
- learn_meansbool
Should the means be trainable?
- learn_covariancesbool
Should the covariances be trainable?
- initial_meansnp.ndarray, optional
Initial means. Shape must be (n_states, n_channels).
- initial_covariancesnp.ndarray, optional
Initial covariances. Shape must be (n_states, n_channels, n_channels).
- covariances_epsilonfloat, optional
Value added to the diagonal of the covariances.
- diagonal_covariancesbool, optional
Should the covariances be diagonal?
- means_regularizercallable, optional
Regularizer for the means.
- covariances_regularizercallable, optional
Regularizer for the covariances.
- covariances_layertf.keras.layers.Layer, optional
Layer for the covariances, used instead of a
CovarianceMatricesLayerorDiagonalMatricesLayer. It must havevalue()andregularization()methods.
- summary_rows()#
Rows for the layer in the summary of a model.
- Returns:
- rowslist of tuple
(name, details, learned by, number of learned values)for each row.
- log_likelihood(x)#
Log-likelihood of each state.
- Parameters:
- xtf.Tensor
Data. Shape is (batch_size, sequence_length, n_channels).
- Returns:
- log_likelihoodtf.Tensor
Shape is (batch_size, sequence_length, n_states).
- regularization()#
Regularization of the means and covariances.
- Returns:
- regularizationtf.Tensor
Scalar.