{'fraction_non_alphanumeric': 0.03412793688904133, 'fraction_numerical': 0.012965186074429771, 'mean_word_length': 4.912796592983168, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Zero-Shot Learning with Structured Embeddings

Despite significant recent advances in image classification, fine-grained classification remains a challenge. In the present paper, we address the zero-shot and few-shot learning scenarios as obtaining labeled data is especially difficult for fine-grained classification tasks. First, we embed state-of-the-art image descriptors in a label embedding space using side information such as attributes. We argue that learning a joint embedding space, that maximizes the compatibility between the input and output embeddings, is highly effective for zero/few-shot learning. We show empirically that such embeddings significantly outperforms the current state-of-the-art methods on two challenging datasets (Caltech-UCSD Birds and Animals with Attributes). Second, to reduce the amount of costly manual attribute annotations, we use alternate output embeddings based on the word-vector representations, obtained from large text-corpora without any supervision. We report that such unsupervised embeddings achieve encouraging results, and lead to further improvements when combined with the supervised ones.


Introduction
There have been significant advances in solving image classification problems, such as generic object categorization [14,5]. These recent advances were enabled by (1) large-scale labeled data (e.g., ImageNet [3]) via crowd-sourcing, and (2) breakthroughs in learning feature representations for images [14]. Despite this progress, fine-grained classification remains a challenging problem.
As the first challenge, since fine grained object classes can only be distinguished by field experts, it is expensive to obtain labeled data. As a result, the problem of classifying images in the absence of sufficient labeled training data, known as zero-and few-shot learning, has recently gained interest in research communities. Although obtaining class labels for fine-grained object categories is costly, with the help of crowd-sourcing websites, it is possible to obtain labels for generic properties of those objects, such as size, color, and texture. These properties, also known as attributes [9], may serve as an intermediate layer of information shared among different categories.
As the second challenge, fine-grained object classes are very similar to each other (e.g., different types of birds all look similar compared to other animals). Therefore, in order to distinguish between different classes, it is necessary to increase the number of attributes, but they are nontrivial to define and costly to obtain. As a complementary approach to attribute-based learning, we investigate an unsupervised learning approach based on word embedding, which can be trained from an unlabeled text corpus [18]. In this paper we show that these vector representations alone and in combination with attribute annotations provide promising results also in the case of fine-grained image classification. This work tackles zero-shot learning in fine-grained datasets by embedding state-of-the-art image descriptors [14] in a label embedding [32] space using side information such as attributes (supervised) and word-vector representations (unsupervised). Specifically, we propose a joint embedding method, which we refer to as Structured Joint Embedding (SJE). Our SJE method learns a joint embedding space by maximizing the compatibility of inputs and outputs. We show that our method works very well with attributes (annotated per class), achieving state-of-the-art zero-shot learning performance both for Caltech-UCSD Bids (CUB-2011) and Animals with Attributes (AWA). In addition, we show that the unsupervised word embedding methods (e.g., Word2Vec trained from a large unlabeled text corpora without any attribute labeling) provide encouragingly good zero-shot and few-shot learning results, surpassing previous published results. We plan to make our code, input and output embeddings publicly available upon acceptance.
Previous Work. We briefly review related work on zero-shot learning and label embedding.
Zero-shot learning: Learning with disjoint training and test classes, also known as zero-shot learning, is a challenging problem. In the absence of class labels, it is necessary to use side information that is shared between classes. Attributes [9] relate different object classes through well-known and shared characteristics of objects which provide an intermediate layer between images and labels. With the emergence of crowd-sourcing platforms, they can be manually collected [7]. Attributes have shown promising results in various applications, i.e. caption generation [15,19], face recognition [24,2], image retrieval [25,6], action recognition [17,33], etc. Zero-shot learning becomes even more challenging for fine-grained datasets because the categories differ only by few visual differences. In order for the attributes to be descriptive enough, they should model small intra-class variance between objects. For fine-grained classes, this can only be achieved by using (1) a large number of (2) specific attributes. However, obtaining a large number of attributes is a costly process. Therefore, we explore alternative word representations that are obtained from large unlabeled text corpus in an unsupervised manner [23,18].
Label embedding: Embedding labels in an Euclidean space is an effective tool to model several relationships between different classes. These relationships can be collected independently of the data [12,4], can be learned from the data [32,11] or can be derived from side information [9]. In order to collect relationships independently of data, compressed sensing [12] uses random projections whereas Error Correcting Output Codes (ECOC) [4] builds embeddings inspired from information theory. WSABIE [32] uses images with their corresponding labels to learn an embedding of the labels, and Canonical Correlation Analysis (CCA) [11] maximizes the correlation between two different data modalities. Learning image classification models using label embeddings have shown to provide excellent results [10,1,26]. For deriving side information, different data sources such as text documents [23] or crowd-sourcing platforms [21] can be used.

Learning with Structured Joint Embeddings
Given input/output pairs with x n ∈ X and y n ∈ Y from a training set S = {(x n , y n ), n = 1 . . . N }, the goal of Structured Joint Embedding (SJE) is to learn a function f : X → Y by minimizing the empirical risk 1 when the true label is y. Here we use the 0/1 misclassification loss.
Following [27], our model uses a large margin learning formulation that defines a compatibility function F : X × Y → R between an input space X and a structured output space Y. Given a specific input embedding, we derive a prediction by maximizing the compatibility F over Structured Joint Embeddings (SJE) as follows: where w denotes the model parameter vector and ψ(x, y) : R D × R E → R DE denotes the input/output embeddings with D being the input embedding dimension and E being the output embedding dimension. The parameter vector w can be written as a D × E matrix W which leads to the bi-linear form of the compatibility function: F (x, y; W ) = θ(x) W ϕ(y).
(2) Here, the input embedding is denoted by θ(x) and the output embedding by ϕ(y). In our largemargin multiclass classification objective, the matrix W is learned by maximizing the ranking of the correct label (see Section 2.3). This formulation is closely related to ALE [1] which uses attributes as side information and ranking objective. Alternatively, [20,26] uses the regression objective, WS-ABIE [32] uses the ranking objective rather than the multiclass objective and CCA [11] maximizes the correlation of input and output embeddings.
In Sections 2.1 and 2.2 we discuss the output and input embeddings that we employ. In Section 2.3 we detail the model parameter estimation in the context of zero-and few-shot learning.

Output Embeddings
The literature offers many ways of embedding class labels into a high dimensional space. Attributes have been proposed as an intermediate representation as well as an alternative to object level classification [16,8]. They have been also used to impose structure on the object class output space and have shown promising performance for zero-shot recognition [13,1]. However, due to the fact that attributes require human supervision we propose and explore alternatives which do not require human supervision. The following details the structured output representations that we compare in our evaluation: attributes, Word2Vec, bag-of-words, and their combination.
Attributes. Attributes model characteristic properties of objects that are understood by humans, readable by computers and shared between different categories. The set of descriptive attributes may be determined by language experts as in [16] or by field experts as in [31] for fine grained data collections. They are particularly useful for fine grained domains because categories are visually highly related to each other. The association between an attribute and a category is obtained manually through crowd sourcing. It can be a binary value depicting the presence/absence of an attribute for each class or a real-number that defines the confidence level of an attribute for each class.
Our Structured Joint Embedding (SJE) method based on attributes assumes that we have C classes, i.e. Y = {1, . . . , C} and a set of E attributes, i.e. A = {a i , i = 1 . . . E} that are associated with each class. Using the binary or continuous measure ρ y,i that associates a class with each attribute, we embed the class y in the E-dim attribute space as follows: Attributes have been widely used in the literature to aid classification and showed excellent results for image classification [16,8,13,1,34]. However, for fine grained domains where the categories visually differ from each other only slightly, we need to increase the number of attributes even though obtaining a high number of attributes for each class is a costly process. Moreover, due to the subjectivity of human annotators, it is prone to errors. In the following, we describe alternative output embeddings, using no supervision, based on word representations.
Word Embeddings. Learning distributed vector representations from a large unlabeled text corpus capturing semantic relationships between words is an alternative of building textual relationships between classes. This is appealing as such word embeddings eliminate the cost of human annotation as required for attributes. Additionally, word embeddings might encode relationships between classes that are missed or not represented by the particular set of attributes employed.
We propose a word embedding method based on the Word2Vec approach [18] that works in a fully unsupervised manner. The first step of Word2Vec creates a vocabulary of single words or word phrases from a large unlabeled text corpus. It searches through the corpus to find and group frequently occurring words. The second step learns the distributed word representations for each of the words in the vocabulary by using continuous skip-gram (SG) models. The SG model feeds each word as an input to a log-linear classifier with a continuous projection layer within a certain window that contains words that occur before and after the word of interest. The output embeddings based on Word2Vec representations are denoted by ϕ w (y) corresponding to F dimensional vectors (in the experimental section we explore different settings of Word2Vec): Word2Vec representations have shown to provide excellent results for image classification in largescale image collections [10]. However, to our knowledge, their applicability to fine-grained image classification has not been investigated before. We show in Section 3 that word embeddings based on Word2Vec indeed capture semantically meaningful relationships between classes and thus allow zero-shot recognition of unknown classes without requiring any human annotation.

Algorithm 1 SGD optimization for SJE
Initialize the learning parameters W (0) randomly. for t = 1 to T do // for a certain number of iterations or until the stopping condition is met for n = 1 to N do // for all the samples in S (S is randomly shuffled) Draw (xn,yn). if arg maxy∈Y (xn, yn, y) = yn then Bag-of-Words. Building unsupervised text representations from a large unlabeled text corpus may not capture the essential information that helps distinguishing between fine-grained object classes. An alternative to using a text corpus that is dominated by general concepts is to build word representations on a fine-grained subset of a large text corpus. The bag-of-words model is such an alternative where a category is represented as a bag of its words, i.e. the frequency of each word to be used as a word representation, disregarding the word ordering or the grammar.
In this work, we collected wikipedia articles that correspond to each class. After eliminating stop words, common verbs and repeated nouns, we use the remaining text to build a dictionary. Based on the presence/absence of each word in the dictionary, we then built a histogram of dictionary words that correspond to each class. These bag-of-words representations are denoted with ϕ bow (y) and can be defined as a G dimensional vector: (5) Combination of Word Embeddings and Attributes. Considering the fact that different output representations can capture different relationships between classes, their combination may lead to improved performance. Output embeddings can be directly combined by concatenation of individual embedding vectors. We denote the combination of ϕ A (y) and ϕ w (y) embeddings with a E + F dimensional vector as follows: ϕ A+w (y) = [ρ y,1 , . . . , ρ y,(E+F ) ] .
(6) Each of the output embeddings are independently 2 normalized which ensures that each class is closest to itself according to the dot-product similarity.In Section 3 we show that such a combination can increase the accuracy of classification.

Input Embeddings
The SJE method treats both the input and the output embedding in a symmetric way. While a detailed analysis of output embeddings is an important contribution of this paper, good image representations are crucial to obtain good classification performance. This section thus describes the three image representations that we use in our experimental evaluation.
The Fisher Vector (FV) framework [22] 1 aggregates per image statistics computed from local image patches into a fixed length local image descriptor. It consists in computing the deviation of a set of local descriptors from an average Gaussian Mixture Model (GMM). On the other hand, deep learning features obtained using Convolutional Neural Networks (CNN) [14] have shown improved results over FVs 2 . They consist of convolutional and fully connected layers with nonlinearity applied to the output of each layer. Features are typically obtained from the activations of the fully connected layers have been shown to induce useful semantic similarities. Finally, we concatenate the FV and CNN representations into an dim F V + dim CN N dimensional vector denoted by COMB.

Zero-and Few-Shot Learning
Our learning strategy is to maximize directly the compatibility between the input and output embeddings. Following the structured SVM formulation [27], the large margin multiclass classification 1 Won the ILSVRC11 challenge and ImageNet fine-grained object categorization challenge of 2013. 2 Won the latest ILSVRC12 and ILSVRC13 challenges of ImageNet. objective is given by: where (x n , y n , y) = max In the zero-shot learning, the training and test classes are disjoint. Therefore, we fix matrix Φ to the output embeddings that belong to the training classes and learn an embedding model W . In the few-shot learning, we not only use images from the training classes but also few images from the test classes. We thus learn the embedding model W by using the side information that is available for both training and test classes. For prediction, we project a test image onto W and assign the class label of the nearest output embedding vector (using the dot product simiarity) that corresponds to one of the test classes.
We use Stochastic Gradient Descent (SGD) for optimization where the decision of an update uses the sample-wise estimate of the misclassification loss based on a single sample. Training with SGD consists in, choosing a sample (x, y) at random at each step, searching the highest ranked class exhaustively from all classes, and updating the projection matrix if the class with the maximum scorē y = y. The optimization procedure for both zero-and few-shot learning is provided in Algorithm 1.

Results
We evaluate the proposed SJE framework on two datasets: the fine-grained dataset Caltech UCSD Birds (CUB) [29] as well as Animals With Attributes (AWA) [16]. CUB contains 11,788 images from 200 different bird classes. AWA contains 30,475 images from 50 different animals. We first give some details of our input and output embeddings used in the experiments.
Input embeddings. We extract 96-dim color descriptors from regular grids at multiple scales, reduce them to 64-dim using PCA and aggregate them into FVs 3 using 256 Gaussians trained with GMMs. We reduce the dimensionality of FVs to 4096. As an alternative, we pre-train a convolutional neural network (CNN) on ImageNet [3], following the model architecture in [14]. After training, the CNN is used to extract image features for AWA and CUB. Specifically, for feature extraction, each image is resized to 224×224 pixels and fed into the CNN, and the 4096 dimensional top-layer hidden unit activations (fc7) of the CNN are taken as the features. Note that we did not perform any task-specific pre-processing, such as cropping foreground objects or detecting parts.
Output Embeddings. For the supervised case, both datasets contain per-class attributes obtained through human supervision. AWA classes are associated with 85 attributes (e.g. big, smart) and CUB dataset contains 312 visual attributes (e.g. color, pattern). In the unsupervised case, we employ Word2Vec and bag-of-words (BoW) representations. For Word2Vec representations, we tokenize the 13 February 2014 version of the English-language Wikipedia to 1.5 million uni-bigram words. We use the skip-gram model and a hierarchical softmax layer to build the distributed word representations. AWA classes are general concepts with short names, so we use the plain Word2Vec representations for this dataset. However CUB classes can be up to four word phrases which are more fine grained concepts. We therefore tokenize long bird names to one-two word phrases, build Word2Vec representations for each token and average them. For BoW, we create 11K dimensional histograms using 200 bird-specific Wikipedia articles.  Comparison of learning methods. We first compare the SJE and CCA objectives for zero-shot learning. The SJE objective uses input and output embeddings to learn a common Structured Joint Embedding space by maximizing the rank of the correct label. On the other hand, CCA maximizes the correlation between the input and output embeddings. In these experiments, we use FVs, CNN features and their combination (COMB) for input embeddings as well as attribute (ϕ A ) and Word2Vec (ϕ w ) representations for output embeddings. Results are provided in Table 1.
Let us first discuss the results on fine-grained dataset CUB. The state-of-the-art (SoA) on this dataset is 18% using binary attributes (i.e. supervised setting) as side information and FV [1]. Using CCA and FV (12.7%) does not achieve SoA performance, while using CCA in combination with more powerful input embeddings (CNN and COMB) does improve the SoA (21.1% and 23%). Using SJE on the other hand already achieves 19.6% using FV and obtains an impressive 46.6% using COMB, significantly outperforming the current SoA. Interestingly, when using the unsupervised output embedding (Word2Vec, ϕ w ) in combination with the input embedding COMB we obtain 24.4% which is better than the previously reported SoA in the supervised case (attributes) showing the power of the proposed Word2Vec representation.
Considering the results on both CUB and AWA in Table 1, we observe that for zero-shot learning CCA can achieve good results compared to the SoA. However, in all cases, CCA is outperformed by SJE. This can be explained by the fact that the SJE objective maximizes the ranking of the correct label which is closely related to our end goal. The remaining results in the paper are thus all based on SJE.
Comparison of input embeddings. From the input embeddings point of view, we observe a significant increase in SoA accuracy with CNN. CNN features have shown to lead to excellent accuracy for large-scale image classification, and our results demonstrate the discriminative power of CNN features also for the problem of zero-shot and fine-grained image classification. Interestingly, the combination of CNN features and FVs obtains an impressive 46.6% on CUB and 65.7% accuracy for AWA (compared to the current SoA for AWA of 43.4% [30]).
Comparison of output embeddings. Table 2 provides a more comprehensive comparison of output embeddings based on attributes, Word2Vec and BoW representations. The attribute representations (85-dim for AWA, 312-dim for CUB) can either model the presence/absence (ϕ {0,1} ) or the confidence level (ϕ A ) of each attribute. Empirically we set the dimensionality of Word2Vec representations (ϕ w ) to be 100 for AWA and 300 for CUB. As mentioned above, Word2Vec for CUB classes is obtained by averaging the Word2Vec representation for multiple one-two word phrases. We also provide results combining the attributes and Word2Vec representations (ϕ A+w ) by concatenation.
We start the discussion with the fine-grained dataset CUB. For all output embeddings, CNN outperforms FV, and their combination COMB further improves results which is why we focus the  Table 3: Summary of zero-shot learning results with SJE and comparison with the current SoA.
following discussion on COMB. Using binary attributes ϕ {0,1} achieves 20.2% accuracy, slightly above the SoA of 18%. As mentioned before, using no manual supervision and word embeddings such as Word2Vec ϕ w we obtain 24.4% thus outperforming the supervised SoA. However, using attributes in a continuos rather than in a binary fashion (ϕ A ) significantly outperforms the SoA. Similar observations hold for AWA. The unsupervised version performs well (39.7%) even though below the supervised SoA (43.4% [30]) and the binary attribute case (45.7%). Using continuous attribute embedding ϕ A for AWA improves the state of the art significantly to 65.7%.
The combination of the attribute and the Word2Vec representations (ϕ A+w ) further improves performance for AWA. This indicates that the set of attributes on AWA does not capture all relevant information and that the unsupervised Word2Vec representation captures additional information useful for recognition. However, in the case of CUB the combination ϕ A+w results in a slightly decreased performance. This is related to the fact that the set of attributes is more exhaustive and chosen by bird experts so that the Word2Vec representation learned on a general corpus such as Wikipedia may not add additional side information for the zero-shot setting. A summary of zero-shot learning results is given on Table 3.
We also explored a more bird-specific word representation learned on bird articles. As a Word2Vec representation requires a sufficiently large corpus, we resort to a BoW-representation. More specifically we learn a BoW representation using the 200 articles of birds from wikipedia. After eliminating stop words we build a dictionary using 5000 mostly occurring words. For each article, based on the presence/absence of each word in the dictionary, we build a histogram of dictionary for each class. Results are shown in the last column of Table 2. While the unsupervised BoW representation achieves reasonable accuracy (15.7%) it is well below the unsupervised Word2Vec representation (24.4%) leaving room for future work on how to effectively learn word representations from a constrained corpus.
Investigating the class names of CUB dataset, we found out that the class names can be up to 4 word phrases. The naive way of building Word2Vec representations is directly using these multi-word class names. However, obtaining descriptive word embeddings for such specific multi-word phrases is a challenging task. Our experimental results using 300 dimensional representations obtain 11.5% and 3000 dimensional representations 18.2% accuracy. On the other hand, 300-dimensional representations built using the combination of one/two word phrases achieve 24.4% accuracy. Word2Vec representations capture a conceptual understanding of language in a way that it allows for arithmetic operations to improve the representations [18]. Our results indicate that this property of Word2Vec becomes useful for fine-grained object names.
As a general remark about Word2Vec representations, it is not trivial to group relevant words together from a large text corpus which is not specifically designed for fine-grained concepts like different types of birds. We suspect that, using a large-scale online animal or bird encyclopedia, more descriptive Word2Vec representations would be obtained and this could further improve the results for zero-shot fine-grained image classification. This is to be investigated as a future work.

Few-Shot Learning
We validate our SJE algorithm in a second setting, namely few-shot learning. In this setting we assume that few labeled images from the test classes are available. We use up to 20 images of test classes for both CUB and up to 50 images for AWA. The remaining images are used as test data thus changing the test data compared to the previous experiments. Thus, we also provide zero-   Figure 1: Few-Shot Learning: images of test classes are gradually added to the training set. The remaining images from test classes are used for evaluation. We use COMB as the input embedding.
shot learning results with the new setting. Since output embeddings are per class, we provide the ground truth output representations from all of the classes for training. For statistical consistency, we randomly select the images with 10 different seeds and report resultsin Figure 1. Since the contribution of input and output embeddings are symmetric, using the output embeddings from all the classes with their corresponding few input embeddings may lead to saturated results. The slight drop of accuracy with ϕ A+w from zero-shot to one-shot can be explained by this phenomenon.
Overall, the results confirm our findings form the previous experiments. As before, the unsupervised Word2Vec embedding ϕ w provides excellent results for an unsupervised method in comparison to the supervised binary attribute embedding ϕ {0,1} . For AWA, ϕ w embeddings have slightly lower accuracies than ϕ {0,1} embeddings. The results significantly improve when using continuous attribute embedding ϕ A and the combination ϕ A+w . For CUB, the unsupervised ϕ w embeddings perform higher than ϕ {0,1} embeddings which is impressive since this is a truly fine-grained dataset. The results obtained with ϕ A embeddings provide a further increase in accuracy and finally we get the highest results with ϕ A+w embeddings.

Summary and Conclusion
We are interested in zero-short learning for image classification in fine-grained datasets. Motivated by the success of attribute based zero-shot learning we argue that the Structured Joint Embedding (SJE) method is effective for zero-and few-shot learning. Various input and output embeddings are proposed and analyzed in this work. Attributes have shown to be profitable as a basis for zeroshot learning. However, for fine-grained image collections, since the objects are visually similar to each other, attributes are costly to obtain through manual labeling. Therefore, we obtain side information from a large unlabeled text corpus using the unsupervised Word2Vec word-embedding method. Unsupervised Word2Vec representations achieve SoA accuracy on two datasets for the zero-shot learning problem. Especially for the challenging fine-grained image categorization dataset CUB we obtain significantly better results than the SoA with Word2Vec (even though the SoA uses supervision and Word2Vec does not). Moreover, continuous attributes (modeling the confidence level of an attribute) outperform their discrete counterpart (modeling he presence/absence of an attribute). Importantly, the proposed SJE method in combination with both the unsupervised, the supervised output embedding methods and CNN features, we improve the SoA on AWA by 23% on AWA (to 66.7%) and by 28% on CUB (to 46.6%, see table 3). In future work we plan to investigate other methods to combine multiple output embeddings and to improve the discriminative power of Word2Vec representations for fine-grained classification.