latte.functional.disentanglement.modularity

Module Contents

Functions

modularity(z: numpy.ndarray, a: numpy.ndarray, reg_dim: Optional[List] = None, discrete: bool = False, thresh: float = 1e-12)

Calculate Modularity between latent vectors and attributes

latte.functional.disentanglement.modularity.modularity(z: numpy.ndarray, a: numpy.ndarray, reg_dim: Optional[List] = None, discrete: bool = False, thresh: float = 1e-12)

Calculate Modularity between latent vectors and attributes

Parameters
  • z (np.ndarray, (n_samples, n_features)) – a batch of latent vectors

  • a (np.ndarray, (n_samples, n_attributes) or (n_samples,)) – a batch of attribute(s)

  • reg_dim (Optional[List], optional) – regularized dimensions, by default None Attribute a[:, i] is regularized by z[:, reg_dim[i]]. If None, a[:, i] is assumed to be regularized by z[:, i].

  • discrete (bool, optional) – Whether the attributes are discrete, by default False

  • thresh (float, optional) – threshold for mutual information, by default 1e-12. Latent-attribute pair with variance below thresh will have modularity contribution zeroed.

Returns

Modularity for each attribute

Return type

np.ndarray, (n_attributes,)

References

1
  1. Ridgeway and M. C. Mozer, “Learning deep disentangled embeddings with the F-statistic loss,” in Proceedings of the 32nd International Conference on Neural Information Processing Systems, 2018, pp. 185–194.