# API Reference

- Models
  - `GMM`
  - `FullCovGMM`
  - `DiagonalGMM`
  - `GmmWrapper`

- Experiments
  - Target Distributions
    - `LNPDF`
    - `GMM_LNPDF`
    - `StudentTMixture_LNPDF`
    - `LogisticRegression`
    - `LogisticRegression_minibatch`
    - `PlanarRobot`
    - `BNN_LNPDF`
  - Evaluation
    - `MMD`

- Optimization
  - GMMVI Modules
    - SampleSelector
    - ComponentAdaptation
    - ComponentStepsizeAdaptation
    - NgBasedComponentUpdater
    - NgEstimator
    - WeightStepsizeAdaptation
    - WeightUpdater
  - Least Squares
    - `LinFunc`
    - `QuadFunc`
    - `RegressionFunc`
  - `SampleDB`
    - `SampleDB.add_samples()`
    - `SampleDB.build_from_config()`
    - `SampleDB.evaluate_background()`
    - `SampleDB.get_newest_samples()`
    - `SampleDB.get_random_sample()`
    - `SampleDB.remove_every_nth_sample()`
  - `GMMVI`
    - `GMMVI.build_from_config()`
    - `GMMVI.train_iter()`

class gmmvi.gmmvi_runner.GmmviRunner(config, log_metrics_interval)

  This class runs `GMMVI`, but also evaluates learning metrics and provides logging functionality.

  Parameters:

    - config – dict A dictionary containing the hyperparameters and environment specifications.

    - log_metrics_interval – int metrics that take non-negligible overhead are evaluated ever log_metrics_interval iterations.

  static build_from_config(config: dict)

    Create a `GMMVI` instance from a configuration dictionary.

    This static method provides a convenient way to create a `GMMVI` instance, based on a dictionary containing the types and parameters of the `GMMVI modules`.

    Parameters:

      config – dict The dictionary should contain for each `GMMVI module` an entry of the form XXX_type (a string) and XXX_config (a dict) for specifying the type of each module, and the module-specific hyperparameters. For example, the dictionary could contain sample_selector_type={“component-based”} and sample_selector_config={“desired_samples_per_component”: 100, “ratio_reused_samples_to_desired”: 2.}. Refer to the example yml-configs, or to the individual GMMVI module for the expected parameters, and type-strings.

  finalize()

    Can be called after learning. Saves the final model parameters to the hard drive.

  get_cheap_metrics()

    Returns a dictionary of ‘cheap’ metrics, e.g. the current number of components, that we can obtain after every iteration without adding computational overhead.

    Returns:

      A dictionary containing cheap metrics.

    Return type:

      dict

  get_expensive_metrics()

    Computes ‘expensive’ metrics, such as plots, test-set evaluations, etc. Some of these metrics can be task-specific (see `LNPDF.expensive_metrics()`).

    Returns:

      A dictionary containing expensive metrics.

    Return type:

      dict

  get_samples_and_entropy(num_samples)

    Draws num_samples from the model and uses them to estimate the model’s entropy.

    Parameters:

      num_samples – int Number of samples to be drawn

    Returns:

      test_samples - The drawn samples

      entropy - MC estimate of the entropy

    Return type:

      tuple(tf.Tensor, float)

  iterate_and_log(n: int) → dict

    Perform one learning iteration and computes and logs metrics.

    Parameters:

      n – int The current iteration

    Returns:

      A dictionary containing metrics and plots that we want to log.

    Return type:

      dict

  log_to_disk(n: int)

    Saves the model parameters to the hard drive

    Parameters:

      n – int The current iteration