deepof.model_utils.cluster_frequencies_regularizer

deepof.model_utils.cluster_frequencies_regularizer(soft_counts: Tensor, k: int, n_samples: int = 1000)

Compute the KL divergence between the cluster assignment distribution and a uniform prior across clusters.

While this assumes an equal distribution between clusters, the prior can be tweaked to reflect domain knowledge.

Parameters:
  • soft_counts (tf.Tensor) – soft counts per cluster

  • k (int) – number of clusters

  • n_samples (int) – number of samples to draw from the categorical distribution modeling cluster assignments.