FPI (Fixed Point Iteration)
- pymdp.algos.fpi.run_vanilla_fpi(A, obs, num_obs, num_states, prior=None, num_iter=10, dF=1.0, dF_tol=0.001, compute_vfe=True)
Update marginal posterior beliefs over hidden states using mean-field variational inference, via fixed point iteration.
- Parameters
A (
numpy.ndarray
of dtype object) – Sensory likelihood mapping or ‘observation model’, mapping from hidden states to observations. Each elementA[m]
of stores annp.ndarray
multidimensional array for observation modalitym
, whose entriesA[m][i, j, k, ...]
store the probability of observation leveli
given hidden state levelsj, k, ...
obs (numpy 1D array or numpy ndarray of dtype object) – The observation (generated by the environment). If single modality, this should be a 1D
np.ndarray
(one-hot vector representation). If multi-modality, this should benp.ndarray
of dtype object whose entries are 1D one-hot vectors.num_obs (list of ints) – List of dimensionalities of each observation modality
num_states (list of ints) – List of dimensionalities of each hidden state factor
prior (numpy ndarray of dtype object, default None) – Prior over hidden states. If absent, prior is set to be the log uniform distribution over hidden states (identical to the initialisation of the posterior)
num_iter (int, default 10) – Number of variational fixed-point iterations to run until convergence.
dF (float, default 1.0) – Initial free energy gradient (dF/dt) before updating in the course of gradient descent.
dF_tol (float, default 0.001) – Threshold value of the time derivative of the variational free energy (dF/dt), to be checked at each iteration. If dF <= dF_tol, the iterations are halted pre-emptively and the final marginal posterior belief(s) is(are) returned
compute_vfe (bool, default True) – Whether to compute the variational free energy at each iteration. If False, the function runs through all variational iterations.
- Returns
qs – Marginal posterior beliefs over hidden states at current timepoint
- Return type
numpy 1D array, numpy ndarray of dtype object, optional
- pymdp.algos.fpi.run_vanilla_fpi_factorized(A, obs, num_obs, num_states, mb_dict, prior=None, num_iter=10, dF=1.0, dF_tol=0.001, compute_vfe=True)
Update marginal posterior beliefs over hidden states using mean-field variational inference, via fixed point iteration.
- Parameters
A (
numpy.ndarray
of dtype object) – Sensory likelihood mapping or ‘observation model’, mapping from hidden states to observations. Each elementA[m]
of stores annp.ndarray
multidimensional array for observation modalitym
, whose entriesA[m][i, j, k, ...]
store the probability of observation leveli
given hidden state levelsj, k, ...
obs (numpy 1D array or numpy ndarray of dtype object) – The observation (generated by the environment). If single modality, this should be a 1D
np.ndarray
(one-hot vector representation). If multi-modality, this should benp.ndarray
of dtype object whose entries are 1D one-hot vectors.num_obs (
list
of ints) – List of dimensionalities of each observation modalitynum_states (
list
of ints) – List of dimensionalities of each hidden state factormb_dict (
Dict
) – Dictionary with two keys (A_factor_list
andA_modality_list
), that stores the factor indices that influence each modality (A_factor_list
) and the modality indices influenced by each factor (A_modality_list
).prior (numpy ndarray of dtype object, default None) – Prior over hidden states. If absent, prior is set to be the log uniform distribution over hidden states (identical to the initialisation of the posterior)
num_iter (int, default 10) – Number of variational fixed-point iterations to run until convergence.
dF (float, default 1.0) – Initial free energy gradient (dF/dt) before updating in the course of gradient descent.
dF_tol (float, default 0.001) – Threshold value of the time derivative of the variational free energy (dF/dt), to be checked at each iteration. If dF <= dF_tol, the iterations are halted pre-emptively and the final marginal posterior belief(s) is(are) returned
compute_vfe (bool, default True) – Whether to compute the variational free energy at each iteration. If False, the function runs through all variational iterations.
- Returns
qs – Marginal posterior beliefs over hidden states at current timepoint
- Return type
numpy 1D array, numpy ndarray of dtype object, optional