osl_dynamics.inference.layers.DirichletLayer#
- class osl_dynamics.inference.layers.DirichletLayer(n_states, n_channels, *, window_size, learn_concentration, initial_concentration=None, concentration_epsilon=1e-09, **kwargs)#
Bases:
tensorflow.keras.layers.LayerDirichlet observation model for compositional data in windows.
The data is split into windows of
window_sizesamples. The log-likelihood of a state for a window is the mean log-density of the samples in the window.- Parameters:
- n_statesint
Number of states.
- n_channelsint
Number of channels (categories).
- window_sizeint
Number of samples in each window.
- learn_concentrationbool
Should the concentrations be trainable?
- initial_concentrationnp.ndarray, optional
Initial concentrations. Shape must be (n_states, n_channels).
- concentration_epsilonfloat, optional
Minimum value of the concentrations.
- 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 for each window: the mean of the log-densities of the samples in the window.
- Parameters:
- xtf.Tensor
Compositional data. Shape is (batch_size, n_windows * window_size, n_channels).
- Returns:
- log_likelihoodtf.Tensor
Shape is (batch_size, n_windows, n_states).
- regularization()#
No regularization.
- Returns:
- regularizationtf.Tensor
Scalar.