{'fraction_non_alphanumeric': 0.03139832055494706, 'fraction_numerical': 0.008371146925363792, 'mean_word_length': 5.0237197612315425, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Unsupervised Discovery, Control, and Disentanglement of Semantic Attributes with Applications to Anomaly Detection

Our work focuses on unsupervised and generative methods that address the following goals: (a) learning unsupervised generative representations that discover latent factors controlling image semantic attributes, (b) studying how this ability to control attributes formally relates to the issue of latent factor disentanglement, clarifying related but dissimilar concepts that had been confounded in the past, and (c) developing anomaly detection methods that leverage representations learned in (a). For (a), we propose a network architecture that exploits the combination of multiscale generative models with mutual information (MI) maximization. For (b), we derive an analytical result (Lemma 1) that brings clarity to two related but distinct concepts: the ability of generative networks to control semantic attributes of images they generate, resulting from MI maximization, and the ability to disentangle latent space representations, obtained via total correlation minimization. More specifically, we demonstrate that maximizing semantic attribute control encourages disentanglement of latent factors. Using Lemma 1 and adopting MI in our loss function, we then show empirically that, for image generation tasks, the proposed approach exhibits superior performance as measured in the quality and disentanglement trade space, when compared to other state of the art methods, with quality assessed via the Frechet Inception Distance (FID), and disentanglement via mutual information gap. For (c), we design several systems for anomaly detection exploiting representations learned in (a), and demonstrate their performance benefits when compared to state-of-the-art generative and discriminative algorithms. The above contributions in representation learning have potential applications in addressing other important problems in computer vision, such as bias and privacy in AI.


Motivations and Goals
There has been unsurpassed success in the application of deep learning (DL) in several areas of visual analysis, computer vision, natural language processing and medical imaging (Litjens et al., 2017). The transformative contribution of DL to artificial intelligence (AI), principally in discriminative models for supervised learning, has mostly hinged on the availability of large training datasets such as ImageNet (Russakovsky et al., 2015). Open problems still remain in DL, especially in unsupervised learning, inference on out-of-training-distribution test samples, domain shift, and also in discriminative tasks where data is not easily obtained or when manual labeling is impractical or prohibitively onerous. Generative models -with their ability to generate data similar to a given dataset and efficient representations of this data -may assist in addressing some of these challenges.
Considering these challenges, the ability to generate images with good quality and diversity at high resolution and to allow the unsupervised discovery and control of individual semantic images attributes via latent space factors are of paramount importance, and are the main aims motivating our study. These goals are also extended here to applying these learned representations to the practical task of anomaly detection.
Generative methods -broadly speaking -learn to sample from the underlying training data distribution so as to generate novel, fake samples that are visually or statistically indistinguishable from the underlying training data. A simple taxonomy of generative models includes: generative adversarial networks (GANs) (see, e.g., Goodfellow et al., 2014;Salimans et al., 2016), autoencoders/variational autoencoders (VAEs) (Kingma & Welling, 2013), and, used to a lesser extent in comparison to the aforementioned ones, generative autoregressive models in (Oord et al., 2016), invertible flow based latent vector models in (Kingma & Dhariwal, 2018), or hybrids of the above models as in (Grover, Dhar, & Ermon, 2018).

Prior Work
Prior and recent research in generative models addressing some of our aims and inspiring our work are organized below along the following areas:

High Resolution GAN Approaches
A goal of GANs has been to achieve good quality image generation for high resolution images. Despite sustained research in GANs, only relatively recently have GANs been able to generate images at somewhat high resolutions (greater than 256 by 256 pixels). Examples of methods that achieve such results include ProGAN (Karras, Aila, Laine, & Lehtinen, 2018), BigGAN (Brock, Donahue, & Simonyan, 2019), and COCO-GAN (Lin et al., 2019). For example, BigGAN relied on SAGAN (Zhang, Goodfellow, Metaxas, & Odena, 2019) as a baseline (self attention GANs) and used large batch sizes to improve performance (multiplying batch size by a factor of 8 leads to over 40% increase in inception score over other state of the art algorithms). That study also noted that larger networks had a comparable positive effect, and so did the usage of the truncation trick (i.e., for the generator, sampling from a standard normal distribution in training while sampling instead from a truncated normal distribution in inference, where samples that are above a certain threshold are re-sampled). Truncating with a lower threshold allowed control of the trade-off between higher fidelity and lower diversity.
Unfortunately, while many best of breed generative approaches made progress in terms of visual quality and high resolutions, these methods cannot be directly used for semantic attribute control, which is one of our goals in this paper.

Style Transfer
StyleGAN (Karras, Laine, & Aila, 2019) has been very successful at addressing the generation of high dimensional images (1024 by 1024) and is an extension of ProGAN, which was based on progressively growing the encoder and decoder/discriminator in GAN networks. Some of the specific novel features in (Karras et al., 2019) consisted of injecting noise at every scale resolution of the decoder, and of using a fully connected (FC) network that mapped a latent vector Z into a 512-length intermediate latent vector W . This so called 'style' vector had incidence on the generation of images throughout multiple scales and was used to influence some attributes of the image (at the low scale coarse attributes like skin tone and at the higher scale fine attributes like hair). An updated version of StyleGAN , StyleGAN2, introduced architectural improvements, along with an improved back projection method for mapping images to latent spaces.
While both methods successfully allowed for using multiple style vectors at different scales as a natural extension, the resulting images may have included undesirable attributes from the original base images. These methods therefore did not allow for directly controlling specific semantic image attributes and, consequently, unsupervised discovery of consistent semantic attributes. In contrast, the approach we seek strives for the discovery, control and isolation of desirable attributes from spurious attributes for complex imagery.

Information Theoretic Approaches
In (X. Chen et al., 2016), InfoGAN made use for the first time of the principle of maximizing the mutual information I(C;X) between a semantic latent vector C and the generated imageX, where C is a semantic component of the latent vector representation Z = (Z ′ , C), with Z ′ being a noise vector. This process was originally set up to achieve disentanglement in latent factors between different scales. Experiments exemplified various degrees of agreement between such factors and semantic attributes. However, as our study should demonstrate, the mutual information principle actually promotes the control of attributes in images, but true disentanglement is not always achieved via this maximization of mutual information. Indeed, the results in (X. Chen et al., 2016) suggested various degree of success and consistency between the ability of the network to actually control and disentangle.
Instead, in our view, the concept of disentanglement was appropriately defined in (T. Q. Chen, Li, Grosse, & Duvenaud, 2018) as the process of finding latent factors that satisfy minimum total correlation, defined by the Kullback-Leibler divergence between the vector's joint distribution and the product of its marginal components. Despite this contribution, the concepts of control and disentanglement have remained used interchangeably and are often confused with each other in recent literature. In this study, we adopt this definition and help bring order by formally demonstrating how this concept relates to the concept of control and maximization of mutual information.

Generative Methods for Anomaly Detection
Our goal (c) strives to demonstrate the utility of disentangled representations for an important machine learning task, specifically, anomaly detection. Related to this is past work that have used DL discriminative and generative model representation learning for anomaly detection. While DL-based anomaly detection schemes initially used discriminative representations -e.g. ( . Generally these exploit two main strategies: i) using cyclic reconstruction error in the image space as an anomaly detection metric or ii) directly using the GAN discriminator. These two techniques were employed for pixel based anomaly detection in (Schlegl et al., 2017) and for image based anomaly detection in (Zenati et al., 2018) and (Deecke et al., 2018). Another approach used metrics of reconstruction in latent/code space and is embodied in the work of (Akcay et al., 2018) The method in (Akcay et al., 2018) was later extended to include skip connections (Akçay, Atapour-Abarghouei, & Breckon, 2019). However those methods did not probe the use of generative models that had ability for large resolution image generation and allowed disentanglement, as is done here. Recently, (Burlina, Joshi, Wang, et al., 2019) found that most generative approaches fell short of using discriminative embeddings. We consequently focus on comparing to these discriminative models as the state of the art.

