{'fraction_non_alphanumeric': 0.038022504773124265, 'fraction_numerical': 0.021367347767802736, 'mean_word_length': 4.605191256830601, 'pattern_counts': {'":': 0, '<': 1, '<?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}}
Deep Unsupervised Hashing with Latent Semantic Components

Deep unsupervised hashing has been appreciated in the regime of image retrieval. However, most prior arts failed to detect the semantic components and their relationships behind the images, which makes them lack discriminative power. To make up the defect, we propose a novel Deep Semantic Components Hashing (DSCH), which involves a common sense that an image normally contains a bunch of semantic components with homology and co-occurrence relationships. Based on this prior, DSCH regards the semantic components as latent variables under the Expectation-Maximization framework and designs a two-step iterative algorithm with the objective of maximum likelihood of training data. Firstly, DSCH constructs a semantic component structure by uncovering the fine-grained semantics components of images with a Gaussian Mixture Modal~(GMM), where an image is represented as a mixture of multiple components, and the semantics co-occurrence are exploited. Besides, coarse-grained semantics components, are discovered by considering the homology relationships between fine-grained components, and the hierarchy organization is then constructed. Secondly, DSCH makes the images close to their semantic component centers at both fine-grained and coarse-grained levels, and also makes the images share similar semantic components close to each other. Extensive experiments on three benchmark datasets demonstrate that the proposed hierarchical semantic components indeed facilitate the hashing model to achieve superior performance.


Introduction
With the explosive growth of social data such as images, how to conduct rapid similarity searches has become one of the basic requirements of large-scale information retrieval. Hashing (Wang et al. 2015) (Liu and Zhang 2016) has become a widely studied solution to this problem. The goal of hashing is to convert high-dimensional feature and similarity information into compact binary codes, which can greatly speed up computation with efficient xor operations and save storage space.
Hashing techniques can be generally divided into supervised and unsupervised categories. Supervised hashing Figure 1: An illustration of semantic component structure, where a picture is normally composed of multiples interrelated semantic components. e.g, dog and grass are associated by an image, we call this relations as co-occurrence. Besides, these semantic components are hierarchically organized from fine to coarse scale, e.g, dog belongs to animal, this relationship known as homology.
methods (Liu et al. 2012) (Shen et al. 2015) (Yuan et al. 2020) use label information to train hashing models, which achieve reliable performances. However, obtaining adequate labeled data is normally expensive and impractical, which hinders the application of these methods. In this scenario, an increasing number of researchers turn their attention to unsupervised hashing methods (Liu et al. 2011) (Liu et al. 2014) ) (Lin et al. 2021). With the lack of labels, the key to unsupervised hashing methods is the manual design of semantic similarity and how they guide the learning of hashing models. However, existed methods ) (Song et al. 2018) (Deng et al. 2019) mainly develop the similarity information derived from the entire image, which fails to recognize the semantic composition of each image. Generally, a real-world picture is composed of different types of objects, which makes it contain rich semantic connotations. We call a type of object with specific semantic meaning as a semantic component. For instance, a picture of walking a dog can be comprised of the following components: people, dog and grasses, in which dog are usually correlated with people as human pets. We call this phenomenon semantic co-occurrence.
Besides the detection of the semantic components of im-ages and their co-occurrence relations, we notice that the homology relationships between them are another useful information, which is organized in a hierarchical way, such as chihuahua and husky both belong to category dog. This allows people to learn new concepts easily by inference its connection with learned concepts. For example, husky is another breed of dog, so it should have some similar biological qualities with chihuahua. The mentioned facts inspired us to introduce the homology of semantic components into the visual retrieval task. Several supervised hashing methods (Sun et al. 2019) (Wang et al. 2018) proved that the semantic hierarchy can benefit hashing models. But how to model it in an unsupervised way is still an open question. Based on the above two observations, in this paper, we propose a novel unsupervised hashing framework, called Deep Semantic Components Hashing (DSCH), which assumes that each image is composed of multiple latent semantic components and propose a two-step iterative algorithm to yield discriminative binary codes. Firstly, DSCH constructs a semantic component structure with fully exploring the homology and co-occurrence relations of semantic knowledge, and an example is shown in Figure. 1. It formulates each image as the mixture of multiple finegrained semantic components with GMM, and clusters them to coarse-grained semantic components to construct the hierarchy. Secondly, DSCH makes the images close to their semantic component centers on both fine-grained and coarsegrained levels, and also makes the images share similar semantic components close to each other. These two steps can be unified into an Expectation-Maximization framework that iteratively optimizes model parameters with the maximum likelihood of the data. The main contributions of this paper can be summarized as follows: • We propose a novel deep unsupervised hashing framework DSCH, which treats the semantic components of images as latent variables and learns hashing models based on a two-step iterative framework. • We propose a semantic component structure, which represents images as the mixture of multiple semantic components considering their co-occurrence and homology relationships. • We propose a hashing learning strategy by extending the contrastive loss to adapt semantic components, where images are pulled to their semantic component centroid and close to other images with similar semantic components. • The extensive experiments on CIFAR-10, FLICKR25K, and NUS-WIDE datasets show that our DSCH is effective and achieves superior performance.

