页面简介
We find that, just as a large transformer model trained on language can generate coherent text, the same exact model trained on pixel sequences can generate coherent image completions and samples. By establishing a correlation between sample quality and image classification accuracy, we show that our best generative model also contains features competitive with top convolutional nets in the unsupervised setting.
正文摘录
OpenAIJune 17, 2020PublicationImage GPTRead paper(opens in a new window)View code(opens in a new window)ICML 2020 Paper (V1)(opens in a new window)Illustration: Ben BarryShareWe find that, just as a large transformer model trained on language can generate coherent text, the same exact model trained on pixel sequences can generate coherent image completions and samples. By establishing a correlation between sample quality and image classification accuracy, we show that our best generative model also contains features competitive with top convolutional nets in the unsupervised setting.IntroductionUnsupervised and self-supervised learning,1 or learning without human-labeled data, is a longstanding challenge of machine learning. Recently, it has seen incredible success in language, as transformer2 models like BERT,3 GPT‑2,4 RoBERTa,5 T5,6 and other variants7, 8, 9, 10 have achieved top performance on a wide array of language tasks. However, the same broad class of models has not been successful in producing strong features for image classification.11 Our work aims to understand and bridge this gap.Transformer models like BERT and GPT‑2 are domain agnostic, meaning that they can be directly applied to 1-D sequences of any form. When we train GPT‑2 on images unrolled into long sequences of pixels, which we call iGPT, we find that the model appears to understand 2-D image characteristics such as object appearance and category. This is evidenced by the diverse range of coherent image samples it generates, even without the guidance of human provided labels. As further proof, features from the model achieve state-of-the-art performance on a number of classification datasets and near state-of-the-art unsupervised accuracyA on ImageNet.EvaluationDatasetOur ResultBest non-iGPT ResultLogistic regression on learned features (linear probe)CIFAR-1096.3 iGPT‑L 32x32 w/ 1536 features95.3 SimCLR12 w/ 8192 featuresCIFAR-10082.8 iGPT‑L 32x32 w/ 1536 features80.2 SimCLR w/ 8192 featuresSTL-1095.5 iGPT‑L 32x32 w/ 1536 features94.2 AMDIM13 w/ 8192 featuresImageNet72.0 iGPT‑XLa 64x64 w/ 15360 features76.5 SimCLR w/ 8192 featuresFull fine-tuneCIFAR-1099.0 iGPT‑L 32x32, trained on ImageNet99.0b GPipe,14 trained on ImageNetImageNet 32x3266.3 iGPT‑L 32x3270.2 Isometric Nets15We only show ImageNet linear probe accuracy for iGPT‑XL since other experiments did not finish before we needed to transition to different supercomputing facilities.Bit-L, trained on JFT (300M images with 18K classes), achieved a result of 99.3.To highlight the potential of generative17, 18 sequence modeling19, 20, 21, 22 as a general purpose unsupervised learning algorithm, we deliberately use the same transformer architecture as GPT‑2 in language. As a consequence, we require significantly more compute in order to produce features competitive with those from top unsupervised convolutional nets.13, 23, 24, 25, 12 However, our results suggest that when faced with a new domain where the correct model priors are unknown, a large GPT‑2 can learn excellent features without the need for domain-specific26, 27, 28 architectural design choices.Loading...From language GPT to image GPTIn language, unsupervised learning algorithms that rely on word prediction (like GPT‑2 and BERT) have been extremely successful, achieving top performance on a wide array of language tasks. One possible reason for this success is that instances of downstream language tasks appear naturally in text: questions are often followed by answers (which could help with question-answering) and passages are often followed by summaries (which could help with summarization). In contrast, sequences of pixels do not clearly contain labels for the images they belong to.Even without this explicit supervision, there is still a reason why GPT‑2 on images might work: a sufficiently large transformer trained on next pixel prediction might eventually learn to generate diverseB samples with clearly recognizable objects. Once it learns to do so, an idea known as “Analysis by Synthesis”29, 30, C suggests that the model will also know about object categories. Many early generative models31, 32, 33, 34, 35, 36 were motivated by this idea, and more recently, BigBiGAN37 was an example which produced encouraging samples and features. In our work, we first show that better generative models achieve stronger classification performance. Then, through optimizing GPT‑2 for generative capabilities, we achieve top-level classification performance in many settings, providing further evidence for analysis by synthesis.Towards general unsupervised learningGenerative sequence modeling is a universal unsupervised learning algorithm: since all data types can be represented as sequences of bytes, a transformer can be directly applied to any data type without additional engineering. Our work tests the power of this generality by directly applying the architecture used to train GPT‑2 on natural language to image generation. We deliberately chose to forgo hand coding any image specific knowledge in the form of convolutions38 or techniques like relative attention,39 sparse attention,40 and 2-D position embeddings.27As a consequence of its generality, our method requires significantly more compute to achieve competitive performance in the unsupervised setting. Indeed, contrastive methods41, 42, 43, 44, 45, 13, 23, 24, 25, 12 are still the most computationally efficient methods for producing high quality features from images. However, in showing that an unsupervised transformer model is competitive with the best unsupervised convolutional nets,24, 25, 12 we provide evidence that it is possible to trade off hand coded domain knowledge for compute. In new domains,46, 47 where there isn’t much knowledge to hand code, scaling compute seems an appropriate technique to test.ApproachWe train iGPT‑S, iGPT‑M, and iGPT‑L, transformers containing 76M, 455M, and 1.4B parameters respectively, on ImageNet. We also train iGPT‑XLD, a 6.8 billion parameter transformer, on a mix of ImageNet and images from the web. Due to the large computational cost of modeling long sequences with dense attention, we train at the low resolutions of 32x32, 48x48, and 64x64.While it is tempting to work at even lower resolutions to further reduce compute cost, prior work has demonstrated that human performance on image classification begins to drop rapidly below these sizes.48 Instead, motivated by early color display palettes,49 we create our own 9-bit color palette to represent pixels. Using this palette yields an input sequence length 3 times shorter than the standard (R, G, B) palette, while still encoding color faithfully.Experimental resultsThere are two methods we use to assess model performance, both of which involve a downstream classification task. The first, which we refer to as a linear probe, uses the trained model to extract featuresE from the images in the downstream dataset, and then fits a logistic regression to the labels. The second method fine-tunesF the entire model on the downstream dataset.Since next pixel prediction is not obviously relevant to image classification, features from the final layer may not be the most predictive of the object category. Our first result shows that feature quality is a sharply increasing, then mildly decreasing function of depth. This behavior suggests that a transformer generative model operates in two phases: in the first phase, each position gathers information from its surrounding context in order to build a contextualized image feature. In the second phase, this contextualized feature is used to solve the conditional next pixel prediction task. The observed two stage performance of our linear probes is reminiscent of another unsupervised neural net, the bottleneck autoencoder, which is manually designed so that features in the middle are used.Loading...Our next result establishes the link between generative performance and feature quality. We find that both increasing the scale of our models and training for more iterations result in better generative performance, which directly translates into better feature quality.Loading...When we evaluate our features using linear probes on CIFAR-10, CIFAR-100, and STL-10, we outperform features from all supervised and unsupervised transfer algorithms. Our results are also compelling in the full fine-tuning setting.Pre-trained on ImageNetEvaluationModelAccuracyw/o labelsw/ labelsCIFAR-10Linear ProbeResNet-1525094.0✔SimCLR1295.3✔iGPT‑L 32x3296.3✔✔CIFAR-100Linear ProbeResNet-15278.0✔SimCLR80.2✔iGPT‑L 32x3282.8✔STL-10Linear ProbeAMDIM-L94.2✔iGPT‑L 32x3295.5✔CIFAR-10Fine-tuneAutoAugment98.5SimCLR98.6✔GPipe99.0✔iGPT‑L99.0✔CIFAR-100Fine-tuneiGPT‑L88.5✔SimCLR89.0✔AutoAugment89.3EfficientNet5291.7✔A comparison of linear probe and fine-tune accuracies between our models and top performing models which utilize either unsupervised or supervised ImageNet transfer. We also include AutoAugment, the best performing model trained end-to-end on CIFAR.Given the resurgence of interest in unsupervised and self-supervised learning on ImageNet, we also evaluate the performance of our models using linear probes on ImageNet. This is an especially difficult setting, as we do not train at the standard ImageNet input resolution. Nevertheless, a linear probe on the 1536 features from the best layer of iGPT‑L trained on 48x48 images yields 65.2% top-1 accuracy, outperforming AlexNet.Contrastive methods typically report their best results on 8192 features, so we would ideally evaluate iGPT with an embedding dimension of 8192 for comparison. However, training such a model is prohibitively expensive, so we instead concatenate features from multiple layers as an approximation. Unfortunately, our features tend to be correlated across layers, so we need more of them to be competitive. Taking 15360 features from 5 layers in iGPT‑XL yields 72.0% top-1 accuracy, outperforming AMDIM, MoCo, and CPC v2, but still underp