osl_dynamics.inference.layers.SessionDeviationLayer#
- class osl_dynamics.inference.layers.SessionDeviationLayer(n_states, n_sessions, n_features, *, spatial_embeddings_dim, epsilon, n_layers, n_units, normalization, activation, dropout, regularizer, regularizer_factor, **kwargs)#
Bases:
tensorflow.keras.layers.LayerSession-specific deviations of a parameter from its group value.
The deviation of each session and state is a magnitude times a map. The map is decoded from the session embedding and an embedding of the group parameter (the spatial embedding), and normalized. The magnitude is the mean of a gamma posterior,
concentration / rate, with an exponential prior whose rate is decoded from the embeddings.- Parameters:
- n_statesint
Number of states/modes.
- n_sessionsint
Number of sessions.
- n_featuresint
Number of elements in the (flattened) parameter of each state.
- spatial_embeddings_dimint
Dimension of the spatial embeddings.
- epsilonfloat
Value added to the gamma and exponential parameters.
- n_layers, n_units, normalization, activation, dropout, regularizer, regularizer_factor
Settings for the decoder (
MultiLayerPerceptronLayer).
- 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.
- call(group_parameter, embeddings, training=None)#
Deviations and the KL divergence of the magnitudes.
- Parameters:
- group_parametertf.Tensor
Flattened group parameter. Shape is (n_states, n_features).
- embeddingstf.Tensor
Session embeddings. Shape is (n_sessions, embeddings_dim).
- trainingbool, optional
Training mode (for dropout).
- Returns:
- deviationstf.Tensor
Shape is (n_sessions, n_states, n_features).
- kltf.Tensor
KL divergence between the posterior and prior of the magnitudes.
- regularization()#
Regularization of the decoder.
- Returns:
- regularizationtf.Tensor
Scalar.