run_optimizer

Function run_optimizer 

Source
pub fn run_optimizer<B: Backend>(
    logl_f: &[f32],
    log_counts_f: &[f32],
    alpha0_f: &[f32],
    options: &OptimizerOpts,
    device: &Device<B>,
) -> Result<(Vec<f32>, Vec<f32>), Box<dyn Error>>
Expand description

Helper function to run on a generic backend

Allocates the input data on the BurnBackend and calls optimize_tensor(optimize_tensor<B: Backend>) to run inference.

burn Backend must be given as the generic <B: Backend>. Does not verify the input dimensions.

§Inputs

  • logl_f: flattened column-major n_cols x n_rows log-likelihood matrix.
  • log_counts_f: n_rows vector of natural logarithm of the weights for logl_f rows.
  • alpha0_f: n_cols vector of prior counts for the Dirichlet model.
  • options: OptimizerOpts
  • device: burn Device wrapping the Backend.

§Outputs

  • thetas: n_cols vector of inferred mixing proportions.
  • gamma_Z: flattened n_cols x n_rows column-major matrix containing inferred probabilities that the row i was generated from cluster j.

§Errors

Propagates errors, does not error on its own.