latte.functional.disentanglement.sap

Module Contents

Functions

get_continuous_sap_score(z: numpy.ndarray, a: numpy.ndarray, thresh: float = 1e-12)

get_discrete_sap_score(z: numpy.ndarray, a: numpy.ndarray, l2_reg: float = 1.0)

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

Calculate Separate Attribute Predictability (SAP) between latent vectors and attributes

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

Calculate Separate Attribute Predictability (SAP) 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

  • l2_reg (float, optional) – regularization parameter for linear classifier, by default 1.0. Ignored if discrete is False.

  • thresh (float, optional) – threshold for latent vector variance, by default 1e-12. Latent dimensions with variance below thresh will have SAP contribution zeroed. Ignored if discrete is True.

Returns

SAP for each attribute

Return type

np.ndarray, (n_attributes,)

References

1
  1. Kumar, P. Sattigeri, and A. Balakrishnan, “Variational inference of disentangled latent concepts from unlabeled observations”, in Proceedings of the 6th International Conference on Learning Representations, 2018.