Novel contributions
When compared to prior work, the novel contributions of this work are as follows: 1. We consider the disentanglement of image attributes and the unsupervised discovery of such attributes, 1 proposing a novel approach relying on the combination of mutual information maximization with multiscale GANs.
2. We bring clarity to the concepts of semantic control and disentanglement, demonstrating that there is a connection between mutual information maximization and 1 Concurrent work we became aware of after first submitting this work in arXiv includes ( total correlation minimization, i.e., between the concepts of attribute control and disentanglement: we demonstrate in Lemma 1 that maximizing semantic attribute control encourages the minimizing of entanglement for latent factors.
3. We show empirically that the proposed approach results in high resolution generation with the ability for unsupervised discovery of latent codes that help control specific semantic image attributes.
4. We develop several methods using the proposed generative architectures, used for representation learning, for the end task of anomaly detection. We then demonstrate empirically the resulting performance benefits when compared to other state of the art discriminative methods.

Approach
The next subsections present our approach including: details on representation learning via our proposed architecture (InfoStyleGAN) in subsection 2.1 and the loss function design and analysis in subsection 2.2.

Definitions of Attribute Control, Disentanglement, Architecture and Loss Functions
We now discuss the concepts of attribute control and disentanglement. Consider first the architecture used here which is depicted in Figure 1   The latent code in Z is split into noise terms Z ′ and semantically relevant variables C. Sample (z ′ , c) is fed into a mapping network and a mutual information maximizing loss is used between latent and output generated image, combined with a conditional loss and traditional GAN adversarial loss. The pathways for the information Q auxiliary network are shown in dotted green while the pathways for anomaly detection via representation and OCSVM and LOF are shown in dashed yellow.
Since we seek to learn latent space representations that relate to generated image attributes, for attribute discovery and control, the latent vector Z = (Z ′ , C) is decomposed into a standard Gaussian noise vector Z ′ and a latent vector component C (henceforth called the latent factors) with distribution p(C), where C and Z ′ are independent of each other.
We define the concept of disentanglement as the minimization of the total correlation between the different latent factors C, while the faculty for discovery and control of semantic image attributes is defined via the maximization of mutual information between the latent factors and the generated image. The latter concept is explicitly used in our considered loss function. We will demonstrate analytically that the former concept of total correlation minimization is implied -under certain conditions -from the latter principle of mutual information maximization.

Control via maximization of mutual information (MI):
The maximization of the mutual information I(C; G(Z ′ , C)) between the semantic vector C and the observation X = G(Z ′ , C) is used as a means of discovering the factors of variations in images and forcing the coupling the vector C to the different factors of variations in the images X in the dataset. Since MI computation is complicated by the fact it entails knowing the posterior p(C|X), one can instead, as in InfoGAN in (X. Chen et al., 2016), employ an auxiliary distribution Q(C|X) that approximates this posterior and that can be selected to maximize the resulting MI measure. Disentanglement via minimization of total correlation: Although (X. Chen et al., 2016) introduced an auxiliary loss to maximize the MI between C = (C 1 , C 2 , . . . , C L ), where each C i can be governed by a different distribution, andX = G(Z ′ , C), where Z ′ is an additional noise vector, there is no explicit objective for controlling a diverse set of image attributes. For example, even with the independence implementation on the prior p(C) = i p(C i ), in (X. Chen et al., 2016), all semantically relevant variables could only seemingly affect the skin in faces, with different variables focusing on skin tone, skin texture, glare on the skin, etc. In effect, despite being sampled as independent, the effect between individual variables on the image are highly correlated. Consequently, a desirable end goal for disentanglement is that knowledge of one latent factor from the image does not affect the knowledge of other latent factors; i.e., having p(C|X = x) = i p(C i |X =x) or conditional independence of the true posterior of the latent factors given a realizationX =x of the generated image. This is equivalent to having TC(C|X =x) = 0, where TC(·|X =x) is the total correlation (T. Q. Chen et al., 2018) givenX =x, defined as the Kullback-Leibler (KL) divergence, denoted by D KL (· ·), between the conditional joint distribution givenX =x and the product of the conditional marginal distributions givenX =x: We will argue that the previous two concepts are connected to each other as shown in Lemma 1. Indeed, under certain assumptions, MI maximization constrains the total correlation. Therefore only one such constraint, namely the MI constraint, will be considered henceforth.

Loss Function
The loss function is comprised of two parts: the adversarial loss V (D, G) for the generator G and discriminator D as well as the lower bound L info (G, Q) on the mutual information where E(·) denotes the expectation operator, Q denotes the auxiliary network referenced earlier, and 0 ≤ D(·) ≤ 1. Note that we abused the notation inX ∼ G(Z ′ , C) to denote the conditional distribution p(X|C) given C (this conditional distribution is intrinsically determined by the distribution of Z ′ and the Gaussian noise maps). The optimization problem consists then of determining the triplet (D, G, Q) that achieves: is sampled from Z, as Z is explicitly defined beforehand, and then fed into the generator to produce the fake imagex(l) = G(z ′ (l), c ′ (l)) B times, as well as the real images x(l) being sampled B times. The estimates for the losses are thus given by: For nomenclature, we refer to InfoGAN as disabling styles and setting β = 1, StyleGAN as having styles and β = 0, InfoStyleGAN as having styles and β = 1, and InfoStyleGAN-Discrete as InfoStyleGAN with C only containing discrete variables.

Relating Attribute Control and Disentaglement
We next show that the choice of the mean field encoder, i.e., using Q(C|X) = i Q(C i |X), for optimizing the mutual information (as used in (X. Chen et al., 2016)) contributes to forcing the total correlation to zero.
Lemma 1. Assume that each C i is discrete for i = 1, . . . , L (hence I(C;X) is bounded from above) and that Q(C|X) = i Q(C i |X). When L info → I(C;X), then TC(C|X) → 0 almost everywhere inX, where TC(C|X) is the total correlation in C givenX.
Proof. First, recall the derivation of the InfoGAN objective from (X. Chen et al., 2016): where H(·) and H(·|·) denote entropy and conditional entropy, respectively. Note that H(C) = i H(C i ) as we assume the prior to the generative model factorizes independently. Starting from (7), we can decompose the logarithmic term for each individual C i to get: Now, purely maximizing the mutual information with respect to all variables could also increase the total correlation of the posterior p(C|X) of a fake imageX, implying that the factors given the image are more entangled, which is undesirable. Thus, we desire a low total correlation TC and high mutual information I betweenX, the generated image, and each variable C i individually, which we argue that the original InfoGAN objective implicitly satisfies for discrete (finite-valued) variables. Indeed, we can lower bound each individual I(C i ;X) term in (12) via the same method as in (9): we have where (15) holds by (12), (16) follows from (9) applied to each I(C i ;X) term. The equality before last is due to our assumption of a mean field encoder and the fact that Thus, when L info → I(C;X), the two inequalities in (14) and (16) become tight, in turn implying that Q(C|X) → p(C|X) and that TC(C|X) → 0 almost everywhere in X.
As explained earlier, while this lemma only applies when C is a discrete random vector, it nevertheless provides useful insights regarding the connection between MI maximization and total correlation minimization, and between the concepts of attribute control and disentanglement, which had been conflated in past literature, by demonstrating that maximizing semantic attribute control encourages minimizing entanglement of latent factors. It shows however that while connected, these two concepts are formally not equivalent. Furthermore, the direction of this relationship, namely that control encourages disentanglement and not the other way around, motivates our choice of using MI rather than TC in our loss function for the rest of the study.

Application to Anomaly Detection
Given our lemma and architecture above, the discriminator may learn a representation of the image not only in the auxiliary network but in layers used for discriminating real versus fake. This is due to using shared weights for both the auxiliary network and the discriminator, encouraging the discriminator to learn a mapping that includes potentially semantic information.
Using InfoStyleGAN trained on a subset of each dataset, we then extract the raw vector output by the discriminator at the end of: (a.) the auxiliary network Q, with dimensions depending on how C is implemented (b.) the last convolutional layer in the discriminator network of dimensions 512 by 4 by 4, and (c.) the last dense layer in the discriminator network, typically of dimension 512.
For nomenclature, the acronyms consisting of these different possibilities for representations and discriminative use of GANs for anomaly detection are described in Table 4. We whiten these embeddings using PCA and keep all components for the best performance. We then use these representations as embeddings for two anomaly detection methods, including one done via one-class support vector machine (OCSVM) and the other via local outlier factor (LOF). One-class support vector machines learn a hypersphere on the data given such that the radius containing most of the data is minimized. LOFs compare a given point to its nearest neighbors, and if the density around the given point is less than those of its neighbors, then it is categorized as an outlier.
As an alternative, we also test using embeddings output from two networks: the average pooling layer from an Inception network pre-trained to classify 1000 categories of objects from Imagenet, and the global representation from the Deep InfoMax (DIM) network. Deep InfoMax (Bachman, Hjelm, & Buchwalter, 2019) is trained via a contrastive loss to maximize the similarity between two different views of the same image, whilst minimizing the similarity with all other representations from different images. Consequently, it should learn as unique of representation as possible with respect to factors invariant to the differences in the view. Note that as both of these networks were pre-trained on the entirety of ImageNet, they can leverage the extra data to output more unique representations when compared to our methods. First, we crop height to match the correct aspect ratio, ignoring any images that require upsampling. We then resize to 512 by 384 pixels, and then pad this image to a 512 by 512 image.
For disentanglement experiments, we use the full dataset in all cases to cover every potential semantic attribute of the dataset. For anomaly detection experiments, we use the following classes as inliers and outliers: male celebrities as inliers and female celebrities as outliers for CelebA, and small vehicles (compacts/sedans) as inliers and large vehicles (trucks/vans) as outliers for Stanford Cars.

Additional Implementation Details
We adopt the basic settings of the implementation from (Karras et al., 2019) for all datasets. However, mixing is turned off, as it was found that mixing the styles reduces disentanglement. Moreover, as we are focused on reconstructing the initial vector used to create the style vector, introducing additional style vectors during generation would cause the information loss term to become ambiguous. For computational efficiency, we append Q to D as in Figure 1 similar to (X. Chen et al., 2016). For CelebA, we use a 512 dimension latent code for (Z ′ , C), with C consisting of seven discrete Bernoulli variables, one discrete categorical variable of dimension 3, and ten continuous uniform variables. For Stanford Cars, we use a 512 dimension latent code for (Z ′ , C), with C consisting of 20 continuous uniform variables. For implementing Q(C|X), we use logits for each of the discrete variables, and treat the posterior distribution of the continuous uniform variables as Gaussian N (µ(X), σ 2 (X)) with mean µ(X) and variance σ 2 (X).
Specifically for anomaly detection, we train each GAN on a dataset comprising of solely images in the inlier class and take a subsampling for training OCSVM or LOF. We then test on a balanced test set for both inliers and outliers for each dataset. Each set of representations was normalized, as well as fed through PCA using whitened components. All generative models and Deep InfoMax were found to perform best when all components are used, whereas Inception V3 performs best when 1,024 components were used. These standardized representations were then used to train the OCSVM/LOF model.

Disentanglement, Control, and Generative Quality: Quantitative Assessment
Although several metrics have emerged to characterize quality and diversity in generative models, we use FID (Heusel, Ramsauer, Unterthiner, Nessler, & Hochreiter, 2017) as our primary measure of distance between the two distributions, which is computed as: where · 2 and Tr(·) denote the L 2 norm and the trace, respectively, and the assumption is made that X r ∼ N (µ r , Σ r ), i.e., a normal distribution (with mean-vector µ r and covariance matrix Σ r ) for the activations from the Inception v3 pool layer for real examples, and likewise X g ∼ N (µ g , Σ g ) for generated examples. FID is reported for each of the architectural variants, and both datasets, as shown in Table 1 InfoGAN and InfoStyleGAN perform slightly worse than StyleGAN in terms of FID, and using only discrete variables in C in InfoStyleGAN performs significantly worse.
As the FID comprises of two terms that can roughly be taken to mean the fidelity and diversity of the fake distribution, we use two additional metrics, precision and recall from (Kynkäänniemi et al., 2019), to better characterize the fidelity (precision) and diversity (recall) separately for CelebA. (Kynkäänniemi et al., 2019) uses the image features of a specific network, Inception V3, chosen in our case to match the feature space of FID, to construct an approximate manifold of each the real images and fake images separately. This manifold is comprised of hyperspheres around each individual point in the dataset, where each hypersphere has the smallest radius that contains the nearest k neighbors. The precision is then defined as the proportion of fake images whose features lie in the constructed manifold of real images, and the recall is defined as the proportion of real images whose features lie in the constructed manifold of fake images.
We show the results in Table 2, where we see that StyleGAN has the highest precision at 0.720, while InfoStyleGAN has the highest recall at 0.319, for k = 3. Comparing InfoGAN and InfoStyleGAN, we see that the results appear to match both models having nearly equal FID, with InfoGAN having marginally higher precision and lower recall than InfoStyleGAN, exhibiting some trade-off between the quality and diversity. For k = 10, we see that the metrics overall follow a similar trend as what is presented in (Kynkäänniemi et al., 2019) for the FFHQ dataset, which can be construed as a higher quality CelebA.
In order to characterize the ability of the algorithms to control individual known image attributes of generated images, we also utilize the mutual information gap (MIG) (T. Q. Chen et al., 2018) for CelebA. Stanford Cars did not have ground truth attributes associated with it. Mutual Information Gap: As we have ground truth attribute labels for CelebA describing various semantic attributes {V k } K k=1 , where K is the number of ground truth attributes, we can use those directly in a supervised fashion to estimate the mutual information between each V k and each C i , i = 1, . . . , L, as described by the auxiliary network Q. Consequently, we estimate over k and i, where X v k is the set of images that correspond to having the label v k . As the overall conditional probability p(x|v k ) is unknown, we assume a uniform distribution over allx that have v k as a label. The MIG is then where i(k) = argmax i I(V k ; C i ) is the index over the latent factors C i that selects the C i with the maximum mutual information with respect to the given ground truth attribute. Consequently, the MIG is the normalized difference between the maximum and second largest mutual information. For CelebA, the set of attributes {V k } consists of 40 attributes, including binary variables for smiling, attractiveness, etc.
There are two consequences of using this measure: (1) a larger value indicates that the information about a ground truth attribute is concentrated in a single latent factor which aligns with the goals of disentanglement and (2) a small value does not necessarily indicate that our model does not successfully disentangle but that the semantic attributes it discovers may not align with any of the ground truth semantic attributes. Consequently, we also include the maximum mutual information to indicate if this is occurring. In Table 3, we see that InfoStyleGAN for CelebA does improve upon disentanglement compared to InfoGAN.  (13)) on the ground truth binary labels of CelebA using the auxiliary network. Unlike the various autoencoder architectures, we do not necessarily expect that the semantic attributes learnt will be all-inclusive; so we include the maximum mutual information (third column) over each ground truth attribute and C i pair to see if any are actually significant. We do see an improvement in disentanglement using architectures with mutual information loss, whereas InfoStyleGAN-Discrete discovers semantic attributes that are not aligned with the ground truth attributes. Consequently, for the discrete-only architecture, the MIG measure is inconclusive.