Notation and Problem Definition
Let us introduce some notations for this paper, we use boldface uppercase letters like A to represent the matrix, a i represents the i-th row of A, a ij represents the i-th row and the j-th column element of A and A T denotes the transpose of A. · 2 represents the l 2 -norm of a vector. · F represents the Frobenius norm of a matrix. sgn(·) represents the sign function, which outputs 1 for positive numbers, or −1 otherwise. tanh(·) represents the hyperbolic tangent function. cos(x, y) x T y x 2 y 2 represents the cosine similarity between vector x and vector y.
Suppose we have n database images X = {x i } n i=1 that contains n images without labels. The purpose of our method is to learn a hash function H : x i → b i that mapping X into compact binary hash codes B = {b i } n i=1 ∈ {−1, +1} n×r , where r represents the length of hash codes.

Related Work Unsupervised Hashing
There are many well-known traditional hashing methods been established in decades. Among them, Iterative Quantization (ITQ) (Gong et al. 2012) minimizes the quantization error of mapping by finding the optimal rotation of the data. Spectral Hashing (SH) (Weiss, Torralba, and Fergus 2009) construct a Laplacians graph with Euclidean distance to determine the pairwise code distances. To speed up the construction of the graph, Anchor Graph Hashing (AGH) (Liu et al. 2011) proposes a sparse low-rank graph by introducing a set of anchors. Although the aforementioned methods have made progress in this area, they are all shallow architectures that rely heavily on hand-crafted features. To tackle this problem, amount of deep unsupervised hashing methods (Deng et al. 2019) ) (Tu et al. 2021a) (Tu et al. 2021b) have been proposed, in which Deep binary descriptors (DeepBit) (Lin et al. 2016) treats the image and its rotation as similar pairs in hash code learning. Semantic Structure-based unsupervised Deep Hashing (SSDH) ) finds the cosine distance distribution of pairs based on Gaussian estimation to construct a semantic structure. Twin-Bottleneck Hashing (TBH) (Shen et al. 2020) introduces two bottlenecks that can collaboratively exchange meaningful information. Recently, inspired by the success in the unsupervised representation domain (He et al. 2020) , contrastive learning have been introduced to reinforce the discrimination power of binary codes (Luo et al. 2020), Contrastive Information Bottleneck (CIB) (Qiu et al. 2021) modifies the contrastive loss (Oord, Li, and Vinyals 2018) to meet the requirement of hashing learning as: in which b a i = f (x a i ) denotes the relaxed binary codes generated from a hash encoder f (·) by giving a transformed view a of image x i as input. v ∈ {a, b} denotes which view is selected and τ represents the temperature parameters.
In the above setting, each image and its augmentation are treated as similar pairs, while all other combinations are treated as negative pairs, which will bury the similar pairs with cross samples. Therefore, in our DSCH, we expand the above objective to cover more potentially similar signals.

Expectation-Maximum
The Expectation-Maximum (EM) algorithm (Dempster, Laird, and Rubin 1977) has been proposed to estimate the model parameters Θ with maximum likelihood based on observed data X and unobserved latent variables Z = {z j } m j=1 : To tackle this objective, EM contains two iterative steps: E step. Expecting the posterior distribution of latent variables Z based on X and the last model parameters Θ t , which is derived as: Then, updating the model parameters Θ by maximizing the expectation of Eq.5.
The EM algorithm iterates the E step and the M step until convergence. By introducing the latent variables Z, the EM algorithm has been proved to optimize the initial objective n i log p(x i |Θ) (Neal and Hinton 1998).

