Unsupervised Learning under Latent Label Shift
Abstract
What sorts of structure might enable a learner to discover classes from unlabeled data?
Traditional approaches rely on feature-space similarity and heroic assumptions on the data.
In this paper, we introduce unsupervised learning under
Latent Label Shift (LLS), where we have access to unlabeled data from multiple domains such that the label marginals p d p y q can shift across domains but the class conditionals p p x | y q do not.
This work instantiates a new principle for identifying classes: elements that shift together group together.
For finite input spaces, we establish an isomorphism between LLS and topic modeling: inputs correspond to words, domains to documents, and labels to topics.
Addressing continuous data, we prove that when each label’s support contains a separable region, analogous to an anchor word, oracle access to p p
d
| x q suffices to identify p d p y q and p d p y | x q up to permutation.
Thus motivated, we introduce a practical algorithm that leverages domain-discriminative models as follows: (i) push examples through domain discriminator p p
d | x q ; (ii) discretize the data by clustering examples in p p d | x q space; (iii) perform non-negative matrix factorization on the discrete data; (iv) combine the recovered p p y | d q with the discriminator outputs p p d | x q to compute p d p y | x q @ d .
With semi-synthetic experiments, we show that our algorithm can leverage domain information to improve state of the art unsupervised classification methods.
We reveal a failure mode of standard unsupervised classification methods when dataspace similarity does not indicate true groupings, and show empirically that our method better handles this case.
Our results establish a deep connection between distribution shift and topic modeling, opening promising lines for future work 2 .
Introduction
Discovering systems of categories from unlabeled data is a fundamental but ill-posed challenge in machine learning.
Typical unsupervised learning methods group instances together based on featurespace similarity.
Accordingly, given a collection of photographs of animals, a practitioner might hope that, in some appropriate feature space, images of animals of the same species should be somehow similar to each other.
But why should we expect a clustering algorithm to recognize that dogs viewed in sunlight and dogs viewed at night belong to the same category?
Why should we expect that butterflies and caterpillars should lie close together in feature space?
In this paper, we offer an alternative principle according to which we might identify a set of classes: we exploit distribution shift across times and locations to reveal otherwise unrecognizable groupings among examples.
For example, if we noticed that whenever we found ourselves in a location where butterflies are abundant, caterpillars were similarly abundant, and that whenever butterflies were scarce, caterpillars had a similar drop in prevalence, we might conclude that the two were tied to the same underlying concept, no matter how different they appear in feature space.
In short, our principle suggests that latent classes might be uncovered whenever instances that shift together group together .
pairs
Domain Domain
Domain r
D o m a i n
D i sc r
i m i n a t
o r
Cluster
NMF
Formalizing this intuition, we introduce the problem of unsupervised learning under Latent Label
Shift (LLS).
Here, we assume access to a collection of domains d P t 1 , . . .
, r u , where the mixture proportions p d p y q vary across domains but the class conditional distribution p p x | y q is domaininvariant.
Our goals are to recover the underlying classes up to permutation, and thus to identify both the per-domain mixture proportions p d p y q and optimally adapted per-domain classifiers p d p y | x q .
The essential feature of our setup is that only the true y ’s, as characterized by their class-conditional distributions p p x | y q , could account for the observed shifts in p
d p x q .
We prove that under mild assumptions, knowledge of this underlying structure is sufficient for inducing the full set of categories.
First, we focus on the tabular setting , demonstrating that when the input space is discrete and finite, LLS is isomorphic to topic modeling [8].
Here, each distinct input x maps to a word each latent label y maps to a topic and each domain d maps to a document.
In this case, we can apply standard identification results for topic modeling [20, 4, 27, 33, 12] that rely only on the existence of anchor words within each topic (i.e., for each label y there is at least one x in the support of y , that is not in the support of any y 1 ‰ y ).
Here, standard methods based on Non-negative Matrix
Factorization (NMF) can recover each domain’s underlying mixture proportion p d p y q and optimal predictor p d p y | x q [20, 33, 27].
However, the restriction to discrete inputs, while appropriate for topic modeling, proves restrictive when our interests extend to high-dimensional continuous input spaces.
Then, to handle high-dimensional inputs, we propose Discriminate-Discretize-Factorize-Adjust (DDFA) , a general framework that proceeds in the following steps: (i) pool data from all domains to produce a mixture distribution q p x, d q ; (ii) train a domain discriminative model f to predict q p d | x q ; (iii) push all data through f , cluster examples in the pushforward distribution, and tabularize the data based on cluster membership; (iv) solve the resulting discrete topic modeling problem (e.g., via
NMF), estimating q p y, d q up to permutation of the latent labels; (v) combine the predicted q p d | x q and q p y, d q to estimate p d p y q and p d p y | x q .
In developing this approach, we draw inspiration from recent works on distribution shift and learning from positive and unlabeled data that (i) leverage black box predictors to perform dimensionality reduction [40, 23, 24]; and (ii) work with anchor sets , separable subsets of continuous input spaces that belong to only one class’s support [52, 41, 21, 6, 24].
Our key theoretical result shows that domain discrimination ( q p d | x q ) provides a sufficient representation for identifying all parameters of interest.
Given oracle access to q p d | x q (which is identified without labels), our procedure is consistent.
Our analysis reveals that the true q p d | x q maps all points in the same anchor set to a single point mass in the push-forward distribution.
This motivates our practical approach of discretizing data by hunting for tight clusters in q p d | x q space.
In semi-synthetic experiments, we adapt existing image classification benchmarks to the LLS setting, sampling without replacement to construct collections of label-shifted domains.
We note that training a domain discriminative classifier is a difficult task, and find that warm starting the initial layers of our model with pretrained weights from unsupervised approaches can significantly boost performance.
We show that warm-started DDFA outperforms state-of-the-art (SOTA) unsupervised approaches when domain marginals p d p y q are sufficiently sparse.
In particular, we observe improvements of as much as 30% accuracy over unsupervised SOTA on CIFAR-20.
Further, on subsets of FieldGuide dataset, where similarity between species and diversity within a species leads to failure of unsupervised learning, we show that DDFA recovers the true distinctions.
To be clear, these are not apples-to- apples comparisons: our methods are specifically tailored to the LLS setting.
The takeaway is that the structure of the LLS setting can be exploited to outperform the best unsupervised learning heuristics.
Related Work
Unsupervised Learning Standard unsupervised learning approaches for discovering labels often rely on similarity in the original data space [42, 50].
While distances in feature space become meaningless for high-dimensional data, deep learning researchers have turned to similarity in a representations space learned via self-supervised contrastive tasks [44, 19, 26, 11], or similarity in a feature space learned end-to-end for a clustering task [9, 10, 47, 57].
Our problem setup closely resembles independent component analysis (ICA), where one seeks to identify statistically independent signal components from mixtures [34].
However, ICA’s assumption of statistical independence among the components does not obtain in our setup.
In topic modeling [8, 4, 33, 12, 46], documents are modeled as mixtures of topics, and topics as categorical distributions over a finite vocabulary.
Early topic models include the well-known Latent Dirichlet Allocation (LDA) [8], which assumes that topic mixing coefficients are drawn from a Dirichlet distribution, along with papers with more relaxed assumptions on the distribution of topic mixing coefficients (e.g., pLSI)
The topic modeling literature often draws on non-negative Matrix Factorization (NMF) methods [45, 53], which decompose a given matrix into a product of two matrices with non-negative elements [18, 16, 25, 28].
In both Topic Modeling and NMF, a fundamental problem has been to characterize the precise conditions under which the system is uniquely identifiable [20, 4, 33, 12].
The anchor condition (also referred to as separability) is known to be instrumental for identifying topic models [4, 12, 33, 20].
In this work, we extend these ideas, leveraging separable subsets of each label’s support (the anchor sets) to produce anchor words in the discretized problem.
Existing methods have attempted to extend latent variable modeling to continuous input domains by making assumptions about the functional forms of the class-conditional densities, e.g., restricting to Gaussian mixtures [50, 49].
A second line of approach involves finding an appropriate discretization of the continuous space [56].
Distribution Shift under the Label Shift Assumption The label shift assumption, where p d p y q can vary but p p x | y q cannot, has been extensively studied in the domain adaptation literature [51, 54, 60, 40, 29, 23] and also features in the problem of learning from positive and unlabeled data [22, 7, 24].
For both problems, many classical approaches suffer from the curse of dimensionality, failing in the settings where deep learning prevails.
Our solution strategy draws inspiration from recent work on label shift [40, 1, 5, 23] and PU learning [7, 41, 52, 24] that leverage black-box predictors to produce sufficient low-dimensional representations for identifying target distributions of interest (other works leverage black box predictors heuristically [36]).
Key differences: While PU learning requires identifying one new class for which we lack labeled examples provided that the positive class contains an anchor set [24], LLS can identify an arbitrary number of classes (up to permutation) from completely unlabeled data, provided a sufficient number of domains.
Domain Generalization
The related problem of Domain Generalization (DG) also addresses learning with data drawn from multiple distributions and where the domain identifiers play a key role [43, 2].
However in DG, we are given labeled data from multiple domains, and our goal is to learn a classifier that can generalize to new domains.
By contrast, in LLS, we work with unlabeled data only, leveraging the problem structure to identify the underlying labels.
Latent Label Shift Setup
Notation For a vector v P R p , we use v j to denote its j th entry, and for an event E , we let I r E s denote the binary indicator of the event.
By | A | , we denote the cardinality of set A .
With r n s , we denote the set t 1 , 2 , . . . , n u .
We use r A
s i,j to access the element at p i, j q in A .
Let X be the input space and Y “ t 1 , 2 , . . .
, k u be the output space for multiclass classification.
We assume throughout this work that the number of true classes k is known.
Throughout this paper, we use capital letters to denote random variables and small case letters to denote the corresponding values they take.
For example, by X we denote the input random variable and by x , we denote a value that X may take.
We now formally introduce the problem of unsupervised learning under LLS.
In LLS, we assume that we observe unlabeled data from r domains.
Let R “ t 1 , 2 , . . .
, r u be the set of domains.
By p d , we denote the probability density (or mass) function for each domain d P R .
D
Y
X
Definition 1 (Latent label shift) .
We observe data from r domains.
While the label distribution can differ across the domains, for all d, d 1 P R and for all p x, y q P X ˆ Y , we have p d p x | y q “ p d 1 p x | y q .
Simply put, Definition 1 states that the conditional distribution p d p x | y q remains invariant across domains, i.e., they satisfy the label shift assumption.
Thus, we can drop the subscript on this factor, denoting all p d p x | y q by p p x | y q .
Crucially, under LLS, p d p y q can vary across different domains.
Under LLS, we observe unlabeled data with domain label tp x 1 , d 1 q , p x 2 , d 2 q , . .
, p x n , d n qu .
Our goal breaks down into two tasks.
Up to permutation of labels, we aim to (i) estimate the label marginal in each domain
p d
p y q ; and (ii) estimate the optimal per-domain predictor p d p y | x q .
Mixing distribution Q A key step in our algorithm will be to train a domain discriminative model.
Towards this end we define Q , a distribution over X ˆ Y ˆ R , constructed by taking a uniform mixture over all domains.
By q , we denote the probability density (or mass) function of Q .
Define Q such that q p x, y | D “ d q “ p d p x, y q , i.e., when we condition on D “ d
we recover the joint distribution over X ˆ Y specific to that domain d .
For all d P R , we define γ d “ q p d q , i.e., the prevalence of each domain in our distribution Q .
Notice that q p x, y q is a mixture over the distributions t p d p x, y qu d P R , with t γ d u d P R as the corresponding mixture coefficients.
Under LLS (Definition 1), X does not depend on D when conditioned on Y (Fig. 2).
Additional notation for the discrete case To begin, we setup notation for discrete input spaces with |X| “ m .
Without loss of generality, we assume that X “ t 1 , 2 , . . .
, m u .
The label shift assumption allows us to formulate the label marginal estimation problem in matrix form.
Let Q X | D be an m ˆ r matrix such that r Q X | D s i,d “ p d p X “ i q , i.e., the d -th column of Q X | D is p d p x q .
Let Q X | Y be an m ˆ k matrix such that r Q X | Y s i,j “ p p X
“ i | Y “ j q , the j -th column is a distribution over X given
Y “ j .
Similarly, define Q Y | D as a k ˆ r matrix whose d -th column is the domain marginal p d p y q .
Now with Definition 1, we have
[Equation]
Since this is true @
d P R , we can express this in a matrix form as Q X | D “ Q X | Y Q Y | D .
Additional assumptions Before we present identifiability results for the LLS problem, we introduce four additional assumptions required throughout the paper:
A.1 There are at least as many domains as classes, i.e., |R| ě |Y| .
A.
The matrix formed by label marginals (as columns) across different domains is full-rank, i.e., rank p Q Y | D q “ k . A.3 Equal representation of domains, i
e., for all d P R , γ d “ 1 { r .
A.4 Fix ϵ ą 0 .
For all y P Y , there exists a unique subdomain A y Ď X , such that q p A y q ě ϵ and x P A y if and only if the following conditions are satisfied: q p x | y q ą 0 and q p x | y 1 q “for all y 1 P Y zt y u .
We refer to this assumption as the ϵ -anchor sub-domain condition.
We now comment on the assumptions.
A.1–A.2 are benign, these assumptions just imply that the matrix Q Y | D is full row rank.
Without loss of generality, A.3 can be assumed when dealing with data from a collection of domains.
When this condition is not satisfied, one could just re-sample data points uniformly at random from each domain d .
Intuitively, A.4 states that for each label y P Y , we have some subset of inputs that only belong to that class y .
To avoid vanishing probability of this subset, we ensure at least ϵ probability mass in our mixing distribution Q .
The anchor word condition is related to the positive sub-domain in PU learning, which requires that there exists a subset of X in which all examples only belong to the positive class [52, 41, 21, 6].
Theoretical Analysis
In this section, we establish identifiability of LLS problem.
We begin by considering the case where the input space is discrete and formalize the isomorphism to topic modeling.
Then we establish the identifiability of the system in this discrete setting by appealing to existing results in topic modeling [33].
Finally, extending results from discrete case, we provide novel analysis to establish our identifiability result for the continuous setting.
Isomorphism to topic modeling Recall that for the discrete input setting, we have the matrix formulation: Q X | D “ Q X | Y Q Y | D .
Consider a corpus of r documents, consisting of terms from a vocabulary of size m .
Let D be an R m ˆ r matrix representing the underlying corpus.
Each column of
D represents a document, and each row represents a term in the vocabulary.
Each element r D s i,j represents the frequency of term i in document j .
Topic modeling [8, 32, 33, 4] considers each document to be composed as a mixture of k topics.
Each topic prescribes a frequency with which the terms in the vocabulary occur given that topic.
Further, the proportion of each topic varies across documents with the frequency of terms given topic remaining invariant.
We can state the topic modeling problem as: D “ CW , where C is an R m ˆ k matrix, r C s i,j represents the frequency of term i given topic j , and W is an R k ˆ r matrix, where r W s i,j represents the proportion of topic i in document j .
Note that all three matrices are column normalized.
The isomorphism is then between document and domain, topic and label, term and input sample, i.e.,
D “ CW ” Q X | D “ Q X | Y Q Y | D .
In both the cases, we are interested in decomposing a known matrix into two unknown matrices.
This formulation is examined as a non-negative matrix factorization problem with an added simplicial constraint on the columns (columns sum to 1) [3, 27].
Identifiability of the topic modeling problem is well-established [20, 4, 27, 33, 12].
We leverage the isomorphism to topic modeling to extend this identifiability condition to our LLS setting.
We formalize the adaptation here:
Theorem 1.
(adapted from Proposition 1 in Huang et al.
[33]) Assume A.1, A.2 and A.4 hold (A.4 in the discrete setting is referred to as the anchor word condition).
Then the solution to
[Equation]
D is uniquely identified up to permutation of class labels.
We refer readers to Huang et al.
[33] for a proof of this theorem.
Intuitively, Theorem 1 states that if each label y has at least one token in the input space that has support only in y , and A.1, A.2 hold, then the solution to Q X | Y , Q Y | D is unique.
Furthermore, under this condition, there exist algorithms that can recover Q X | Y , Q Y | D within some permutation of class labels [33, 27, 3, 4].
Extensions to the continuous case We will prove identifiability in the continuous setting, when
X “ R p for some p ě 1 .
In addition to A.1–A.4, we make an additional assumption that we have oracle access to q p d | x q , i.e., the true domain discriminator for mixture distribution Q .
This is implied by assuming access to the marginal q p x, d q from which we observe our samples.
Formally, we define a push forward function f such that r f p x qs d “ q p d | x q , then push the data forward through f to obtain outputs in ∆ r ´ 1 .
In the proof of Theorem 2, we will show that these outputs can be discretized in a fashion that maps anchor subdomains to anchor words in a tabular, discrete setting.
We separately remark that the anchor word outputs are in fact extreme corners of the convex polytope in ∆ r ´ 1 which encloses all f p x q mass; we discuss this geometry further in App.
F.
After constructing the anchor word discretization, we appeal to Theorem 1 to recover Q Y | D .
Given Q Y | D , we show that we can use Bayes’ rule and the LLS condition (Definition 1) to identify the distribution q p y | x, d q “ p d p y | x q over latent variable y .
We formalize this in the following theorem:
Theorem 2.
Let the distribution Q over random variables X, Y, D satisfy Assumptions A.1–A.4.
Assuming access to the joint distribution q p x, d q , and knowledge of the number of true classes k , we show that the following quantities are identifiable:
[Equation]
ii) q p y | X “ x q , for all x P X that lies in the support (i.e. q p x q ą 0 ); and (iii) q p y | X “ x, D “ d q , for all x P X and d P R such that q p x, d q ą 0 .
Before presenting a proof sketch for Theorem 2, we first present key lemmas (we include their proofs in App.
A).
Lemma 1.
Under the same assumptions as Theorem 2, the matrix Q Y | D and f p x q “ q p d | x q uniquely determine q p y | x q for all y P Y and x P X such that q p x q ą 0 .
Lemma 1 states that given matrix Q Y | D and oracle domain discriminator, we can uniquely identify q p y | x q .
In particular, we show that for any x P X , q p d | x q can be expressed as a convex combination of the k columns of Q D | Y (which is computed from Q Y | D and is column rank k ) and the coefficients of the combination are q p y | x q .
Combining this with the linear independence of the columns of Q D | Y , we show that these coefficients are unique.
In the following lemma, we show how the identified q p y | x q can then be used to identify q p y | x, d q :
Lemma 2.
Under the same assumptions as Theorem 2, for all y P Y , and x P X such that q p x, d q ą 0 .
the matrix Q Y | D and q p y | x q uniquely determine q p y | x, d q .
To prove Lemma 2, we show that we can combine the conditional distribution over the labels given a sample x P X with the prior distribution of the labels in each domain to determine the posterior distribution over labels given the sample x and the domain of interest.
Next, we introduce a key property of the domain discriminator classifier f :
Lemma 3.
Under the same assumptions as Theorem 2, for all x, x 1 in anchor sub-domain, i.e., x, x 1 P A y for a given label y P Y , we have f p x q “ f p x 1 q .
Further, for any y P Y , if x P A y , x 1 R A y , then f p x q ‰ f p x 1 q .
Lemma 3 implies that the oracle domain discriminator f maps all points in an anchor subdomain, and only those points in that anchor subdomain to the same point in f p x q “ q p d | x q space.
We can now present a proof sketch for Theorem 2 (full proof in App.
B):
Proof sketch of Theorem 2.
The key idea of the proof lies in proposing a discretization such that some subset of anchor subdomains for each label y in the continuous space map to distinct anchor words in discrete space.
In particular, if there exists a discretization of the continuous space X that for any y P Y , maps all
x P A y to the same point in the discrete space, but no x R A y maps to this point, then this point serves as an anchor word.
From Lemma 3, we know that all the x P A y and only the x P A y get mapped to specific points in the f p x q space.
Pushing all the x P X through f , we know from A. that there exists k point masses of size ϵ , one for each f p
A y q in the f p x q “ q p d | x q space.
We can now inspect this space for point masses of size at least ϵ to find at most O p 1 { ϵ q such point masses among which are contained the k point masses corresponding to the anchor subdomains.
Discretizing this space by assigning each point mass to a group (and non-point masses to a single additional group), we have k groups that have support only in one y each.
Thus, we have achieved a discretization with anchor words.
Further, since the discrete space arises from a pushforward of the continuous space through f , the discrete space also satisfies the latent label shift assumption A.1.
We now use
Theorem 1 to claim identifiability of Q Y | D .
We then use Lemmas 1 and 2 to prove parts (ii) and (iii).
DDFA Framework
Motivated by our identifiability analysis, in this section, we present an algorithm to estimate
Q Y | D , q p y | x q , and q p y | x, d q when X is continuous by exploiting domain structure and approximating the true domain discriminator f .
Intuitively, q p y | x, d q is the domain specific classifier p d
p y | x q and q p y | x q is the classifier for data from aggregated domains.
Q Y | D captures label marginal for individual domains.
A naive approach would be to aggregate data from different domains and exploit recent advancements in unsupervised learning [57, 47, 9, 10].
However, aggregating data from multiple domains loses the domain structure that we hope to leverage.
We highlight this failure mode of the traditional unsupervised clustering method in Sec.
We remark that DDFA draws heavy inspiration from the proof of Theorem 2, but we do not present a guarantee that the DDFA solution will converge to the identifiable solution.
This is primarily due to the K-means clustering heuristic we rely on, which empirically offers effective noise tolerance, but theoretically has no guarantee of correct convergence.
Discriminate We begin Algorithm 1 by creating a split of the unlabeled samples into the training and validation sets.
Using the unlabeled data samples and the domain that each sample originated from, we first train a domain discriminative classifier p f .
The domain discriminative classifier outputs a distribution over domains for a given input.
This classifier is trained with cross-entropy loss to predict the domain label of each sample on the training set.
With unlimited data, the minimizer of this loss is the true f , as we prove in App.
C. To avoid overfitting, we stop training p f
when the crossentropy loss on the validation set stops decreasing.
Note that here the validation set also only contains domain indices (and no information about true class labels).
Discretize We now push forward all the samples from the training and validation sets through the domain discriminator to get vector p
f p x i q for each sample x i .
In the proof of Theorem 2, we argue that when working with true f , and the entire marginal q p x, d q , we can choose a discretization satisfying the anchor word assumption by identifying point masses in the distribution of f p x q and filtering to include those of at least ϵ mass.
In the practical setting, because we have only a finite set of data points and a noisy p f , we use clustering to approximately find point masses.
We choose m ě k and
6: p q p c p X q “ a | D “
[Table]
Ð
ř i Pr n s I r c p x i q“ a, d i “
[Table]
s ř j Pr n s I r d j “
[Table]
s 7: b q
Q c
[Table]
q
[Table]
Y
D p
Q c q output p Q
D , f recover m clusters with any standard clustering procedure (e.g. K-means).
This clustering procedure is effectively a useful, but imperfect heuristic: if the noise in p f is sufficiently small and the clustering sufficiently granular, we hope that our m discovered clusters will include k pure clusters, each of which only contains data points from a different anchor subdomain which are tightly packed around the true f p A y q for the corresponding label y .
Clustering in this space is superior to a naive clustering on the input space because close proximity in this space indicates similarity in q p d | x q .
Let us denote the learned clustering function as c , where c p x q is the cluster assigned to a datapoint x .
We now leverage the cluster id c p x i q of each sample x i to discretize sample into a finite discrete space r m s .
Combining cluster id with the domain source d i for each sample, we estimate p Q c p X q| D by simply computing, for each domain, the fraction of its samples assigned to each cluster.
Factorize We apply an NMF algorithm to p Q c p X q| D to obtain estimates of p Q c p X q| Y and p Q Y | D .
Adjust We begin Algorithm 2 by considering a test point p x 1 , d 1 q .
To make a prediction, if we had access to oracle f and true Q Y | D , we could precisely compute q p y | x 1 q (Lemma 1).
However, in place of these true quantities, we plug in the estimates p f and p Q Y | D .
Since our estimates contain noise, the estimate p q p y | x 1 q is found by left-multiplying p f p x 1 q with the pseudo-inverse of p Q D | Y , as opposed to solving a sufficient system of equations.
As our estimates p f and p Q D | Y approach the true values, the projection of p f p x 1 q into the column space of p Q D | Y tends to p f p x 1 q itself, so the pseudo-inverse approaches the true solution.
Now we can use the constructive procedure introduced in the proof of
Lemma 2 to compute the plug-in estimate p q p y | x 1 , d 1 q “ p p d 1 p y | x 1 q .
Algorithm input p Q Y | D , p f, p x 1 , d 1 q „ q p x, d q 1: Populate p Q D | Y as r p Q D | Y s d,y Ð r p Q Y | D s y,d ř d 2 “ r d 2“ 1 r p Q Y | D s y,d2:
Assign p q p y | X “ x 1 q Ð „´ p Q D | Y ¯ : p
f p x 1 q ȷ y 3: Assign p q p y
X “ x 1 , D “ d 1 q Ð r p Q D | Y s d 1 ,y p q p y | X “ x 1 q ř y
Pr k s r p Q D
| Y s d 1 ,y 2 p q p y 2 | X “ x 1 q 4: y pred Ð arg max y Pr k s p q p y | X “ x 1 , D “ d 1 q output : p q p y | X “ x 1 , D “ d 1 q “ p p d 1 p y | x 1 q , p q p y | X “ x 1 q , y pred
Experiments
Experiment code is available at https://github.com/acmi-lab/Latent-Label-Shift-DDFA .
Baselines We select the unsupervised classification method SCAN as a state-of-the-art baseline [57].
SCAN pretrains a ResNet [30] backbone using SimCLR [11] and MoCo [31] setups (pretext tasks).
SCAN then trains a clustering head to minimize the SCAN loss (refer [57] for more details) 3 .
We make sure to evaluate SCAN on the same potentially class-imbalanced test subset we create for each experiment.
Since SCAN is fit on a superset of the data DDFA sees, we believe this gives a slight data advantage to the SCAN baseline (although we acknowledge that the class balance for SCAN training is also potentially different from its evaluation class balance).
To evaluate SCAN, we use the public pretrained weights available for CIFAR-10, CIFAR-20, and ImageNet-50.
We also train
SCAN ourselves on the train and validation portions of the FieldGuide2 and FieldGuide28 datasets with a ResNet18 backbone and SimCLR pretext task.
We replicate the hyperparameters used for
CIFAR training.
Datasets First we examine standard multiclass image datasets CIFAR-10, CIFAR-20 [38], and
ImageNet-50 [17] containing images from 10, 20, and 50 classes respectively.
Images in these datasets typically focus on a single large object which dominates the center of the frame, so unsupervised classification methods which respond strongly to similarity in visual space are well-suited to recover true classes up to permutation.
These datasets are often believed to be separable (i.e., single true label applies to each image), so every example falls in an anchor subdomain (satisfying A.4).
Motivated by the application of LLS problem, we consider the FieldGuide dataset 4 , which contains images of moths and butterflies.
The true classes in this dataset are species, but each class contains images taken in immature (caterpillar) and adult stages of life.
Based on the intuition that butterflies from a given species look more like butterflies from other species than caterpillars from their own species, we hypothesize that unsupervised classification will learn incorrect class boundaries which distinguish caterpillars from butterflies, as opposed to recovering the true class boundaries.
Due to high visual similarity between members of different classes, this dataset may indeed have slight overlap between classes.
However, we hypothesize that anchor subdomain still holds, i.e., there exist some images from each class that could only come from that class.
Additionally, if we have access to data from multiple domains, it is natural to assume that within each domain the relative distribution of caterpillar to adult stages of each species stay relatively constant as compared to prevalence of different species.
We create two subsets of this dataset: FieldGuide2, with two species, and FieldGuide28, with 28 species.
LLS Setup The full sampling procedure for semisynthetic experiments is described in App.
D.
Roughly, we sample p d p y q from a symmetric Dirichlet distribution with concentration α { k , where k is the number of classes and α is a generation parameter that adjusts the difficulty of the synthetic problem, and enforce maximum condition number κ on Q Y | D .
Small α and small κ encourages sparsity in Q Y | D , so each label tends to only appear in a few domains.
Larger parameters encourages p d p y q to tend toward uniform.
We draw from test, train, and valid datasets without replacement to match these distributions, but discard some examples due to class imbalance.
Training and Evaluation
The algorithm uses train and validation data consisting of pairs of images and domain indices.
We train ResNet50 [30] (with added dropout) on images x i with domain indices d i as the label, choose best iteration by valid loss, pass all training and validation data through p f , and cluster pushforward predictions p
f p x i q into m ě k clusters with Faiss K-Means [37].
We compute the p
Q c p X q| D matrix and run NMF to obtain p Q c p X q| Y , p Q Y | D .
To make columns sum to 1, we normalize columns of p Q c p X q| Y , multiply each column’s normalization coefficient over the corresponding row of p
Q Y | D (to preserve correctness of the decomposition), and then normalize columns of p Q Y | D .
Some
NMF algorithms only output solutions satisfying the anchor word property [3, 39, 27].
We found the strict requirement of an exact anchor word solution to lead to low noise tolerance.
We therefore use the Sklearn implementation of standard NMF [13, 55, 48].
We instantiate the domain discriminator as ResNet18, and preseed its backbone with SCAN [57] pre-trained weights or [57] contrastive pre-text weights.
We denote these models DDFA (SI) and
DDFA (SPI) respectively.
We predict class labels with Algorithm 2 .
With the Hungarian algorithm, implemented in [14, 58], we compute the highest true accuracy among any permutation of these labels (denoted “Test acc”).
With the same permutation, we reorder rows of p P Y | D , then compute the average absolute difference between corresponding entries of p Q Y | D and Q Y | D (denoted “ Q Y | D err”).
[Table]
Results On CIFAR-10, we observe that DDFA alone is incapable of matching highly competitive state-of-the-art baseline SCAN performance—however, in suitably sparse problem settings (small α ), it comes substantially close, indicating good recovery of true classes.
Due to space constraints, we include CIFAR-10 results in App.
E. DDFA (SI) combines SCAN’s strong pretrain with domain discrimination fine-tuning to outperform SCAN in the easiest, sparsest setting and certain denser settings.
On CIFAR-20, baseline SCAN is much less competitive, so our DDFA(SI) dominates baseline SCAN in all settings except the densest (Table 1).
These results demonstrate how adding domain information can dramatically boost unsupervised baselines.
On FieldGuide-2, DDFA (SPI) outperforms SCAN baselines across all problem settings and domain counts (Table 5); in sparser settings, the accuracy gap is 20-30%.
In this dataset, SCAN performs only slightly above chance, reflecting perhaps a total misalignment of learned class distinctions with true species boundaries.
We do not believe that SCAN is too weak to effectively detect image groupings on this data; instead we acknowledge that the domain information available to DDFA (SPI) (and not to SCAN) is informative for ensuring recovery of the true class distinction between species as opposed to the visually striking distinction between adult and immature life stages.
Results from more domains are available in App.
E.
On FieldGuide-28 (Table 6), DDFA outperforms SCAN when
Q Y | D is sufficiently sparse (sampled with α : 0 .
5 or α : 3 ), with the highest observed accuracy difference ranging above 30-40%.
Conclusion
Our theoretical results demonstrate that under LLS, we can leverage shifts among previously seen domains to recover labels in a purely unsupervised manner, and our practical instantiation of the
DDFA framework demonstrates both (i) the practical efficacy of our approach; and (ii) that generic unsupervised methods can play a key role both in clustering discriminator outputs, and providing weights for initializing the discriminator.
We believe that this work is just the first step in a new direction for leveraging structural assumptions together with distribution shift to perform unsupervised learning.
Within the LLS setup, several components of the DDFA framework warrant further investigation: (i) the deep domain discriminator can be enhanced in myriad ways; (ii) for clustering discriminator outputs, we might develop methods specially tailored to our setting to replace the current generic clustering heuristic; (iii) clustering might be replaced altogether with geometrically informed methods that directly identify the corners of the polytope; (iv) the theory of LLS can be extended beyond identification to provide statistical results that might hold when q p d | x q can only be noisily estimated, and when only finite samples are available for the induced topic modeling problem; (v) when the number of true classes k is unknown, we may develop approaches to estimate this k .
[Table]
Limitations
Assumptions Our approach is limited by the set of assumptions needed (label shift, as many data domains as true latent classes, known true number of classes k , and other assumptions established in
A.1-A.4).
Future work should aim to relax some or all of these assumptions.
Theory The work does not include finite sample bounds for the DDFA algorithm.
In addition, we cannot include a formal guarantee that the clustering heuristic in the Discretize step of DDFA will retrieve pure anchor sub-domain clusters under potentially noisy black-box prediction of q p d | x q .
In particular, this problem is complicated by the difficulty of reasoning about the noise that may be produced by a neural network or other complex non-linear model (acting as the black-box domain discriminator), and by the lack of concrete guarantees that K-means will recover the anchor subdomains among its recovered clusters.
In particular, in the case in which the anchor subdomains do not contain all of the mass (equivalently, there are some x which could belong to more than one y ), the arbitrary distribution of mass outside of the anchor subdomains makes it difficult to reason about the behavior of K-means.
Semi-synthetic Experiments Semi-synthetic experiments present an ideal environment for evaluating under the precise label shift assumption.
However, we do not evaluate on datasets in which the separation into domains is organic, and the label shift is inherent.
Acknowledgements
SG acknowledges Amazon Graduate Fellowship and JP Morgan PhD Fellowship for their support.
ZL acknowledges Amazon AI, Salesforce Research, Facebook, UPMC, Abridge, the PwC Center, the Block Center, the Center for Machine Learning and Health, and the CMU Software Engineering
Institute (SEI) via Department of Defense contract FA8702-15-D-0002, for their generous support of
ACMI Lab’s research on machine learning under distribution shift.
A Proofs of Lemmas
In this section, we present several new lemmas which are required to prove Theorem 2, and provide proofs.
We also provide proofs for Lemmas 1, 2, and 3.
Lemma 4.
Let distribution Q over random variables X, Y, D satisfy A.1–A.4.
Then for all y P Y , q p
y q ą 0 .
That is, all labels have nonzero probability under Q .
Proof of Lemma 4.
Proof by contradiction.
Let y P Y with q p y q “ 0 .
[Equation]
Since q p y | D “ d q ě 0 for all d P R , we see that if q p y q “ 0 , then q p y | D “ d q “ 0 for all d P R .
Then r Q Y | D s y,d “ 0 for all d P R .
Then there is a row (row d ) in the matrix Q Y | D in which every entry is 0, so Q Y | D cannot be full row rank k .
This violates assumption A.2.
Then by contradiction we have shown q p y q ą 0 .
Lemma 5.
Let distribution Q over random variables X, Y, D satisfy Assumptions A.1–A.4.
Let x
P
X
such that q p x q ą 0 .
Then if x P A y for some y P Y , we have that q p y | X “ x q “ 1 , and for all y 1 P
Y zt y u , q p y 1 |
X “ x q “ 0 .
The converse is also true:
if q p y | X “ x q “ 1 for some y P Y and q p y 1 | X “ x q “ 0 @ y 1 P Y zt y u , then we know that x P A y .
Proof of Lemma 5.
We prove directions one at a time.
Forward direction.
Assume x P A y .
[Equation]
q “ ÿ y 2 P Y q p y 2 q q p x | Y “ y 2 q “ q p y q q p x | Y “ y q ` ÿ y 1 P Y
zt y u
q p y 1 q q p x | Y “ y 1 q “ q p y q q p x | Y “ y q ` ÿ y 1 P Y
zt y u
q p y 1 q p 0 q “ q p y q q p x | Y “ y q .
Recalling q p x | y q ą 0 (by A.4) and q p y q ą 0 (by Lemma 4), we know that q p x q “ q p y q q p x | Y “ y q ą 0 .
Then q p y | X “ x q “ q p y q q p x | Y “ y q q p x q “ q p x q q p x q “ 1 (Bayes’ rule).
Because probabilities sum to 1, q p y | X “ x q ` ř y 1 P Y zt y u q p y 1 | X “ x q “ 1 .
Then because q p y | X “ x q “ 1 , we have : ř y 1 P Y
zt y u
q p y 1 | X “ x q “ 0 .
Then for all y 1 P Y zt y u , it must be that q p y 1 | X “ x q “ 0 .
Then we have shown q p y | X “ x q “ 1 , and for all y 1 P Y zt y u ,
q p y 1 | X “ x q “ 0 .
Converse.
Assume q p y | X “ x q “ 1 and for all y 1 P Y zt y u , q p
y
| X “ x q “ 0 .
We recall that q p x q ą 0 .
Also, q p y q ą 0 by Lemma 4.
Then q p x | Y “ y q “ q p y | X “ x q q p x q q p y q “ p 1 q q p x q q p y q ą 0 .
Let y 1 P Y
zt y u .
Then q p x | Y “ y 1 q “ q p y 1 | X “ x q q p x q q p y 1 q “ p 0 q q p x q q p y 1 q “ 0 .
Then because q p x | Y “ y q ąand @
y 1 P Y zt y u , q p x | Y “ y 1 q “ 0 , we see that x P A y .
Lemma 6.
Let random variables X, Y, D and distribution Q satisfy Assumptions A.1–A.4.
Then, the matrix Q D | Y , defined as an r ˆ k matrix whose elements are r Q D | Y s i,j “ Q p D “ i | Y “ j q , and in which each column is a conditional distribution over the domains given a label, has linearly independent columns.
Furthermore, Q D | Y can be computed directly from only Q Y | D .
Proof of Lemma 6.
Let random variables X, Y, D and distribution Q satisfy Assumptions A.1–A.4.
Each r Q D | Y s d,
[Equation]
Since each y th column of Q D | Y is a probability distribution that sums to 1, and rq p y q is constant down each y th column, we can obtain Q D | Y by simply taking Q J Y | D , in which each r Q J Y
| D s d,y “ r Q Y | D s y,d “ q p y | D “ d q , and normalizing the columns so they sum to 1.
The matrix Q Y | D has linearly independent rows by Assumption A.2.
Then Q J Y | D has linearly independent columns.
Scaling these columns by a nonzero value does not change their linear independence, so the columns of Q D | Y are also linearly independent.
Then matrix Q D | Y has linearly independent columns, and can be computed by taking Q J Y | D and normalizing its columns.
Lemma 7.
Let random variables X, Y, D and distribution Q satisfy Assumptions A.1–A.4.
Let d P R , x P X , y P Y .
Then q p d | X “ x, Y “ y q “ q p d | Y “ y q .
Proof of Lemma 7.
[Equation]
Lemma 1.
We restate this lemma, first presented in Sec. 4, for convenience.
Let the distribution Q over random variables X, Y, D satisfy Assumptions A.1–A.4.
Then the matrix Q Y | D and f p x q “ q p d | x q uniquely determine q p y | x q for all y P Y and x P X such that q p x q ą 0 .
Proof of Lemma 1.
Let distribution Q over random variables X, Y, D satisfy Assumptions A.1-A.4.
Let x P X with q p x q ą 0 , and y P Y .
Assume we know Q Y | D and r f p x qs d “ q p d | X “ x q .
With Q Y | D , we know q p y | D “ d q for all y, d .
Also, with the oracle domain discriminator f , we are able to obtain q p d | X “ x q for all x, d .
Formally, for all x P X , d P R ,
[Equation]
Now using Lemma 7,
[Equation]
Define the vector-valued function g : X Ñ R k such that r g p x qs y “ q p y | X “ x q for all x P supp Q p X q .
Q D | Y is a matrix of shape r ˆ k , with r Q D
| Y s i,j “ Q p D “ i | Y “ j q .
It can be computed from Q Y | D and has linearly independent columns—both facts shown in Lemma 6.
Then r f p x qs d “ q p d | X “ x q “ Q D | Y r d, : s g p x q , a product between the d th row vector of Q D | Y and the column vector g p x q .
Then f p x q “ Q D | Y g p x q .
This system is a linear system with r ě k equations.
Recalling that Q D | Y has k linearly independent columns, we can select any k linearly independent rows of Q D | Y to solve the equation for the true, unique solution for the unknown vector g p x q .
Another way to describe this is with the pseudo-inverse: g p x q “ p Q D | Y q : f p x q .
Then we have r g p x qs y “ q p y | X “ x q for all y P Y .
Lemma 2.
We restate this lemma, first presented in Sec. 4, for convenience.
Let the distribution Q over random variables X, Y, D satisfy Assumptions A.1–A.4.
Then for all y P Y , and x P X such that q p x, d q ą 0 .
the matrix Q Y | D and q p y | x q uniquely determine q p y | x, d q .
Proof of Lemma 2.
Let distribution Q over random variables X, Y, D satisfy Assumptions A.1-A.4.
Let x P X , d P R with q p x, d q ą 0 , and y P Y .
Assume we know matrix Q Y | D and q p y 1 | X “ x q , @
y 1 P Y .
We can compute Q D | Y from Q Y | D via
Lemma 6.
[Equation]
Using Lemma 7, q p d | X “ x, Y “ y q “ q p d | Y “ y q .
We apply this property.
[Equation]
The denominator q p d | X “ x q is constant across all values of y , so we can write that q p y | X “ x, D “ d q 9 q p d | Y “ y q q p y | X “ x q and normalize to find the probability:
[Equation]
We know q p d | Y “ y q as r Q D | Y s d,y , and every q p d | Y “ y 1 q , where y 1 P Y zt y u , as r Q D | Y s d,y 1 .
We also know q p y | X “ x q and every q p y 1 |
X “ x q where y 1 P Y zt y u , by the precondition assumptions.
Then we can compute q p y | X “ x, D “ d q .
Lemma 3.
We restate this lemma, first presented in Sec. 4, for convenience.
Let the distribution
Q over random variables X, Y, D satisfy Assumptions A.1–A.4.
Then for all x, x 1 in anchor subdomain, i.e., x, x 1 P A y for a given label y P Y , we have f p x q “ f p x 1 q .
Further, for any y P Y , if x P A y , x 1 R A y , then f p x q ‰ f p x 1 q .
Proof of Lemma 3.
Let distribution Q over random variables X, Y, D satisfy Assumptions A.1-A.4.
Recall f : R p Ñ R r is a vector-valued oracle function such that r f p x qs d “ q p d | X “ x q for all x P supp Q p X q .
Also let us recall that Q D | Y is defined as an r ˆ k matrix whose elements r Q D
| Y s i,j “
Q p D “ i | Y “ j q , and each column is a conditional distribution over the domains given a label.
It has linearly independent columns by Lemma 6.
First recognize that for all d P R , x P X such that q p x q ą 0 , r f p x qs d “ q p d | X “ x q “ ÿ y 2 P Y q p d, y 2 | X “ x q .
“ ÿ y 2 P Y q p d | Y “ y 2 , X “ x q q p y 2 | X “ x q .
Using Lemma 7, q p d | X “ x, Y “ y q “ q p d | Y “ y q .
We apply this property.
r f p x qs d “ q p d | X “ x q “ ÿ y 2 P Y q p d | Y “ y 2 q q p y 2 | X “ x q .
Then we can write f p x q “ ř y 2 P Y q p y 2 | X “ x q Q D | Y r : , y 2 s , where Q D | Y r : , y 2 s is the y 2 th column of
Q D | Y .
Now we could also rewrite f p x q “ Q D | Y r Q p Y “ 1 | X “ x q ... Q p Y “ k | X “ x qs J .
We now prove two key components of the lemma.
Let y P Y .
Let x P A
y
such that q p x q ą 0 .
Points in same anchor sub-domain map together.
Let x
1 P
A y such that q p x 1 q ą 0 .
We now seek to show that f p x q “ f p x 1 q .
Recall that x, x 1 P A y .
By Lemma 5, q p y | X “ x q “ q p y | X “ x 1 q “ 1 .
Also by lemma 5, @
y 2 P Y zt y u , q p y 2 |
X “ x q “ q p y 2 | X “ x 1 q “ 0 .
Then for all y 2 P Y , q p y 2 | X “ x q “ q p y 2 | X “ x 1 q .
Therefore, @
d P R , r f p x qs d “ q p d | X “ x q “ ÿ y 2 P Y q p d | Y “ y 2 q q p y 2 | X “ x q “ ÿ y 2 P Y q p d | Y “ y 2 q q p y 2 |
X “
[Equation]
Then f p x q “ f p x 1 q .
Point outside of the anchor sub-domain does not map with points in the anchor sub-domain .
Let x 0 R
A
y
such that q p x 0 q ą 0 .
We now seek to show that f p x q ‰ f p x 0 q .
Because x 0 R A y with q p x 0 q ą 0 , and because A y contains all x such that q p x q ą 0 , q p y | X “ x q “ 1 , and q p y 1 | X “ x q “for all y 1 P Y zt y u , then by Lemma 5, it must be that one of the following cases is true:
• Case 1: q p y | X “ x 0 q ‰• Case 2: q p y 1 | X “ x 0 q ą 0 for some y 1 P Y zt y u .
In all circumstances, there exists some y 2 P Y : q p y 2 | x 0 q ‰ q p y 2 | x q .
Then,
[Equation]
Because Q D | Y has linearly independent columns (shown in Lemma 6), we now know that
[Equation]
So f p x q ‰ f p x 0 q .
B Proof of Theorem
Theorem 2.
We restate this theorem, first presented in Sec. 4, for convenience.
Let the distribution Q over random variables X, Y, D satisfy Assumptions A.1–A.4.
Assuming access to the joint distribution q p x, d q , and knowledge of the number of true classes k , we show that the following quantities are identifiable: (i) Q Y | D , (ii) q p y | X “ x q , for all x P X that lies in the support (i.e. q p x q ą 0 ); and (iii) q p y | X “ x, D “ d q , for all x P X and d P R such that q p x, d q ą 0 .
Proof of Theorem 2.
Let distribution Q over random variables X, Y, D satisfy Assumptions A.1-A.4.
Recall f : X Ñ R r is a vector-valued oracle function such that r f p x qs d “ q p d | X “ x q for all x P supp Q p X q .
It is known because we know the marginal q p x, d q .
Let y P Y .
Then by Lemma 3, f sends every x P
A y (and no other x R A y ) to the same value.
We overload notation to denote this as f p A y q .
Then Q p f p X q
“ f p A y qq “ Q p X P A y q ě ϵ .
Then in the marginal distribution of f p X q with respect to distribution Q , there is a distinct point mass on each f p A y q , with mass at least ϵ .
Because we know the marginal q p x, d q , we know the marginal q p x q , so we can obtain the distribution of f p X q with respect to distribution Q .
If we analyze the marginal distribution of f p X q with respect to distribution Q , and recover all point masses with mass at least ϵ , we can recover no more than
O p 1 { ϵ q such points.
We set m P Z ` so that the number of points we recovered is m ´ 1 .
We denote a mapping ψ : R r Ñ r m s .
This mapping sends each value of f p x q corresponding to a point mass with mass at least ϵ to a unique index in t 1 , ..., m ´ 1 u .
It sends any other value in R p to m .
We note that the ordering of the point masses might have p m ´ 1 q ! permutations.
Notice that the point mass on each f p
A y q must be recovered among these m ´ 1 masses.
Recall that for all y P Y , f p x q “ f p A y q if and only if x P A y .
Then for all y P Y , ψ p f p x qq “ ψ p f p A y qq if and only if x P A y , because ψ does not send any other value in R r besides f p A y q to ψ p f p
A y qq .
For convenience, we now define a mapping c : X Ñ r m s such that c “ ψ ˝ f .
We will also abuse notation here to denote c p
A y q “ ψ p f p
A y qq .
Then c p X q is a discrete, finite random variable that takes values in r m s .
As c is a pushforward function on X , c p X q satisfies the label shift assumption because X does (i.e., when conditioning on Y , the distribution of c p X q is domain-invariant).
We might now define a matrix Q c p X q| D in which each entry r Q c p X q| D
s i,d “ Q p c
p
X q “ i | D “ d q .
We recall that we know the number of true classes k .
Then we know that there is a (possibly unique) unknown decomposition of the following form:
[Equation]
Using the label shift property,
[Equation]
To express this decomposition in matrix form, we write Q c p X q| D “ Q c p X q| Y Q Y | D .
Now we make observations about the unknown Q
[Equation]
|
[Equation]
For all y P Y ,
[Equation]
Then for each y P Y , the row of Q c p X q| Y with row index c
p
A y q is positive in the y th column, and zero everywhere else.
Restated, for each y P Y , there is some row with positive entry exactly in y th column.
This is precisely the anchor word assumption for a discrete, finite random variable.
We already know that Q Y | D is full row-rank, so because Q c p X q| Y satisfies the anchor word assumption, we can identify Q Y | D up to permutation of rows by Theorem 1.
In other words, when we set the constraint that the recovered Q c p X q| Y must have k columns and satisfy anchor word and the recovered Q Y | D must have k rows and be full row-rank, any solution to the decomposition Q c p X q| D “ Q c p X q| Y Q Y | D must identify the ground truth Q Y | D , up to permutation of its rows.
C Minimizing Cross-Entropy Loss yields Domain Discriminator
Let distribution Q over random variables X, Y, D satisfy Assumptions A.1-A.4.
We here examine the behavior of the cross-entropy loss, in the infinite data case (when we can work with expectations over the entire distribution instead of empirical expectations over a finite set of datapoints).
Define the vector-valued function z : R Ñ R r such that z p d q is a one-hot vector of length r , such that r z p d qs i “ 1 , iff d “ i .
Then we write the cross-entropy objective in expectation over the input random variable X and target random variable D as:
[Equation]
In order to find the minimizer of the cross entropy loss over the class of all functions from R p Ñ r
[Equation]
1 s r
[Equation]
we formulate the following objective with the Lagrange constraint:
[Equation]
˜
[Equation]
qs
[Equation]
¸
Setting partial derivative with respect to r f p
X qs r to 0 , we get ´
Q p D “ i | X q r f ‹ p
X qs i ` λ “ 0 and r f ‹ p
X qs i “ 1 λ Q p D “ i |
X q .
From KKT condition, the optimal solution lies on constraint surface, giving:
[Equation]
Finally, we get r f ‹ p
X qs i “ Q p D “ i | X q , so the optimal f ˚ by the cross entropy loss as defined will in fact recover the oracle domain discriminator.
83 0 .ȷ
(a) α : 0 . 5 , κ :„ 0 .
63 0 .ȷ
(b) α : 3 , κ :„ 0 . 42 0 .0 .
0 .ȷ
(c) α : 10 , κ :
D Additional Experimental Details
Our code is available at https://github.com/acmi-lab/Latent-Label-Shift-DDFA .
Here we present the full generation procedure for semisynthetic example problems, and discuss the parameters.
Choose a Dirichlet concentration parameter α ą 0 , maximum condition number κ ě(with respect to 2-norm), and domain count r ě k . 2.
For each y P r k s , sample p d p y q „ Dir p αk 1 k q . 3.
Populate the matrix Q Y | D with the computed p d p y q s. If cond p Q Y | D q ě k , return to stepand re-sample.
Distribute examples across domains according to Q Y | D , for each of train, test, and valid sets.
This procedure entails creating a quota number of examples for each (class, domain) pair, and drawing datapoints without replacement to fill each quota.
We must discard excess examples from some classes in the dataset due to class imbalance in the Q Y | D matrix.
Due to integral rounding, domains may be slightly imbalanced.
Conceal true class information and return p x i , d i q pairs.
It is important to note the role of κ and α in the above formulation.
Although they are unknown parameters to the classification algorithm, they affect the sparsity of the Q Y | D and difficulty of the problem.
Small α encourages high sparsity in p d p y q , and large α causes p d p y q to tend towards a uniform distribution.
We observe an example of the effects of α in Fig.
κ has a strong effect on the difficulty of the problem.
Consider the case when k “ 2 .
When κ “ 1 , the only potential Q Y | D matrices are I 2 up to row permutation (which means that domains and classes are exactly correlated, so the domain indicates the class and the problem is supervised).
In the other limit, if κ Ñ `8 , we may generate Q Y | D matrices that are singular, breaking needed assumptions for domain discriminator output to uniquely identify true class of anchor subdomains.
κ also helps control the class imbalance (if a row of Q Y | D is small, indicating that the class is heavily under-represented across all domains, the condition number will increase).
D.1 FieldGuide-2 and FieldGuide-28 Datasets
The dataset and description is available at https://sites.google.com/view/fgvc6/ competitions/butterflies-moths-2019 .
From this data we create two datasets FieldGuideand FieldGuide-28.
For FieldGuide-28 we select the 28 classes which have 1000 datapoints in the training file.
Since the test set provided in the website does not have annotations, we manually create a test set by sampling 200 datapoints from training file of each of the 28 classes.
Therefore, we finally have 22400 training points and 5600 testing points.
The FieldGuide-2 dataset is created by considering two classes from the created FieldGuide-28 dataset.
D.2 Hyperparameters and Implementation Details: SCAN baseline
In all cases, we initialize the SCAN [57] network with the clustering head attached, sample data according to the Q D | Y matrix, and predict classes.
With the Hungarian algorithm, implemented in
[14, 58], we compute the highest true accuracy among any permutation of these labels (denoted “Test acc”).
• CIFAR-10 and CIFAR-20 Datasets [38] We use ResNet-18 [30] backbone with weights trained by SCAN-loss and obtained from the SCAN repo https://github.com/ wvangansbeke/Unsupervised-Classification .
We use the same transforms present in the repo for test data.
• ImageNet-50 Dataset [17] We use ResNet-50 backbone with weights trained by SCANloss and obtained from the SCAN repo.
We use the same transforms present in the repo for test data.
• FieldGuide-2 and FieldGuide-28 Datasets
For each of the two datasets, we pretrain a different SCAN baseline network (including pretext and SCAN-loss steps) on all available data from the dataset.
The backbone for each is ResNet-18.
For training the pretext task, we use the same transform strategy used in the repo for CIFAR-10 data (with mean and std values as computed on the Fieldguide-28 dataset, and crop size 224).
For training SCAN, we resize the smallest image dimension to 256, perform a random horizontal flip and random crop to size 224.
We also normalize.
For validation we resize smallest image dimension to 256, center crop to 224, and normalize.
D.3 Hyperparameters and Implementation Details: DDFA (RI)
This is the DDFA procedure with random initialization.
The bulk of this procedure is described in
Section 6, but for completeness we reiterate here.
We train ResNet-50 [30] (with random initialization and added dropout) based on the implementation from https://github.com/kuangliu/pytorch-cifar on images x i with domain indices
d i as the label, choose best iteration by valid loss, pass all training and validation data through p f , and cluster pushforward predictions p
f p x i q into m ě k clusters with Faiss K-Means [37].
We compute the p
Q c p X q| D matrix and run NMF to obtain p Q c p X q| Y , p Q Y | D .
To make columns sum to 1, we normalize columns of p Q c p X q| Y , multiply each column’s normalization coefficient over the corresponding row of p Q Y | D (to preserve correctness of the decomposition), and then normalize columns of p Q Y | D .
Some NMF algorithms only output solutions satisfying the anchor word property [3, 39, 27].
We found the strict requirement of an exact anchor word solution to lead to low noise tolerance.
We therefore use the Sklearn implementation of standard NMF [13, 55, 48].
We predict class labels with Algorithm 2 .
With the Hungarian algorithm, implemented in [14, 58], we compute the highest true accuracy among any permutation of these labels (denoted “Test acc”).
With the same permutation, we reorder rows of p Q Y | D , then compute the average absolute difference between corresponding entries of p Q Y | D and Q Y | D (denoted “ Q Y | D err”).
In order to make hyperparameter choices for final experiments, such as the choice of the NMF solver, clustering algorithm, and learning rate, we consulted CIFAR-10 and CINIC-10 (similar to an extension of CIFAR-10)
[15] final test task accuracy.
We were also able to confirm our intuition that minimum validation loss on domain discriminator training corresponds to good final task performance.
Final evaluation runs on CIFAR-10 were made with the best hyperparameters found here.
We acknowledge that this may lead to test-set overfitting on CIFAR-10, but point out that on all other datasets, we consulted only validation loss on domain discriminator training when adjusting the hyperparameters.
Final evaluation runs used the following fixed hyperparameters:
Common Hyperparameters Hardware: A single NVIDIA RTX A6000 GPU was used for each experiment (on this hardware, trial length varies < 1 hour to 24 hours, depending on the dataset).
Architecture: ResNet-50 with added dropout Faiss KMeans number of iterations (niter):Faiss Kmeans number of clustering redos (nredo):Learning Rate: 0.
Learning Rate Decay: Exponential, parameter 0.
SKlearn NMF initialization: random
Dataset
-Specific
Hyperparameters • CIFAR-10 Dataset Training Epochs:Number of Clusters ( m ):• CIFAR-20 Dataset Training Epochs:Number of Clusters ( m ):• ImageNet-50 Dataset DDFA (RI) was not evaluated for this dataset due to poor performance of the domain discriminator without an appropriate pre-seed in early trials.
• FieldGuide-2 Dataset Training Epochs:Number of Clusters ( m ):• FieldGuide-28 Dataset DDFA (RI) was not evaluated for this dataset due to poor performance of the domain discriminator without an appropriate pre-seed in early trials.
D.4 Hyperparameters and Implementation Details: DDFA (SI) and DDFA (SPI)
This is the DDFA procedure with SCAN initialization.
DDFA (SI) uses the SCAN pretext + SCAN loss pretraining steps, while DDFA (SPI) uses only the SCAN pretext step.
The procedure is identical to the standard DDFA procedure, except that SCAN [57] pre-trained weights or SCAN [57] contrastive pre-text weights are used to initialize the domain discriminator before it is fine-tuned on the domain discrimination task.
Hyperparameters used also differ.
When SCAN pretrained weights are available, we use those.
When they are not, we train SCAN ourselves.
Much like SCAN (RI), we used CIFAR-10 final test acuracy to choose hyperparameters and make algorithm decisions.
For all other datasets, we consulted only validation domain discrimination loss.
Final evaluation runs used the following fixed hyperparameters:
Common Hyperparameters
Faiss KMeans number of iterations (niter):
Faiss Kmeans number of clustering redos (nredo):
Learning Rate: 0.
Learning Rate Decay: Exponential, parameter 0.
SKlearn NMF initialization: random
Dataset
-Specific Hyperparameters
• CIFAR-10 Dataset Architecture: ResNetPre-seed: Weights trained with SCAN pretext and SCAN-loss on entirety of CIFAR- (from SCAN repo).
Training
Epochs:
Number of Clusters ( m )
[Table]
Transforms used: Same as SCAN repo.
• CIFAR-20 Dataset Architecture:
ResNet-
Pre-seed: Weights trained with SCAN pretext and SCAN-loss on entirety of CIFAR- (from SCAN repo).
Training Epochs:Number of Clusters ( m ):Transforms used:
Same as SCAN repo.
• ImageNet-50 Dataset Architecture:
ResNetPre-seed: Weights trained with SCAN pretext and SCAN-loss on entirety of ImageNet- (from SCAN repo).
Training Epochs:Number of Clusters ( m ):Transforms used:
Same as SCAN repo.
• FieldGuide-2 Dataset Architecture: ResNetPre-seed: Weights trained with SCAN pretext on entirety of FieldGuide-2 (trained by us).
Training Epochs:Number of Clusters ( m ):Transforms used for pretext: Same strategy as CIFAR-10 in SCAN repo with appropriate mean, std, and crop size 224.
Transform used for SCAN:
Resize to 256, Random horizontal flip, Random crop to 224, normalize Learning rate used for SCAN:
0.001 (other hyperparameters were same as in SCAN repo for CIFAR-10)
Note :
During one of the random seeds of training, test data transforms were mismatched with train transforms (specifically, missing the Resize(256) transform on test only).
We consider this to disadvantage our approach for that random seed as compared to the SCAN baseline, which uses the proper transforms in all seeds.
We report these results regardless due to the fact that our approach still competes effectively even despite the transform disadvantage.
This random seed is the one displayed in Section 6 of the main paper.
The results shown in App.
E are different results, with the Resize(256) included (and are therefore the best, fair-footing evaluation comparison between our method and baseline).
• FieldGuide-28 Dataset Architecture: ResNetPre-seed: Weights trained with SCAN pretext on entirety of FieldGuide-28 (trained by us).
Training Epochs:Number of Clusters ( m ):Transforms used for pretext: Same strategy as CIFAR-10 in SCAN repo with appropriate mean, std, and crop size 224.
Transform used for SCAN:
Resize to 256, Random horizontal flip, Random crop
to 224, normalize
Learning rate used for SCAN: 0.01 (other hyperparameters were same as in SCAN repo for
CIFAR-10)
Note :
During one of the random seeds of training, test data transforms were mismatched with train transforms (specifically, missing the Resize(256) transform on test only).
We consider this to disadvantage our approach for that random seed as compared to the SCAN baseline, which uses the proper transforms in all seeds.
We report these results regardless due to the fact that our approach still competes effectively even despite the transform disadvantage.
This random seed is the one displayed in Section 6 of the main paper.
The results shown in App.
E are different results, with the Resize(256) included (and are therefore the best, fair-footing evaluation comparison between our method and baseline).
E Additional Experimental Results
We also investigated evaluations on the Waterbirds dataset, but although DDFA showed some reasonable results, we did not find SCAN hyperparameters that lead to a successful SCAN baseline.
Accordingly, we do not include these results as they do not present a reasonable comparison.
[Table]
[Table] [Table]
[Table] [Table]
[Table]
F Discussion of Convex Polytope Geometry
The geometric properties of topic modeling for finite, discrete random variables has been explored in depth in related works ([33, 20, 12]).
The observation that columns in Q X | D are convex combinations of columns in Q X | Y leads to a perspective on identification of the matrix decomposition as identification of the convex polytope in R m which encloses all of the columns of Q X | D (the corners of which correspond to columns of Q X | Y under certain identifiability conditions).
Here, we briefly discuss an interesting but somewhat different application of convex polytope geometry.
Instead of a convex polytope in R m with corners as columns of Q X | Y , we concern
[Figure]
ourselves with the convex polytope in R r with corners as columns in Q D | Y , which must enclose all values taken by the oracle domain discriminator f p x q for x P X , q p x q ą 0 .
Let us assume that Assumptions A.1–A.4 are satisfied.
We recall the oracle domain discriminator f defined such that r f p x qs d “ q p d | X “ x q .
Let x
P
X
“ R p .
Now, since the r values q p d | X “ x q for d P t 1 , 2 , ..., r u together constitute a categorical distribution, each of these r values lie betweenand 1 , and also their sum adds to 1.
Therefore the vector f p x q lies on the simplex ∆ r ´ 1 .
We now express f p x q as a convex combination of the k columns of Q D | Y .
We denote these column vectors
Q D | Y r : , y s for each y P Y “ r k s .
Note that each such vector also lies in the ∆ r ´ 1 simplex.
As an intermediate step in the proof of Lemma 3 given in App.
A, we showed that each f p x q is a linear combination of these columns of Q D | Y with coefficients q p y | X “ x q for all y P Y .
That is, we can rewrite f p x q
[Equation]
Since the coefficients in the linear combination are probabilities which, taken together, form a categorical distribution, they lie between 0 and 1 and sum to 1.
Thus, for all x P X with q p x q ą 0 , f p x q can be expressed as a convex combination of the columns of Q D | Y .
Therefore, for any x with q p x q ą 0 , f p x q lies inside the k ´ vertex convex polytope with corners as the columns of Q D | Y (which are linearly independent by Lemma 6).
This polytope is embedded in ∆ r ´ 1 .
Now consider x in an anchor sub-domain, that is x P
A y for some y P Y .
We know that if q p x q ą 0 , q p y | X “ x q “ 1 , q p y 1 | X “ x q “ 0 for all y 1 ‰ y
(Lemma 5).
Since the q p y | X “ x q are now onehot, we have that f p x q “ Q D | Y r : , y s for x P A y .
In words, this means that f p A y q is precisely the y th column of Q D | Y .
It follows that the domain discriminator maps each of the k anchor sub-domains exactly to a unique vertex of the polytope.
The situation is described in Fig.
We could now recover the columns of Q D | Y , up to permutation, with the following procedure:
Push all x P X through f . 2.
Find the minimum volume convex polytope that contains the resulting density of points on the simplex.
The vectors that compose the vertices of this polytope are the columns of Q D | Y , up to permutation.
Note that from Assumption A.4, we are guaranteed to have a region of the input space with at least ϵ ą 0 mass that gets mapped to each of the vertices when carrying out step (i).
Therefore, our discovered minimum volume polytope must enclose all of these vertices.
Since no mass will exist outside of the true polytope, requiring a minimum volume polytope will ensure that the recovered polytope fits the true polytope’s vertices precisely (as any extraneous volume outside of the true polytope must be eliminated).
Then step (ii) recovers Q D | Y , up to permutation of columns.
Having recovered Q D | Y , we can use Lemmas 1 and 2 to recover q p y | x, d q .
This procedure is a geometric alternative to the clustering approach outlined in Algorithm 1 .
In practice, fitting a convex hull around the outputs of a noisy, non-oracle estimated domain discriminator may be computationally expensive, and noise may lead this sensitive procedure to fail to recover the true vertices.
G Ablation Study on Number of Clusters
We conduct an ablation on the choice of m , the parameter indicating how many clusters to find in the q p d | x q space.
We use the CIFAR-20 dataset with 20 domains and employ DDFA (SI) and SCAN models, following the same hyperparameters as outlined in App.
D, except for modifying the choice of m for DDFA (SI).
Results are obtained as the average of three random seeds.
[Figure]
We
The number of true classes is 20 in CIFAR-20.
As seen in Fig.
5, when m is chosen to be 10, violating the typical constraint that m ě k , we can still solve for the solution, but we get poor performance, seeing a drop in accuracy as much as 20% from a better-chosen value of m .
Choosing m directly equal to or slightly larger than k provide the best performance, with a slope-off in performance at very large m .
The trend is roughly mirrored in Fig.
6, which shows how the reconstruction error modifies over the same change in m .
Under all settings, using m “ 10 ă k clusters provides a poor reconstruction, while the best reconstruction is found with m roughly equal to k or slightly larger.
Performance degrades as m grows very large, although the effect is very slight for the alpha = 0.5 setting.
Intuitively, these results show that breaking the m ě k condition not only violates the theoretical identifiability, but also leads to poorer empirical performance; choosing very large m can also lead to degraded performance, likely due to propagation of inaccuracies in the finite-sample estimation of the p Q c p X q| D matrix.
[Figure]
Q
[Figure] [Figure]
H Ablation Study with a Naïve Feature Space
One might ask whether the semantic meaning of the domain discrimination space is necessary in
DDFA; might we exchange the domain discrimination step in Algorithm 1 for a naive step in which we simply pass the input through an arbitrary feature extractor and then proceed to clustering in this space?
The first remark we make is that the domain discriminator does not purely provide a clustering representation; its semantic meaning is also important for the computation of the final domainadjusted p d p y | x q prediction, as a reliable estimate of q p d | x q , in conjunction with the estimate of the
Q Y | D matrix, allow us to estimate p d p y | x q via Algorithm 2.
Without this semantic meaning, our class prediction can be based only on a coarse prediction at the level of the cluster , not the individual datapoint.
However, if we are still determined to use an alternate representation, it is indeed possible to do so.
We illustrate a variant of DDFA using a naïve representation in Algorithms 3 and 4, and then evaluate this procedure on CIFAR-20 as an ablative study on DDFA.
We compare naïve results with standard
DDFA results, and with a traditional SCAN baseline, in Table 7.
Naïve Representation Variant of DDFA
The only major changes from the original DDFA for
Algorithm 3 are the removal of the need to train any p f domain discriminator, the use of the arbitrary representation space ϕ before clustering, and the output of the clustering discretization function c as well as p Q c p X q| Y (which are both discarded in the original procedure).
We need c and p Q c p X q| Y because in Algorithm 4 we will use them for domain-adjusted class prediction.
Algorithm 4 includes significant changes from the DDFA procedure.
Since we do not have the estimate of q p d | x q to use, we cannot directly reason about how different locations in the representation space induced by ϕ correspond to different probabilities of class labels.
However, because we have p
Q c p X q| Y and p Q Y | D , two outputs of the NMF decomposition in Algorithm 3, we can calculate a coarse prediction over labels y for each cluster, and then assign the same prediction to each point in input k r ě k i d i
Pr n q q “ a | D “ q Ð ř i Pr n s I r c p x i q“ a d i “ b s ř j Pr n s I r d j “ b s 5:
Populate p Q c p X q| D as r p Q c p X q| D
s a,b Ð p q p c
p
X
q “ a | D “ b q 6: p Q c p X q| Y p Q Y | D
Ð NMF p p Q c p X q| D
q output p Q c p X q| Y , p Q
| D function c input q y | c
Ð p q p c p x 1 q| Y “ y q p q p y | D “ d 1 q ř y 2 P Y p
q p c p x 1 q| Y “ y 2 q p q p y 2 | D “ d 1 q 5: y pred Ð arg max
y Pr k s p q p y | c p X q “ c p x 1 q , D “ d 1 q
[Equation]
that cluster.
To obtain the closed-form for this coarse prediction
p p
d p y | c p x qq used in Algorithm 4, we use the following derivation:
[Equation]
By label shift, q p c p x q| y, d q “ q p c p x q| y q , then
[Equation]
Combining Algorithms 3 and 4 allows us to empirically evaluate the behavior of an ablation on DDFA which does not use any domain discriminator.
For a reasonable comparison, we need a meaningful naïve representation space.
We use a SCAN pretrain backbone for ResNet-18, and remove the last linear layer in the ResNet-18 backbone in order to expose a 512-dimension representation space.
Since clustering in high-dimensional spaces often performs poorly, we also map this 512-dimension representation down to only r (the number of domains) dimensions using two different common dimensionality reduction methods: Independent Component Analysis (ICA) [35] and Principal
Component Analysis (PCA) [59].
These smaller-dimension clustering problems provide a closer comparison to the dimensionality of the clustering problem in the DDFA (SI) procedure, for which we employ m clusters.
Note: we use ICA and PCA implementations from scikit-learn [48].
SCAN, DDFA (RI), and DDFA (SI) experiment details are the same as explained in App.
D; in fact these are the same results presented for CIFAR-20 in Sec. 6.
In general, we can see that all variants of the Naïve/ablated DDFA procedure perform worse than
DDFA (SI) in all problem settings, over both metrics of interest.
All variants of the Naïve procedure are also worse than DDFA (RI) in both metrics of interest when α is 0.5 or 3, although they match or outpace it slightly in some of the hardest settings ( α “ 10 ).
It is worth pointing out that this is predominantly due to the fact that DDFA (RI) performs notably poorly at harder settings.
The SCAN baseline outpaces these Naïve approaches, in terms of classification accuracy, in all problem settings.
However, the Naïve approaches always achieve better Q Y | D reconstruction error.
[Table]
acc
Q Y
| D err
Test acc
Q Y
| D err
Test acc
Q Y
| D err
SCAN 0.
DDFA (RI) 0.
DDFA (SI) 0.
Naïve 0.
Naïve (ICA) 0.
Naïve (PCA) 0.
SCAN 0.
DDFA (RI) 0.
DDFA (SI) 0.
Naïve 0.
Naïve (ICA) 0.
Naïve (PCA) 0.
SCAN 0.
DDFA (RI) 0.
DDFA (SI) 0.
[Table]