techlist.io

Image Classification

3 posts

OpenAI2020-06-164 min readCurated summary

Image GPT

Image GPT shows that a transformer trained on pixel sequences, using the same architecture as GPT-2 for language, can generate coherent image completions and samples without any human-labeled data. The authors show that generative quality tracks feature quality, and their best model's features compete with top unsupervised convolutional networks on classification benchmarks. The approach needs far more compute than contrastive methods, so the authors frame it as a proof of concept for domain-agnostic learning rather than a practical vision method. ## Motivation: Bridging the Gap Between Language and Vision - Transformers such as BERT, GPT-2, RoBERTa, and T5 have set top results across language tasks, but the same class of models has not produced strong image classification features. - Language tasks naturally appear inside text (questions followed by answers, passages followed by summaries), while pixel sequences carry no explicit labels. - The authors rely on the "Analysis by Synthesis" idea: a model that learns to generate realistic images should also learn object categories. ## Image GPT (iGPT) Architecture and Training - The authors use the GPT-2 transformer unchanged, feeding it images unrolled into pixel sequences, and deliberately avoid image-specific components such as convolutions, relative or sparse attention, and 2-D position embeddings. - Three model sizes were trained on ImageNet: iGPT-S (76M parameters), iGPT-M (455M), and iGPT-L (1.4B). A 6.8B-parameter iGPT-XL was trained on ImageNet plus web images. - Training used low resolutions (32x32, 48x48, 64x64) because dense attention over long sequences is expensive. - A custom 9-bit color palette shortens the input sequence to one-third the length of a standard RGB encoding while preserving color. ## Evaluation Methods and Feature Behavior - **Linear probe:** features are extracted from a frozen model, average-pooled over the sequence, and fed to logistic regression. - **Full fine-tune:** the entire model is trained on the downstream dataset. - Feature quality rises and then falls slightly with depth. The authors read this as two phases: early layers build contextual image features, and later layers serve next-pixel prediction. This resembles a bottleneck autoencoder. - Larger models and longer training improve generative quality, which in turn improves feature quality. ## Results - **Linear probes:** iGPT-L (32x32) reaches 96.3% on CIFAR-10, 82.8% on CIFAR-100, and 95.5% on STL-10, beating the best listed supervised and unsupervised transfer methods on those datasets. - **ImageNet linear probe:** iGPT-L at 48x48 reaches 65.2% top-1, above AlexNet. Concatenating features from five layers of iGPT-XL reaches 72.0%, ahead of AMDIM, MoCo, and CPC v2 but behind SimCLR's 76.5%. - **Full fine-tune:** iGPT-L matches GPipe at 99.0% on CIFAR-10 and scores 66.3% on ImageNet at 32x32. - **BERT-style masked pixel training:** linear probe accuracy is notably worse, but fine-tuning results are strong. - **Semi-supervised CIFAR-10:** a logistic regression on iGPT-L features, with no augmentation or fine-tuning, beats Mean Teacher and MixMatch but trails FixMatch. ## Limitations - Compute cost is very high. iGPT-L took roughly 2,500 V100-days, while a similarly performing MoCo model needs about 70 V100-days. - Transformers on low-resolution pixels lack the easy high-resolution scaling of convolutional encoders, so a new architecture may be needed. - Generative models can absorb dataset biases. The authors give the example of a "scientist" concept skewed toward men. ## Conclusion The authors argue that trading hand-coded 2-D image knowledge for scale, and taking features from middle layers, lets a plain sequence transformer compete with convolutional networks in unsupervised image classification. Given enough compute, they suggest, this simple and general approach could learn strong features in many domains. The paper positions the work as proof of concept, since the compute and resource costs keep it from practical vision applications today.

OpenAI2017-07-162 min readCurated summary

Robust adversarial inputs

Researchers have created adversarial images that stay effective across different scales and viewing perspectives, which challenges the view that self-driving cars would be hard to fool because they capture images from many angles. Standard adversarial examples break under small image transformations, but the authors show that deliberately optimizing against a range of transformations produces perturbations that remain adversarial. The result is a single image that fools a neural network classifier under scaling, rotation, translation, noise, and other changes. ## Why Standard Adversarial Examples Are Fragile - Ordinary adversarial examples, created with projected gradient descent, fail under simple image transformations. - In the post's demo, a cat image perturbed to be classified as a "desktop computer" by Inception v3 (trained on ImageNet) was correctly relabeled as a "tabby cat" after a zoom of just 1.002. - The authors suspected that adversarial examples could be made robust with deliberate effort, since prior work showed they can transfer to the physical world. ## Scale-invariant Adversarial Examples - Instead of optimizing against one fixed view, the method optimizes over an ensemble of stochastic classifiers that randomly rescale the input before classifying it. - This produces perturbations that are adversarial across scales. - Even when only the pixels belonging to the cat are modified, a single perturbed image can be adversarial at all desired scales at once. ## Transformation-invariant Adversarial Examples - The same technique is extended by adding random rotations, translations, scaling, noise, and mean shifts during optimization. - The resulting single input remains adversarial under any of these transformations. - Transformations are sampled randomly at test time, which shows the example is robust across the whole distribution of transformations, not just a few cherry-picked ones. ## Implications The findings suggest that vision systems relying on multiple viewpoints are not automatically protected against adversarial attacks, since an attacker can deliberately optimize an input to survive those variations.