{"notes":[{"id":"contrastive-learning/invaspread","category":"contrastive-learning","legacyPath":"contrastive-learning/1904-invaspread","legacySlug":"1904-invaspread","legacyPaths":[],"title":"InvaSpread","subtitle":"Traces Under Difficulties","author":"Z. Yuan","paperDate":"2019-04-06","publishedOn":"2025-01-23","paperTitle":"Unsupervised Embedding Learning via Invariant and Spreading Instance Feature","paperUrl":"https://arxiv.org/abs/1904.03436","bibliography":{"title":"Unsupervised Embedding Learning via Invariant and Spreading Instance Feature","authors":["Mang Ye","Xu Zhang","Pong C. Yuen","Shih-Fu Chang"],"url":"https://arxiv.org/abs/1904.03436","pdfUrl":"https://arxiv.org/pdf/1904.03436","codeUrl":null,"preprint":{"id":"1904.03436","submittedOn":"2019-04-06","url":"https://arxiv.org/abs/1904.03436"},"publication":{"venue":"CVPR","year":2019,"kind":"conference","url":"https://arxiv.org/abs/1904.03436"},"citation":"@misc{contrastivelearninginvaspread2019,\n  title = {{Unsupervised Embedding Learning via Invariant and Spreading Instance Feature}},\n  author = {Mang Ye and Xu Zhang and Pong C. Yuen and Shih-Fu Chang},\n  year = {2019},\n  eprint = {1904.03436},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/1904.03436}\n}\n","citationPath":"/content/papers/citations/contrastive-learning/invaspread.a46b3f57ac16.bib"},"thumbnail":{"src":"/content/papers/assets/135f248ffa5c98e798e9cd5d75ab7cdb38fda8130eae2511547941d70f316165.jpg","width":1596,"height":524},"locale":"en","path":"/content/papers/en/contrastive-learning/invaspread.294046788c59.md","headings":[{"id":"defining-the-problem","text":"Defining the Problem","depth":2},{"id":"solving-the-problem","text":"Solving the Problem","depth":2},{"id":"model-architecture","text":"Model Architecture","depth":3},{"id":"loss-function","text":"Loss Function","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"comparison-with-other-methods","text":"Comparison with Other Methods","depth":3},{"id":"experiments-with-unknown-classes","text":"Experiments with Unknown Classes","depth":3},{"id":"ablation-study","text":"Ablation Study","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"contrastive-learning/examplar-cnn","relation":"comparison","topic":"How to define a self-supervised prediction task"},{"id":"contrastive-learning/cpc","relation":"comparison","topic":"How to define a self-supervised prediction task"}]},{"id":"contrastive-learning/examplar-cnn","category":"contrastive-learning","legacyPath":"contrastive-learning/1406-examplar-cnn","legacySlug":"1406-examplar-cnn","legacyPaths":[],"title":"Exemplar CNN","subtitle":"Finding Invariant Features","author":"Z. Yuan","paperDate":"2014-06-26","publishedOn":"2025-01-22","paperTitle":"Discriminative Unsupervised Feature Learning with Exemplar Convolutional Neural Networks","paperUrl":"https://arxiv.org/abs/1406.6909","bibliography":{"title":"Discriminative Unsupervised Feature Learning with Exemplar Convolutional Neural Networks","authors":["Alexey Dosovitskiy","Philipp Fischer","Jost Tobias Springenberg","Martin Riedmiller","Thomas Brox"],"url":"https://arxiv.org/abs/1406.6909","pdfUrl":"https://arxiv.org/pdf/1406.6909","codeUrl":null,"preprint":{"id":"1406.6909","submittedOn":"2014-06-26","url":"https://arxiv.org/abs/1406.6909"},"publication":{"venue":"IEEE Transactions on Pattern Analysis and Machine Intelligence","shortVenue":"IEEE TPAMI","year":2016,"kind":"journal","url":"https://doi.org/10.1109/tpami.2015.2496141"},"citation":"@misc{contrastivelearningexamplarcnn2014,\n  title = {{Discriminative Unsupervised Feature Learning with Exemplar Convolutional Neural Networks}},\n  author = {Alexey Dosovitskiy and Philipp Fischer and Jost Tobias Springenberg and Martin Riedmiller and Thomas Brox},\n  year = {2014},\n  eprint = {1406.6909},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/1406.6909}\n}\n","citationPath":"/content/papers/citations/contrastive-learning/examplar-cnn.9f293122852b.bib"},"thumbnail":{"src":"/content/papers/assets/52a4c5931d81eeedf2a0857944f10ddc3749d7195e81184efa2a80bc736d062d.jpg","width":1080,"height":418},"locale":"en","path":"/content/papers/en/contrastive-learning/examplar-cnn.be54ec33fac2.md","headings":[{"id":"defining-the-problem","text":"Defining the Problem","depth":2},{"id":"solving-the-problem","text":"Solving the Problem","depth":2},{"id":"experimental-setup","text":"Experimental Setup","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"comparison-with-other-methods","text":"Comparison with Other Methods","depth":3},{"id":"ablation---number-of-proxy-categories","text":"Ablation - Number of Proxy Categories","depth":3},{"id":"ablation---number-of-samples","text":"Ablation - Number of Samples","depth":3},{"id":"ablation---type-of-image-augmentation","text":"Ablation - Type of Image Augmentation","depth":3},{"id":"ablation---parameter-configuration","text":"Ablation - Parameter Configuration","depth":3},{"id":"filter-visualization","text":"Filter Visualization","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{"ablation---performance-in-image-classification":"ablation---parameter-configuration"},"guide":null,"relatedReading":[{"id":"contrastive-learning/invaspread","relation":"comparison","topic":"How to define a self-supervised prediction task"},{"id":"contrastive-learning/cpc","relation":"comparison","topic":"How to define a self-supervised prediction task"}]},{"id":"contrastive-learning/cpc","category":"contrastive-learning","legacyPath":"contrastive-learning/1807-cpc","legacySlug":"1807-cpc","legacyPaths":[],"title":"CPC","subtitle":"Today shapes tomorrow","author":"Z. Yuan","paperDate":"2018-07-10","publishedOn":"2025-01-16","paperTitle":"Representation Learning with Contrastive Predictive Coding","paperUrl":"https://arxiv.org/abs/1807.03748","bibliography":{"title":"Representation Learning with Contrastive Predictive Coding","authors":["Aaron van den Oord","Yazhe Li","Oriol Vinyals"],"url":"https://arxiv.org/abs/1807.03748","pdfUrl":"https://arxiv.org/pdf/1807.03748","codeUrl":null,"preprint":{"id":"1807.03748","submittedOn":"2018-07-10","url":"https://arxiv.org/abs/1807.03748"},"publication":null,"citation":"@misc{contrastivelearningcpc2018,\n  title = {{Representation Learning with Contrastive Predictive Coding}},\n  author = {Aaron van den Oord and Yazhe Li and Oriol Vinyals},\n  year = {2018},\n  eprint = {1807.03748},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/1807.03748}\n}\n","citationPath":"/content/papers/citations/contrastive-learning/cpc.4cc0d1d40232.bib"},"thumbnail":{"src":"/content/papers/assets/a60b1a92f6088b36ddee7c87fed67d1e73769e003c30805f963c6b284d0c3a86.jpg","width":1382,"height":626},"locale":"en","path":"/content/papers/en/contrastive-learning/cpc.915decb4d747.md","headings":[{"id":"defining-the-problem","text":"Defining the Problem","depth":2},{"id":"solving-the-problem","text":"Solving the Problem","depth":2},{"id":"model-architecture","text":"Model Architecture","depth":3},{"id":"infonce","text":"InfoNCE","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"speech-recognition","text":"Speech Recognition","depth":3},{"id":"ablation-experiments","text":"Ablation Experiments","depth":3},{"id":"speaker-identification-visualization","text":"Speaker Identification Visualization","depth":3},{"id":"image-recognition","text":"Image Recognition","depth":3},{"id":"visualization-of-image-features","text":"Visualization of Image Features","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"contrastive-learning/examplar-cnn","relation":"comparison","topic":"How to define a self-supervised prediction task"},{"id":"contrastive-learning/invaspread","relation":"comparison","topic":"How to define a self-supervised prediction task"}]}],"text":"The main comparative targets of this paper are the Exemplar CNN and InstDisc papers.\n\n\n> [!TIP]\n> \n> If you are unfamiliar with these two papers, you might want to check out our previous articles:\n> \n> - [**[14.06] Exemplar CNN: Finding Invariant Features**](/blog/papers/contrastive-learning/examplar-cnn)\n> - [**[18.05] InstDisc: The More the Merrier**](/blog/papers/contrastive-learning/instdisc)\n> \n> In this paper, the `InstDisc` paper is referred to as NCE, and the `Exemplar CNN` paper is referred to as Exemplar.\n\n\n## Defining the Problem\n\nTo find universal features, one approach is to use the classifier weight's Softmax embedding, as proposed by Exemplar CNN: **treat each image as an independent class**.\n\nExemplar CNN defines a matrix $W = [w_1, w_2, \\dots, w_n]^T \\in \\mathbb{R}^{n \\times d}$, where $w_j$ corresponds to the classifier weight for the $j$-th instance.\n\nDuring training, based on the Softmax function, the probability of sample $x_j$ being recognized as the $i$-th instance is:\n\n$$\nP(i|x_j) = \\frac{\\exp(w_i^T f_j)}{\\sum_{k=1}^n \\exp(w_k^T f_j)}\n$$\n\nAt each step, the network pulls feature $f_i$ closer to its corresponding classifier weight $w_i$, and pushes it away from other classifier weights $w_k$.\n\nHowever, this method’s classifier weights restrict explicit comparisons between features, ultimately leading to poor efficiency and recognition power.\n\nNext, InstDisc discarded the classifier weights and proposed the Memory Bank method, storing the instance features $f_i$ calculated the last time each instance was encountered as $v_i$.\n\nThese stored features are then \"directly\" used as the classifier weights for corresponding instances, with the probability of sample $x_j$ being recognized as the $i$-th instance:\n\n$$\nP(i|x_j) = \\frac{\\exp(v_i^T f_j / \\tau)}{\\sum_{k=1}^n \\exp(v_k^T f_j / \\tau)}\n$$\n\nHere, $\\tau$ is a temperature parameter controlling the concentration of the distribution. With both features L2-normalized, $v_i^T f_j$ represents the cosine similarity between feature $f_j$ and memory feature $v_i$.\n\nThe drawback is that memory features are updated less frequently, and comparisons between the real-time feature $f_i$ and outdated memory feature $v_i$ reduce training efficiency.\n\nSince using parameterized Softmax is ineffective and the Memory Bank method is not very efficient, is there a way to directly optimize the features themselves, instead of the classifier weights or memory features?\n\nThe authors argue that we should abandon the Memory Bank and directly optimize the features themselves!\n\n## Solving the Problem\n\n### Model Architecture\n\n\n\n![model_arch](/content/papers/assets/135f248ffa5c98e798e9cd5d75ab7cdb38fda8130eae2511547941d70f316165.jpg)\n\n\n\nThe figure above shows the framework of the method proposed by the authors, which seems quite simple. First, a batch of images is input, which undergoes random data augmentation.\n\n- **Original images:** A set of unlabeled images serves as the data source.\n- **Data augmentation:** Random resized cropping, grayscale conversion, color jitter, and horizontal flipping create another view of each image. These transformations are intended to preserve useful instance information; very aggressive augmentation can still remove semantic content.\n\nEach image and another augmented version enter CNN branches with shared weights to produce the corresponding features. The first branch may also use augmentation. We denote the two features by $f_i$ and $\\hat{f}_i$ and L2-normalize them.\n\nFinally, there is feature alignment and spreading:\n\n- **Feature alignment for the same image (Invariance):** For the same instance (i.e., the original image and its augmented version), the embedded features $f_i$ and $\\hat{f}_i$ should be consistent (features are close). This encourages features to become less sensitive to the selected augmentations.\n- **Feature spreading for different images (Spread-out):** The embedded features of different instances in the batch should be separated to help distinguish the images. Unlabeled data may contain images of the same category, so some of these apparent negatives can be false negatives.\n\n### Loss Function\n\nAt the end of the methodology, let's look at the loss function designed in this paper.\n\nFirst, for the positive sample classification probability, the probability of the augmented sample $\\hat{x}_i$ being correctly classified as instance $i$ is:\n\n$$\nP(i|\\hat{x}_i) = \\frac{\\exp(f_i^T \\hat{f}_i / \\tau)}{\\sum_{k=1}^m \\exp(f_k^T \\hat{f}_i / \\tau)}\n$$\n\nWhere:\n\n- $f_i$: The embedding feature of the original image $x_i$.\n- $\\hat{f}_i$: The embedding feature of the augmented image $\\hat{x}_i$.\n- $\\tau$: The temperature parameter, which adjusts the concentration of the probability distribution.\n\nThen, for the misclassification probability, the probability of other instances $x_j, j \\neq i$ being misclassified as instance $i$ is:\n\n$$\nP(i|x_j) = \\frac{\\exp(f_i^T f_j / \\tau)}{\\sum_{k=1}^m \\exp(f_k^T f_j / \\tau)}\n$$\n\nThe probability that $x_j$ is not misclassified as instance $i$ is:\n\n$$\n1 - P(i|x_j)\n$$\n\nAssuming the classification of different instances as instance $i$ is independent, the joint probability is:\n\n$$\nP_i = P(i|\\hat{x}_i) \\prod_{j \\neq i} (1 - P(i|x_j))\n$$\n\nWhere:\n\n- $P(i|\\hat{x}_i)$: The probability that the augmented sample $\\hat{x}_i$ is correctly classified as instance $i$.\n- $1 - P(i|x_j)$: The probability that other instances $x_j, j \\neq i$ are not misclassified as instance $i$.\n\nBased on maximum likelihood estimation, we can take the negative logarithm of the joint probability to obtain the loss function:\n\n$$\nJ_i = -\\log P(i|\\hat{x}_i) - \\sum_{j \\neq i} \\log(1 - P(i|x_j))\n$$\n\nHere, the loss function consists of two parts:\n\n1. The loss from correctly classifying the augmented sample $\\hat{x}_i$ (the first term).\n2. The loss from not misclassifying other samples (the second term).\n\nThe final total loss function is defined by summing over all instances in the batch:\n\n$$\nJ = -\\sum_i \\log P(i|\\hat{x}_i) - \\sum_i \\sum_{j \\neq i} \\log(1 - P(i|x_j))\n$$\n\nIn implementation, each of the $m$ instances in a batch has one augmented counterpart: one corresponding positive and $2m-2$ other features used as negatives. The loss uses current batch features instead of per-instance classifier weights or a memory bank. The efficiency and discriminability gains are evaluated in the experiments below.\n\n## Discussion\n\n### Comparison with Other Methods\n\n\n\n![result](/content/papers/assets/eb4a0a0dbcc50eebe3f7127b3de08345d6b7f34fe7983030df5223e8e5c89e08.jpg)\n\n\n\nThe authors first follow the experimental design of InstDisc, conducting experiments on the CIFAR-10 and STL-10 datasets, using ResNet18 as the backbone network, with the output dimension of the embedding features set to 128. Evaluation retrieves the $k=200$ nearest neighbors by cosine similarity and then uses weighted kNN voting.\n\nThe table above shows the CIFAR-10 results. The authors compare their method with DeepCluster, Exemplar CNN, NPSoftmax, NCE, and Triplet loss methods. Their 83.6% kNN accuracy is highest among the methods shown, compared with 80.8% for NPSoftmax and 80.4% for NCE.\n\nIn different epochs, the authors plot the learning curves of other methods as shown below:\n\n\n\n![efficiency](/content/papers/assets/f16c3ebfc9432881d14b78787ab4d0836d1fc8df71f13361b31cc4424dd04a71.jpg)\n\n\n\nIn this CIFAR-10 experiment, the proposed method reaches about 60% kNN accuracy in 2 epochs, whereas NCE needs about 25 and Exemplar about 45 epochs to reach the same threshold.\n\nThe curve supports faster convergence at the same accuracy threshold. The authors attribute this to directly optimizing current batch features rather than depending on classifier weights or a memory bank; the epoch count alone is not a wall-clock comparison.\n\n\n> [!TIP]\n> \n> The STL-10 results distinguish 5,000 from 105,000 training images. When comparing methods, keep the data amount and linear-classifier versus kNN metric aligned; we leave the full table to the original paper.\n\n\n### Experiments with Unknown Classes\n\nBased on existing work in supervised deep embedding learning, the authors evaluated the following metrics on the test set:\n\n- **Retrieval Performance (R@K):** Measures the fraction of queries with at least one same-class match among their top $k$ retrieved results.\n- **Clustering Performance (NMI):** Measures the clustering quality of the test set using Normalized Mutual Information (NMI).\n\nNext, to assess the discriminative ability of the learned feature embeddings when there is no overlap in semantic classes between the training and test samples, the authors conducted experiments on the CUB200, Product, and Car196 datasets:\n\n- **CUB200 (Bird Dataset):** The first 100 classes (5,864 images) were used for training, and the remaining 100 classes (5,924 images) were used for testing.\n- **Product (Product Dataset):** The first 11,318 classes (59,551 images) were used for training, and the remaining 11,316 classes (60,502 images) were used for testing.\n- **Car196 (Car Dataset):** The first 98 classes (8,054 images) were used for training, and the remaining 98 classes (8,131 images) were used for testing.\n\nThese experiments use an ImageNet-pretrained Inception-V1 backbone by default; the target datasets' category labels are not used to train the embeddings. For CUB200, the method also uses pretrained features to find a nearest neighbor as an additional positive. The paper separately reports a Product experiment without pretrained weights, so the following table should not be read as a wholly from-scratch comparison.\n\n\n\n![unknown](/content/papers/assets/173388835b8984902cbb2e35ada33d63c22dadb194b67b70542bac60e09b46b1.jpg)\n\n\n\nIn the CUB200 table, the method reaches 46.2% R@1 and 55.4% NMI, above the other unsupervised methods shown. Its R@1 also exceeds some listed supervised methods, though it remains below the best listed 49.8%. These results need to be read with the ImageNet-pretraining condition in mind.\n\n\n> [!TIP]\n> \n> Here, we have only shown the results for the CUB200 dataset; the results for the other two datasets can be found in the original paper.\n\n\n### Ablation Study\n\nThe proposed method introduces two key properties in instance feature learning: **data augmentation invariance** and **instance dispersion**.\n\nTo verify the impact of these properties on performance, the authors conducted an ablation study on the CIFAR-10 dataset.\n\n- **Impact of Data Augmentation Invariance**\n\n\n\n    ![data_aug](/content/papers/assets/868decd7c0ca0ec37b18d0050c71028a127492cb644137b18c2f0c002d1477c9.jpg)\n\n\n\n  The table above shows the results, where:\n\n  - **`w/o`**: Indicates the removal of a specific augmentation operation.\n  - **`R`**: Indicates random cropping (RandomResizedCrop).\n  - **`G`**: Indicates random grayscale (RandomGrayscale).\n  - **`C`**: Indicates color jittering (ColorJitter).\n  - **`F`**: Indicates random horizontal flipping (RandomHorizontalFlip).\n\n  Removing each listed augmentation reduces accuracy: from the full model's 83.6% to 56.2% without random cropping, 79.3% without grayscale, 75.7% without color jitter, or 82.6% without horizontal flipping. Random cropping has the largest effect in this table. The authors also tested using no data augmentation (No DA), shown below:\n\n\n\n    ![no_data_aug](/content/papers/assets/fe08a5b5998d659fa2b5efdb53bb81786cc1861f222d2bb5894d06165eceaf97.jpg)\n\n\n\n  The classification accuracy dropped sharply from 83.6% to 37.4%, which is quite astonishing!\n\n  The authors argue that without augmented views, the model lacks different versions of the same instance to form positive pairs and cannot learn the intended invariance. Table 8's accuracy drop supports the importance of augmentation in this setup.\n\n- **Impact of Instance Dispersion**\n\n  To study the effect of instance dispersion, the authors tested two negative sample selection strategies:\n\n  1. **Hard Negative:** Select the top 50% most similar features to the query instance as negative samples.\n  2. **Easy Negative:** Select the top 50% least similar features to the query instance as negative samples.\n\n\n\n    ![no_data_aug](/content/papers/assets/fe08a5b5998d659fa2b5efdb53bb81786cc1861f222d2bb5894d06165eceaf97.jpg)\n\n\n\n  The same table shows that using only easy negatives drops accuracy from the full model's 83.6% to 57.5%, whereas using only hard negatives reaches 83.2%, close to the full model.\n\n  This means that separating difficult negative samples helps improve the discriminative power of the learned embedding features. In contrast, easy negative samples provide almost no challenge to the model and do not effectively help the model learn instance dispersion.\n\n## Conclusion\n\nThis paper emphasizes two key points: **data augmentation invariance** and **instance dispersion**.\n\nThese experiments support diverse, suitable augmentations and informative negative samples. Hard negatives can be useful, but some may be false negatives from the same semantic class; selecting only the hardest examples is not a universal rule.\n\nThese two conclusions continue to appear in subsequent research and can be regarded as important observations in the field of unsupervised learning.\n","imageSizes":{"/content/papers/assets/135f248ffa5c98e798e9cd5d75ab7cdb38fda8130eae2511547941d70f316165.jpg":{"width":1596,"height":524},"/content/papers/assets/eb4a0a0dbcc50eebe3f7127b3de08345d6b7f34fe7983030df5223e8e5c89e08.jpg":{"width":488,"height":324},"/content/papers/assets/f16c3ebfc9432881d14b78787ab4d0836d1fc8df71f13361b31cc4424dd04a71.jpg":{"width":488,"height":388},"/content/papers/assets/173388835b8984902cbb2e35ada33d63c22dadb194b67b70542bac60e09b46b1.jpg":{"width":624,"height":446},"/content/papers/assets/868decd7c0ca0ec37b18d0050c71028a127492cb644137b18c2f0c002d1477c9.jpg":{"width":1038,"height":126},"/content/papers/assets/fe08a5b5998d659fa2b5efdb53bb81786cc1861f222d2bb5894d06165eceaf97.jpg":{"width":984,"height":124}}}
