API Reference

class gmmvi.gmmvi_runner.GmmviRunner(config, log_metrics_interval)[source]

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)[source]

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()[source]

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

get_cheap_metrics()[source]

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()[source]

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)[source]

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[source]

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)[source]

Saves the model parameters to the hard drive

Parameters:

n – int The current iteration