Methodology
In this section, we illustrate DSCH from three folds. Firstly, how we define the hash encoder. Secondly, how to model the semantic components. Lastly, how we learn binary codes from built semantic components. An overall pipeline is shown in Fig.2, and we will discuss each regard in detail.

Hash Encoder
We employ the VGG-19 (Simonyan and Zisserman 2014) as hash encoder and denote it as f (·|Θ) with network parameters Θ. To make this architecture meets the requirements of hash learning, we replace its last layers with a fc layer with 1000 hidden units and followed by another fc layer, where the node number is equal to hash codes length r. In training process, we adopt the tanh(·) as the final activation function to tackle the ill-posed gradient of sgn(·), and get the continuous approximation of binary code b i as: Once finished training, we adopt sgn(·) to yield the discrete binary code for Out-of-Sample extension:

Semantic Component Structure
In this subsection, we illustrate that how we build a semantic component structure with co-occurence and homology relationships. Semantic Co-occurrence Each image in the real world is usually composed of different types of objects, and each type of object is associated with a specific category. But in the unsupervised domain, since the label information is not available, it is a challenge to identify such categories meaning. Considering that any combination of objects may appear in an image, we assume that an image is generated from a mixture of a finite number of semantic components, where the distribution of each semantic component represents a kind of categories information. Based on the discussion above, it is natural to adopt GMM to model the relations between data points and semantic components. We set the component number as a large number m 1 to cover any possible semantics categories in fine-grained, and we denotes these fine-grained components as {C (1) j } m1 j=1 . Next, we fit the parameters of components based on code representation H = {h i } n i=1 , therefore the distribution of a sample h i can be modeled by these fine-grained components: could be calculated iteratively via GMM algorithm: When GMM converges, we use mean vector µ (1) j to denote the representation of j-th fine-grained semantic component C (1) j m1i ] T to rep-resent the assignments of sample h i belong to each finegrained component, which elements p (1) ji is estimated as: Semantic Homology Next, we explore another correlation among semantic components, name semantic homology, which means that components with similar meanings should be from the same source. For example, chihuahua and husky are both breeds of dogs. Intuitively, these relationships can be organized in a hierarchical way by clustering.
We are inspired and perform k-means with a less cluster number m 2 < m 1 on mean vectors {µ where the assignment of fine-grained C (1) j belongs to coarse-grained C (2) k is defined as: and we represent the representation of C (2) k as: Also, we define the prior probability of coarse-grained component p(C 2 k ) as π (2) k = 1 m2 , since the centroid obtained with k-means should be treated fairly.
Lastly, based on the assignment h i → C (1) j of Eq.11 and

C
(1) j → C (2) k of Eq.12, we establish the assignment p k , which formulated as: Complexity analysis. The complexity of constructing a semantic structure is O(nm 1 r 3 + m 1 m 2 r + nm 1 m 2 ) with n training samples, code length r, m 1 fine-grained components and m 2 coarse-grained components. In the above, the first term is GMM algorithm, the second term denotes kmeans clustering, and the third term is brought by the mapping of Eq.14. Notably, this complexity is linear to data samples number O(n).

Learning from Structure
In this section, we illustrate how we learn a discriminative hash model from the built semantic component structure. We decouple this structure as multiple connections with two kinds: instance correlation and semantic correlation.

Instance Correlation
The pairwise similarity between images is an essential cue to direct the hash model. Generally, if two images are similar semantically, then their semantic composition should also be similar. For example, two pictures both contain sky, dog and airplane are very likely to describe a similar scene. Thus, the similarity of images can be expressed by how similar their semantic components are. Based on this tuition, we develop a metric s ij based on sample assignments to fine-grained components p i of Eq.11 as: where s ij ∈ [0, 1], denotes how similar h i and h j are in their distribution of assigned fine-grained semantic components. Especially, when s ij equals to 1, we have p i = p j , which means h i and h j are almost the same semantically. When s ij is equal to 0, it means h i and h j are totally dissimilar.
In the loss of Eq.2, it normally treats two transformed views of an image as a positive pair, while ignoring the similarity information with cross samples. Thus, a straightforward idea is expanding the scope of similar pairs. We adopt the s ij to identify which pairs are similar and extent the contrastive loss of Eq.1 as follows: where α ij equals to sij 4 i j sij with normalization and l ab ij as: in which v 1 ∈ {a, b} and v 2 ∈ {a, b}. In the objective of Eq.16, these data pair with a higher similar semantic components s ij will be encouraged to be closer more with their different transformed views. Notably, our similar information is not only cross-views but also cross-samples, and the Eq.1 can be formulated as a special case when only s ii = 1.

Component Correlation The goal of hash encoder f (·|Θ)
can be formulated to find the parameters Θ with the maximum likelihood of n i log p(x i |Θ). By regarding these semantic components {C j } m2 j=1 as latent variables. We can rewrite the initial goal as: (18) and this objective can be solved iteratively via the EM algorithm, which includes the following two steps: E step. We estimate the posterior distribution Q i (C (l) j ) of latent semantic components based on X and parameters Θ t , which with solutions Eq.11 and Eq.14.
M step. Based on Q i (C (l) j ), we estimate the loglikelihood of Θ as: where p(C (l) j ) equal to π (1) j from Eq.10 when l = 1, and equal to π j . Also, consider that probability p(h i |C (l) j ) is non-negative and should be normalized, we formulate it as: Combining the Eq. 19, Eq. 20 and Eq. 22 together, the solution of model parameters is defined as: ji . The principle behind Eq.23 is that we direct every data sample h i close to their associated components center µ (l) j with its assignment weights β k ij , with the purpose for align the instance representation with a weighted combination of components in different semantic granularities.

Objective Function and Optimization
We introduce data augmentation into L 2 and integrate L 1 into the EM framework M steps. Besides, we discretize the component center µ (l) j in Eq.23 as sgn(µ (l) j ) to minimize the quantization error. Therefore, the total loss is formed as: (24) where λ is a weight coefficient of loss L 2 and l ab ij is defined in Eq.17.
The algorithm of DSCH is described in Algorithm.1, which is based on the EM algorithm, and its optimization contains two alternate steps: where η is the learning rate and ∇ Θ represents a derivative of Θ.

Experiments
In this section, we conduct experiments on various public benchmark datasets to evaluate our DSCH method.

Datasets
We evaluate our methods on three public benchmark datasets, i.e. CIFAR-10, FLICKR25K, and NUS-WIDE. CIFAR-10 dataset contains 60,000 images in 10 categories, where each class contains 6,000 images with size 32 × 32. We randomly selected 100 images for each class as the query set, 1,000 in total. Then we used the remaining images as the retrieval set, among them, we randomly selected 1,000 images per class as the training set.
FLICKR25K is a dataset with multi-label, which contains 25,000 images and each image is labeled with at least one of 24 classes labels. We randomly selected 1,000 images per class as the query set and the remaining images are left for retrieval sets. In the retrieval sets, we randomly choose 10,000 images as the training set.
NUS-WIDE is a multi-label dataset that includes 269,648 images in 81 classes, and each image is also tagged with multiple labels more than classes. We selected 21 most frequent classes from the dataset and each class contains at least 5,000 related images. Among them, 2100 images are selected as a query set randomly while the remaining images were treated as a retrieval set, where 10,500 images were for training. For multi-label datasets, if the retrieved image shares at least one label, it is regarded as being associated with the query image.

Experiment Settings
Metrics. We evaluate model performance by three widely used metrics: Mean Average Precision (MAP) to measure the hamming ranking quality, Precision/Precision-recall curves to display model overall performance. Baseline Methods. We compared DSCH with twelve unsupervised hashing methods, including six shallow hashing models: LSH (Andoni and Indyk 2006), SH (Weiss, Torralba, and Fergus 2009), ITQ (Gong et al. 2012), AGH (Liu et al. 2011), SP (Xia et al. 2015, SGH (Dai et al. 2017) and six deep hashing models: GH (Su et al. 2018), SSDH , BGAN (Song et al. 2018), MLS 3 RDUH  and TBH (Shen et al. 2020) and CIB (Qiu et al. 2021). The parameters of the above methods referred to the setting provided by papers, and all shallow hashing methods use the fc7 layer 4096-dimensional feature of VGG19 pre-trained on ImageNet.
Implementation Details. We conducted experiments on a workstation equipped with Intel Xeon Platinum 8255C CPU and Nvidia V100 GPU. During the training, each input image was resized to 224 × 224. For data augmentation, we use the same strategy as CIB. The epoch number was set to 100 with batch size 128, and the factor τ we set as 1. We adopted the Adam optimization with learning rate η to 5e-4. The parameters m 1 and m 2 were set to {1000, 1000, 2000} and {900, 100, 1500} for CIFAR, FLICKR and NUS-WIDE respectively, and λ was fixed to 0.1 by default.

Comparison Results and Discussions
The MAP@5000 results on three benchmarks are shown in Tab. 1, with code length varying from 16 to 64. It is clear that DSCH consistently achieves the best results among three datasets, with an averaged increase of 11.9%, 5.0%, 2.1% on CIFAR-10, FLICKR25K, NUS-WIDE compared with the CIB. To sufficiently reveal the overall performance of DSCH, we report the PR curve and Precision@5000 curve of 64 bits in Fig.3. It can be found that the PR curve of DSCH covers more areas in three benchmarks and normally has a higher precision with the same returned images number. This means DSCH yields a stable superior performance.

Ablation Study
In this section, we conduct an ablation analysis to understand the effect of DSCH components, which consists of two major losses: (a) instance correlation with L 1 by expanding the L 0 to cover cross-sample similar pairs. (b) components correlation with L 2 to keep semantic alignment at both fine and coarse levels. Therefore, we first design a variant with loss L 0 as a baseline (Base), and then replace it by L 1 to evaluate the instance correlation (IC). Further, equip this variant with the fine-grained (CC-F) and coarse-grained components correlation (CC-C) progressively. We list the results on the FLICKR25K in Table.2, which are evaluated with MAP@5000 and the code length varies from 16 to 64.  As shown in the second row, introducing instance correlation is able to obtain 4.4% (16 bits), 5.0% (32 bits), 3.6% (64 bits) improvements, which means that semantic components provide good clues to seek similar pairs. Further, the performance can be gradually improved by involving the fine-grained and coarse-grained semantic correlation, resulting in 11.1% (16 bits), 11.1% (32 bits), 7.6% (64 bits) gains over baseline, which indicates that the hierarchical semantic components enhance the discrimination power of model.

Parameter Sensitivity
In Fig.4 (a)(b), we evaluate the influence of different settings of components number (m 1 , m 2 ) on CIFAR-10 and FLICKR25K with 32 bits, where m 1 ∈ [100, 500, 1000, 1500, 2000] and m 2 = γm 1 , γ ∈ [0.1, 0.3, 0.5, 0.7, 0.9]. The pattern shows that retrieval performance is jointly affected by m 1 and m 2 under different semantic granularity. Generally, MAP@5000 increases with m 1 , this is due to the larger fine-grained components number bringing a finer division of semantic, which helps the model achieve better discrimination capabilities. Besides, a proper m 2 brings a certain performance improvement. We noticed that in CIFAR-10, a larger m 2 is preferred but in FLICKR25K, a very large m 2 will bring relative performance degradation. The recommended value is 0.9m 1 for CIFAR-10 and 0.1m 1 for FLICKR25K. In Fig.4(c)(d), we study the effect of λ, which denotes the weights of component correlation. We find that performance gain is brought when λ smaller than 0.1 and λ = 0.1 are a good choice in two datasets. Visualization Analysis In Fig.5, we display the t-SNE visualization of hash codes on CIFAR-10 with 32 bits from different variants enumerated in Tab.2. The color of points indicates the category samples belong to. The figure shows that introducing instance correlation obviously refine the manifold structure, where the images within the same class shared smaller distances to each other. By further equipping components correlation, data points are encouraged to be closer to their associated components, so the cluster structure is more compact.

Conclusion
We proposed a novel DSCH to yield binary hash codes by regarding every image is composed of latent semantic components and optimizing the model based on an EM framework, which includes the iterative two steps: E-step, DSCH constructs a semantic structure to recognize the semantic component of images and explores their homology and cooccurrence relationships. M-step, DSCH maximizes the similarities among samples with shared semantic components and pulls data points to their associated components centers at different granularities.. Extensive experiments on three datasets demonstrate the effectiveness of DSCH.