Namespace that contains functions related to Allocation Model [5].
More...
|
struct | Params |
| Structure to hold the parameters for the Allocation Model [5]. More...
|
|
|
template<typename T , typename Scalar > |
double | log_marginal_S (const tensor_t< T, 3 > &S, const Params< Scalar > &model_params) |
| Compute the log marginal of tensor S with respect to the given distribution parameters. More...
|
|
template<typename T , typename Scalar > |
std::tuple< matrix_t< T >, matrix_t< T >, vector_t< T > > | bnmf_priors (const shape< 3 > &tensor_shape, const Params< Scalar > &model_params) |
| Return prior matrices W, H and vector L according to the Bayesian NMF allocation model using distribution parameters. More...
|
|
template<typename T > |
tensor_t< T, 3 > | sample_S (const matrix_t< T > &prior_W, const matrix_t< T > &prior_H, const vector_t< T > &prior_L) |
| Sample a tensor S from generative Bayesian NMF model using the given priors. More...
|
|
template<typename Integer , typename Scalar > |
double | total_log_marginal (const matrix_t< Integer > &X, const Params< Scalar > &model_params) |
| Calculate total marginal value, \(p(X|\Theta) = \sum_S p(X|S)p(S|\Theta)\) where \(Theta\) is model parameters. More...
|
|
template<typename Scalar > |
Params< Scalar > | make_bld_params (const shape< 3 > &tensor_shape) |
| Make default BLD solver parameters. More...
|
|
template<typename Scalar > |
std::vector< Params< Scalar > > | make_EM_params (const shape< 3 > &tensor_shape) |
| Make default EM solver parameters. More...
|
|
Namespace that contains functions related to Allocation Model [5].
template<typename T , typename Scalar >
Return prior matrices W, H and vector L according to the Bayesian NMF allocation model using distribution parameters.
According to the Bayesian NMF allocation model [5],
\(L_j \sim \mathcal{G}(a, b) \qquad W_{:k} \sim \mathcal{D}(\alpha) \qquad H_{:j} \sim \mathcal{D}(\beta)\).
- Template Parameters
-
T | Value type of the matrix/vector objects. |
Scalar | Type of the model parameters. |
- Parameters
-
tensor_shape | Shape of the sample tensor \(x \times y \times z\). |
model_params | Allocation Model parameters. See bnmf_algs::alloc_model::Params<double>. |
- Returns
- std::tuple of \(<W_{x \times z}, H_{z \times y}, L_y>\).
- Exceptions
-
assertion | error if number of alpha parameters is not \(x\), if number of beta parameters is not \(z\). |
template<typename T , typename Scalar >
double bnmf_algs::alloc_model::log_marginal_S |
( |
const tensor_t< T, 3 > & |
S, |
|
|
const Params< Scalar > & |
model_params |
|
) |
| |
Compute the log marginal of tensor S with respect to the given distribution parameters.
According to the Bayesian NMF allocation model [5],
\(\log{p(S)} = \log{p(W, H, L, S)} - \log{p(W, H, L | S)}\).
- Template Parameters
-
T | value type of tensor S. |
Scalar | Type of the model parameters. |
- Parameters
-
S | Tensor \(S\) of size \(x \times y \times z \). |
model_params | Allocation model parameters. See bnmf_algs::alloc_model::Params<double>. |
- Returns
- log marginal \(\log{p(S)}\).
- Exceptions
-
assertion | error if number of alpha parameters is not equal to S.dimension(0), if number of beta parameters is not equal to S.dimension(2). |
template<typename Scalar >
Params<Scalar> bnmf_algs::alloc_model::make_bld_params |
( |
const shape< 3 > & |
tensor_shape | ) |
|
Make default BLD solver parameters.
This function makes default BLD parameters as specified in Params::Params.
- Template Parameters
-
Scalar | Type of the parameters. |
- Parameters
-
tensor_shape | Shape of tensor \(S_{x \times y \times z}\). |
- Returns
- Default parameters to be used with any BLD algorithm.
template<typename Scalar >
Make default EM solver parameters.
This function makes default EM algorithm (such as online_EM) parameters. Note that EM algorithms have a different parametrization than BLD solvers, i.e. there is a parameter for each entry of \(W\) and \(H\) matrices. Therefore, this function returns a vector of \(z\) Params objects where \(z\) is the rank of the decomposition (depth of the hidden tensor \(S\).)
- Template Parameters
-
Scalar | Type of the parameters. |
- Parameters
-
tensor_shape | Shape of tensor \(S_{x \times y \times z}\). |
- Returns
- Default parameters to be used with EM algorithms.
Sample a tensor S from generative Bayesian NMF model using the given priors.
According to the generative Bayesian NMF model [5],
\(S_{ijk} \sim \mathcal{PO}(W_{ik}H_{kj}L_{j})\).
- Template Parameters
-
T | Value type of the matrix/vector/tensor objects. |
- Parameters
-
prior_W | Prior matrix for \(W\) of shape \(x \times z\). |
prior_H | Prior matrix for \(H\) of shape \(z \times y\). |
prior_L | Prior vector for \(L\) of size \(y\). |
- Returns
- A sample tensor of size \(x \times y \times z\) from generative Bayesian NMF model.
- Exceptions
-
assertion | error if number of columns of prior_W is not equal to number of rows of prior_H, if number of columns of prior_H is not equal to number of columns of prior_L |
template<typename Integer , typename Scalar >
double bnmf_algs::alloc_model::total_log_marginal |
( |
const matrix_t< Integer > & |
X, |
|
|
const Params< Scalar > & |
model_params |
|
) |
| |
Calculate total marginal value, \(p(X|\Theta) = \sum_S p(X|S)p(S|\Theta)\) where \(Theta\) is model parameters.
- Template Parameters
-
Integer | Type of the matrix entries (must be an integer type). |
Scalar | Type of the model parameters. |
- Parameters
-
X | Integer matrix whose every possible tensor allocation will be tried. |
model_params | Model parameters. |
- Returns
- Total marginal value \(p(X|\Theta)\).