Disentanglement, Control, and Generative Quality: Qualitative Assessment
Figures 2a and 2b display example attribute control for the proposed architecture for CelebA. Similar to the original results for InfoGAN, we see variables corresponding to emotion and head position; however these correspond to a continuous variable here rather than a categorical variable and exhibit in our case a greater magnitude of control. Surprisingly, the image fourth from the right in Figure 2a appears to also control the glare of the glasses as the head is tilted up. Although some entanglement is still seen, such as the example on the left side of Figure 2a, where the faces become more masculine as the orientation increases, or the third from the right on Figure 2b which has glasses appear through increasing the smile. However, across all source images, the effect the attribute control is always very consistent in nature. In contrast, for InfoGAN, we see comparatively more entanglement across the various source images and less control. For Figure 2c, we see that InfoGAN exhibits a significant degree of control over the horizontal orientation of the head, but the endpoints are not consistent with their starting and final positions compared to Figure 2a. For Figure 2d, we also see control over the gender, which is entangled somewhat with smiling, and the degree of this smiling is not as significant as Figure 2b. Consequently,

Anomaly Detection: Quantitative Assessment
Tables 4 and 5 report comparisons between the various different variants of our pipeline for anomaly detection on CelebA and Stanford Cars respectively. We weigh ROC AUC most heavily, though accuracy and F1 score are closely correlated.
For CelebA in Table 4, we see that the Q network representations performs the worst, followed by the convolutional representations, and that the dense representations Table 4: Table describing ROC AUC, overall accuracy, and F1 score for each method tested on CelebA dataset with confidence intervals in brackets. The first entry in each method is the network used to get the representation, the second entry for generative methods is the representation used, and the last is the anomaly detection method. The second column is the abbreviation for each method, taking the first letter from each field. Inliers are male celebrities, and outliers are female celebrities.  Finally, we also plot the ROC curves for each dataset in Figures 3a and 3b. For Stanford Cars, we see that improvements in AUC are distributed evenly throughout the curve. However, for CelebA, we see that we do not get any actual improvement in the true positive rate between different methods without increasing the false positive rate significantly. This may be due to how gender is characterized by finer details, such as makeup or facial structure, which may be treated as invariants by only training on the inliers.
(b) Stanford Cars:  InfoStyleGAN). FID was worse for other state of the art algorithms that did not attempt to disentangle, except for COCO-GAN, which uses a much bigger model, so the comparison is not really apple-to-apple. In general, comparing InfoGAN to our method InfoStyleGAN, we see that InfoGAN does not have the same level of control as InfoStyleGAN likely due to these architectural differences despite having a comparable distance to the real distribution. From the purported benefits of StyleGAN, this disentanglement on the semantic variables is consistent with increased disentanglement of the overall latent space. Also interesting is that the overall distance from the real distribution is similar for InfoGAN and In-foStyleGAN, with StyleGAN performing slightly better. As the FID comprises of two terms, one measuring the distance between the two means and the other measuring the distance between the covariances. As the mutual information maximization increases the entropy of the generated images, then presumably the info-methods are closer in terms of diversity rather than closer in terms of the average, especially given that the generators still have to generate all combinations of semantic attributes and still maintain the image's realism. These generators may not be able to infer from the training dataset how to combine these factors in a realistic way, which may be reflected in the precision and recall metrics in Table 2 for k = 3.
Of note, during our experiments we observed that CelebA did not have L inf o fully maximized, which explains why some entanglement is still observable in some of the images. Consequently an avenue of future work is to address this issue by trying to explicitly minimize total correlation in the loss function along with attempting different methods for the maximization of mutual information such as those found in (Poole, Ozair, van den Oord, Alemi, & Tucker, 2019).
In terms of Stanford Cars, the best lower bound of the mutual information it could achieve was roughly 0.1. One possibility for this performance may be that due to the dataset having significantly less data compared to CelebA, the generator does not know how to combine potential attributes in a realistic way, so it focuses more on maintaining its realism rather than optimizing for the mutual information, which may also relate to its performance in anomaly detection.
In aggregate, we find that the proposed approach gave promising results for control and discovery of semantic attributes. Our findings that sometimes one latent factor appeared to influence jointly two different attributes is consistent with our lemma explaining that it is the control objective (via mutual information maximization) that encourages disentanglement (via total correlation minimization). Indeed since mutual information maximization is achieved via maximization of a lower bound on mutual information, if this bound is not tight, then minimization of total correlation down to zero may not be achieved (in the case of discrete variables) which explains residual correlation between factors.
We believe that the discovery of latent factors that control semantic attributes has other potential applications for AI tasks such as debiasing in healthcare. It allows the discovery of factors of variations that can be the basis for a sensitivity analysis that can help address issues of bias in AI. These can be of importance for healthcare applications where phenotype discovery and sensitivity analysis of AI with regard to these phenotype is of interest. Fundamentally it is complementary to methods that address direct classification of image semantic attributes when those attributes are known a priori. When attributes and phenotypes are not known, the problem is much more arduous and our method can help address this issue.

