{'fraction_non_alphanumeric': 0.03740379958021635, 'fraction_numerical': 0.009149130832570906, 'mean_word_length': 4.806875, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Odd-One-Out Representation Learning

The effective application of representation learning to real-world problems requires both techniques for learning useful representations, and also robust ways to evaluate properties of representations. Recent work in disentangled representation learning has shown that unsupervised representation learning approaches rely on fully supervised disentanglement metrics, which assume access to labels for ground-truth factors of variation. In many real-world cases ground-truth factors are expensive to collect, or difficult to model, such as for perception. Here we empirically show that a weakly-supervised downstream task based on odd-one-out observations is suitable for model selection by observing high correlation on a difficult downstream abstract visual reasoning task. We also show that a bespoke metric-learning VAE model which performs highly on this task also out-performs other standard unsupervised and a weakly-supervised disentanglement model across several metrics.


Introduction
The ability to solve many different tasks in a variety of different environments is considered a hallmark of intelligence [1,2,3]. Generalising in this manner requires representations of the world which effectively capture the most salient features of their environments [4,5,6,7]. Recent work in representation learning has been focused on the learning and evaluation of disentangled representations [8,9,10,11,12]. While such representations have been empirically shown to be useful for several downstream tasks [4,5,13,14], unsupervised disentanglement techniques rely on disentanglement metrics that require full knowledge of underlying ground-truth factors of variation.
While Locatello et al. [15] demonstrate that only observing very few fully labelled examples is sufficient for calculating disentanglement metrics, a number of interesting datasets will not have explicit labels for ground-truth factors and can therefore not be evaluated under existing metrics. For example, Locatello et al. [16] recently showed that comparison-based information (such as between ordered and temporally close video frames) can be used to learn disentangled representations. Without a particular focus on disentanglement, we extend previous work and demonstrate that similarity-based information is both relevant for learning representations but also for measuring useful properties of representations, where such measurements are otherwise inaccessible in many useful real-world scenarios. We contrast this approach with disentanglement learning and evaluation techniques to highlight the competitiveness of our method.
In particular, we propose a metric which relies on implicit pairwise-comparison information from triplets of observations, where one out of three objects is labelled as the odd-one-out (OoO) providing weak similarity constraints (i.e. one object is the most dis-similar to all other objects, and two objects are the most similar). Secondly, we leverage the OoO information to show that a bespoke Variational Auto-encoder (VAE) model outperforms existing unsupervised and a weakly-supervised state-of-theart disentanglement models across all disentanglement metrics (including the triplet-based metric as expected). Finally, we explore how useful weakly-supervised representations are for a practical downstream abstract visual reasoning task, using the procedurally generated Raven's Progressive Matrices (RPM) [17] task proposed by van Steenkiste et al. [7], which requires learners to infer abstract relations between objects and generalize these relations to unseen settings.

Methodology
We consider recent representation learning techniques which are largely based on Variational Auto-Encoders (VAEs) [18], where the key underlying assumption is that datapoint x is sampled from some stochastic process p θ (x|z), dependent on a low-dimensional random variable z, considered to be the generative factors of the data. State of the art unsupervised representation learning techniques aim to disentangle representations by regularizing the VAE objective. However, Locatello et al. [6] recently showed that these methods were dependent on random initial seed, hyperparameter selection, and, in particular, supervised disentanglement metrics which require full knowledge of the underlying factors of variation for model selection.
OoO Triplet VAE (TVAE): We propose a VAE variant for an OoO paradigm which follows a common metric learning technique for learning semantically meaningful embeddings of perceptual information [19,20,21]. Such approaches rely on weak supervision settings such as similarity information between multiple observations.
If the set of all individual objects is indexed by i, j, k, then a triplet observation, m, is a set x is known to be the odd-one-out thus implicitly providing the weak supervision. For each triplet observation, we embed the three objects in the latent space and assume it is a metric space such that we can interpret the odd-one-out supervision as providing two pairwise distance constraints as follows: since k is the odd-one-out then the distance between i and k, d(z i , z k ), should be larger than d(z i , z j ), and d(z j , z k ) larger than d(z i , z j ). We use the Euclidean distance evaluated based on the mean of q φ (z|x). Each distance constraint is modeled as a Bernoulli random variable, c, indicating if the constraint is obeyed or not, and with the probability of the outcome defined by a Probit function, i.e., in general p(c d(zr,zs)>d(zr,zt . Combining the two constrains allows us to model the triplet as a Bernoulli random variable , y k ∈ {0, 1}, encoding if k is indeed the OoO or not based on the model with a proper likelihood defined as the product of two Probit terms, i.e., p( With the aim to simultaneously embed the triplets and obey the constraint defined by the OoO information, we extend the standard VAE objective [18] with our new likelihood which yields the following lower bound on the marginal log-likelihood which should be maximised w.r.t θ and φ: where γ varies the influence from the triplet loss on the (variational) posterior. While our approach is similar in spirit to [22,21], we emphasize that our formulation explicitly considers the odd-oneout paradigm resulting in two distinct pairwise distance constraints per triplet compared to their formulations only considering individual pairwise distance constraints. However, the additional information from a OoO observation can arguably be added as an additional albeit separate pairwise constraint in their methods. Moreover, in contrast to Karaletsos et al. [22] we follow Locatello et al. [16] and jointly embed the three objects for each triplet along with the constraint instead of considering these separate aspects of the observation.
Triplet Score: To ensure fairness across a variety of possible representation learning techniques, and consistency with existing disentanglement metrics, we evaluate representations by using the predictive performance of a low-VC classifier identifying the odd-one-out from our generative model detailed in Appendix A (rather than just using the likelihood p(y k |z i , z j , z k ) in Eq. 1). We define the Triplet Score as the accuracy a low-VC classifier achieves in predicting the odd-one-out, given an encoding model q φ (z|x), a number of points m, a classifier clf , as follows: • Step 1: Sample m triplets from the triplet generative model. • Step 2: Compute µ φ (x) for each object in the triplet, for all m triplets of observations, where Step 3: Calculate the accuracy of predicting the index of the odd-one-out, using clf .
With the exception of the UDR metric [23], common techniques for evaluating representations for model selection rely on full knowledge of all the ground-truth factors of variation. We emphasize that the triplet score only requires knowledge of which observation is the odd-one-out. Furthermore, we aim to compare against the UDR metric in future work, however, we note that in comparison our proposed method requires far less computational resource. In line with previous work [6,7] we calculate this score by training a GBT classifier on 10,000 points and test on 5,000 points, however, we note that any classifier capable of implicitly comparing the distances is suitable (such as a MLP).

Experiments
We build our experimental procedure on the work by van Steenkiste et al. [7]. Our study evaluates the Triplet Score to determine how much it agrees with existing disentanglement metrics, as well as evaluating the TVAE across these disentanglement metrics [24]. We then evaluate the same set of disentanglement models on a downstream abstract reasoning task to determine the extent to which Triplet Score correlates with predictive performance on the task, as well as how the TVAE improves predictive performance on this task compared to state-of-the-art unsupervised models and a weakly-supervised model. Overall, we evaluate 60 VAEs and 90 WReNs. Experimental setup for evaluating representations: To provide a fair comparison for the Triplet Score and the TVAE, we evaluate several state of the art representation learning models as baselines. Following notation from Tschannen et al. [25], we use two unsupervised methods which regularize the VAE objective in the form of L(θ, φ, x) = E q φ (z|x) [− log p θ (x|z)] + βKL(q φ (z|x)||p θ (z)) + τ KL(q φ (z|x)|| j q φ (z j |x)). The β-VAE [8] restricts the information capacity of the encoder by increasing β ≥ 1, with τ = 0. Similarly, the β-TCVAE [26] penalizes an estimate of the total correlation of the representation, with τ = 1 and β > 1. We also consider the group-based and weaklysupervised Ada-GVAE model of Locatello et al. [16], which learns disentangled representations from pairs of observations that are similar to one another. We use the extension to the dSprites dataset [27] proposed by van Steenkiste et al. [7], which adds object and background colour to the generative model. We sample i.i.d. observations for the unsupervised models, and implement the paired-observations generative model in Locatello et al. [16] for the Ada-GVAE (we fix k = rnd for this study). We implement our triplet generative model similar to the paired generative model which we detail in Appendix A. We plan to further evaluate our technique on the natural image THINGS [28] behavioural odd-one-out object dataset from Hebart et al. [29].
We consider three different regularization strengths for each of the models, and train each model and hyperparamter choice five times with different random seeds, resulting in 60 representation learning models. We evaluate each model for the Factor VAE score [11], the B-VAE score [8], the DCI Disentanglement score [12], and our Triplet Score. We detail our hyperparameters and implementation details in Appendix B.
Triplet-based weak supervision: In Figure 1, we compare the different disentanglement metrics across the models. We observe that the weakly supervised models outperform the unsupervised models, and that the TVAE performs the best across all metrics.
This result is expected considering the TVAE has access to weak labels which the other models do not. However we note that our modified TVAE objective function does not directly promote disentanglement, thus we leave an explanation of our empirical observations to future work. We also  note that the Ada-GVAE, which is trained on a similar task based on the similarities between pairs of observations, outperforms the other unsupervised models on the Triplet Score.
We provide the rank correlations between the different disentanglement scores in Figure 2 (Left), which show that the Triplet Score is very strongly correlated with existing disentanglement metrics. We note that this is likely due to the fact that VAE models tested happen to axis-align well, disentangling their observations by default, rather than indicating that our metric specifically captures disentanglement properties. Figure 3: The TVAE improves sample efficiency and overall predictive performance on the RPM task.
Experimental setup for evaluating downstream abstract reasoning: In line with van Steenkiste et al. [7], we evaluate the sample efficiency of representations produced by disentanglement models above by using the Wild Relational Network (WReN) to solve a procedurally generated RPM task. Our study similarly investigates the predictive performance of WReNs on solving the RPM task at various sample sizes, and controlling for different sources of panel embeddings: integer-encoded ground-truth panel factor values, CNN embeddings trained from scratch, embeddings from the unsupervised disentanglement models, embeddings from the weakly-supervised Ada-GVAE, and embeddings from the TVAE. Further experimental details are outlined in Appendix B.
Abstract Reasoning: In Figure 2 (Right) we show the rank correlation between the different disentanglement metrics and the WReN accuracy using embeddings from the representation learning models, at different sample sizes during training. We observe that the Triplet Score is equally highly correlated with all other disentanglement metrics across the sample sizes, indicating that the Triplet Score is also a reliable measure of how useful a representation is. Furthermore, In Figure 3 we plot the training accuracy of the WReN during training using different sources of embeddings. We show that both weakly-supervised approaches outperform existing unsupervised approaches, and as expected, the TVAE outperforms all other approaches with the additional inductive bias from the weak supervision labels.

Conclusion
In this work, we proposed a simple weak supervision task for evaluating disentanglement in representation learning models based on odd-one-out triplet constraints. We also proposed a bespoke weaklysupervised representation learning model which is similar to existing metric-learning techniques, and empirically showed that the additional weak-supervision loss outperforms other unsupervised representation learning techniques. In our experiments, our weakly-supervised task was shown to correlate highly with predictive performance on an abstract visual reasoning task, without assuming any knowledge of ground-truth factors of variation.

A Triplet Generative Model
Given a ground-truth model with d i.i.d. generative factors p(z) = d i p(z i ), we aim to sample z 1 , z 2 , z 3 such that z 1 , z 2 differ in exactly k factors, z 1 , z 3 differ in d − k factors, and z 2 , z 3 differ in d factors. In this study, we consider randomly sampling k unif (1, d 2 ) to respect the triplet constraint d − k > k, but invite further work to consider fixed k to reflect real-world scenarios when the similarity conditions are known and consistent. We note that in the case of fixed k = 1, the differences between the two most similar images, and the similarities between the odd-one-out, sparse, and easy to perceive, e.g. x 1 , x 2 have only one factor difference, and x 1 , x 3 have only one factor in common. We define our generative model as follows: Where we define S = {S ⊂ [d] : |S| = k} as the subset of factor indices which will be re-sampled between z 1 and z 2 , and R = {R ⊂ [d] : |R| = d − k} as the subset of factor indices which will be re-sampled between z 1 and z 3 , and other share factor values for factor indices which aren't in either set for each pair i.e. p(z 1i ) = p(z 2i ), ∀i / ∈ S, p(z 1i ) = p(z 3i ), ∀i / ∈ R. We include samples from our triplet generative model in Figure 4. Figure 4: Samples from the dSprites triplet dataset, with fixed k = 1 (left), and k unif (1, 3) (center and right), for each row of triplets. We note that fixing k = 1 makes the differences between the two most similar images, and the similarities between the odd-one-out, sparse, and easy to perceive, e.g. x 1 , x 2 have only one factor difference, and x 1 , x 3 have only one factor in common, whereas randomly sampling k, in the most difficult case k = 3, results in x 1 , x 2 having 3 factors difference, and x 1 , x 3 having 3 factors in common.
We use the abstract visual reasoning task proposed by van Steenkiste et al. [7], based on procedurally generating Raven's Progressive Matrices from ground-truth disentanglement models (we refer to their work for samples from the dataset). RPMs consist of three rows of context panels, with abstract relations present across each row, and the final row being incomplete. The task involves completing the final row by selecting from a set of possible answer panels, of which only one in correct. Selecting the correct answer panel requires the participant to infer the abstract relations across each row, and apply this knowledge to predict which answer panel correctly completes the final row. Recent work by Barrett et al. [24] explored the diagnostic ability of RPMs to measure abstract reasoning in neural networks. Using a dataset of procedurally generated RPMs and a variety of generalisation schemes, they found that models without significant inductive bias towards learning relational concepts perform poorly on the RPM task.
For evaluating representations on the RPM task, we use the WReN [24]. The WReN was proposed as an extension to the original Relational Network (RN) module for solving RPMs by repeatedly applying the RN module on context and answer panels. Given a set of objects O = {o 1 , o 2 , ..., o n }, o i ∈ R n : The RN infers relations between pairs of objects using neural networks g θ and f φ , where g θ determines how two objects are related, and f φ scores this relation for the given task by considering all of the relations as a whole. Given C = {c 1 , c 2 , ..., c 8 } context panels, and A = {a 1 , a 2 , ..., a 6 } answer panels, the WReN produces a score s k for each answer panel a k , by evaluating the RN over all pairs in the set of objects E = {C} ∪ {a k }. Intuitively, for a particular answer panel, we can think of this as the RN inferring the relations between every pair of context panels, and also between every context panel and the given answer panel, and then integrating information about all relations to produce a score for the answer panel. Formally, the WReN is evaluated as: In our study, when training embeddings for the WReN from scratch using a CNN, we use the implementation of van Steenkiste et al. [7] over Barrett et al. [24], as the former authors don't use batch normalization after each convolutional layer. We evaluate the accuracy of the WReN on 100 newly sampled batches every 1000 steps.