pub fn optimize<F: Float + FromPrimitive, U: PrimInt>(
log_likelihood: &[Vec<F>],
counts: &[U],
prior: &[F],
opts: Option<OptimizerOpts>,
) -> Result<(Vec<f32>, Vec<f32>), Box<dyn Error>>Expand description
Run optimizer on 2D f32 log-likelihoods and integer weights.
Wrapper around optimize_flat that flattens the input and computes the log counts.
This function uses extra memory to handle generic floating point and integer types. optimize_flat or optimize_tensor(optimize_tensor<B: Backend>) should be preferred if memory usage is a concern.
§Inputs
log_likelihood: 2D vector withn_cols x n_rowslog-likelihood matrix.counts:n_rowsvector of integer weights forlog_likelihoodrows.prior:n_colsvector of prior counts for the Dirichlet model.opts: OptimizerOpts.
§Outputs:
thetas:n_colsvector of inferred mixing proportions.gamma_Z: flattenedn_cols x n_rowscolumn-major matrix containing inferred probabilities that the rowiwas generated from clusterj.
§Floating point width
Values will be converted to and returned as 32-bit floats regardless of input width.
Computation is performed in 32-bit space by default. If you want to perform
computation in 64-bit space, specify a 64-bit device via opts.
If you want to supply log likelihoods using non-32-bit floating point numbers, call optimize_tensor(optimize_tensor<B: Backend>) with the appropriate tensor data.