latte.functional.disentanglement.sap
Module Contents
Functions
|
Calculate Separate Attribute Predictability (SAP) between latent vectors and attributes |
- sap(z, a, reg_dim=None, discrete=False, l2_reg=1.0, thresh=1e-12)
Calculate Separate Attribute Predictability (SAP) between latent vectors and attributes
Separate Attribute Predictability (SAP) is similar in nature to MIG but, instead of mutual information, uses the coefficient of determination for continuous attributes and classification accuracy for discrete attributes to measure the extent of relationship between a latent dimension and an attribute. SAP is given by
\[\operatorname{SAP}(a_i, \mathbf{z}) = \mathcal{S}(a_i, z_j)-\mathcal{S}(a_i, z_k),\]where \(j=\operatorname{arg}\max_d \mathcal{S}(a_i, z_d)\), \(k=\operatorname{arg}\max_{d≠j} \mathcal{S}(a_i, z_d)\), and \(\mathcal{S}(\cdot,\cdot)\) is either the coefficient of determination or classification accuracy.
If reg_dim is specified, \(j\) is instead overwritten to reg_dim[i], while \(k=\operatorname{arg}\max_{d≠j} \mathcal{S}(a_i, z_d)\) as usual.
- 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. See sklearn.svm.LinearSVC for more details.
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,)
See also
sklearn.svm.LinearSVCLinear SVC
References
[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.