{
  "File Number": "1097",
  "Title": "Enhance the Visual Representation via Discrete Adversarial Training",
  "Limitation": "However, DAT still costs increased training time, this limitation also holds for any adversarial training. The strict assumption of an ideal discretizer is another potential limitation, despite DAT has used powerful VQGAN model to approach this assumption. The effect of DAT is empirically studied without deeper theoretical explanation. All the above limitations are remained as the future optimization direction.",
  "Reviewer Comment": "Reviewer_3: Strengths: 1) Well written paper. Easy to understand. 2) Motivation is explained clearly. 3) Major strength lies in the extensive experimental evaluation. 4) Shown improvements of network generalization across different ImageNet distribution shift datasets and higher adversarial robustness on both ResNet50 and ViT. 5) Conducted ablation studies to understand the effect of different components.\nWeakness: Different assumptions are made to ease the computation of gradients, backpropagation through VQGAN to generate adversarial examples. No theoretical details are shown to support the assumptions and approximations are made through heuristics.\nQuestions:\nIn line 148, it is mentioned that “We delete the constraint term since there is no need to bound the per-pixel values of \\delta”. Would you elaborate on why this constraint is not needed?\nIn line 157, authors mention “as proposed in previous work, a straight-through gradient estimator can be used by copying the gradients from v_q to v”. Which previous work is referred here? Would you provide justification how the gradients can be estimated and copied from v_q to v?\nSimilarly a straight-through gradient estimator was used between Q(x) and x. How does this hold in practice (not in ideal setting) ?\nIn line 179, it is mentioned that “x + \\delta is discretized by VQGAN again and acts as the adversarial input”. Do authors cross check that these adversarial inputs generated by VQGAN still mislead the classifier F?\nLimitations:\nAuthors have not discussed about their limitations. I find no potential negative impact from this work. The method requires heavily parameterized VQGAN to train different networks. This imposes heavy computation time and budget during the training process.\nEthics Flag: No\nSoundness: 2 fair\nPresentation: 3 good\nContribution: 3 good\n\nReviewer_4: Strengths:\nThe presentation is clear and extensive experimental results are convincing.\nWeaknesses:\nMy biggest concern is why discrete representation helps?\nDrVit is very similar except for inner optimization and quantization training. DrVit is training VQVAE from scratch. Will that become unfair comparison? For example, you are using different data for training or pretraining. Could you provide the results if the proposed method is also trained from scratch using the same dataset, loss and architecture? Or DrVit is also using VQGAN\nIn Table 1, why the winner between DrVit and AugReg-Vit keeps changing on different metrics?\nQuestions:\nSee above.\nLimitations:\nn/a\nEthics Flag: No\nSoundness: 3 good\nPresentation: 4 excellent\nContribution: 3 good\n\nReviewer_5: Originality - The idea to use discrete adversarial samples to enhance the performance of vision tasks seems novel/interesting.\nClarity - The paper is well written and can be easily understood.\nClarity - I felt some of the experimental details are missing. For example, the implementation details of the adversarial robustness experiments - FGSM and Damagenet. There are some typos which needs to be proofread.\nQuality - The paper lacks theoretical intuition and the experimental section needs more stronger baselines for robustness tasks. For example the intuition that the straight-through gradient computation and backpropagation canjust be skipped seems very odd to me. At least some empirical evidence (comparison of the adversarial examples that are actually computed by backpropagation) should be reported.\nSignificance - It is difficult to analyze the superiority of the method in adversarial robustness since the robustness experiments is missing baselines from RobustBench. However, number for much smaller epsilons than the ones usually evaluated in robustBench indicate that the method strongly underperforms in this respect.\nWithout error bars, it is unclear how significant the results are.\nAfter the rebuttal and extentive discussion, I see that the proposed approach might have potential w.r.t. model generalization. My orignial argument w.r.t. adversarial robustness holds, but I am willing to increase my score based on the presented results.\nQuestions:\nPlease report robust accuracy values for epsilon = 4/255 on ImageNet and L_inf for AutoAttack.\nI understand that error bars on ImageNet are not possible - but for CIFAR, that would be easier - and allow for a comparison to more SotA methods on RobustBench. For CIFAR, the epsilon for the comparison should be 8/255 for L_inf on AutoAttack.\nLimitations:\nThe authors already mention the limitations of the proposed method – the computational cost and lack of theoretical intuition. Although there are some empirical intuitions provided in the paper (fig 2), the missing error bars in all experiments make the empirical findings less convincing.\nEthics Flag: No\nSoundness: 2 fair\nPresentation: 3 good\nContribution: 2 fair\n\nReviewer_6: Strengths\nThe motivation of the paper comes from an informed perspective of both vision and NLP literature on AT, and I like the fact that the phenomenon from NLP of AT improving both robustness and clean accuracy is used as a goal for AT in vision. This exchange of ideas often leads to improvements across various application domains of machine learning.\nPerformance is evaluated extensively and reported\n3 benchmarks (classification, detection, self-supervised image classification)\nmultiple architectures\nThe paper is well written, especially the methods section. I have a few questions about the method though (see below)\nWeaknesses\nOne major weakness is that previous work on adversarial training has been used for improving domain generalization (see my question1). However, experiments have not been performed in this paper on DG benchmarks.\nThe methods section has some assumptions (see Q 3 and 4) -- these assumptions are not clearly justified (either theoretically or intuitively). More study along these assumptions is needed.\nThe effect of discrete perturbations is not discussed. In pixel-wise AT, the perturbation leads to noisy images. But that need not be true for DAT -- a comparison should be included, perhaps in terms of photorealism comparison between \"real\" images and perturbed images.\nQuestions:\nQuestions\nAdversarial training has also been used in image classification literature for domain generalization: see (GUD: Volpi et al NeurIPS 2018 https://arxiv.org/abs/1805.12018, MADA: Qiao et al. CVPR 2019 https://arxiv.org/abs/2003.13216, ME-ADA: Zhao et al. NeurIPS 2020 https://arxiv.org/abs/2010.08001). This leads me to two questions:\nHow does DAT perform on domain generalization benchmarks such as Digits, PACS, OfficeHome etc.?\nOn the imagenet benchmarks presented in this paper, how does DAT compare with GUD, MADA? (if some of the baselines that you have used have been shown to be better than GUD, MADA -- please let me know which paper).\nLine 148: We delete the constraint term since there is no need to bound the per-pixel values of $\\delta$ -- what are the effects on the performance if the perturbation is bounded? is it better / worse in general? Is is better for some eval datasets but worse for others?\nLine 166: Since xˆ ≃ x established for an ideal discretizer Q -- this connects to my question-3: does the magnitude of the perturbation affect this assumption? Will a large perturbation make this assumption false?\nLine 184: Previous work has pointed out that the underlying distributions of adversarial examples are different from clean images. -- which paper? please cite.\nSuggestions (about References, Structure, Grammar, etc.)\nReferences: you may also add references to \"vision-like\" AT that have been explored in NLP. You have mentioned one of them (FreeLB). Another one is:\nhttps://arxiv.org/abs/2006.06195 (NeurIPS 2020) -- here \"VILLA\" perturbs encoded features (of images and/or text) encoded by pretrained V&L model. In that sense, it is similar to perturbing the VQGAN encoding of images (DAT) is similar to VILLA, but DAT perturbs in the symbolic codebook space.\nReferences: other forms of adversarial training (beyond pixel-wise perturbations) have been explored for vision tasks:\nhttps://arxiv.org/abs/2012.01806 (AAAI 2021) -- \"AGAT\" is an adversarial training pipeline which starts with a given knowledge of symbolic attributes of images, and then perturbs images along those attributes. A comparison should be made between DAT and AGAT: in my view DAT indirectly uses the symbolic knowledge from VQGAN encoder, whereas AGAT assumes that such symbols/attributes will be given.\nTypo: Fig 4 caption: last word should be \"attackers\".\nFig 3 caption: please mention in words what\nα\nis (step size/magnitude of adversarial update).\nFig 2: please label the x-axis\nLine 201: Using robustness: please rephrase this to using \"robustness\" library since robustness is a standard ML term, so people might get confused.\nLimitations:\nLimitations are not discussed clearly. Please add a section in/after conclusion to discuss them. Especially about the assumptions in the method.\nEthics Flag: No\nSoundness: 3 good\nPresentation: 3 good\nContribution: 3 good",
  "5 Limitations and Conclusions": "In this paper, we find transferring NLP-style adversarial training to vision models can enhance the learned visual representation effectively. We propose Discrete Adversarial Training (DAT), where images are presented as discrete visual words by VQGAN, and the model is training on examples which have the adversarially altered discrete visual representation. DAT needs not to modify the model architecture and works for both CNNs and ViTs across multiple tasks. DAT reports the state-ofthe-art robustness on ImageNet-C and Stylized-ImageNet, exhibiting strong generalization. However, DAT still costs increased training time, this limitation also holds for any adversarial training. The strict assumption of an ideal discretizer is another potential limitation, despite DAT has used powerful VQGAN model to approach this assumption. The effect of DAT is empirically studied without deeper theoretical explanation. All the above limitations are remained as the future optimization direction.",
  "abstractText": "Adversarial Training (AT), which is commonly accepted as one of the most effective approaches defending against adversarial examples, can largely harm the standard performance, thus has limited usefulness on industrial-scale production and applications. Surprisingly, this phenomenon is totally opposite in Natural Language Processing (NLP) task, where AT can even benefit for generalization. We notice the merit of AT in NLP tasks could derive from the discrete and symbolic input space. For borrowing the advantage from NLP-style AT, we propose Discrete Adversarial Training (DAT). DAT leverages VQGAN to reform the image data to discrete text-like inputs, i.e. visual words. Then it minimizes the maximal risk on such discrete images with symbolic adversarial perturbations. We further give an explanation from the perspective of distribution to demonstrate the effectiveness of DAT. As a plug-and-play technique for enhancing the visual representation, DAT achieves significant improvement on multiple tasks including image classification, object detection and self-supervised learning. Especially, the model pre-trained with Masked Auto-Encoding (MAE) and fine-tuned by our DAT without extra data can get 31.40 mCE on ImageNet-C and 32.77% top-1 accuracy on Stylized-ImageNet, building the new state-of-the-art. The code will be available at https://github.com/alibaba/easyrobust.",
  "1 Introduction": "Nowadays, Deep Neural Networks (DNNs) has achieved excellent performance surpassing humans in most computer vision tasks. Although remarkable progress has been made, the success of DNNs is actually a false sense when i.i.d hypothesis is not satisfied in wild. Researchers have shown that deep models fail in most circumstances including adversarial perturbations [1], common corruptions [2], colors or textures changing [3, 4], etc. There is still a long way to make DNNs closer to the robust human perception.\nA possible way towards robust machine perception can be Adversarial Training (AT) [5], which automatically finds failure input cases of DNNs and augment online with these cases for fixing \"bugs\". With online augmentation of adversarial examples, AT greatly enhances the adversarial robustness, and helps for learning perceptually-aligned representations [6] with good interpretability [7, 8] and transferability [9]. However, AT is double-edged, which meanwhile degrades the standard performance caused by problematic regularization [10]. Such problematic regularization makes the decision boundaries over-smoothed and enlarges indecisive regions.\nSurprisingly, previous works [11, 12] observe a strange phenomenon that AT behaves conversely in Natural Language Processing (NLP) tasks. By automatically finding adversarial textual inputs,\n⇤Corresponding author: Yao Zhu (E-mail: ee_zhuy@zju.edu.cn)\n36th Conference on Neural Information Processing Systems (NeurIPS 2022).\nAT will not hurt the accuracy and even benefit for both generalization and robustness of language models. This phenomenon motivates us considering whether the merit of NLP-style AT can be transferred to vision tasks. We notice such merit could derive from the unique data organizing form of language models. To be specific, an adversarial image perturbed in continuous pixel space actually differs with the truly \"hard\" examples appeared in real world. Contrarily, text space is discrete and symbolic, where adversarial text is practically existing when a typo is made by humans. Learning on such adversarial text will obviously improve the generalization on other more texts with confusing typos. Therefore, we borrow the symbolic nature of languages, and apply it on CV tasks by discretizing continuous images into a more meaningful symbolic space. Afterwards, AT is conducted for minimizing the maximal risk on such text-like inputs with symbolic adversarial perturbations.\nIn this paper, we propose Discrete Adversarial Training (DAT), a new type of adversarial training which aims to improve both robustness and generalization of vision models. DAT leverages VQGAN [13] to learn a vocabulary of visual words, also known as image codebook. For a continuous image input, each encoded patch embedding is replaced with its closest visual word in the codebook, and represented as a corresponding index. Then the image is transformed to a sequence of symbolic indices similar with language input. For generating adversarial examples based on such symbolic sequence, direct use of optimization methods in NLP like combinatorial optimization [14, 15, 16] or synonym substitutions [14, 16] can be challenging. The reason lies in: 1) the large search space of images and 2) the non-existence of synonym in visual codebook. To make it more efficient, DAT adopts a gradient-based method which assumes the backward adversarial gradient goes straightthrough the complex discretization process, thus gradients on discretized image can be copied to original input. Then it use one-step search along the direction of estimated gradient such that the discrete representation will altered adversarially during the discretization process, resulting a discrete adversarial examples. Finally the discrete adversarial examples is fed into models for training. Different from AT which always adds lp bound on augmented adversarial examples, DAT affects the discretization process to produce diverse adversarial inputs beyond lp bound for training. We show in ablation experiment that DAT not only enhances the robustness on lp bounded attacks, but also is partly beneficial in defense of unrestricted semantic attacks [17, 18]. The overall pipeline of discrete adversarial training is shown in Figure 1.\nWe further give an analysis to explain the effectiveness of our DAT from the perspective of distribution. By comparing the distributional difference of training examples in AT and DAT with clean images, we find the discrete adversarial examples in our DAT are much closer to the clean distribution. Such ability of generating \"in-distribution\" adversarial examples makes DAT can improve the visual representation learning on multiple vision models and tasks, with no sacrificing of clean accuracy.\nOur contributions are summarized below:\n• To the best of our knowledge, we appear to be the first to transfer the merit of NLPstyle adversarial training to vision models, for improving robustness and generalization simultaneously.\n• We propose Discrete Adversarial Training (DAT), where images are presented as discrete visual words, and the model is training on example which has the adversarially altered discrete visual representation.\n• DAT achieves significant improvement on multiple tasks including image classification, object detection and self-supervised learning. Especially, it establishes a new state-of-the-art for robust image classification. By combining MAE [19] pre-training and DAT fine-tuning, our ViT-Huge [20] achieves 31.40 mCE on ImageNet-C [2] and 32.77% top-1 accuracy on Stylized-ImageNet [3].",
  "2 Related Work": "Adversarial Training Adversarial Training (AT) [5] is first proposed to improve robustness by training models with adversarial examples. As one of the most effective defense, existing works [21, 22] have suggested a trade-off between adversarial and clean accuracy in AT. Despite great efforts [23, 24, 25] have been made for mitigating this trade-off, the bad generalization of AT still cannot be fully remedied till now. In opposite way, some other works [26, 27] use AT to improve the clean accuracy rather than adversarial robustness. The most close work to ours is the AdvProp [26], which splits batch norms to prevent the mixed statistics of clean and adversarial\nexamples, thus learns better adversarial feature for generalization. Pyramid AT [28] makes AT specific to ViTs by crafting pyramid perturbation with Dropout enabling, yielding imporved performance. However, these methods are only applicable under specific models or tasks. VILLA [29] is also a representation enhancement technique using AT. But contrary to us, it applies vision-style AT only for vision-and-language representation learning. AGAT [30] is another kind of AT beyond pixel space, which perturbs images along attributes, however it has strict requirement of attributes annotation.\nAdversarial Augmentation By borrowing the idea of AT, some previous works [31, 32, 33] propose to search augmentations adversarially for improving the hardness of training examples. Adversarial AutoAugment [31] uses augmentation policy network to produce hard augmentation policies on a pre-defined policy space. AugMax [32] mixes multiple randomly sampled augmentation operators like AugMix [34], by using adversarially learned mixing factors. AdA [33] optimizes the parameters of image-to-image models to generate adversarially corrupted augmented images. MaxUp [35] uses the worst augmented data of each data point in a set of random perturbations or transforms for training. However, these methods create adversarial inputs indirectly and rely on pre-defined augmentations or translation models. They cannot perturb the images locally. Instead, our DAT directly modifies the image with no need of pre-defined transforms, and can craft local perturbations on images, which is more elaborate.\nDiscrete Visual Representation Learning Early technique [36, 37] of Bag-Of-Visual-Words (BOVW) model has shown great power of discrete representation in visual understanding. VQVAE [38] uses DNNs to learn neural discrete representations, also known as visual codebook, by generative modeling the image distribution. Recently, the idea of discrete representations learning has been widely emerged in many vision tasks. In most Masked Image Modeling (MIM) methods [39, 40], visual codebook is needed for BERT-like self-supervised pretraining. For image classification, discrete representations strengthen the robustness by preserving the global structure of an object and ignoring local details [41]. For image synthesis, adversarial and perceptual objective can be added to VQ-VAE for learning perceptually-aligned visual codebook [13]. With growing power of generative models, now a well trained VQGAN can produce vivid images with 0.58 FID [42]. In this work, we use VQGAN for the discretization process in our DAT. As a powerful generative model, VQGAN can greatly reduce the information loss in reconstruction process and ensure the high-quality of the generated discrete adversarial examples.",
  "3.1 Traditional Adversarial Training": "We take the typical image classification task as an example to show the formulation of Adversarial Training (AT). Consider the training image and label set D = {xi, yi}ni=1, and a classifier F with learnable parameters ✓, the classification objective is always a cross-entropy loss L(x, y, ✓). Adversarial Training (AT) finds the optimal ✓ by solving a minimax optimization problem:\nmin ✓\nE(x,y)⇠D  max L(x+ , y, ✓) s.t.k kp < ✏, (1)\nwhere the inner optimization finds the perturbations on per-pixel values for maximizing the loss, and the outer minimization update ✓ to improve the worst-case performance of the network w.r.t. the perturbation. k · kp constraints the p-norm of to a small value ✏. A problem is that AT finds the failure case i.e. x+ in continuous pixel space. However, human does not create or recognize images from complex pixel values, but from discrete semantic concepts. Although adversarial examples can successfully fool the models, they are still different from the real \"hard\" examples appeared in practice.",
  "3.2.1 Image Discretization by Visual Codebook": "For discrete adversarial training, it is desirable first to learn an expressive visual codebook and represent the training image set in discrete space. We utilize VQGAN [13] for image discretization. More\nprecisely, consider a continuous image x 2 RH⇥W⇥3, VQGAN learns an encoder Enc (·), decoder Dec (·) and quantization qZ (·). Enc is a convolutional model which maps x to intermediate latent vectors v = Enc (x) 2 R(h⇥w)⇥d, where h,w is the height, width of the intermediate feature map and d is the latent dimension. Subsequently, qZ(·) learn a codebook Z = {zk|zk 2 Rd}Kk=1, such that each latent vector vij 2 Rd can be quantized onto its closest codebook entry zk as:\nvq = qZ(v) := ✓ argmin zk2Z kvij zkk ◆ 2 Rh⇥w⇥d, (2)\nwhere i, j present each location in feature map. Then the decoder Dec (·) outputs the reconstruction image x̂ from the quantized vectors vq by:\nx̂ = Dec (vq) . (3)\nVQGAN is trained by minimizing the reconstructed difference between x̂ and x. More details can be referred to Appendix A. So far, given a continuous image x, we can get its corresponding discrete reconstruction x̂. For simplicity, we use Q to stand for the above image discretization process, and then we have x̂ = Q(x).",
  "3.2.2 Discrete Adversarial Training": "Based on the definition in Sec 3.2.1, we can generate discrete adversarial examples in inner maximization step of AT. By slightly modifying the Eq 1, the objective of DAT is formulated as:\nmin ✓\nE(x,y)⇠D  max L(Q(x+ ), y, ✓) , (4)\nwhere Q transforms the continuous pixel space to discrete input space. We delete the constraint term since there is no need to bound the per-pixel values of . Suppose that Q is an ideal discretizer with no information loss in discretization process. The problem lies how to find the worst for maximizing the classification loss. Similar with traditional AT, we can use gradient-based methods to approximate by: ' ↵rxL(Q(x), y, ✓), (5) where ↵ determines the magnitude of the perturbations along the gradient direction. We set ↵ = 0.1 by default in DAT. To expandrxL(Q(x), y, ✓) by chain rule, we have four partial derivative terms as follows:\nrxL(Q(x), y, ✓) = @L @x̂ · @x̂ @vq · @vq @v · @v @x\n(6)\nThrough analysing the feasibility of each term, we find only @vq @v is hard to solve as the nondifferentiable nature of Eq 2. Fortunately, as proposed in previous work, a straight-through gradient estimator [43, 44] can be used by copying the gradients from vq to v. By replacing @x̂@vq · @vq @v with @x̂\n@v , we can simplify the Eq 6 to rxL(Q(x), y, ✓) = @L@x̂ · @x̂ @v · @v @x , which has derivative everywhere.\nAlgorithm 1: Pseudo code of DAT Input: Classifier F ; Pre-trained discretizer Q; A sampled mini-batch of clean images x with labels y; attack magnitude ↵. Output: Learned network parameter ✓ of F\n1: Fix the network parameters of Q 2: for each training steps do 3: x̂ Q(x) //Get the discrete reconstruction x̂ 4: ↵rx̂L(x̂, y, ✓) //Estimate the adversarial perturbations 5: xadv Q(x+ ) //Generate discrete adversarial examples 6: Minimize the classification loss w.r.t. network parameter\nargmin ✓ L(xadv, y, ✓)\n7: end for\nAlthough the solution seems workable theoretically, the huge cost makes it impractical on large-scale vision tasks. The bottleneck mainly lies on that @x̂\n@v and @v @x require the adversarial gradients backward\nthrough Enc and Dec. Actually, a generator capable of producing high-quality images always has a large amount of parameters. Compared with original adversarial training which only needs F for gradient calculation, it requires more than tripled GPU memory and computation cost.\nTo solve this problem, we propose an efficient alternative solution. Since x̂ ' x is empirically observed for an ideal discretizer Q, we can also use a straight-through estimator between x̂ and x, which is given by\nrxL(Q(x), y, ✓) = @L @x̂ · @x̂ @x ' @L @x̂ . (7)\nFinally, we can solve the worst by rx̂L(x̂, y, ✓). By this way, the computation cost of DAT has been largely reduced. Compared with original adversarial training, it only has extra computation cost on VQGAN forward, which is relatively controllable.\nFor clarity, let us restate the pipeline of our DAT. For each training image x, DAT first use VQGAN to get discrete reconstruction x̂. By feeding x̂ to classifier F , a worst-case perturbation can be estimated by computing the gradient of x̂ towards maximizing the classification loss. The perturbed image thus can be created by adding on original x. Finally, x+ is discretized by VQGAN again and acts as the adversarial input, on which F is trained by minimizing the classificaiton loss. The details of our DAT is summarized in Algorithm 1.\nExplaining the Effectiveness of DAT from the Perspective of Distribution We give an empirical analysis to explain why DAT can improve the robustness and generalization without sacrificing clean accuracy. Previous work [26] has pointed out that the underlying distributions of adversarial examples are different from clean images. Training on both clean and adversarial images will force the Batch Normalization (BN) [45] to estimate an inaccurate mixture statistics of feature distribution, and thus impact the standard performance. We study this effect by sampling 1000 mini-batches in ImageNet validation set, and generate corresponding adversarial images for AT and our DAT. For each batch we calculate the mean and variance statis-\ntics of last BN of ResNet50. Then the Pearson correlation coefficient (PCC) between the statistics on clean and adversarial examples is computed for showing the distributional difference. Figure 2 shows the frequency histogram of the distributional difference on 1000 mini-batches. For training samples of DAT, the peak of the histogram is at 0.95, which is greater than AT. It suggests that DAT\ngenerates discrete adversarial examples much closer with the clean distributions. Therefore, training on these examples will reduce the shift of clean distribution in AT, yielding both the robustness and generalization improvement.",
  "4 Experiments": "To demonstrate the versatility of our method, we experiment Discrete Adversarial Training (DAT) on multiple tasks including image classification, object detection and self-supervised learning.",
  "4.1 Image Classification": "Implementation We implement DAT on two representative architectures: ResNet50 [46] and ViTs [20]. For ResNet50, we first experiment DAT with vanilla training recipes using \"robustness\" library 2. Then we combine DAT with other orthogonal robust training techniques: DeepAugment [47] and AugMix [34]. Only cross entropy loss is used for generating discrete adversarial examples. The JSD loss in AugMix is optimized merely on clean samples. For ViTs, we adopt ViT-B/16 as baseline models, which is trained by the recipes in AugReg [48]. Besides, we use DAT to conduct supervised finetuning on downstream ImageNet classification task based on a self-supervised ViTHuge pretrained by MAE [19]. By default, we refer ViT to ViT-B/16 in all tables and figures.\nBenchmarks The trained model is evaluated in three aspects: 1) in-distribution performance on ImageNet-Validation set; 2) adversarial robustness on white-box FGSM [50] and transfer-based black-box attack dataset DamageNet [51]; 3) out-of-distribution robustness on ImageNet(IN)-A, IN-C, IN-V2, IN-R, IN-Sketch and Stylized IN. Each of them represents a type of out-of-distribution scenario where the classifier is prone to make mistakes. IN-A [52] places the ImageNet objects in hard contexts; IN-C [53] applies a series of noise, blur, digital and weather corruptions; IN-R [47] collects online images with artificial creation, e.g., cartoons, graphics, video game renditions, etc; IN-Sketch [54] contains images described by sketches; Stylized IN [3] destroys the texture but maintains the shape feature by conducting style transfer on ImageNet images. Except for IN-C which is measured by mCE, we report the top-1 accuracy on all above datasets.\nResults We report all results in Table 1. For fair comparison, we add DAT on base methods without modifying the original training hyper-parameters, such that improvement is entirely attributed to the\n2https://github.com/MadryLab/robustness\nDAT. For ResNet50, DAT achieves significant improvement on both clean accuracy, adversarial and out-of-distribution robustness. The improvement seems greater when combining DAT with DeepAugment and AugMix. For ViTs, we find DAT is compatible with other complex augmentations such as MixUp [55], CutMix [56] or RandAugment [57] used in AugReg, yielding greater improvement. Compared with plain ViT, AugReg-ViT and ViT with discrete representation called DrViT [41], DAT with AugReg achieves better performance. The best result is from ViT-Huge pretrained by MAE [19] and finetuned by DAT, which suggests DAT is also effective in downstream fine-tuning tasks.\nAdditionally, we also compare DAT with other robust training strategies in Table 2. AugReg-ViT is adopted as the baseline model. Most strategies, e.g., AdvProp [26] and Debiased [49] are proposed for ResNet with auxiliary BatchNorm. We show these methods cannot work properly on ViTs with only LayerNorm. Compared with Pyramid AT [28], our DAT has lower clean accuracy but yields stronger robustness. More results of strategies comparison on ResNet50 refer to Appendix B.1.",
  "4.2 Self-Supervised Learning": "Implementation We experiment DAT on three self-supervised methods: SimCLR [58], SimSiam [59] and recently proposed MoCov3 [60]. The discrete adversarial training is only conducted during pre-training stage, and the learned representation is evaluated on downstream tasks by standard pipeline [61]. We craft adversarial examples based on RoCL [62], which attacks the pre-training objective by maximizing the contrastive loss. For preventing the cost explosion, we pre-train 200 epochs for SimCLR, and 100 epochs for both SimSiam and MoCov3. The batch size used for SimCLR, SimSiam, MoCov3 is set as 1024, 512, 2048 respectively.\nBenchmarks For self-supervised learning, we adopt ImageNet-1K for both training and indistribution testing. Beyond that, in order to give more comprehensive assessment, we build three downstream tasks to metric the transferability of the learned visual representation. Specifically, the linear evaluation reports the top-1 accuracy on five classification datasets: Flowers, CIFAR10, Caltech101, Cars and DTD. For downstream evaluation of object detection, we present mAP, AP50, AP75 on Pascal VOC2007 [63]. ADE20K [64] is used for semantic segmentation task, and both the mean intersection over union (mIoU) and accuracy are reported.\nResults As shown in Table 3, DAT can enhance the learned representation on ImageNet and get 0.97%, 0.58% and 0.25% improvement on MoCov3, SimCLR, SimSiam respectively. For excluding that DAT is not just over-fitting on ImageNet, we transfer the representations on downstream recognition, object detection, semantic segmentation tasks. The results suggest that DAT enhances the self-supervised representations with better transferability. In particular, MoCov3 with DAT achieves significant improvement in all downstream tasks. This conclusion echoed with previous works [9], which find adversari-\nally robust models often perform better on transfer learning.",
  "4.3 Object Detection": "Implementation We implement DAT on two popular detectors: EfficientDet [65] and YOLOv3 [66]. Object detection generally has two sub-tasks: classification and localization. DetAdvProp [67] proposes to select more vulnerable sub-task to generate adversarial images, and use auxiliary BN for training. Instead, DAT regards the two sub-tasks as a whole, and attacks the overall detection loss to produce adversarial images. Besides, DAT does not modify BN in detectors. As the memory and computation cost of VQGAN increased quadratic with the input resolution, DAT become unaffordable when input size is large. Therefore, we only experiment DAT on lightweight version of EfficientDet and YOLOv3 with input size smaller than 512.\nBenchmarks We train the detectors using the COCO 2017 object detection dataset [68] and evaluate them on COCO’s validation set. COCO-C [69] is used for testing the robustness to natural corruptions. We report mAP on COCO and COCO-C as the clean and robust performance respectively. rPC [69] is used to to measure relative performance degradation under corruption.\nResults We compare the detectors with DAT, Det-AdvProp [67] and vanilla training in Table 4. Although Det-AdvProp has been shown effective on EfficientDet with size larger than D0, we find on smaller detectors, the promotion of Det-AdvProp is subtle. On EfficientDet-Lite0 and YOLOv3-320, it even gets worse on COCO mAP than vanilla training. While our DAT achieves better result on both clean and corrupted input. EfficientDet-Lite0 with DAT get 27.3 and 17.89 mAP on COCO and COCO-C, resulting in 65.53% Relative rPC. By comparison, vanilla YOLOv3 models have lower Relative rPC, showing it is more vulnerable than EfficientDet at same clean mAP. After equipped with DAT, YOLOv3-320 can get 20.55 mAP on COCO-C, leading to 7.75% improvement on rPC.",
  "4.4 Ablations": "Impact of the Codebook in DAT A general understanding is that the codebook with larger K should have stronger representation power. As suggested in Table 5, when the K is reduced from 16384 to 256, the FID of generated images increases 0.35. We show DAT on larger codebook size can achieve better generalization. However, the clean accuracy seems no improvement with increasing of K. We think the reason is that the reconstruction quality has already met the demand of DAT. And the improvement on clean accuracy is saturated when K further increases.\nDifferent Types of Discretizer Q Our work is based on the hypothesis of an ideal Q with no loss in discretization process. However, such perfect Q is not existing in practice. So we study if and how the ability of Q affects the performance of our DAT in Table 5. The results show DAT performs better by using discretizer with higher FID. We find clean accuracy declines 1.3% on DALL-E, showing it is important for choosing a powerful discretizer. Types of pre-training datasets have little impact. We find the discretizer pre-trained on OpenImages [70] and transferred to discretize ImageNet images, can also achieve comparable results.\nThe Performance on Different Magnitude ↵ We present the DAT results on ResNet50 and ViT with different magnitude ↵ in Figure 3. ↵ = 0 means the model is only trained on images augmented by VQGAN with no adversarial training process. We show DAT with ↵ = 0 makes the models have high clean accuracy but the lowest robustness. With the increase of ↵, there is still a robustness and accuracy trade-off. DAT with ↵ = 0.4 on ResNet50 achieves the best adversarial robustness but generalization is getting worse. By contrast, we surprisingly find ViT has the lower sensibility on ↵. Even if ViT is trained on DAT with ↵ = 0.4, there is still no great drop of clean and OOD accuracy.\nWe suspect that ViT is more suitable for training on discrete examples, and the strong modeling ability makes ViT greater than ResNet50.\nResults on Stronger Attacks In the main experiment, only one-step FGSM is used for examining the robustness under white-box adversarial attacks. To give more comprehensive evaluation, we additionally test our DAT under stronger AutoAttack [73], and two unrestricted attacks named AdvDrop [17] and PerC-Adversarial [18]. The result is shown in Figure 4. DAT brings the improvement of robustness under all three attackers. ViT trained with DAT achieved extremely high robust accuracy on PerC-Adversarial, which suggests DAT also effects well in defense against unrestricted adversarial attacks. More details can be referred to Appendix C.",
  "4.5 In-depth Analysis": "Discrete Perturbations vs. Pixel-Space Perturbations We compare the proposed Discrete Adversarial Examples (DAEs) with traditional Pixel-space Adversarial Examples (PAEs) in Figure 5. DAEs have following three superior properties: 1) DAEs are more realistic. By calculating the number of colors [17], we find PAEs add more invalid colors, resulting in a noisy image. While DAEs have minor changes on the color numbers, its modification is harder to be perceived by humans. To give quantitative results, we additionally report the FID score of DAEs. The FID score of our DAEs is 14.65, which is lower than 65.18 of AEs. The results are also consistent with our visual presentation result in Figure 5; 2) DAEs have less high frequency component compared with AEs in frequency analysis. It may lead the DAEs more close to natural image distributions; 3) Discrete perturbations are more structural. From the perturbation visualization in third row of Figure 5, we find discrete perturbations have more structured information about objects, shown it attends to more important locations. While pixel-wise perturbations are noisy and disordered.\nVisualized Attention. We visualize the attention of ViT trained by DAT in Figure 6(b). For the object with unusual renditions in ImageNet-R, ViT cannot attend to semantically relevant image regions. While our DAT can locate the attention to the central object more related for the classification. This phenomenon is also reflected by the statistical average of the attention in Figure 6(c). By randomly sampling 1000 images in ImageNet-R and averaging the attention maps, we find the attentions of our DAT are more global. Compared with ViT which puts much attentions on the corners of the image found by prior work [20], our DAT additionally attends the central regions in where the classified object is often located.\nShape-bias Analysis. We conduct an analysis based on shape-bias, which represents the fraction of correct decisions based on object shape. The result is shown in Figure 6(a). The averaged scores on 16 categories is denoted by the colored vertical line. We compare decisions with Humans, ResNet50 w/ and w/o DAT, ViT w/ and w/o DAT. Human decisions are highly based on shape, which achieve the best average fraction of 0.96 to correctly recognize an image by shape. By comparison, ViT and ResNet50 still have large gap with humans on the ability of learning shape features. In this work, we find our DAT can help for improving the fraction of shape-based decisions of models. It suggests DAT regularizes the models to learn texture independent shape features, and behave more like a human.",
  "Reviewer Summary": "Reviewer_3: The paper proposes Discrete Adversarial Training (DAT) strategy for vision tasks that avoids continuous-Lp based perturbations and encourages adversarial examples generated through image discretization using VQGAN. Authors derive the motivation for using image discretization from the observation of improved generalization via discrete adversarial training in NLP tasks. Adversarial examples generated using this discretization process are used for training different architectures for different downstream tasks. Unlike traditional adversarial training (AT), DAT shown to improve network generalization across different tasks, different distribution shifts and also improve adversarial robustness. Major improvements are noticed in image classification task and minimal or comparable performance seen on object detection and semantic segmentation tasks.\n\nReviewer_4: This paper proposes discrete adversarial training to boost the performance on representation learning. Extensive results on image classification, object detection and self-supervised learning validate the effectiveness.\n\nReviewer_5: The paper proposes a discrete adversarial training strategy to alleviate the robustness-generalization trade-off in vision tasks. Motivated from the adversarial training used in NLP models, the authors claim that a discrete representation of the image space will aid in more robust models without much drop in generalization. The method utilizes a VQGAN model to generate discrete adversarial samples for adversarial training. The authors show that the adversarial training strategy enhances the performances of various vision tasks such as classification, object detection and self-supervised learning.\n\nReviewer_6: This paper studies the problem of adversarial training for vision tasks by borrowing ideas from NLP. A new method called \"DAT\" (Discrete Adversarial Training) is proposed. DAT uses a VQA-GAN encoder to convert images into discrete tokens, by learning a vocabulary of words (aka image codebook). Adversarial perturbations are applied on these tokens. Performance is reported on:\n6 versions of Imagenet for evaluating robustness (Imagenet-A/C/V2/R/ Stylized/Sketch)\nagainst adversarial attacks (FGSM, DamageNet)\nCOCO-C for object detection"
}