Anomaly Detection
From the above results in the experiment section with regard to anomaly detection, we remark that anomaly detection based on representation learning from these generative models provides encouraging results. We view ROC AUC as our primary metric for comparison, though Accuracy and F1 Score are also both correlated with ROC AUC.
In general, CelebA was a difficult dataset for all methods, with the best overall, Inception V3, only achieving an AUC of 0.629, a performance close to InfoStyleGAN with LOF, which had AUC of 0.608. Also, as can be seen in Figure 3a, for regimes with low false positive rates, InfoStyleGAN based methods somewhat outperform the discriminative methods. From the off diagonals of Figure 4a, one possible reason for this could be that the most apparent features of gender could actually apply to both inliers and outliers. As an example, take the top rightmost image in the predicted outlier/actual inlier and the bottom leftmost image in the predicted inlier/actual outlier. Ignoring the hat, both have thick eyebrows and darkened eyes, with the women having slightly redder lips and a slightly different facial structure.
For Stanford Cars, the generative models actually improve on the discriminative methods, which is fairly surprising given that large vehicles and small vehicles are actually contained in several separate categories in ImageNet. One possible reason is that of domain shift, given some of the images in Figure 4b are heavily zoomed in, making distinguishing between small and large vehicles difficult from purely the size and forcing features to focus on areas such as the grill and body shape. Similar reasons possibly explain why the dense/global representation performs so much better than the other representations.

Conclusion
This study is concerned with generative models that address the joint objectives of discovery, disentanglement, and control of image semantic attributes, as well as the goal of performing anomaly detection using representation from this model. We describe a method that uses multiscale generative models and maximize mutual information (so called InfoStyleGAN) and achieve those joint goals -as evaluated both quantitatively and qualitatively. Results show that our method is competitive in two datasets in terms of anomaly detection compared with models trained on significantly larger datasets with multiple diverse classes, giving promising new directions to continue research into generative anomaly detection methods.