SlowGuess commited on
Commit
f76b6ec
·
verified ·
1 Parent(s): 2f9a251

Add Batch d7b56815-af37-4d96-a38a-285f13d76d14

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. draftandreviseeffectiveimagegenerationwithcontextualrqtransformer/69e4999c-0dda-47a8-bf21-e7202be93717_content_list.json +3 -0
  2. draftandreviseeffectiveimagegenerationwithcontextualrqtransformer/69e4999c-0dda-47a8-bf21-e7202be93717_model.json +3 -0
  3. draftandreviseeffectiveimagegenerationwithcontextualrqtransformer/69e4999c-0dda-47a8-bf21-e7202be93717_origin.pdf +3 -0
  4. draftandreviseeffectiveimagegenerationwithcontextualrqtransformer/full.md +326 -0
  5. draftandreviseeffectiveimagegenerationwithcontextualrqtransformer/images.zip +3 -0
  6. draftandreviseeffectiveimagegenerationwithcontextualrqtransformer/layout.json +3 -0
  7. drawingoutofdistributionwithneurosymbolicgenerativemodels/005c4d28-ffc7-46e2-81d4-52d16d0e294e_content_list.json +3 -0
  8. drawingoutofdistributionwithneurosymbolicgenerativemodels/005c4d28-ffc7-46e2-81d4-52d16d0e294e_model.json +3 -0
  9. drawingoutofdistributionwithneurosymbolicgenerativemodels/005c4d28-ffc7-46e2-81d4-52d16d0e294e_origin.pdf +3 -0
  10. drawingoutofdistributionwithneurosymbolicgenerativemodels/full.md +245 -0
  11. drawingoutofdistributionwithneurosymbolicgenerativemodels/images.zip +3 -0
  12. drawingoutofdistributionwithneurosymbolicgenerativemodels/layout.json +3 -0
  13. dreamshardgeneralizableembeddingtableplacementforrecommendersystems/b7e19046-19b1-47d6-85d0-e1ea6fd3dc21_content_list.json +3 -0
  14. dreamshardgeneralizableembeddingtableplacementforrecommendersystems/b7e19046-19b1-47d6-85d0-e1ea6fd3dc21_model.json +3 -0
  15. dreamshardgeneralizableembeddingtableplacementforrecommendersystems/b7e19046-19b1-47d6-85d0-e1ea6fd3dc21_origin.pdf +3 -0
  16. dreamshardgeneralizableembeddingtableplacementforrecommendersystems/full.md +298 -0
  17. dreamshardgeneralizableembeddingtableplacementforrecommendersystems/images.zip +3 -0
  18. dreamshardgeneralizableembeddingtableplacementforrecommendersystems/layout.json +3 -0
  19. dropcovasimpleyeteffectivemethodforimprovingdeeparchitectures/91a0e411-0419-4d5c-bce3-b3bc7a6abb08_content_list.json +3 -0
  20. dropcovasimpleyeteffectivemethodforimprovingdeeparchitectures/91a0e411-0419-4d5c-bce3-b3bc7a6abb08_model.json +3 -0
  21. dropcovasimpleyeteffectivemethodforimprovingdeeparchitectures/91a0e411-0419-4d5c-bce3-b3bc7a6abb08_origin.pdf +3 -0
  22. dropcovasimpleyeteffectivemethodforimprovingdeeparchitectures/full.md +301 -0
  23. dropcovasimpleyeteffectivemethodforimprovingdeeparchitectures/images.zip +3 -0
  24. dropcovasimpleyeteffectivemethodforimprovingdeeparchitectures/layout.json +3 -0
  25. dualcoopfastadaptationtomultilabelrecognitionwithlimitedannotations/93b11b1a-5d67-437e-801d-520aeff5c6bc_content_list.json +3 -0
  26. dualcoopfastadaptationtomultilabelrecognitionwithlimitedannotations/93b11b1a-5d67-437e-801d-520aeff5c6bc_model.json +3 -0
  27. dualcoopfastadaptationtomultilabelrecognitionwithlimitedannotations/93b11b1a-5d67-437e-801d-520aeff5c6bc_origin.pdf +3 -0
  28. dualcoopfastadaptationtomultilabelrecognitionwithlimitedannotations/full.md +327 -0
  29. dualcoopfastadaptationtomultilabelrecognitionwithlimitedannotations/images.zip +3 -0
  30. dualcoopfastadaptationtomultilabelrecognitionwithlimitedannotations/layout.json +3 -0
  31. dualcurriculumcontrastivemultiinstancelearningforcancerprognosisanalysiswithwholeslideimages/5b1c0314-65cc-4c15-ad5e-c31a6e0ab1b5_content_list.json +3 -0
  32. dualcurriculumcontrastivemultiinstancelearningforcancerprognosisanalysiswithwholeslideimages/5b1c0314-65cc-4c15-ad5e-c31a6e0ab1b5_model.json +3 -0
  33. dualcurriculumcontrastivemultiinstancelearningforcancerprognosisanalysiswithwholeslideimages/5b1c0314-65cc-4c15-ad5e-c31a6e0ab1b5_origin.pdf +3 -0
  34. dualcurriculumcontrastivemultiinstancelearningforcancerprognosisanalysiswithwholeslideimages/full.md +370 -0
  35. dualcurriculumcontrastivemultiinstancelearningforcancerprognosisanalysiswithwholeslideimages/images.zip +3 -0
  36. dualcurriculumcontrastivemultiinstancelearningforcancerprognosisanalysiswithwholeslideimages/layout.json +3 -0
  37. dualdiscriminativegraphneuralnetworkforimbalancedgraphlevelanomalydetection/43b450fc-7716-499c-9a02-4761f33f68d2_content_list.json +3 -0
  38. dualdiscriminativegraphneuralnetworkforimbalancedgraphlevelanomalydetection/43b450fc-7716-499c-9a02-4761f33f68d2_model.json +3 -0
  39. dualdiscriminativegraphneuralnetworkforimbalancedgraphlevelanomalydetection/43b450fc-7716-499c-9a02-4761f33f68d2_origin.pdf +3 -0
  40. dualdiscriminativegraphneuralnetworkforimbalancedgraphlevelanomalydetection/full.md +371 -0
  41. dualdiscriminativegraphneuralnetworkforimbalancedgraphlevelanomalydetection/images.zip +3 -0
  42. dualdiscriminativegraphneuralnetworkforimbalancedgraphlevelanomalydetection/layout.json +3 -0
  43. dungeonsanddataalargescalenethackdataset/21cf6cd0-c8cb-46b3-bf74-fb3b6f182a21_content_list.json +3 -0
  44. dungeonsanddataalargescalenethackdataset/21cf6cd0-c8cb-46b3-bf74-fb3b6f182a21_model.json +3 -0
  45. dungeonsanddataalargescalenethackdataset/21cf6cd0-c8cb-46b3-bf74-fb3b6f182a21_origin.pdf +3 -0
  46. dungeonsanddataalargescalenethackdataset/full.md +320 -0
  47. dungeonsanddataalargescalenethackdataset/images.zip +3 -0
  48. dungeonsanddataalargescalenethackdataset/layout.json +3 -0
  49. dynamicfairdivisionwithpartialinformation/bfcf9575-ec57-4370-818d-1572738087d3_content_list.json +3 -0
  50. dynamicfairdivisionwithpartialinformation/bfcf9575-ec57-4370-818d-1572738087d3_model.json +3 -0
draftandreviseeffectiveimagegenerationwithcontextualrqtransformer/69e4999c-0dda-47a8-bf21-e7202be93717_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:337aa7eab31cdc8339f7c4b39c1cabb80c286d489f919e8ba2f801b6a91ce06a
3
+ size 77300
draftandreviseeffectiveimagegenerationwithcontextualrqtransformer/69e4999c-0dda-47a8-bf21-e7202be93717_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c53356ccc8658ce1118e83007651c2a07267d65b6c5914fd09a17b84811d30c
3
+ size 92781
draftandreviseeffectiveimagegenerationwithcontextualrqtransformer/69e4999c-0dda-47a8-bf21-e7202be93717_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dc07e8dd876b17f58b9556d33975134c831504d21b180b4c33380dc7b7b51996
3
+ size 3577324
draftandreviseeffectiveimagegenerationwithcontextualrqtransformer/full.md ADDED
@@ -0,0 +1,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Draft-and-Revise: Effective Image Generation with Contextual RQ-Transformer
2
+
3
+ Doyup Lee*
4
+
5
+ Kakao Brain
6
+
7
+ doyup.lee@kakaobrain.com
8
+
9
+ Chiheon Kim*
10
+
11
+ Kakao Brain
12
+
13
+ chiheon.kim@kakaobrain.com
14
+
15
+ Saehoon Kim
16
+
17
+ Kakao Brain
18
+
19
+ shkim@kakaobrain.com
20
+
21
+ Minsu Cho
22
+
23
+ POSTECH
24
+
25
+ mscho@postech.ac.kr
26
+
27
+ Wook-Shin Han†
28
+
29
+ POSTECH
30
+
31
+ wshan@dblab.postech.ac.kr
32
+
33
+ # Abstract
34
+
35
+ Although autoregressive models have achieved promising results on image generation, their unidirectional generation process prevents the resultant images from fully reflecting global contexts. To address the issue, we propose an effective image generation framework of Draft-and-Revise with Contextual RQ-transformer to consider global contexts during the generation process. As a generalized VQ-VAE, RQ-VAE first represents a high-resolution image as a sequence of discrete code stacks. After code stacks in the sequence are randomly masked, Contextual RQ-Transformer is trained to infill the masked code stacks based on the unmasked contexts of the image. Then, we propose the two-phase decoding, Draft-and-Revise, for Contextual RQ-Transformer to generate an image, while fully exploiting the global contexts of the image during the generation process. Specifically, in the draft phase, our model first focuses on generating diverse images despite rather low quality. Then, in the revise phase, the model iteratively improves the quality of images, while preserving the global contexts of generated images. In experiments, our method achieves state-of-the-art results on conditional image generation. We also validate that the Draft-and-Revise decoding can achieve high performance by effectively controlling the quality-diversity trade-off in image generation.
36
+
37
+ # 1 Introduction
38
+
39
+ Learning discrete representations of images enables autoregressive (AR) models to achieve promising results on image generation. Here, an image is encoded into a feature map, which is represented as a sequence of discrete codes [13, 33] or code stacks [23]. Then, an AR model generates a sequence of codes in the raster scan order and decodes the codes into an image. Consequently, AR models show high performance and scalability on large-scale datasets [13, 23, 26].
40
+
41
+ Despite the promising results of AR models, we pos
42
+
43
+ tulate that the ability of AR models is limited due to the lack of considering global contexts in the generation process. Specifically, since AR models generate images by sequentially predicting the
44
+
45
+ ![](images/1a021e2ddb834f507f24a7adfb38c60de78e47a5df0dfff6837c7d3a913785d5.jpg)
46
+ Figure 1: Examples of image inpainting by an AR model (middle) and ours (right).
47
+
48
+ next code and attending to only precedent codes generated, they neither exploit the later part of the generated image nor consider the global contexts during generation. For example, Figure 1 (middle) shows that an AR model fails to generate a coherent image, when it is asked to inpaint the masked region of Figure 1 (left) with a school bus. Such a failure is due to the inability of AR models to refer to the context of traffic lane on the right side of the masked region.
49
+
50
+ To address this issue, we propose an effective image generation framework, Draft-and-Revise, with a contextual transformer to exploit the global contexts of images. Given a randomly masked image, the contextual transformer is first trained to infill the masks by bidirectional self-attention similarities similarly to BERT [8]. To fully leverage the contextual prediction in generation, we propose Draft-and-Revise decoding which has two phases, draft and revise, imitating the image generation process of a human expert who draws a draft first and iteratively revises the draft to improve its quality. In the draft phase, the model first infills an empty image to generate a draft image with diverse contents despite the rather low-quality. In the revise phase, the visual quality of the draft is iteratively improved, while the global contexts of the draft are preserved and exploited. Consequently, our Draft-and-Revise with contextual transformer effectively generates high-quality images with diverse contents.
51
+
52
+ We use residual-quantized VAE (RQ-VAE) [23] to implement our image generation framework, since RQ-VAE generalizes vector-quantized VAE (VQ-VAE) [33] by representing an image as a sequence of code stacks instead of a sequence of codes. Then, we propose Contextual RQ-Transformer as a contextual transformer for masked code stack modeling of RQ-VAE. Specifically, given a sequence of randomly masked code stacks, Contextual RQ-Transformer first uses a bidirectional transformer to capture the global contexts of unmasked code stacks. Based on the global contexts, the masked code stacks are predicted in parallel, while the codes in each masked code stack are sequentially predicted. In experiments, our Draft-and-Revise framework with Contextual RQ-Transformer achieves state-of-the-art results on conditional image generation and remarkable improvements on image inpainting. In addition, we demonstrate that Draft-and-Revise decoding can effectively control the quality-diversity trade-off in image generation to achieve high performance.
53
+
54
+ The main contributions of this paper are summarized as follows. 1) We propose an intuitive and powerful framework, Contextual RQ-Transformer, for masked code stack modeling of RQ-VAE based on a bidirectional transformer. 2) We propose a novel two-phase decoding, Draft-and-Revise, for bidirectional transformers to fully exploit the global contexts during image generation and achieve state-of-the-art results on class- and text-conditional image generation benchmarks. 3) An extensive ablation study validates the effectiveness of Draft-and-Revise decoding on controlling the quality-diversity trade-off and its capability to generate high-quality images with diverse contents.
55
+
56
+ # 2 Related Work
57
+
58
+ Discrete Representation for Image Generation By representing an image as a sequence of codes, VQ-VAE [33] becomes an important part for high-resolution image generation [6, 10, 15, 23, 26, 33], but suffers from low quality of reconstructed images. However, VQGAN [13] significantly improves the perceptual quality of reconstructed images by adding the adversarial and perceptual losses into the training objective of VQ-VAE. As a generalized approach of VQ-VAE and VQGAN, RQ-VAE [23] represents an image as a sequence of code stacks, which consists of ordered codes, and reduces the sequence length, while preserving the reconstruction quality. Then, RQ-Transformer [23] achieves high performance with lower computational costs on generating high-resolution images. However, as an AR model of RQ-VAE, RQ-Transformer cannot capture the global contexts of generated images.
59
+
60
+ Generation Tasks with Bidirectional Transformers To overcome the limitation of AR models on unidirectional architecture, bidirectional transformers have been studied for generative tasks. After a bidirectional transformer is trained to infill a random mask as the masked token modeling of BERT [8], an effective decoding method has been proposed for bidirectional transformers to generate texts [14, 30], images [6, 35], or videos [16]. For image generation, M6-UFC [35] first incorporates the masked token modeling in the codes of VQGAN [13] for image generation. MaskGIT [6] proposes the confidence-based decoding to achieve high performance on ImageNet [7]. Similar to M6-UFC [35] and MaskGIT [6], we also incorporate the masked token modeling of RQ-VAE in a bidirectional transformer for image generation. However, instead of the confidence-based decoding [6, 35], we propose a novel two-phase decoding for a bidirectional transformer to achieve state-of-the-art performance and validate its effectiveness. Recently, discrete diffusion models [1, 4, 12, 15] also uses
61
+
62
+ ![](images/85b2b461df4adcf46cfff9c147818bb911c91bcc6f29722f41939288924226d9.jpg)
63
+ Tokenizing (RQ-VAE)
64
+
65
+ ![](images/3a8d5e5d9bccc7f9f2a06611831589d0ac3651e507dcb5f6bd91f61b22336391.jpg)
66
+ Random Masking
67
+
68
+ ![](images/1439462acfd962d87b120f2817578afe2131efb46b0493ddd5ad0db5c46a8c38.jpg)
69
+ Contextual RQ-Transformer
70
+
71
+ ![](images/bc648c59fbd0bf28332fef86ae8569fd66d73b98fd942c32fb3132eaaca0475a.jpg)
72
+ Draft-and-Revise Decoding
73
+
74
+ ![](images/f27ea1a4bd6e4f51135f24cf0cbc79dd4875a95db8398031423bd42202a3d399.jpg)
75
+ Figure 2: The overview of Draft-and-Revise framework with Contextual RQ-Transformer. Our framework exploits global contexts of images to generate high-quality images with diverse contents.
76
+
77
+ bidirectional transformers to generate an image, and the training with an absorbing state [1] is also the same to infill randomly masked sequence [4, 6]. However, different from the reverse process of diffusion models, our decoding method has explicit two phases to generate high-quality images with diverse contents.
78
+
79
+ # 3 Draft-and-Revise Framework for Effective Image Generation
80
+
81
+ In this section, we propose our Draft-and-Revise framework for effective image generation using bidirectional contexts of images. We first review RQ-VAE [23] as a generalization of VQ-VAE. Then, we propose Contextual RQ-Transformer which is trained to infill a randomly masked sequence of code stacks of RQ-VAE by understanding bidirectional contexts of unmasked parts in the sequence. Lastly, we propose draft-and-revise decoding for a bidirectional transformer to effectively generate high-quality images exploiting global contexts of images. Figure 2 provides the overview of our proposed framework, including Contextual RQ-Transformer and Draft-and-Revise decoding.
82
+
83
+ # 3.1 Residual-Quantized Variational Autoencoder (RQ-VAE)
84
+
85
+ RQ-VAE [23] represents an image as a sequence of code stacks. Let a codebook $\mathcal{C} = \{(k, \mathbf{e}(k))\}_{k \in [K]}$ include pairs of a code $k$ and its code embedding $\mathbf{e}(k) \in \mathbb{R}^{n_z}$ , where $K = |\mathcal{C}|$ is the codebook size and $n_z$ is the dimensionality of $\mathbf{e}(k)$ . Given a vector $\mathbf{z} \in \mathbb{R}^{n_z}$ , $\mathcal{Q}(\mathbf{z}; \mathcal{C})$ is defined as the code of $\mathbf{z}$ :
86
+
87
+ $$
88
+ \mathcal {Q} (\mathbf {z}; \mathcal {C}) = \underset {k} {\arg \min } \| \mathbf {z} - \mathbf {e} (k) \| _ {2} ^ {2}. \tag {1}
89
+ $$
90
+
91
+ Then, RQ with depth $D$ represents a vector as a code stack which consists of $D$ codes:
92
+
93
+ $$
94
+ \mathcal {R Q} (\mathbf {z}; \mathcal {C}, D) = \left(k _ {1}, \dots , k _ {D}\right) \in [ K ] ^ {D}, \tag {2}
95
+ $$
96
+
97
+ where $k_{d}$ is the $d$ -th code of $\mathbf{z}$ . Specifically, RQ first initializes the 0-th residual vector as $\mathbf{r}_0 = \mathbf{z}$ , and then recursively discretizes a residual vector $\mathbf{r}_{d-1}$ and computes the next residual vector $\mathbf{r}_d$ as
98
+
99
+ $$
100
+ k _ {d} = \mathcal {Q} \left(\mathbf {r} _ {d - 1}; \mathcal {C}\right), \quad \mathbf {r} _ {d} = \mathbf {r} _ {d - 1} - \mathbf {e} \left(k _ {d}\right), \tag {3}
101
+ $$
102
+
103
+ for $d \in [D]$ . Finally, $\mathbf{z}$ is approximated by the sum of the $D$ code embeddings $\hat{\mathbf{z}} := \sum_{d=1}^{D} \mathbf{e}(k_d)$ . We remark that RQ is a generalized version of VQ, as RQ with $D = 1$ is equivalent to VQ. For $D > 1$ , RQ conducts a finer approximation of $\mathbf{z}$ as the quantization errors are sequentially reduced as $d$ increases. Here, the coarse-to-fine approximation ensures the $D$ codes to be sequentially dependent.
104
+
105
+ RQ-VAE represents an image as a map of code stacks. Specifically, a given image $\mathbf{X}$ is first converted to a low-resolution feature map $\mathbf{Z} = E(\mathbf{X}) \in \mathbb{R}^{H \times W \times n_z}$ , and then each feature vector $\mathbf{Z}_{hw}$ at spatial position $(h, w)$ is discretized into a code stack by RQ with depth $D$ . As a result, we get a map of code stacks $\mathbf{S} \in [K]^{H \times W \times D}$ . Further details of RQ-VAE are referred to Appendix.
106
+
107
+ # 3.2 Contextual Transformer for Image Generation with Global Contexts
108
+
109
+ As a bidirectional transformer for RQ-VAE, we propose Contextual RQ-Transformer for image generation based on a contextual understanding of images. First, we adopt the pretraining of BERT [8] to formulate a masked code stack modeling of RQ-VAE. Then, we introduce how Contextual RQ-Transformer infills the randomly masked code stacks after reading the given contextual information.
110
+
111
+ # 3.2.1 Masked Code Stack Modeling of RQ-VAE
112
+
113
+ By adopting the pretraining of BERT [8], we formulate the masked code stack modeling of RQ-VAE with a contextual transformer to generate an image by iterative mask-infilling as non-AR models [14]. We first convert the map $\mathbf{S} \in [K]^{H \times W \times D}$ into a sequence of code stacks $\mathbf{S}' \in [K]^{N \times D}$ using the raster-scan ordering, where $N = HW$ and $\mathbf{S}_n' = (\mathbf{S}_{n1}', \dots, \mathbf{S}_{nD}') \in [K]^D$ for $n \in [N]$ . We denote $\mathbf{S}'$ as $\mathbf{S}$ for the brevity of notation. A mask vector $\mathbf{m}$ is defined as a binary vector $\mathbf{m} \in \{0, 1\}^N$ to indicate the spatial positions to be masked. Then, the masked sequence $\mathbf{S}_{\backslash \mathbf{m}}$ of $\mathbf{S}$ by $\mathbf{m}$ is defined as
114
+
115
+ $$
116
+ \left(\mathbf {S} _ {\backslash \mathbf {m}}\right) _ {n} = \left\{ \begin{array}{l l} \mathbf {S} _ {n} & \text {i f} \mathbf {m} _ {n} = 0 \\ {[ \mathrm {M A S K} ] ^ {D}} & \text {i f} \mathbf {m} _ {n} = 1 \end{array} , \right. \tag {4}
117
+ $$
118
+
119
+ where $[\mathbf{MASK}]$ is a mask token to substitute for $\mathbf{S}_{nd}$ if $\mathbf{m}_n = 1$ . Given a random mask vector $\mathbf{m} \sim q(\mathbf{m})$ , the masked code stacks given $\mathbf{S}_{\backslash \mathbf{m}}$ are modeled as
120
+
121
+ $$
122
+ \prod_ {n: \mathbf {m} _ {n} = 1} p (\mathbf {S} _ {n} | \mathbf {S} _ {\backslash \mathbf {m}}) = \prod_ {n: \mathbf {m} _ {n} = 1} \prod_ {d = 1} ^ {D} p \left(\mathbf {S} _ {n d} | \mathbf {S} _ {n, < d}, \mathbf {S} _ {\backslash \mathbf {m}}\right), \tag {5}
123
+ $$
124
+
125
+ where $q(\mathbf{m})$ is a mask distribution where the masking portion $\sum_{n=1}^{N} \mathbf{m}_i / N$ in (0, 1] as well as the masking positions are randomly chosen. Instead of fixing the portion to $15\%$ as in BERT, training a model with a random masking portion from (0, 1] enables the model to generate new images based on various masking patterns including $\mathbf{m}_n = 1$ for all $n$ . We explain the details of $q(\mathbf{m})$ in Section 3.2.3.
126
+
127
+ The left-hand side of Eq. 5 implies that all masked code stacks can be decoded in parallel based on the contexts of $\mathbf{S}_{\backslash \mathbf{m}}$ . If $D = 1$ , Eq. 5 becomes equivalent to conventional masked token modeling of texts [8] and images [6, 16] where a single token at each masked position is predicted. For $D > 1$ , the $D$ codes of $\mathbf{S}_n$ are autoregressively predicted, as they are sequentially computed in Eq. 3 for a coarse-to-fine approximation and hence well-suited for an AR prediction. We show that the effectiveness of our framework is generalizable regardless of $D$ in Appendix B. In addition, the parallel decoding can control the trade-off between the quality and sampling speed of image generation.
128
+
129
+ # 3.2.2 Contextual RQ-Transformer
130
+
131
+ We modify the previous RQ-Transformer [23] for masked code stack modeling with bidirectional contexts in Eq. 5. Contextual RQ-Transformer consists of Bidirectional Spatial Transformer and Depth Transformer: Bidirectional Spatial Transformer understands contextual information in the unmasked code stacks using bidirectional self-attention, and Depth Transformer infills the masked code stacks in parallel, by autoregressively predicting the $D$ codes at each position.
132
+
133
+ Bidirectional Spatial Transformer Given a masked sequence of code stacks $\mathbf{S}_{\backslash \mathbf{m}}$ , bidirectional spatial transformer first embeds the masked sequence $\mathbf{S}_{\backslash \mathbf{m}}$ using the code embeddings of RQ-VAE as
134
+
135
+ $$
136
+ \mathbf {u} _ {n} = \mathrm {P E} _ {N} (n) + \left\{ \begin{array}{l l} \sum_ {d = 1} ^ {D} \mathbf {e} \left(\mathbf {S} _ {n d}\right) & \text {i f} \mathbf {m} _ {n} = 0 \\ \mathbf {e} _ {[ \text {M A S K} ]} & \text {i f} \mathbf {m} _ {n} = 1 \end{array} , \right. \tag {6}
137
+ $$
138
+
139
+ where $\mathrm{PE}_N(n)$ is an embedding for position $n$ , and $\mathbf{e}_{[\mathrm{MASK}]} \in \mathbb{R}^{n_z}$ is a mask embedding. Then, the bidirectional self-attention blocks, $f_{\theta}^{\mathrm{spatial}}$ , extracts the context vector $\mathbf{h}_n$ to predict a code stack $\mathbf{S}_n$ ,
140
+
141
+ $$
142
+ \left(\mathbf {h} _ {1}, \dots , \mathbf {h} _ {N}\right) = f _ {\theta} ^ {\text {s p a t i a l}} \left(\mathbf {u} _ {1}, \dots , \mathbf {u} _ {N}\right). \tag {7}
143
+ $$
144
+
145
+ Depth Transformer The code stack at a masked position $\mathbf{S}_n = (\mathbf{S}_{n1},\dots ,\mathbf{S}_{nD})$ is autoregressively predicted. The input of depth transformer $(\mathbf{v}_{nd})_{d = 1}^{D}$ is defined as
146
+
147
+ $$
148
+ \mathbf {v} _ {n d} = \mathrm {P E} _ {D} (d) + \left\{ \begin{array}{l l} \mathbf {h} _ {n} & \text {i f} d = 1 \\ \sum_ {d ^ {\prime} = 1} ^ {d - 1} \mathbf {e} \left(\mathbf {S} _ {n d ^ {\prime}}\right) & \text {i f} d > 1 \end{array} \right. \tag {8}
149
+ $$
150
+
151
+ Algorithm 1 UPDATE of S
152
+ Require: A sequence of code stacks S, a partition $\Pi = (\mathbf{m}^1,\dots ,\mathbf{m}^T)$ , a model $\theta$ 1: for $t = 1,\dots ,T$ do 2: Sample $\mathbf{S}_n\sim p_\theta (\mathbf{S}_n|\mathbf{S}_{\backslash \mathbf{m}^t})$ $\forall n:\mathbf{m}_n^t = 1$ update the codes at masked positions 3: end for 4: return S
153
+ Algorithm 2 Draft-and-Revise decoding
154
+ Require: Partition sampling distributions $p_{\mathrm{draft}}$ and $p_{\mathrm{rev}}$ , the number of revision iterations M /* draft phase \*/ 1: $\mathbf{S}^{\mathrm{empty}}\gets ([\mathrm{MASK}],\dots ,[\mathrm{MASK}])^N$ ▷initialize empty code map 2: Sample $\Pi \sim p(\Pi ;T_{\mathrm{draft}})$ 3: $\mathbf{S}^{\mathrm{draft}}\gets \mathrm{UPDATE}(\mathbf{S}^{\mathrm{empty}},\Pi ;\theta)$ generate a draft code map /* revision phase \*/ 4: $\mathbf{S}^{0}\gets \mathbf{S}^{\mathrm{draft}}$ 5: for $m = 1,\dots ,M$ do 6: Sample $\Pi \sim p(\Pi ;T_{\mathrm{revise}})$ 7: $\mathbf{S}^{m}\gets \mathrm{UPDATE}(\mathbf{S}^{m - 1},\Pi ;\theta)$ iteratively revise the code map 8: end for 9: return $\mathbf{S}^{M}$
155
+
156
+ where $\mathrm{PE}_D(d)$ is the positional embedding for depth $d$ . Then, depth transformer $f_{\theta}^{\mathrm{depth}}$ , which consists of causal attention blocks, outputs the logit $\mathbf{p}_{nd}$ to predict the $d$ -th code $\mathbf{S}_{nd}$ at position $n$ as
157
+
158
+ $$
159
+ \mathbf {p} _ {n d} = f _ {\theta} ^ {\mathrm {d e p t h}} \left(\mathbf {v} _ {n 1}, \dots , \mathbf {v} _ {n d}\right) \quad \text {a n d} \quad p _ {\theta} \left(\mathbf {S} _ {n d} = k | \mathbf {S} _ {n, < d}, \mathbf {S} _ {\backslash \mathbf {m}}\right) = \operatorname {s o f t m a x} \left(\mathbf {p} _ {n d}\right) _ {k}. \qquad (9)
160
+ $$
161
+
162
+ We remark that the architecture of Contextual RQ-Transformer subsumes bidirectional transformers. Specifically, RQ-Transformer with the depth $D = 1$ is equivalent to a bidirectional transformer since the depth transformer becomes a multilayer perceptron with layer normalization [2].
163
+
164
+ # 3.2.3 Training of Contextual RQ-Transformer
165
+
166
+ For the training of Contextual RQ-Transformer, let us define a mask distribution $q(\mathbf{m})$ with a mask scheduling function $\gamma$ . Following previous approaches [6, 14, 16], the scheduling function $\gamma$ is chosen to be decreasing and to satisfy $\gamma(0) = 1$ and $\gamma(1) = 0$ . Then, a mask $\mathbf{m} \sim q(\mathbf{m})$ is specified as
167
+
168
+ $$
169
+ r \sim \operatorname {U n i f} ([ 0, 1)) \quad \text {a n d} \quad \mathbf {m} \sim \operatorname {U n i f} (\{\mathbf {m}: | \mathbf {m} | = \lceil \gamma (r) \cdot N \rceil \}), \tag {10}
170
+ $$
171
+
172
+ where $|\mathbf{m}| = \sum_{n\in [N]}\mathbf{m}_n$ is the count of masked positions. Finally, the training objective of Contextual RQ-Transformer is to minimize the negative log-likelihood of masked code stacks:
173
+
174
+ $$
175
+ \mathcal {L} = \mathbb {E} _ {\mathbf {m} \sim q (\mathbf {m})} \left[ \mathbb {E} _ {\mathbf {S}} \left[ \sum_ {n: \mathbf {m} _ {n} = 1} ^ {D} \sum_ {d = 1} ^ {D} - \log p _ {\theta} \left(\mathbf {S} _ {n d} \mid \mathbf {S} _ {n, < d}, \mathbf {S} _ {\backslash \mathbf {m}}\right) \right] \right]. \tag {11}
176
+ $$
177
+
178
+ # 3.3 Draft-and-Revise: Two-Phase Decoding with Global Contexts of Generated Images
179
+
180
+ We propose a novel decoding algorithm, Draft-and-Revise, for Contextual RQ-Transformer to effectively generate high-quality images with diverse visual contents. We remark that our effective decoding method is required for bidirectional transformers to fully exploit the global contexts of images and achieve high performance of image generation. Here, we introduce the details of our Draft-and-Revise decoding and then explain how the two-phase decoding of Draft-and-Revise can effectively control the quality-diversity trade-off of generated images.
181
+
182
+ We define a partition $\Pi = (\mathbf{m}^1, \dots, \mathbf{m}^T)$ as a collection of pairwise disjoint $T$ mask vectors to cover all spatial positions, where $\sum_{t=1}^{T} \mathbf{m}_n^t = 1$ for all $n \in [N]$ . A partition $\Pi$ is sampled from the distribution $p(\Pi; T)$ , which is the uniform distribution over all balanced partitions with size $T$ :
183
+
184
+ $$
185
+ p (\boldsymbol {\Pi}; T) = \operatorname {U n i f} \left(\left\{\boldsymbol {\Pi} = \left(\mathbf {m} ^ {1}, \dots , \mathbf {m} ^ {T}\right): | \mathbf {m} ^ {t} | = \frac {N}{T} \forall t \in [ T ] \right\}\right). \tag {12}
186
+ $$
187
+
188
+ Table 1: FIDs, ISs, Precisions, and Recalls for class-conditional generation on ImageNet [7]. † denotes the use of pretrained classifier for rejection sampling, gradient guidance, or training.
189
+
190
+ <table><tr><td></td><td>Params</td><td>H × W × D</td><td>FID↓</td><td>IS↑</td><td>Precision↑</td><td>Recall↑</td></tr><tr><td>BigGAN-deep [5]</td><td>112M</td><td>-</td><td>6.95</td><td>202.6</td><td>0.87</td><td>0.23</td></tr><tr><td>StyleGAN-XL†[29]</td><td>166M</td><td>-</td><td>2.3</td><td>262.1</td><td>0.78</td><td>0.53</td></tr><tr><td>ADM [9]</td><td>554M</td><td>-</td><td>10.94</td><td>101.0</td><td>0.69</td><td>0.63</td></tr><tr><td>ADM-G†[9]</td><td>608M</td><td>-</td><td>4.59</td><td>186.7</td><td>0.82</td><td>0.52</td></tr><tr><td>ImageBART [12]</td><td>3.5B</td><td>16×16×1</td><td>21.19</td><td>61.6</td><td>-</td><td>-</td></tr><tr><td>VQ-Diffusion [15]</td><td>518M</td><td>16×16×1</td><td>11.89</td><td>-</td><td>-</td><td>-</td></tr><tr><td>LDM-8 [27]</td><td>395M</td><td>32×32</td><td>15.51</td><td>79.03</td><td>0.65</td><td>0.63</td></tr><tr><td>LDM-8-G†[27]</td><td>506M</td><td>32×32</td><td>7.76</td><td>209.52</td><td>0.84</td><td>0.35</td></tr><tr><td>MaskGIT [6]</td><td>227M</td><td>16×16×1</td><td>6.18</td><td>182.1</td><td>0.80</td><td>0.51</td></tr><tr><td>VQ-GAN [13]</td><td>1.4B</td><td>16×16×1</td><td>15.78</td><td>74.3</td><td>-</td><td>-</td></tr><tr><td>RQ-Transformer [23]</td><td>1.4B</td><td>8×8×4</td><td>8.71</td><td>119.0</td><td>0.71</td><td>0.58</td></tr><tr><td>RQ-Transformer [23]</td><td>3.8B</td><td>8×8×4</td><td>7.55</td><td>134.0</td><td>0.73</td><td>0.58</td></tr><tr><td>RQ-Transformer†[23]</td><td>3.8B</td><td>8×8×4</td><td>3.80</td><td>323.7</td><td>0.82</td><td>0.50</td></tr><tr><td>Contextual RQ-Transformer</td><td>333M</td><td>8×8×4</td><td>5.45</td><td>172.6</td><td>0.81</td><td>0.49</td></tr><tr><td>Contextual RQ-Transformer</td><td>821M</td><td>8×8×4</td><td>3.45</td><td>221.9</td><td>0.82</td><td>0.52</td></tr><tr><td>Contextual RQ-Transformer</td><td>1.4B</td><td>8×8×4</td><td>3.41</td><td>224.6</td><td>0.79</td><td>0.54</td></tr><tr><td>Validation Data</td><td>-</td><td>-</td><td>1.62</td><td>234.0</td><td>0.75</td><td>0.67</td></tr></table>
191
+
192
+ We first define a procedure UPDATE(S, II) to update the sequence S as described in Algorithm 1, which updates $\mathbf{S}_n$ with $\mathbf{m}_n^t = 1$ for $t \in [T]$ . Then, Draft-and-Revise decoding in Algorithm 2 generates a draft from the empty sequence of code stacks and improves the quality of the draft.
193
+
194
+ Draft phase In the draft phase, our model gradually infills the empty sequence of code stacks to generate a draft image, considering the global contexts of filled code stacks. Let $\mathbf{S}^{\mathrm{empty}}$ be an empty sequence of code stacks with $\mathbf{S}_n^{\mathrm{empty}} = [\mathbf{MASK}]^D$ for all $n$ . Given a partition size $T_{\mathrm{draft}}$ , our model generates a draft image as
195
+
196
+ $$
197
+ \mathbf {S} ^ {\text {d r a f}} = \operatorname {U P D A T E} \left(\mathbf {S} ^ {\text {e m p t y}}, \boldsymbol {\Pi}; \theta\right) \quad \text {w h e r e} \quad \boldsymbol {\Pi} \sim p (\boldsymbol {\Pi}; T _ {\text {d r a f}}). \tag {13}
198
+ $$
199
+
200
+ Revise phase The generated draft $\mathbf{S}^{\mathrm{draft}}$ is repeatedly revised to improve the visual quality of the image, while preserving the overall structure of the draft. Given a partition size $T_{\mathrm{revise}}$ and the number of updates $M$ , the draft $\mathbf{S}^{0} = \mathbf{S}^{\mathrm{draft}}$ is repeatedly updated $M$ times as
201
+
202
+ $$
203
+ \mathbf {S} ^ {m} = \operatorname {U P D A T E} \left(\mathbf {S} ^ {m - 1}, \boldsymbol {\Pi}; \theta\right) \quad \text {w h e r e} \quad \boldsymbol {\Pi} \sim p (\boldsymbol {\Pi}; T _ {\text {r e v i s e}}) \quad \text {f o r} m = 1, \dots , M. \tag {14}
204
+ $$
205
+
206
+ Note that Draft-and-Revise is not a tailored method, since we can adopt any mask-infilling-based generation method [4, 6] for UPDATE in Algorithm 1. For example, confidence-based decoding [6, 16], which iteratively updates S from high-confidence to low-confidence predictions, can be used for UPDATE. However, we find that confidence-based decoding generates low-diversity images with oversimplified contents, since a model tends to predict simple visual patterns with high confidence. In addition, confidence-based decoding often leads to biased unmasking patterns, which are not used in training. We attach the detailed discussion about confidence-based decoding in Appendix C. Thus, we use a uniformly random partition $\Pi$ in UPDATE as the most simplified rule, leaving investigations on sophisticated update methods as future work.
207
+
208
+ We postulate that our Draft-and-Revise can generate high-quality images with diverse contents by explicitly dividing two phases. Specifically, a model first generates draft images with diverse visual contents despite the rather low quality of drafts. After semantically diverse images are generated as drafts, we use sampling strategies such as temperature scaling [19] and classifier-free guidance [20] in the revise phase to improve the visual quality of the drafts, while preserving the major semantic contents in drafts. Thus, our method can improve the performance of image generation by effectively controlling the quality-diversity trade-off. In addition, we emphasize that the two-phased decoding is intuitive and resembles the image generation process of human experts, who repeatedly refine their works to improve the quality after determining the overall contents first.
209
+
210
+ ![](images/1e1ecd1d8a7bea6f6343191c16e57446eecad6297532918c069209173516bb91.jpg)
211
+ Figure 3: The examples of generated $256 \times 256$ images of our model trained on (Top) ImageNet and (Bottom) CC-3M. The used text conditions are "Sunset over the skyline of a {beach, city}.", "an avocado {in the desert, on the seashore}.", and "a painting of a {dog, cat} with sunglasses."
212
+
213
+ # 4 Experiments
214
+
215
+ In this section, we show that our Draft-and-Revise with Contextual RQ-Transformer can outperform previous approaches for class- and text-conditional image generation. In addition, we conduct an extensive ablation study to understand the effects of Draft-and-Revise decoding on the quality and diversity of generated images, and the sampling speed. We use the publicly released RQ-VAE [23] to represent a $256 \times 256$ resolution of images as $8 \times 8 \times 4$ codes. For a fair comparison, we make Contextual RQ-Transformer have the same model size as the previous RQ-Transformer [23]. For training, the quarter-period of cosine is used as the mask scheduling function $\gamma$ in Eq. 10 following the previous studies [6, 24]. We include the implementation details in Appendix.
216
+
217
+ # 4.1 Class-conditional Image Generation
218
+
219
+ We train Contextual RQ-Transformer with 333M, 821M, and 1.4B parameters on ImageNet [7] for class-conditional image generation. For Draft-and-Revise decoding, we use $T_{\mathrm{draft}} = 64$ , $T_{\mathrm{revise}} = 2$ , and $M = 2$ . We use temperature scaling [19] and classifier-free guidance [20] only in the revise phase, while none of the strategies are applied in the draft phase. Fréchet Inception Distance (FID) [18], Inception Score (IS) [28], and Precision and Recall [22] are used for evaluation measures.
220
+
221
+ Table 1 shows that Contextual RQ-Transformer significantly outperforms the previous approaches. Notably, Contextual RQ-Transformer with 333M parameters outperforms RQ-Transformers with 1.4B and 3.8B parameters on all evaluation measures, despite having only about $4.2 \times$ and $11.4 \times$ fewer parameters. In addition, the performance is improved as the number of parameters increases to 821M and 1.4B. Our model with 333M parameters is competitive with MaskGIT [6], and hence we conduct additional analysis on the effect of confidence-based decoding in Appendix C. Contextual RQ-Transformer can achieve the lower FID score without a pretrained classifier than ADM-G and 3.8B parameters of RQ-Transformer with the use of pretrained classifier. StyleGAN-XL also uses a pretrained classifier during both training and image generation and achieves the lowest FID in Table 1. However, our model with 1.4B parameters has higher precision and recall than StyleGAN-XL, implying that our model generates images of better fidelity and diversity without a pretrained classifier. Our high performance without a classifier is remarkable, since the gradient guidance and rejection sampling are the tailored techniques to the model-based evaluation metrics in Table 1. Considering that the performance is marginally improved as the number of parameters increases from 821M to 1.4B, an improved RQ-VAE can boost the performance of Contextual RQ-Transformer, since the reconstruction quality determines the best results of generated images.
222
+
223
+ # 4.2 Text-conditional Image Generation
224
+
225
+ We train our model with 333M and 654M parameters on CC-3M [32] for text-to-image (T2I) generation as described in Appendix A. A text condition is encoded into 32 tokens using Byte Pair Encoding [31, 34]. We report CLIP-score [25] with ViT-B/32 [11] as the correspondence between texts and images.
226
+
227
+ ![](images/01a5a094d911ba644570275b642dc97ffe509fcc534c97cdb049bbc41be666c1.jpg)
228
+ (a)
229
+
230
+ ![](images/8c762a29de380054c734f4e4b827aa15e1d6d69137f399dd31341237929a33c0.jpg)
231
+ (b)
232
+
233
+ ![](images/13fcaac615d4c36121922965f9fdbbe4e32a15ff10f5da2ab7a071fdb91af042.jpg)
234
+ (c)
235
+
236
+ ![](images/c929168cabc71ed06563ad9f15d2be2f99ee4b69cc6165adfe0a1b85520e8cb5.jpg)
237
+ Figure 4: Ablation study of Draft-and-Revise decoding. (a) FIDs with the partition sizes of the draft phase $T_{\mathrm{draft}}$ . (b) Precision and recall with the revision iterations $M$ . (c) FID with $T_{\mathrm{revise}}$ .
238
+ Figure 5: Examples of generated images in the draft phase (left) and revise phases at each iteration $M = 1,2,3,4,5$ . The draft images are generated with $T_{\mathrm{draft}} = 8$ (top) and $T_{\mathrm{draft}} = 64$ (bottom).
239
+
240
+ Contextual RQ-Transformer in Table 2 outperforms the previous T2I generation models. Contextual RQ-Transformer with 333M parameters achieves better FID than RQ-Transformer with 654M parameters, and outperforms ImageBART and LDM-4, although our model has $12\times$ fewer parameters than ImageBART. When we increase the number of parameters to 654M, our model achieves state-of-the-art FID on CC3M. In Figure 3, our model generates images with unseen texts in CC-3M.
241
+
242
+ Table 2: FIDs and CLIP scores [25] on the validation dataset of CC-3M [32] for T2I generation.
243
+
244
+ <table><tr><td></td><td>Params</td><td>FID↓</td><td>CLIP-s↑</td></tr><tr><td>VQ-GAN [13]</td><td>600M</td><td>28.86</td><td>0.20</td></tr><tr><td>ImageBART [12]</td><td>2.8B</td><td>22.61</td><td>0.23</td></tr><tr><td>LDM-4 [27]</td><td>645M</td><td>17.01</td><td>0.24</td></tr><tr><td>RQ-Transformer [23]</td><td>654M</td><td>12.33</td><td>0.26</td></tr><tr><td>Ours</td><td>333M</td><td>10.44</td><td>0.26</td></tr><tr><td>Ours</td><td>654M</td><td>9.80</td><td>0.26</td></tr></table>
245
+
246
+ # 4.3 Conditional Image Inpainting
247
+
248
+ We conduct conditional image inpainting where a model infills a masked area according to the given condition and contexts. Figure 1 shows the example of image inpainting by RQ-Transformer (middle) and Contextual RQ-Transformer (right), when the class-condition is school bus. RQ-Transformer cannot attend to the right and bottom sides of the masked area and fails to generate a coherent image with given contexts. However, our model can complete the image to be coherent with given contexts by exploiting global contexts. We attach more examples of image inpainting in Appendix.
249
+
250
+ # 4.4 Ablation Study on Draft-and-Revise
251
+
252
+ We conduct an extensive ablation study to demonstrate the effectiveness of Draft-and-Revise decoding of our framework. We use Contextual RQ-Transformer with 821M parameters trained on ImageNet.
253
+
254
+ Quality improvement of draft images in the revise phase Figure 4(a) shows the effects of $T_{\mathrm{draft}}$ on draft images and their quality improvement in the revised phase with $T_{\mathrm{revise}} = 2$ and $M = 2$ .
255
+
256
+ In the draft phase, FID is improved as $T_{\mathrm{draft}}$ increases from 4 to 64. At each inference, Contextual RQ-Transformer generates $N / T_{\mathrm{draft}}$ code stacks in parallel, starting with the empty sequence. Thus, the model with a large $T_{\mathrm{draft}}$ generates a small number of code stacks at each inference and can avoid generating incoherent code stacks in the early stage of the draft phase. Although FIDs in the draft phase are worse due to low precision, we intend to increase the diversity of generated images, since the precision is significantly improved in the revise phase as shown in Figure 4(b).
257
+
258
+ Effect of revision iteration $M$ and partition size $T_{\text{revise}}$ in the revise phase Figure 4(b) shows the effects of the number of updates $M$ in the revise phase on the quality and diversity of generated images. Since the quality-diversity trade-off exists as the updates are repeated, we select $M = 2$ as the default hyperparameter to balance the precision and recall, considering that the increase of precision starts to slow down. Interestingly, Figure 5 shows that the overall contents remain unchanged even after $M > 2$ . Thus, we claim that Draft-and-Revise decoding does not harm the perceptual diversity of generated images throughout the revise phase despite the consistent deterioration of recall.
259
+
260
+ Figure 4(c) shows the effects of $T_{\mathrm{revise}}$ on the quality of generated images. The FIDs are significantly improved in the revise phase regardless of the choice of $T_{\mathrm{revise}}$ , but increasing $T_{\mathrm{revise}}$ slightly deteriorates FIDs. We remark that some code stacks of a draft can be erroneous due to its low quality, and a model with large $T_{\mathrm{revise}}$ slowly updates a small number of code stacks at once in the revise phase. Therefore, the updates with large $T_{\mathrm{revise}}$ can be more influenced by the erroneous code stacks. Although $T_{\mathrm{revise}} = 2$ updates half of an image at once, our draft-and-revise decoding successfully improves the quality of generated images, while preserving the global contexts of drafts, as shown in Figure 5. The study on self-supervised learning [17] also reports similar results, where a masked auto-encoder reconstructs the global contexts of an image after masking half of the image.
261
+
262
+ Quality-diversity control of Draft-and-Revise Our Draft-and-Revise decoding can effectively control the quality-diversity trade-off in generated images. Table 3 shows FID, precision (P), and recall (R) according to the use of classifier-free guidance [20] with a scale of 1.8, while applying temperature scaling with 0.8 only to the revise phase. Contextual RQ-Transformer without the guidance already outperforms RQ-Transformer with 3.8B parameters and demonstrates the effectiveness of our framework. When the guidance is used for both draft and
263
+
264
+ revise phases, the precision dramatically increases but the recall decreases to 0.33. Consequently, FID becomes worse due to the lack of diversity in generated images. However, when the guidance is applied only to the revise phase, our model achieves the lowest FID, as the quality and diversity are well-balanced. Thus, the explicitly separated two phases of Draft-and-Revise can effectively control the issue of quality-diversity trade-off by generating diverse drafts and then improving their quality.
265
+
266
+ Table 3: The effects of classifier-free guidance on the image generation.
267
+
268
+ <table><tr><td>Draft</td><td>Revise</td><td>FID</td><td>P</td><td>R</td></tr><tr><td></td><td></td><td>5.78</td><td>0.72</td><td>0.58</td></tr><tr><td></td><td>✓</td><td>3.45</td><td>0.82</td><td>0.52</td></tr><tr><td>✓</td><td>✓</td><td>8.90</td><td>0.92</td><td>0.33</td></tr></table>
269
+
270
+ Trade-off between quality and sampling speed Table 4 shows that our framework can control the trade-off between the quality and sampling speed according to $T_{\mathrm{draft}}$ after we fix $T_{\mathrm{revise}} = 2$ and $M = 2$ . We generate 5,000 samples with batch size of 100 as the previous study [23]. Contextual RQ-Transformer with $T_{\mathrm{draft}} = 8$ outperforms both FID and sampling speed of VQGAN and RQ-Transformer with 1.4B parameters. Although the sampling speed becomes slow with increased $T_{\mathrm{draft}}$ , the FID scores are consistently improved. We remark that the sampling speed with $T_{\mathrm{draft}} = 64$ is about $3\times$ slower than RQ-Transformer, but our model outperforms 3.8B parameters of RQ-Transformer with rejec
271
+
272
+ tion sampling in Table 1. The results show that our framework has inexpensive costs to generate high-quality images, considering that rejection sampling requires generating up to $20\times$ more samples.
273
+
274
+ Table 4: Comparison of FID and the sampling speed of image generation.
275
+
276
+ <table><tr><td></td><td>FID</td><td>s/sample</td></tr><tr><td>VQGAN</td><td>15.78</td><td>0.16</td></tr><tr><td>RQ-Transformer</td><td>8.71</td><td>0.04</td></tr><tr><td colspan="3">Contextual RQ-Transformer</td></tr><tr><td>\(T_{\text{draft}}=8\)</td><td>5.41</td><td>0.03</td></tr><tr><td>\(T_{\text{draft}}=32\)</td><td>3.73</td><td>0.06</td></tr><tr><td>\(T_{\text{draft}}=64\)</td><td>3.45</td><td>0.10</td></tr></table>
277
+
278
+ # 5 Conclusion
279
+
280
+ In this study, we have proposed Draft-and-Revise for an effective image generation framework with Contextual RQ-Transformer. After an image is represented as a sequence of code stacks, Contextual RQ-Transformer is trained to infill a randomly masked sequence. Then, Draft-and-Revise decoding is used to generate high-quality images by first generating a draft image with diverse contents and then improving its visual quality based on the global contexts of the draft. Consequently, we can achieve state-of-the-art results on ImageNet and CC-3M, demonstrating the effectiveness of our framework.
281
+
282
+ Our study has two main limitations to be further explored. Firstly, Draft-and-Revise decoding always updates all code stacks in the revise phase, although some code stacks might not need an update. In future work, a selective method can be developed to improve the efficiency of the revise phase by a sophisticated approach. Secondly, our generative model is not validated on various downstream tasks. Since masked token modeling is successful self-supervised learning for texts [8] and images [3, 17], a unified model for both generative and discriminative tasks [21] is worth exploration for future work.
283
+
284
+ # 6 Acknowledgements
285
+
286
+ This work was supported by Institute of Information & communications Technology Planning & Evaluation(IITP) grant funded by the Korea government(MSIT) (No.2018-0-01398: Development of a Conversational, Self-tuning DBMS, 35%; No.2021-0-00537: Visual Common Sense, 30%) and the National Research Foundation of Korea(NRF) grant funded by the Korea government(MSIT) (No. NRF-2021R1A2B5B03001551, 35%)
287
+
288
+ # References
289
+
290
+ [1] Jacob Austin, Daniel D Johnson, Jonathan Ho, Daniel Tarlow, and Rianne van den Berg. Structured denoising diffusion models in discrete state-spaces. Advances in Neural Information Processing Systems, 34:17981-17993, 2021.
291
+ [2] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016.
292
+ [3] Hangbo Bao, Li Dong, Songhao Piao, and Furu Wei. BEit: BERT pre-training of image transformers. In International Conference on Learning Representations, 2022.
293
+ [4] Sam Bond-Taylor, Peter Hessey, Hiroshi Sasaki, Toby P Breckon, and Chris G Willcocks. Unleashing transformers: Parallel token prediction with discrete absorbing diffusion for fast high-resolution image generation from vector-quantized codes. arXiv preprint arXiv:2111.12701, 2021.
294
+ [5] Andrew Brock, Jeff Donahue, and Karen Simonyan. Large scale GAN training for high fidelity natural image synthesis. In International Conference on Learning Representations, 2019.
295
+ [6] Huiwen Chang, Han Zhang, Lu Jiang, Ce Liu, and William T. Freeman. Maskgit: Masked generative image transformer. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2022.
296
+ [7] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pages 248–255. IEEE, 2009.
297
+ [8] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 4171–4186, 2019.
298
+ [9] Prafulla Dhariwal and Alexander Nichol. Diffusion models beat gans on image synthesis. Advances in Neural Information Processing Systems, 34, 2021.
299
+
300
+ [10] Ming Ding, Zhuoyi Yang, Wenyi Hong, Wendi Zheng, Chang Zhou, Da Yin, Junyang Lin, Xu Zou, Zhou Shao, Hongxia Yang, et al. Cogview: Mastering text-to-image generation via transformers. Advances in Neural Information Processing Systems, 34, 2021.
301
+ [11] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv:2010.11929, 2020.
302
+ [12] Patrick Esser, Robin Rombach, Andreas Blattmann, and Bjorn Ommer. Imagebart: Bidirectional context with multinomial diffusion for autoregressive image synthesis. Advances in Neural Information Processing Systems, 34, 2021.
303
+ [13] Patrick Esser, Robin Rombach, and Bjorn Ommer. Taming transformers for high-resolution image synthesis. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 12873-12883, 2021.
304
+ [14] Marjan Ghazvininejad, Omer Levy, Yinhan Liu, and Luke Zettlemoyer. Mask-predict: Parallel decoding of conditional masked language models. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pages 6112-6121, 2019.
305
+ [15] Shuyang Gu, Dong Chen, Jianmin Bao, Fang Wen, Bo Zhang, Dongdong Chen, Lu Yuan, and Baining Guo. Vector quantized diffusion model for text-to-image synthesis. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2022.
306
+ [16] Ligong Han, Jian Ren, Hsin-Ying Lee, Francesco Barbieri, Kyle Olszewski, Shervin Minaee, Dimitris Metaxas, and Sergey Tulyakov. Show me what and tell me how: Video synthesis via multimodal conditioning. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2022.
307
+ [17] Kaiming He, Xinlei Chen, Saining Xie, Yanghao Li, Piotr Dólár, and Ross Girshick. Masked autoencoders are scalable vision learners. arXiv preprint arXiv:2111.06377, 2021.
308
+ [18] Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. Advances in neural information processing systems, 30, 2017.
309
+ [19] Geoffrey Hinton, Oriol Vinyals, Jeff Dean, et al. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2(7), 2015.
310
+ [20] Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. In NeurIPS 2021 Workshop on Deep Generative Models and Downstream Applications, 2021.
311
+ [21] Saehoon Kim, Sungwoong Kim, and Juho Lee. Hybrid generative-contrastive representation learning. arXiv preprint arXiv:2106.06162, 2021.
312
+ [22] Tuomas Kynkänniemi, Tero Karras, Samuli Laine, Jaakko Lehtinen, and Timo Aila. Improved precision and recall metric for assessing generative models. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché-Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 32. Curran Associates, Inc., 2019.
313
+ [23] Doyup Lee, Chiheon Kim, Saehoon Kim, Minsu Cho, and Wook-Shin Han. Autoregressive image generation using residual quantization. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2022.
314
+ [24] Alexander Quinn Nichol and Prafulla Dhariwal. Improved denoising diffusion probabilistic models. In International Conference on Machine Learning, pages 8162-8171. PMLR, 2021.
315
+ [25] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, and Ilya Sutskever. Learning transferable visual models from natural language supervision. In Marina Meila and Tong Zhang, editors, Proceedings of the 38th International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research, pages 8748-8763. PMLR, 18-24 Jul 2021.
316
+
317
+ [26] Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. In Marina Meila and Tong Zhang, editors, Proceedings of the 38th International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research, pages 8821-8831. PMLR, 18-24 Jul 2021.
318
+ [27] Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. High-resolution image synthesis with latent diffusion models, 2021.
319
+ [28] Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, Xi Chen, and Xi Chen. Improved techniques for training gans. In D. Lee, M. Sugiyama, U. Luxburg, I. Guyon, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 29. Curran Associates, Inc., 2016.
320
+ [29] Axel Sauer, Katja Schwarz, and Andreas Geiger. Stylegan-xl: Scaling stylegan to large diverse datasets. arXiv preprint arXiv:2202.00273, 2022.
321
+ [30] Nikolay Savinov, Junyoung Chung, Mikolaj Binkowski, Erich Elsen, and Aaron van den Oord. Step-unrolled denoising autoencoders for text generation. In International Conference on Learning Representations, 2022.
322
+ [31] Rico Senrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words with subword units. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1715-1725, 2016.
323
+ [32] Piyush Sharma, Nan Ding, Sebastian Goodman, and Radu Soricut. Conceptual captions: A cleaned, hypernymed, image alt-text dataset for automatic image captioning. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 2556–2565, Melbourne, Australia, July 2018. Association for Computational Linguistics.
324
+ [33] Aaron van den Oord, Oriol Vinyals, and koray kavukcuoglu. Neural discrete representation learning. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017.
325
+ [34] Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumont, Clement Delangue, Anthony Moi, Pierrick Cistac, Tim Rault, Rémi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, Quentin Lhoest, and Alexander M. Rush. Transformers: State-of-the-art natural language processing. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pages 38-45, Online, October 2020. Association for Computational Linguistics.
326
+ [35] Zhu Zhang, Jianxin Ma, Chang Zhou, Rui Men, Zhikang Li, Ming Ding, Jie Tang, Jingren Zhou, and Hongxia Yang. UFC-BERT: Unifying multi-modal controls for conditional image synthesis. In A. Beygelzimer, Y. Dauphin, P. Liang, and J. Wortman Vaughan, editors, Advances in Neural Information Processing Systems, 2021.
draftandreviseeffectiveimagegenerationwithcontextualrqtransformer/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:00ad02b71ecb7af546fa896c6cbaa4a9a304e5eec1293be2d80a3560001da0da
3
+ size 502407
draftandreviseeffectiveimagegenerationwithcontextualrqtransformer/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6ae9d7d7971b0b30b59c249fad1c3f06daed06d0d62080ac2d9df65748243161
3
+ size 434228
drawingoutofdistributionwithneurosymbolicgenerativemodels/005c4d28-ffc7-46e2-81d4-52d16d0e294e_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:433c59c59af53e1c7d1a79a27612dc4b1359b59412cce5edc7fbec0ef5a443be
3
+ size 65386
drawingoutofdistributionwithneurosymbolicgenerativemodels/005c4d28-ffc7-46e2-81d4-52d16d0e294e_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bbdb3aad97605af8d133a98134f942fff6de43fe21153eb58b5a7da5b51cf291
3
+ size 77714
drawingoutofdistributionwithneurosymbolicgenerativemodels/005c4d28-ffc7-46e2-81d4-52d16d0e294e_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:69979fddd8e6665df7e574a09c8e09e71ac4db51e4afeb4745684709e24929d8
3
+ size 4266154
drawingoutofdistributionwithneurosymbolicgenerativemodels/full.md ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Drawing out of Distribution with Neuro-Symbolic Generative Models
2
+
3
+ Yichao Liang $^{1,2}$ , Joshua B. Tenenbaum $^{2}$ , Tuan Anh Le $^{*,3}$ & N. Siddharth $^{*,4}$
4
+
5
+ <sup>1</sup>University of Oxford, <sup>2</sup>MIT, <sup>3</sup>Google, <sup>4</sup>University of Edinburgh
6
+
7
+ # Abstract
8
+
9
+ Learning general-purpose representations from perceptual inputs is a hallmark of human intelligence. For example, people can write out numbers or characters, or even draw doodles, by characterizing these tasks as different instantiations of the same generic underlying process—compositional arrangements of different forms of pen strokes. Crucially, learning to do one task, say writing, implies reasonable competence at another, say drawing, on account of this shared process. We present Drawing out of Distribution (DooD), a neuro-symbolic generative model of stroke-based drawing that can learn such general-purpose representations. In contrast to prior work, DooD operates directly on images, requires no supervision or expensive test-time inference, and performs unsupervised amortised inference with a symbolic stroke model that better enables both interpretability and generalization. We evaluate DooD on its ability to generalise across both data and tasks. We first perform zero-shot transfer from one dataset (e.g. MNIST) to another (e.g. Quickdraw), across five different datasets, and show that DooD clearly outperforms different baselines. An analysis of the learnt representations further highlights the benefits of adopting a symbolic stroke model. We then adopt a subset of the Omniglot challenge tasks, and evaluate its ability to generate new exemplars (both unconditionally and conditionally), and perform one-shot classification, showing that DooD matches the state of the art. Taken together, we demonstrate that DooD does indeed capture general-purpose representations across both data and task, and takes a further step towards building general and robust concept-learning systems.
10
+
11
+ # 1 Introduction
12
+
13
+ Humans can learn representations of data that are general-purpose and meaningful. Being general-purpose permits effective reuse when characterizing novel observations, and being meaningful facilitates tasks like generating or classifying observations. Key to this is a generic process for characterizing observations—inferring what features are relevant and how they compose to generate the observations [9, 13, 33]. For example, when observing handwritten numbers, we learn to characterise them as sequential compositions (how) of different pen strokes (what). This is general-purpose as it allows characterizing novel observations, say doodles instead of numbers, simply as novel compositions of previously learnt pen strokes. It is also meaningful since pen-strokes themselves are symbolic and interpretable.
14
+
15
+ ![](images/2e5adfac8142b1de0ae09be6206d98888f2d23279671148f96d32ca5640d5f5f.jpg)
16
+ Figure 1: DooD trained on MNIST generalises to other data with no extra training. Each column denotes a target and its step-by-step reconstruction.
17
+
18
+ Current computational approaches capture important aspects of generalizability, but none of these is simultaneously efficient, reliable, interpretable, and unsupervised [25]. At one end, symbolic approaches like Lake et al. [24] attribute generalization to an explicit hierarchical composition process involving sub-strokes, strokes, and characters, and build concomitant models that demonstrate human-like generalization abilities across different tasks. At the other end, neural approaches like deep generative models [9, 18, 29] and deep meta-learning [11, 32, 34] favour scalable learning from raw
19
+
20
+ ![](images/711f37b4c36bcf2f56f7051c91feb0406983a67f84d66148f2c4a10b9525bc2c.jpg)
21
+ Figure 2: The generative model sequentially samples both an image location $(l_{t})$ and a corresponding stroke $(s_t)$ at that location. The rendered stroke $x_{t}$ is composited onto intermediate rendering $x_{< t}$ to produce $x_{\leq t}$ . A binary on/off variable $(o_{t})$ determines when to continue drawing. Differentiable rendering $(\delta \bar{R})$ and differentiable affine transformations via Spatial Transformer Networks (STNs) [20] enables gradient-based learning. The recognition model conditions on a residual $\Delta x_{t} = x - x_{< t}$ to sample where to draw next $(l_{t})$ and what to draw next $(s_{t})$ , and whether to continue drawing $(o_{t})$ . Both models are autoregressive via two (shared) RNNs with hidden states $h_t^s$ and $h_t^l$ .
22
+
23
+ ![](images/c8b9b694abb1b8ca7ff73fee61ccc623499e7db574d4f45b5815d671293e89bb.jpg)
24
+
25
+ ![](images/6dbf7038bacb56e14bd08f65080a87782b269cd3fa7810c85be0bd6dd1b7d01d.jpg)
26
+
27
+ perceptual data, unfettered by explicit representational biases such as strokes and their compositions. Each comes with its own shortcomings—symbolic approaches typically need additional supervision or data processing along with expensive special-purpose inference, and neural approaches fail to generalise well and don't capture interpretable representations. Neuro-symbolic approaches [10] seek to make the best of both worlds by judiciously combining neural processing of raw perceptual inputs with symbolic processing of extracted features, but typically involve a different set of trade-offs.
28
+
29
+ We present Drawing out of Distribution (DooD), a neuro-symbolic generative model of stroke-based drawing that can learn general-purpose representations (Fig. 1). Our model operates directly on images, requires no supervision, pre-processing, or expensive test-time inference, and performs efficient amortised inference with a symbolic stroke model that helps with both interpretability and generalization, setting us apart from the current state-of-the-art in neuro-symbolic approaches [10, 17]. We evaluate on two axes (a) generalization across data, which measures how well the learnt representations can be reused to characterise out-of-distribution data, and (b) generalization across task, where we measure how useful the learnt representations are for auxiliary tasks drawn from the Omniglot challenge set [24]. We show that DooD significantly outperforms baselines on generalization across datasets, highlighting the quality of the learnt representations as a factor, and on generalization across tasks, show that it outperforms neural models, while being competitive against SOTA neuro-symbolic models without requiring additional support such as supervision or data augmentation.
30
+
31
+ # 2 Method
32
+
33
+ The framework for DooD involves a generative model over sequences of strokes and their layouts, a recognition model that conditions on a given observation to predict where to place what strokes, and an amortised variational-inference learning setup that uses these models to estimate an evidence lower bound (ELBO) as the objective.
34
+
35
+ # 2.1 Generative Model
36
+
37
+ Conceptually, the model can be seen as drawing a figure over a sequence of steps, building up to the final image (as seen in Fig. 1). At each step $t$ the model identifies a region of the image canvas to draw in, puts down Bezier curve control points within that region, renders the curve in a differentiable manner, and then composites this rendered stroke over the previously rendered canvas. We refer to these as the layout, stroke, rendering, and compositing modules respectively (elaborated below).
38
+
39
+ The model sits on a substrate of recurrent neural networks (RNNs), one each for the layout and stroke modules, with hidden states $h_t^l$ and $h_t^s$ respectively. The complete setup is depicted in Fig. 2 along with example values (images) for the different variables involved. See Appendix B for details.
40
+
41
+ Formally, the generative model defines a joint distribution over an image $x$ composed over $T$ steps, with latent variables $l_{t}$ and $s_t$ that characterise a stroke's location and form, and a binary latent variable $o_{t}$ that determines stopping, as
42
+
43
+ $$
44
+ \begin{array}{l} p (x, l _ {\leq T}, s _ {\leq T}, o _ {\leq T + 1}) \\ = \left(\prod_ {t = 1} ^ {T} p _ {\text {o n}} \left(o _ {t} \mid x _ {< t}\right) p _ {\text {s t r o k e}} \left(s _ {t} \mid l _ {t}, \tilde {x} _ {< t}, h _ {t} ^ {s}\right) p _ {\text {l a y o u t}} \left(l _ {t} \mid x _ {< t}, h _ {t} ^ {l}\right)\right) p _ {\text {c o m p}} \left(x \mid x _ {\leq T}\right) p _ {\text {o n}} \left(o _ {T + 1} \mid x _ {\leq T}\right), \tag {1} \\ \end{array}
45
+ $$
46
+
47
+ where terminal step $T$ is the last $t$ where $o_{t} = 1$ , $x_{t}$ the rendered stroke given $(s_{t},l_{t})$ , $x_{<t}$ the canvas-so-far, and all variables at step $t = 0$ initialised to 0. Note that the likelihood is evaluated only at the terminal step $T$ .
48
+
49
+ Layout Module: At step $t$ , given the canvas-so-far $x_{<t}$ and corresponding layout-RNN hidden state $h_t^l$ , we define the layout as a distribution over affine transforms. This allows transforming the canvas into a "glipse" $\tilde{x}_{<t}$ using a Spatial Transformer Network (STN) [20], which allows focussing on a particular canvas region. The affine transform is constructed from appropriately constrained scale $(l_t^{sc})$ , translation $(l_t^{tr})$ , and rotation $(l_t^r)$ random variables, by employing a Gaussian Mixture Model (GMM) with $M$ components over the collection as
50
+
51
+ $$
52
+ \begin{array}{l} p _ {\text {l a y o u t}} \left(l _ {t} \mid x _ {< t}, h _ {t} ^ {l}\right) = \sum_ {m = 1} ^ {M} \alpha_ {m} \cdot \mathcal {N} _ {\mathrm {s c}, m} \left(l _ {t} ^ {\mathrm {s c}, m} \mid x _ {< t}, h _ {t} ^ {l}\right) \cdot \mathcal {N} _ {\mathrm {t r}, m} \left(l _ {t} ^ {\mathrm {t r}, m} \mid x _ {< t}, h _ {t} ^ {l}\right) \cdot \mathcal {N} _ {r, m} \left(l _ {t} ^ {r, m} \mid x _ {< t}, h _ {t} ^ {l}\right), \tag {2} \\ \tilde {x} _ {< t} = \operatorname {S T N} \left(l _ {t}, x _ {< t}\right). \\ \end{array}
53
+ $$
54
+
55
+ Stroke Module: Given the sampled affine transform $l_{t}$ , selected "glimpse" $\tilde{x}_{<t}$ , and corresponding stroke-RNN hidden state $h_{t}^{s}$ , this module defines a distribution over strokes parametrised as $D^{\mathrm{th}}$ order Bézier splines, constructing a GMM with K components for each spline control point as
56
+
57
+ $$
58
+ p _ {\text {s t r o k e}} \left(s _ {t} \mid l _ {t}, \tilde {x} _ {< t}, h _ {t} ^ {s}\right) = \prod_ {d = 0} ^ {D} \sum_ {k = 1} ^ {K} \pi_ {d, k} \cdot \mathcal {N} _ {\mathrm {d}, \mathrm {k}} \left(s _ {t} ^ {d, k} \mid l _ {t}, \tilde {x} _ {< t}, h _ {t} ^ {s}\right). \tag {3}
59
+ $$
60
+
61
+ **Rendering Module:** Note that the Bézier spline control points sampled from the stroke module are taken to be in a canonical centered coordinate frame. While this can help simplify learning by reducing the variation required to be captured by the stroke module, the points can't be rendered onto the canvas as is. We situate them properly within the context of the previously determined "glimpse" by simply applying the affine transform $l_{t}$ to the control points as $\tilde{s}_{t} = l_{t} \odot s_{t}$ . The transformed control points now describe a stroke to be drawn over the whole canvas for step $t$ , through a differentiable renderer $\delta \mathbf{R}$ , to produce the rendered stroke as $x_{t} = \delta \mathbf{R}(\tilde{s}_{t})$ (see Appendix B.1 for details). Using the intermediate canvas to guide model unrolling is termed execution guidance (EG).
62
+
63
+ Compositing Module: At step $t$ this defines a distribution over whether the model should continue drawing strokes given the rendered canvas-so-far $x_{<t}$ as
64
+
65
+ $$
66
+ p _ {\mathrm {o n}} \left(o _ {t} \mid x _ {< t}\right) = \operatorname {B e r n o u l l i} \left(o _ {t} \mid x _ {< t}\right). \tag {4}
67
+ $$
68
+
69
+ Once the model has decided to stop drawing, it stops permanently. At step $t$ , the rendered stroke $x_{t}$ is composited with the canvas-so-far $x_{<t}$ to generate $x_{\leq t} = x_{<t} \otimes x_{t}$ . When the model stops, i.e., at the last $t$ when $o_{t} = 1$ (denoted $T$ ), the likelihood, with global learnable parameter $\sigma$ , is given as
70
+
71
+ $$
72
+ p _ {\text {c o m p}} (x \mid x _ {\leq T}) = \operatorname {L a p l a c e} (x \mid x _ {\leq T}, \operatorname {d i a g} (\sigma)). \tag {5}
73
+ $$
74
+
75
+ # 2.2 Recognition Model
76
+
77
+ As with prior approaches, we construct an approximate posterior to facilitate learning with amortised variational inference. Using the same notation from the generative model section, we define
78
+
79
+ $$
80
+ q \left(l _ {\leq T}, s _ {\leq T}, o _ {\leq T + 1} \mid x\right) = q _ {\text {o n}} \left(o _ {T + 1} \mid \Delta x _ {T + 1}\right) \prod_ {t = 1} ^ {T} q _ {\text {l a y o u t}} \left(l _ {t} \mid \Delta x _ {t}, h _ {t} ^ {l}\right) q _ {\text {s t r o k e}} \left(s _ {t} \mid \tilde {\Delta x} _ {t}, h _ {t} ^ {s}\right) q _ {\text {o n}} \left(o _ {t} \mid \Delta x _ {t}\right). \tag {6}
81
+ $$
82
+
83
+ A couple of things stand out. First, where the generative model made heavy use of the canvas-sofar $x_{<t}$ , the recognition model primarily uses the residual $\Delta x_t = x - x_{<t}$ . Second, being given
84
+
85
+ the target observation $x$ itself, the information available to the layout and stroke modules is quite different. While they needed to speculate where, and what stroke to draw, in the generative model, here their task is simply to isolate a part of the drawing ("glipse") and fit a spline to that.
86
+
87
+ As a consequence of these different characteristics, the distributions over layout and strokes in the recognition model do not need to be as flexible as the generative model—locating a curve in the residual and fitting it with a spline does not typically involve much ambiguity. To factor this in, and have the variational objective be reasonable, we define corresponding distributions in the recognition model using just a single component of the corresponding GMMs in the generative model as
88
+
89
+ $$
90
+ q _ {\text {l a y o u t}} \left(l _ {t} | \Delta x _ {t}, h _ {t} ^ {l}\right) = \mathcal {N} _ {\mathrm {s c}} \left(l _ {t} ^ {\mathrm {s c}} \mid \Delta x _ {t}, h _ {t} ^ {l}\right) \cdot \mathcal {N} _ {\mathrm {t r}} \left(l _ {t} ^ {\mathrm {t r}} \mid \Delta x _ {t}, h _ {t} ^ {l}\right) \cdot \mathcal {N} _ {r} \left(l _ {t} ^ {r} \mid \Delta x _ {< t}, h _ {t} ^ {l}\right), \tag {7}
91
+ $$
92
+
93
+ $$
94
+ \tilde {\Delta} x _ {t} = \operatorname {S T N} \left(l _ {t}, \Delta x _ {t}\right),
95
+ $$
96
+
97
+ $$
98
+ q _ {\text {s t r o k e}} \left(s _ {t} \mid \tilde {\Delta} x _ {t}, h _ {t} ^ {s}\right) = \prod_ {d = 0} ^ {D} \mathcal {N} _ {\mathrm {d}} \left(s _ {t} ^ {d} \mid \tilde {\Delta} x _ {t}, h _ {t} ^ {s}\right). \tag {8}
99
+ $$
100
+
101
+ # 2.3 Learning
102
+
103
+ Having defined the generative and recognition models, we now bring them together in order to construct the variational objective that will enable learning both models simultaneously from data.
104
+
105
+ $$
106
+ \log p (x) \geq \mathbb {E} _ {q \left(l _ {\leq T}, s _ {\leq T}, o _ {\leq T + 1} \mid x\right)} \left[ \log \frac {p \left(x , l _ {\leq T} , s _ {\leq T} , o _ {\leq T + 1}\right)}{q \left(l _ {\leq T} , s _ {\leq T} , o _ {\leq T + 1} \mid x\right)} \right] \tag {9}
107
+ $$
108
+
109
+ Note that except for the stopping criterion $o_t$ which is a Bernoulli random variable, all other distributions employed are reparametrizable. In order to construct an effective variational objective with this discrete variable, we employ a control variate method, NVIL [28], that helps reduce the variance of the standard REINFORCE estimator, as is also done in related work [9] (see Appendix C.2).
110
+
111
+ Furthermore, in order to ensure that the ELBO objective is appropriately balanced, we employ additional weighting $\beta$ for the KL-divergence over stopping criterion $o_t$ within the objective [2, 19] (see Appendix C.1 for details). This weight plays a crucial role as a mismatch could result in the model either stopping too early or too late, resulting in incomplete or incorrect figures respectively.
112
+
113
+ # 3 Experiments
114
+
115
+ We wish to understand how well DooD generalises across both datasets (§ 3.1) and tasks (§ 3.2). For across-dataset generalization, we train DooD and Attend-Infer-Repeat (AIR) [9]², an unsupervised part-based model, on each of five stroke-based image datasets (i) MNIST (handwritten digits) [26], (ii) EMNIST (handwritten digits and letters) [7], (iii) KMNIST (cursive Japanese characters) [6], (iv) Quickdraw (doodles) [15], and (v) Omniglot (handwritten characters from multiple alphabets) [24], and evaluate how well the model generalises to unseen exemplars both within the same dataset and across other datasets. We find that DooD significantly outperforms AIR, which from ablation studies, is attributed to explicit stroke modelling and execution guidance. Note that we only compare against a fully-unsupervised approach since most datasets do not provide additional data in the form of stroke labels (as required elsewhere [10]). For across-task generalization, we primarily focus on Omniglot and evaluate on three out of the five challenge tasks for this dataset [25], which include contextual generation and classification. We find that our model outperforms unsupervised baselines, and is competitive against SOTA neuro-symbolic models without requiring additional support in the form of supervision or data augmentation. We include exact details about datasets (Appendix A), our model and the baselines (Appendix B), the training procedure (Appendix C), and the evaluation procedure (Appendix D) in the supplementary material.
116
+
117
+ # 3.1 Across-Dataset Generalization
118
+
119
+ MNIST-trained transfer. To understand how our model and AIR generalise to new datasets, we look at sequential reconstructions (Fig. 3). We train on MNIST and show sample reconstructions from all five datasets without fine tuning. Each model renders one step at a time by rendering latent parses of increasing length, allowing us to evaluate and compare the performance of part decomposition and inference. Note that we limit the maximum number of strokes to 6 throughout all experiments.
120
+
121
+ ![](images/b7222f107179a708eaffade15a0fc4191abee34edb4f2188bc8844e61377d4cd.jpg)
122
+ Figure 3: (a) Our model generalises better than AIR. Our model trained on MNIST reconstructs characters from all other four datasets while the baseline AIR model's reconstructions are often inaccurate, blurry or incomplete. Explicit stroke parametrization $(\delta R)$ and execution-guided inference (EG) are responsible for this generalization which degrades when using our model without either of these components. (b-d) Both DooD and Difference AIR (AIR elsewhere) trained on MNIST generalise to using more strokes unlike Vanilla AIR which doesn't have execution-guided inference.
123
+
124
+ ![](images/115e19c961f3adaf6a41c8f247c195e04a49bfc0ca47484c0ccd23b2d1fa6294.jpg)
125
+ (b) DooD
126
+
127
+ ![](images/ad36450b390140e1f59546580ad03589e1e12a3d52226677e003edc1c8713932.jpg)
128
+ (c) Difference AIR [9]
129
+
130
+ ![](images/20bc7253492a778f474d54bf73be8de3a571cf4cbd5d9d541be1e2114dd9370a.jpg)
131
+ (d) Vanilla AIR [9]
132
+
133
+ Our model reconstructs in-distribution images perfectly and out-of-distribution images near-perfectly while using fewer strokes for simpler datasets (e.g. MNIST) and more strokes for more complex datasets (e.g. Omniglot). While the AIR baseline also uses an appropriate number of steps for more complex datasets, the reconstructions degrade significantly for out-of-distribution images—they are blurry (e.g. the car & motorbike in QuickDraw), strokes go missing (e.g. the second KMNIST image) or the reconstructions are inaccurate (e.g. the last Omniglot character).
134
+
135
+ Ablation studies. To better understand why our model generalises well, we evaluate two further variants of DooD that ablate a key component each: an explicit spline decoder (DooD-δR) and execution-guided inference (DooD-EG) (Fig. 3a). In the model without an explicit spline decoder, we replace the differentiable spline renderer by a neural network decoder similar to AIR. This model still differs from the AIR in terms of the learnable sequential prior and the fact that we enforce explicit constrains over the latent variable ranges—e.g. enforcing the mean of the control-point Gaussian to not stray too far away from the image frame. In the variant without execution guidance, we do not perform intermediate rendering, removing the direct dependence of the generative model and the recognition model on the canvas-so-far $x_{<t}$ and the residual $\Delta x_t$ .
136
+
137
+ Both the explicit spline decoder and the execution guidance prove to be important. Without the explicit spline decoder (DooD-δR), the reconstruction quality suffers—the strokes are blurry (e.g. first three QuickDraw images), strokes go missing (e.g. the last EMNIST image), or the reconstructions are inaccurate (e.g. the last Omniglot character is interpreted as a “9” due to overfitting). However, even without the explicit spline decoder, the model learns to be parsimonious, using fewer strokes to reconstruct simpler images (Fig. 3b-d). On the other hand, without execution guidance (DooD-EG), the model is unable to be selective with the number of strokes, always using the maximum allowed number. And while the reconstructions are better than AIR and DooD-δR, it still shows instances of missing strokes (e.g. some Omniglot characters). Note that although we use the canvas-so-far in a manner that disallows gradients (stop_gradient), just providing it as a conditioning variable for the different components (layout, stroke, RNN hidden states) has a tangible effect.
138
+
139
+ ![](images/2f782c000a8d32e3016f75c9eb04fa86d2fb3f2889ead58fc4a01f36b12d134b.jpg)
140
+ Figure 4: When training on a "source" dataset and testing on another "target" dataset, our model, DooD, (left) has a higher log marginal likelihood (values in each cell) than AIR (right). Given targets on top of the tables, DooD's reconstructions (images in each cell) are high quality when transferring out of distribution, unlike AIR which often struggles. Training on MNIST or Omniglot as a source dataset leads to worse transfer (the corresponding rows are the darkest) due to a larger distribution shift. Particularly AIR fails when trained on Omniglot using a Laplace likelihood (standard across all other model-dataset combination for good reconstructions), due to which we employ a Gaussian likelihood just for Omniglot-trained AIR (highlighted in purple).
141
+
142
+ Quantifying zero-shot transfer. We look at how DooD and AIR trained on each of the five datasets transfers to each other dataset to further understand how our model generalises. Models are trained on each "source" dataset and tested on each "target" dataset, resulting in a $5 \times 5$ table for each model (Fig. 4). Each cell shows the log marginal likelihood of the target dataset using the model trained on the source dataset, estimated using the importance weighted autoencoder (IWAE) objective [3] with 200 samples (mean and standard deviation over five runs). We also show reconstructions obtained by running the model trained on the source dataset on a few examples from the target dataset.
143
+
144
+ Our model generalises significantly better than AIR across datasets (off diagonal cells), while also performing better within dataset (diagonal cells). For both models, the values on the diagonal are the highest in any given column, suggesting that not training on directly on the target dataset results in a worse performance, as expected. For both models, the row values for MNIST and Omniglot are lower than in other rows, indicating that transfer learning performance is the worst when the source dataset is MNIST or Omniglot—potentially due to a larger distribution shift since MNIST has low diversity and Omniglot has little to no variation in stroke thickness, in contrast to the other datasets. However, we note that our reconstructions are high quality despite transferring out of distribution, unlike reconstructions from AIR which are qualitatively worse. For example, when transferring from simple datasets (MNIST), AIR makes incomplete, incorrect and blurry reconstructions, as we have seen before, while AIR trained on complex datasets like Omniglot results in blurry reconstructions for both in-distribution and out-of-distribution datasets. Furthermore, AIR fails when trained on Omniglot using a Laplace likelihood (used as standard across all other model-dataset combination). We thus employ a Gaussian likelihood just for Omniglot-trained AIR, and highlight it as an outlier.
145
+
146
+ Understanding learned representations. To better understand DooD's generalization ability, we investigate its learnt representations by clustering the inferred strokes using $k$ -means clustering ( $k = 8$ ), and study the clusters both qualitatively and quantitatively. For AIR, we cluster the corresponding part-representation latents. We then visualise things, using a t-SNE plot (Fig. 5) of the clusters, with exemplar strokes overlaid. We find that DooD has better-clustered representations, with clusters denoting largely distinct types of strokes—e.g., clusters for a “/”, “c”, and its horizontally flipped version. In contrast, the clusters from AIR are less sensible with some clusters even capturing full characters (“0”), comprising multiple strokes. There are also clusters which contain visually different strokes, and many visually similar strokes are assigned to different clusters. Quantitatively,
147
+
148
+ following Aksan et al. [1], we found DooD's better cluster consistency is reflected in a higher Silhouette Coefficient [30] than AIR (0.21 for DooD, 0.11 for AIR).
149
+
150
+ ![](images/cf3e8d157026a45aa9b8d05641ff9a1733f1744aeb52aefd699ba757b7f10bf1.jpg)
151
+ Figure 5: Clusters of inferred strokes for DooD (left) and inferred part representations for AIR (right) overlaid on a t-SNE plot. DooD's representation clusters to more semantically meaningful parts as indicated by better formed clusters.
152
+
153
+ ![](images/7c1979bf492ce4cb474b9dd7bd5be7dcc8c2c90f4d8b5e223ab5b64f1ee74404.jpg)
154
+
155
+ ![](images/3deb65c3c6ce27d87d3236a42b1f702736839748bd7e2dc2d0901dc7f9181e01.jpg)
156
+
157
+ ![](images/32c27387a927bcae2fce1795dca8185bd22ff60cb2cdf87c446ed3c90c3181af.jpg)
158
+
159
+ # 3.2 Across-Task Generalization
160
+
161
+ Here, we focus on a subset of the Omniglot challenge tasks [24], to evaluate our model's utility on a range of auxiliary tasks that it was not trained to do. Despite much progress in deep generative modelling, relevant models are still not fully task general and often result in unrealistic (e.g. blurry) samples [10, 25]. DooD combines handling raw perceptual inputs with the compositional structure of strokes, which we evaluate on three out of the five Omniglot challenge tasks: unconditional generation, conditional generation, and one-shot classification. We compare against AIR and a state-of-the-art neuro-symbolic model (GNS [10]), where relevant. Note that GNS requires stroke and character-class supervision and practically, at least for now, only applies to Omniglot.
162
+
163
+ Unconditional generation. DooD generates realistic unconditional samples of all datasets (Fig. 6), indicating that the model has learned the high-level characteristics of each dataset. The strokes are sharp, and the stroke structure composes into realistic images from each dataset. For example, there are clear digits in the MNIST samples, there are recognizable objects (cars, bicycles, glasses, and smileys) in the QuickDraw samples, and the samples for EMNIST, KMNIST and Omniglot can be easily recognised as possible instances coming from those datasets. It generates samples of comparable fidelity to GNS without requiring any supervision, and as evaluated using the Fréchet inception distance (FID) [16] (smaller is better), outperforms GNS (0.051 versus 0.133).
164
+
165
+ The key to being able to generate realistic prior samples is the learnable sequential prior and the symbolic latent representation. AIR doesn't have a sequential prior, so although it is possible to get good reconstructions, it is impossible for it to generate realistic unconditional samples.
166
+
167
+ Character-conditioned generation. In order to generate new exemplars of the same Omniglot character, we follow Feinman and Lake [10], Lake et al. [24] and extend our model to a hierarchical generative model of an abstract character "type" or "template" that generates a concrete instance of a character "token", which is rendered out to an image. We consider the previously used latent variables as the type latent variable and introduce a token model which conditions on the type latent variable. The token model introduces (i) a drawing noise represented by adding a Gaussian noise with fixed standard deviations to spline control points and (ii) and an affine transformation on the noise perturbed points, whose parameters are also sampled from a Gaussian distribution (described in Appendix B.4). To sample a new exemplar of a character, we first sample the type variable from
168
+
169
+ <table><tr><td>MNIST .134 ± .013</td><td>EMNIST .137 ± .006</td><td>KMNIST .123 ± .020</td><td>QuickDraw .084 ± .009</td><td>Omniglot (DooD) .051 ± .007</td><td>Omniglot (GNS[10]) .133 ± .007</td><td>Omniglot (True) .025 ± .004</td></tr><tr><td>7 9 8</td><td>#</td><td>#</td><td>#</td><td>#</td><td>H</td><td>#</td></tr><tr><td>2 5 7</td><td>#</td><td>#</td><td>#</td><td>#</td><td>L</td><td>#</td></tr><tr><td>2 1 4</td><td>#</td><td>#</td><td>#</td><td>#</td><td>O</td><td>#</td></tr><tr><td>2 7 0</td><td>#</td><td>#</td><td>#</td><td>#</td><td>d</td><td>#</td></tr></table>
170
+
171
+ Figure 6: DooD generates high quality unconditional character samples for all datasets which are visually indistinguishable from the real characters as it successfully captures the layout of strokes and their forms. Omniglot samples are compared to GNS [10] and real samples. Numbers denote Fréchet inception distance (FID), with smaller being better (mean $\pm 1$ std. over 5 runs).
172
+
173
+ ![](images/42bfd1bcbe9fb731f7930f093e1013ab16557d0609eec1ab346f79bfd4b63263.jpg)
174
+ Figure 7: Given a target image of a handwritten Omniglot character, our model produces realistic new exemplars by inferring an explicit stroke-based representation.
175
+
176
+ ![](images/d2b6857c058dd8bd45460cd81e24536292af30d23f162a1152787e01d7d9ed70.jpg)
177
+ Figure 8: Given a partially drawn character, our model can generate a realistic distribution over its completions by sampling from the generative model conditioned on the image of the partial character.
178
+
179
+ our recognition model, and produce different exemplars by sampling and rendering different token variables given this type variable. Distinctly from [10, 24], the parameters of the token model are not learned through supervision but simply set to a sensible value by examining the noise level in the output - any learned statistics can be straightforwardly plugged in.
180
+
181
+ DooD generates realistic new exemplars of complex QuickDraw drawings and Omniglot characters (Fig. 7) thanks to the accurate inference and the ability to add noise to explicitly parametrised strokes. While we can add an equivalent token model for AIR by (i) adding a Gaussian noise to the uninterpretable feature vector representing each part and (ii) applying a Gaussian affine transformation to the rendered image, the new exemplars are not as realistic both because of worse inference and the hard-to-control variations of the part vectors. GNS generates realistic conditional samples, but notably still makes unnatural samples in multiple instances (e.g., in column 1, 3 the detachments of strokes) despite having a hierarchical model learned with multi-levels of supervision.
182
+
183
+ Partial completion. As with inferring an entire figure in the previous case, we can interpret conditional generation in a slightly different way as well—where the condition is an initialization of a number, character, or figure, and the model tries to extend/complete it as best it can (Fig. 8). To do this, we first employ the recognition model over the partial figure to compute the hidden states of the shared recurrent networks. Next, starting with these computed states, we set the canvas-so-far $x_{<t}$ to be the partial figure itself and then unroll the generative model from that point onwards. As can be seen in the figure, DooD can generate a varied range of completions for each initial stroke, demonstrating its versatility and the utility of its learnt representations.
184
+
185
+ One-shot classification. Finally, we can apply the type-token hierarchical generative model used for generating new exemplars to perform within-alphabet, 20-way one-shot classification. The key quantity needed for performing this task is the posterior predictive score of the query image $x^{(T)}$ given a set of support images $\{x^{(c)}\}_{c}$ , $\hat{c} = \arg \max_{c} p(x^{(T)}|x^{(c)})$ , which requires marginalizing over the token variables corresponding to $x^{(T)}$ and $x^{(c)}$ , and the type variable of $x^{(c)}$ . Following [10, 24], we approximate this score by sampling from the recognition model given $x^{(c)}$ , and perform gradient-based optimization to marginalize out the token variable of $x^{(T)}$ (details in Appendix D.2.3). We find that DooD outperforms the neural baseline (AIR), while attaining a competitive accuracy in comparison to other baselines (Table 1)
186
+
187
+ Table 1: Accuracy in one-shot classification, without data augmentation (DA), extra supervision (ES), or 2-way classification (2W).
188
+
189
+ <table><tr><td>Model</td><td>DA</td><td>ES</td><td>2W</td><td>Accuracy</td></tr><tr><td>AIR</td><td>X</td><td>X</td><td>X</td><td>14.5%</td></tr><tr><td>DooD</td><td>X</td><td>X</td><td>X</td><td>73.5%</td></tr><tr><td>VHE[18]</td><td>✓</td><td>✓</td><td>X</td><td>81.3%</td></tr><tr><td>GNS[10]</td><td>X</td><td>✓</td><td>✓</td><td>94.3%</td></tr><tr><td>BPL[24]</td><td>X</td><td>✓</td><td>✓</td><td>96.7%</td></tr></table>
190
+
191
+ without requiring additional forms of support such as data augmentation, supervision for strokes, or more complex ways of computing the classification score such as two-way scoring (predicting $\hat{c} = \arg \max_c\frac{p(x^{(c)}|x^{(T)})}{p(x^{(c)})} p(x^{(T)}|x^{(c)}))$
192
+
193
+ # 4 Related Work
194
+
195
+ Our work takes inspiration from Lake et al. [24]'s symbolic generative modelling approach which hypothesises that the human ability to generalise comes from our causal and compositional understanding that characters are generated by composing substrokes into strokes, strokes into characters and rendering characters to images. As a result, Lake et al. [24] demonstrate human-like generalization on a wide range of tasks. However, it is trained using stroke sequences, and inference is performed using expensive MCMC sampling.
196
+
197
+ We combine features of neuro-symbolic generative models and deep generative models to be able to generalise well across tasks while using amortised inference and being unsupervised. From neuro-symbolic models, we share key features of Feinman and Lake [10]'s model like (i) using the canvas-so-far in the generative model and adopt a similar feature in the recognition model like Ellis et al. [8], (ii) parametrizing parts as splines and using a differentiable spline renderer, (iii) extending the model to have a type-token hierarchy for generating new exemplars and performing one-shot classification. Our model can be seen as an extension of [10] that learns directly from images and uses a recognition model for amortised inference. Like Hewitt et al. [17], we learn how to infer a stroke sequence directly from images using a differentiable renderer but infer strokes directly instead of learning a stroke bank and use a more flexible parametrization of strokes based on a differentiable spline renderer, leading to a more accurate model.
198
+
199
+ Similar to deep generative modelling approaches like [9, 14, 23, 29], we use attention to focus on parts of the canvas we want to generate to or recognise, and more generally exploit the compositionality of objects from which allows neural networks to learn simpler and hence more generalizable mappings. To be able to train our model from unsupervised images, we adopt the NVIL control variate [28] used by Eslami et al. [9] to be able to train a model with a discrete stop-drawing latent variable. This family of models, along with deep meta-learning approaches [11, 32, 34], is easier to learn due to the lack of symbolic variables and results in a fast amortised recognition model. However, the lack of strong inductive biases leads to poor and unreliable generalization [25]. We also share idea with other works combining deep learning and explicit stroke modelling [1, 12, 15, 27], but we focus on learning a principled generative model which allows tackling tasks like one-shot classification and generating new exemplars, in addition to conditional and unconditional sampling.
200
+
201
+ # 5 Conclusion
202
+
203
+ We demonstrated that DooD generalises across datasets and across tasks thanks to an explicit symbolic parametrization of strokes and execution guidance. This allows us to train on one dataset such as MNIST and generalise to a more complex, out-of-distribution dataset such as Omniglot. Given a compositional representation and an associated learned sequential prior, DooD can be applied to additional tasks in the Omniglot challenge like generating new exemplars and one-shot classification by extending it to have a type-token hierarchy. Our model produces realistic new exemplars without blur and artefacts unlike deep generative models.
204
+
205
+ More broadly, DooD is an example of a system that successfully combines symbolic generative models to achieve generalization and deep learning models to handle raw perceptual data and perform fast amortised inference while being learned from unsupervised data. We believe these principles can be useful for building fast, reliable and robust learning systems going beyond stroke-based data.
206
+
207
+ Acknowledgements We thank Rob Zinkov for his contribution to the early versions of the renderer; Reuben Feinman, Luke Hewitt, Kevin Ellis for their thoughtful comments on the manuscript; and Reuben's prompt support in running the GNS model. NS was in part supported by the Turing 2.0 'Enabling Advanced Autonomy' project, funded by the EPSRC and the Alan Turing Institute.
208
+
209
+ # References
210
+
211
+ [1] E. Aksan, T. Deselaers, A. Tagliasacchi, and O. Hilliges. Cose: Compositional stroke embeddings. Advances in Neural Information Processing Systems, 33:10041-10052, 2020.
212
+ [2] S. Bowman, L. Vilnis, O. Vinyals, A. Dai, R. Jozefowicz, and S. Bengio. Generating sentences from a continuous space. In Proceedings of The 20th SIGNLL Conference on Computational Natural Language Learning, pages 10-21, 2016.
213
+ [3] Y. Burda, R. Grosse, and R. Salakhutdinov. Importance weighted autoencoders. arXiv preprint arXiv:1509.00519, 2015.
214
+ [4] C. P. Burgess, L. Matthew, N. Watters, R. Kabra, I. Higgins, M. Botvinick, and A. Lerchner. Monet: Unsupervised scene decomposition and representation, 2019. URL https://arxiv.org/abs/1901.11390.
215
+ [5] J. Chung, K. Kastner, L. Dinh, K. Goel, A. C. Courville, and Y. Bengio. A recurrent latent variable model for sequential data. Advances in neural information processing systems, 28: 2980-2988, 2015.
216
+ [6] T. Clanuwat, M. Bober-Irizar, A. Kitamoto, A. Lamb, K. Yamamoto, and D. Ha. Deep learning for classical japanese literature. arXiv preprint arXiv:1812.01718, 2018.
217
+ [7] G. Cohen, S. Afshar, J. Tapson, and A. Van Schaik. Emmist: Extending mnist to handwritten letters. In 2017 International Joint Conference on Neural Networks (IJCNN), pages 2921-2926. IEEE, 2017.
218
+ [8] K. Ellis, M. Nye, Y. Pu, F. Sosa, J. Tenenbaum, and A. Solar-Lezama. Write, execute, assess: Program synthesis with a repl. Advances in Neural Information Processing Systems, 32, 2019.
219
+ [9] S. Eslami, N. Heess, T. Weber, Y. Tassa, D. Szepesvari, G. E. Hinton, et al. Attend, infer, repeat: Fast scene understanding with generative models. Advances in Neural Information Processing Systems, 29:3225-3233, 2016.
220
+ [10] R. Feinman and B. M. Lake. Learning task-general representations with generative neurosymbolic modeling. arXiv preprint arXiv:2006.14448, 2020.
221
+ [11] C. Finn, P. Abbeel, and S. Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In International conference on machine learning, pages 1126–1135. PMLR, 2017.
222
+ [12] Y. Ganin, T. Kulkarni, I. Babuschkin, S. A. Eslami, and O. Vinyals. Synthesizing programs for images using reinforced adversarial learning. In International Conference on Machine Learning, pages 1666-1675. PMLR, 2018.
223
+ [13] M. A. Goodale and A. D. Milner. Separate visual pathways for perception and action. Trends in neurosciences, 15(1):20-25, 1992.
224
+ [14] K. Gregor, I. Danihelka, A. Graves, D. Rezende, and D. Wierstra. Draw: A recurrent neural network for image generation. In International Conference on Machine Learning, pages 1462-1471. PMLR, 2015.
225
+ [15] D. Ha and D. Eck. A neural representation of sketch drawings. arXiv preprint arXiv:1704.03477, 2017.
226
+ [16] M. Heusel, H. Ramsauer, T. Unterthiner, B. Nessler, and S. Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. Advances in neural information processing systems, 30, 2017.
227
+ [17] L. Hewitt, T. A. Le, and J. Tenenbaum. Learning to learn generative programs with memoised wake-sleep. In Conference on Uncertainty in Artificial Intelligence, pages 1278-1287. PMLR, 2020.
228
+ [18] L. B. Hewitt, M. I. Nye, A. Gane, T. Jaakkola, and J. B. Tenenbaum. The variational homoen-coder: Learning to learn high capacity generative models from few examples. arXiv preprint arXiv:1807.08919, 2018.
229
+
230
+ [19] I. Higgins, L. Matthey, A. Pal, C. Burgess, X. Glorot, M. Botvinick, S. Mohamed, and A. Lerchner. beta-VAE: Learning basic visual concepts with a constrained variational framework. In Proceedings of the International Conference on Learning Representations, 2016.
231
+ [20] M. Jaderberg, K. Simonyan, A. Zisserman, et al. Spatial transformer networks. Advances in neural information processing systems, 28, 2015.
232
+ [21] D. P. Kingma and J. Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
233
+ [22] D. P. Kingma and M. Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013.
234
+ [23] A. Kosiorek, S. Sabour, Y. W. Teh, and G. E. Hinton. Stacked capsule autoencoders. Advances in neural information processing systems, 32, 2019.
235
+ [24] B. M. Lake, R. Salakhutdinov, and J. B. Tenenbaum. Human-level concept learning through probabilistic program induction. Science, 350(6266):1332-1338, 2015.
236
+ [25] B. M. Lake, R. Salakhutdinov, and J. B. Tenenbaum. The omniglot challenge: a 3-year progress report. Current Opinion in Behavioral Sciences, 29:97-104, 2019.
237
+ [26] Y. LeCun. The mnist database of handwritten digits. http://yann.lecun.com/exdb/mnist/, 1998.
238
+ [27] J. F. Mellor, E. Park, Y. Ganin, I. Babuschkin, T. Kulkarni, D. Rosenbaum, A. Ballard, T. Weber, O. Vinyals, and S. Eslami. Unsupervised doodling and painting with improved spiral. arXiv preprint arXiv:1910.01007, 2019.
239
+ [28] A. Mnih and K. Gregor. Neural variational inference and learning in belief networks. In International Conference on Machine Learning, pages 1791-1799. PMLR, 2014.
240
+ [29] D. Rezende, I. Danihelka, K. Gregor, D. Wierstra, et al. One-shot generalization in deep generative models. In International conference on machine learning, pages 1521-1529. PMLR, 2016.
241
+ [30] P. J. Rousseeuw. Silhouettes: a graphical aid to the interpretation and validation of cluster analysis. Journal of computational and applied mathematics, 20:53-65, 1987.
242
+ [31] J. Schulman, N. Heess, T. Weber, and P. Abbeel. Gradient estimation using stochastic computation graphs. arXiv preprint arXiv:1506.05254, 2015.
243
+ [32] J. Snell, K. Swersky, and R. Zemel. Prototypical networks for few-shot learning. Advances in neural information processing systems, 30, 2017.
244
+ [33] J. Tenenbaum and W. Freeman. Separating style and content. Advances in neural information processing systems, 9, 1996.
245
+ [34] O. Vinyals, C. Blundell, T. Lillicrap, D. Wierstra, et al. Matching networks for one shot learning. Advances in neural information processing systems, 29, 2016.
drawingoutofdistributionwithneurosymbolicgenerativemodels/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3bc90e4275a30240309f01559be3eb6609f4bd401c5c399619c4bf45f5afc309
3
+ size 606148
drawingoutofdistributionwithneurosymbolicgenerativemodels/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:41bfe0d6d91a5ecd9f9424e4f2fc18592cabc45d9fc36410098f29c59abcf934
3
+ size 312046
dreamshardgeneralizableembeddingtableplacementforrecommendersystems/b7e19046-19b1-47d6-85d0-e1ea6fd3dc21_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bd861d7ebbce09bf8419aabc88f74d61167c9983508c4fb884e9be60090c1742
3
+ size 84990
dreamshardgeneralizableembeddingtableplacementforrecommendersystems/b7e19046-19b1-47d6-85d0-e1ea6fd3dc21_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f4bc47800e46355e329f036dfd90443b52f4fca968090220d4c884222ce708bd
3
+ size 110630
dreamshardgeneralizableembeddingtableplacementforrecommendersystems/b7e19046-19b1-47d6-85d0-e1ea6fd3dc21_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e738a21e4ce421f597f624a3a7724631b3754017e663077e7d4b52034bfbb775
3
+ size 627811
dreamshardgeneralizableembeddingtableplacementforrecommendersystems/full.md ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DreamShard: Generalizable Embedding Table Placement for Recommender Systems
2
+
3
+ Daochen Zha $^{1}$ Louis Feng $^{2}$ Qiaoyu Tan $^{3}$ Zirui Liu $^{1}$ Kwei-Herng Lai $^{1}$ Bhargav Bhushanam $^{2}$ Yuandong Tian $^{2}$ Arun Kejariwal $^{2}$ Xia Hu $^{1}$
4
+
5
+ $^{1}$ Rice University $^{2}$ Meta Platforms, Inc. $^{3}$ Texas A&M University
6
+
7
+ {daochen.zha,Zirui.Liu,khlai,Xia.Hu}@rice.edu
8
+
9
+ {lofe, bbhushanam, yuandong, akejariwal}@fb.com
10
+
11
+ qytan@tamu.edu
12
+
13
+ # Abstract
14
+
15
+ We study embedding table placement for distributed recommender systems, which aims to partition and place the tables on multiple hardware devices (e.g., GPUs) to balance the computation and communication costs. Although prior work has explored learning-based approaches for the device placement of computational graphs, embedding table placement remains to be a challenging problem because of 1) the operation fusion of embedding tables, and 2) the generalizability requirement on unseen placement tasks with different numbers of tables and/or devices. To this end, we present DreamShard, a reinforcement learning (RL) approach for embedding table placement. DreamShard achieves the reasoning of operation fusion and generalizability with 1) a cost network to directly predict the costs of the fused operation, and 2) a policy network that is efficiently trained on an estimated Markov decision process (MDP) without real GPU execution, where the states and the rewards are estimated with the cost network. Equipped with sum and max representation reductions, the two networks can directly generalize to any unseen tasks with different numbers of tables and/or devices without finetuning. Extensive experiments show that DreamShard substantially outperforms the existing human expert and RNN-based strategies with up to $19\%$ speedup over the strongest baseline on large-scale synthetic tables and our production tables. The code is available at https://github.com/daochenzha/dreamshard.
16
+
17
+ # 1 Introduction
18
+
19
+ Embedding learning is a commonly used technique to deal with categorical features in deep recommendation models by mapping sparse features into dense vectors [1, 2, 3, 4, 5]. However, the embedding tables can be extremely large due to the large feature sizes [6]. For example, in the YouTube recommendation model, a single categorical feature contains tens of millions of video IDs [7]; the Meta recommendation model demands multi-terabyte memory [8]. Distributed training has been adopted to place the tables on multiple hardware devices such as GPUs [3, 6, 9, 10, 11]. However, even with distributed training, the embedding tables are often still the efficiency bottlenecks. For instance, embedding lookup is shown to dominate the training throughput in the Meta recommendation model [8]. In our internal production model, which has hundreds of tables, embedding lookup accounts for $48\%$ and $65\%$ of the total computation and communication costs, respectively.
20
+
21
+ How the embedding tables are placed can significantly impact the costs. Figure 1 shows the traces of different placement strategies on a task of placing 50 tables on 4 devices. Typically, embedding lookup consists of four stages. In the forward pass, the sparse indices are mapped into dense vectors (forward computation), which are then sent to the target devices (forward communication).
22
+
23
+ In the backward pass, the gradients of the embedding vectors are sent back from the target devices (backward communication) and applied to the embedding vectors (backward computation). The tables will easily lead to imbalances if not carefully partitioned. The random placement in Figure 1a is bottlenecked by GPU2 with a 56.6 milliseconds latency, while the more balanced placements in Figure 1b and 1c significantly reduce the costs to 42.8 and 35.95 milliseconds, respectively. This work asks: given a set of embedding tables, how can we identify the best placement of the tables to balance the costs?
24
+
25
+ Device placement is essentially a partition problem, which is one of the classical NP-hard combinatorial optimization problems [12]. A recent line of research uses reinforcement learning (RL) for device placement of computational graphs [13, 14, 15, 16, 17, 18, 19, 20]. For example, [13] proposed to train an RNN controller with content-based attention to predict the placement. Other studies advanced [13] in different ways, such as using hierarchical models [14], more sophisticated RL algorithms [15], and graph neural networks [16].
26
+
27
+ However, embedding table placement remains to be an open and challenging problem due to the operation fusion [21] of tables and the generalizability requirement. 1) Modern embedding implementations (e.g., FBGEMM [22]), use a single operation to subsume multiple tables for acceleration. The speedup of the fused operation over the sum of the single-table operation costs is not constant and depends on the characteristics of the fused tables (e.g., table dimensions). Our analysis finds that the speedups vary significantly across different table
28
+
29
+ ![](images/1d6780327929ea1d5894f958a87372a82d2c74ff19c7adeede6ee19ebe140fc1.jpg)
30
+
31
+ ![](images/702765353bbe0594a2e435d96799e4a2a9664dca0d334cd4b2e90aa261d9e20c.jpg)
32
+ (a) Random placement
33
+
34
+ ![](images/1b985853b1f01a687728129eb9bd71a66457d7978469fa1d0263d00f9d80030e.jpg)
35
+ (b) The existing best human expert strategy
36
+ (c) DreamShard
37
+ Figure 1: Visualization of random placement, the existing best human expert strategy, and DreamShard on a task of placing 50 tables on 4 GPUs. The dense computations and communications are omitted in the traces because they do not have an imbalance issue. We provide more visualizations in Appendix L.
38
+
39
+ combinations, ranging from 1X to 3X (Figure 12 in Appendix A.3.2). Thus, we not only need to reason about cost balance but also how the tables should be fused to maximize the speedup. 2) In real-world scenarios, the adopted embedding tables and the available devices can change frequently (e.g., machine learning engineers/researchers may conduct concurrent experiments with various table combinations and numbers of devices). Thus, a practical algorithm should generalize to tasks with unseen tables, different numbers of tables, and different numbers of devices. It is non-trivial to achieve this with the existing device placement approaches.
40
+
41
+ To this end, we introduce DreamShard, an RL approach for embedding table placement. DreamShard achieves the reasoning of operation fusion and generalizability with two novel ideas. 1) It learns a cost network to directly predict the costs of the fused operations. Specifically, the network takes as input the table features (e.g., table dimension) of each single-table and outputs the computation and communication costs. 2) It trains a policy network by interacting with an estimated Markov decision process (MDP) without real GPU execution, where the states and the rewards are estimated by the predictions of the cost network. Equipped with sum reductions for the table representations and max reductions for the device representations, the two networks can directly generalize to unseen placement tasks with different numbers of tables and/or devices without fine-tuning.
42
+
43
+ Extensive experiments show that DreamShard outperforms the existing human expert and RNN-based [13] strategies on open-sourced synthetic tables [23] and our production tables, achieving up to $19\%$ speedup over the strongest baseline. Moreover, it can generalize to unseen tasks that have different numbers of tables and/or devices with negligible performance drop ( $< 0.5$ milliseconds). Additionally, its inference is very efficient. It can place hundreds of tables in less than one second.
44
+
45
+ # 2 Generalizable Embedding Table Placement Problem
46
+
47
+ The embedding table placement problem seeks a device placement<sup>1</sup> of all the tables such that the overall cost (in terms of execution time) is minimized (we provide a background for the distributed training of recommendation models in Appendix A.1). Consider $M$ embedding tables $\{\mathbf{e}_1, \mathbf{e}_2, \dots, \mathbf{e}_M\}$ and $D$ devices, where $\mathbf{e}_i \in \mathbb{R}^N$ denotes the table features that characterize the embedding lookup patterns. In our work, we use 21 table features, including hash size, dimension, table size, pooling factor, and distribution (their definitions are provided in Appendix A.2). A placement $\mathbf{a} = [a_1, a_2, \dots, a_M]$ , where $a_i \in \{1, 2, \dots, D\}$ , assigns each table to a device. Let $c(\mathbf{a})$ denote the cost measured on GPUs. The goal of embedding table placement is to find the $\mathbf{a}$ such that $c(\mathbf{a})$ is minimized. Due to the NP-hardness of the partition problem [12], identifying the exact solution demands extensive computational overhead. Thus, the state-of-the-art algorithms often approximate the optimal partition via sampling with RL [24, 13]. However, sampling remains expensive because obtaining $c(\mathbf{a})$ requires running operations on GPUs. Given that the embedding tables and the available devices can frequently change, we wish to approximate the best $\mathbf{a}$ without GPU execution.
48
+
49
+ Motivated by this, we study the generalizable embedding table placement (GETP) problem. Let $\mathcal{E}$ be the space of all the embedding tables. A placement task can be denoted as $T_{i} = (\mathcal{E}_{i},D_{i})$ , where $\mathcal{E}_i\subseteq \mathcal{E}$ is a set of tables, and $D_{i}$ is the number of devices. Given $N_{\mathrm{train}}$ training tasks $\mathcal{T}_{\mathrm{train}} = \{T_1,T_2,\dots,T_{N_{\mathrm{train}}}\}$ , and $N_{\mathrm{test}}$ testing tasks $\mathcal{T}_{\mathrm{test}} = \{T_1,T_2,\dots,T_{N_{\mathrm{test}}}\}$ , the goal is to train a placement policy based on $\mathcal{T}_{\mathrm{train}}$ (GPU execution is allowed during training) such that the learned policy can minimize the costs for the tasks in $\mathcal{T}_{\mathrm{test}}$ without GPU execution.
50
+
51
+ # 3 DreamShard Framework
52
+
53
+ We present DreamShard, an RL framework based on estimated MDP, to tackle the GETP problem. An overview of the framework is shown in Figure 2. The key idea is to formulate the table placement process as an MDP (Section 3.1) and train a cost network to estimate its states and rewards (Section 3.2). A policy network with a tailored generalizable network architecture is trained by efficiently interacting with the estimated MDP (Section 3.3). The two networks are updated iteratively to improve the state/reward estimation and the placement policy.
54
+
55
+ ![](images/b8ada32b1cb29bb2fbd756573635d84223efdee9837bc86b27cbd2988cc71150.jpg)
56
+ Figure 2: DreamShard framework. The agent interacts with the estimated MDP, which is trained with the cost data collected from GPUs.
57
+
58
+ # 3.1 MDP Formulation
59
+
60
+ Given embedding tables $\{\mathbf{e}_1, \mathbf{e}_2, \dots, \mathbf{e}_M\}$ and $D$ devices, we aim to generate a placement $\mathbf{a} = [a_1, a_2, \dots, a_M]$ . The key idea is to place the tables one by one at each step, where the state characterizes the tables that have been placed so far, the action is the device ID, and the reward represents the execution time on GPUs. Specifically, at a step $t$ , the state $s_t = \{s_{t,d}\}_{d=1}^D$ is all the table features of the tables placed on all the devices, where $s_{t,d} = \{\mathbf{e}_i | i \in \mathcal{P}_d\}$ denotes all the table features corresponding to device $d$ ( $\mathcal{P}_d$ is the set of table IDs that have been placed on device $d$ ). We further augment the raw features with cost features which are obtained by collecting the operation computation and communication times from GPUs (Appendix A.3 provides a comprehensive analysis of the cost features). Formally, the augmented state is defined as $\widetilde{s}_t = \{s_t, \{\mathbf{q}_{t,d}\}_{d=1}^D\}$ , where $\mathbf{q}_{t,d} \in \mathbb{R}^3$ has three elements representing forward computation time, backward computation time, and backward communication time for the current operation in device $d$ (we provide detailed explanations of why forward communication time is excluded in Appendix A.4). We find that the augmented cost features can significantly boost the performance, evidenced by the ablations in Table 3. The action $a_t \in \mathcal{A}_t$ is an integer specifying the device ID, where $\mathcal{A}_t$ is the set of legal actions at step $t$ . A device ID is considered legal if placing the current table on the corresponding device does not cause a memory explosion. The reward $r_t$ is 0 for all the intermediate steps, and the reward at the final step $M$ is the negative of the cost, i.e., $r_M = -c(\mathbf{a})$ , which encourages the agent to achieve lower cost.
61
+
62
+ ![](images/beb4ca0f790cec2fd155b44093cafcb10bfbb77dba2dec1125deb4998087f850.jpg)
63
+ Figure 3: MDP formulation of embedding table placement.
64
+
65
+ ![](images/ea8add6d93b15c288db750ec0e9966a393eb7a9081c615edb65d368c9a9a325d.jpg)
66
+ Figure 4: DreamShard's cost network (left) and policy network (right).
67
+
68
+ ![](images/6f9c6ee5063ed7ac720ceb5c0154082f1609cdfd2b75d220b79abc67aa9ea342.jpg)
69
+
70
+ The procedure is illustrated for an example task of placing 8 tables $\{\mathbf{e}_1,\mathbf{e}_2,\dots,\mathbf{e}_8\}$ on 2 devices in Figure 3. At step 0, no table has been placed so $s_0 = \{\{\},\{\}\}$ and the augmented state $\widetilde{s}_0 = \{s_0,\{\mathbf{q}_{0,0},\mathbf{q}_{0,1}\}\}$ , where both $\mathbf{q}_{0,0}$ and $\mathbf{q}_{0,1}$ are zero vectors (i.e., $[0,0,0]$ ) since all the computation and communication times are 0 as well. Then the action $a_0 = 1$ makes the MDP transit to the next state $s_1 = \{\{\mathbf{e}_1\},\{\}\}$ with its corresponding augmented state $\widetilde{s}_1 = \{s_1,\{\mathbf{q}_{1,0},\mathbf{q}_{1,1}\}\}$ , where $\mathbf{q}_{1,0}$ becomes a non-zero vector containing the computation and communication costs by running $\{\mathbf{e}_1\}$ and $\{\}$ on GPUs. We repeat the above process, and finally at step 8, we have $s_8 = \{\{\mathbf{e}_1,\mathbf{e}_4,\mathbf{e}_7,\mathbf{e}_8\},\{\mathbf{e}_2,\mathbf{e}_3,\mathbf{e}_5,\mathbf{e}_6\}\}$ . The corresponding $\mathbf{q}_{8,1}$ , and $\mathbf{q}_{8,2}$ are the measured times of running $\{\mathbf{e}_1,\mathbf{e}_4,\mathbf{e}_7,\mathbf{e}_8\}$ and $\{\mathbf{e}_2,\mathbf{e}_3,\mathbf{e}_5,\mathbf{e}_6\}$ on two devices. The action sequence $\mathbf{a} = [a_1,a_2,\dots,a_8]$ is the generated placement, which is then evaluated on GPUs to obtain the reward.
71
+
72
+ Discussion 1. The MDP enjoys two desirable properties. 1) The legal action $\mathcal{A}_t$ can guarantee that the generated placement satisfies the memory constraints. 2) The one-by-one placement enables the agent to be generalized across different numbers of tables. For example, an agent trained on an MDP with very few tables can be applied to another MDP with more tables by simply executing more steps.
73
+
74
+ Discussion 2. A straightforward idea to solve the MDP is to greedily place the current table on the device with the lowest cost at each step, where the cost function can be one of or a combination of the state features (e.g., the sum of the table dimensions, or the sum of all the cost features). However, greedy heuristics are often sub-optimal. Thus, we seek a learning-based algorithm to explore various placement possibilities and make comprehensive decisions based on all the state features.
75
+
76
+ # 3.2 Learning an Estimated MDP
77
+
78
+ Interacting with the above MDP is computationally expensive since obtaining the cost features and the reward requires GPU execution. Motivated by world models [25, 26], we build an estimated MDP by approximating the cost features and the reward with a cost network. Let $f_{\mathrm{cost}}$ denote the cost network. $f_{\mathrm{cost}}$ takes as input the raw table features $s_t$ , and predicts cost features $\{\mathbf{q}_{t,d}\}_{d=1}^D$ and the overall cost $c(\mathbf{a})$ . $f_{\mathrm{cost}}$ is trained with mean squared error (MSE) loss using the cost data collected from the GPUs. Once trained, it can predict the cost features or the reward with a single forward pass without GPU execution. However, it is non-trivial to design the architecture of $f_{\mathrm{cost}}$ because it needs
79
+
80
+ Algorithm 1 Training of DreamShard
81
+ 1: Input: Training tasks $\mathcal{T}_{\text{train}}$ , the number of data collection steps $N_{\text{collect}}$ , the number of cost network update steps $N_{\text{cost}}$ , the batch size for updating the cost network $N_{\text{batch}}$ , the number RL update steps $N_{\text{RL}}$ , the number of considered episodes in each RL update $N_{\text{episode}}$
82
+ 2: Initialize a cost network, a policy network, and a buffer
83
+ 3: for iteration = 1, 2, ... until convergence do
84
+ 4: for step = 1, 2, ... $N_{\text{collect}}$ do ▷ Collect cost data from GPUs
85
+ 5: Randomly sample a training task from $\mathcal{T}_{\text{train}}$
86
+ 6: Generate a placement by interacting with the estimated MDP using the policy network
87
+ 7: Evaluate the placement on the hardware and store the collected cost data to the buffer
88
+ 8: end for
89
+ 9: for step = 1, 2, ... $N_{\text{cost}}$ do ▷ Update the cost network (no GPU execution)
90
+ 10: Randomly sample $N_{\text{batch}}$ cost data from the buffer
91
+ 11: Update the cost network based on MSE loss (Eq. 1 in Appendix B.4.1)
92
+ 12: end for
93
+ 13: for step = 1, 2, ... $N_{\text{RL}}$ do ▷ Update the policy network (no GPU execution)
94
+ 14: Randomly sample a training task from $\mathcal{T}_{\text{train}}$
95
+ 15: Collect $N_{\text{episode}}$ episodes by interacting with the estimated MDP using the policy network
96
+ 16: Update the policy network based on the policy gradient loss (Eq. 2 in Appendix B.4.1)
97
+ 17: end for
98
+ 18: end for
99
+
100
+ to accommodate different numbers of devices (i.e., $s_t$ can have variable sizes), and different numbers of tables in each device (i.e., $s_{t,d}$ can have variable lengths).
101
+
102
+ The left-hand side of Figure 4 shows DreamShard's generalizable design of $f_{\mathrm{cost}}$ , which is based on two key ideas. First, it uses a shared MLP to map raw table features into table representations. For any unseen tables, this MLP can be directly applied to extract table representations. Second, it enables a fixed-dimension representation for each device with sum reductions (i.e., the element-wise sum of the table representations in the device), and similarly for the overall representation across devices with max reductions (Appendix B.3 compares different reduction choices and finds that this sum-max combination leads to the most accurate prediction). The reduced representations are then followed by multiple MLP heads for cost predictions. For unseen tasks with different numbers of tables and/or devices, the reductions will always lead to fixed-dimension device/overall representations, so that the prediction heads can be directly applied. Appendix B.1 provides more details.
103
+
104
+ # 3.3 Training the Policy Network on the Estimated MDP
105
+
106
+ Generalizable policy network architecture. Let $\pi$ be the policy network. $\pi$ maps the augmented state $\widetilde{s}_t = \{s_t,\{\mathbf{q}_{t,d}\}_{d = 1}^D\}$ to action $a_{t}$ , i.e., $a_{t} = \pi (\widetilde{s}_{t})$ . $\pi$ also adopts a generalizable design, shown in the right-hand side of Figure 4. Like $f_{\mathrm{cost}}$ , $\pi$ uses a shared MLP and sum reductions to produce a fixed-dimension representation, which is then concatenated with the cost features to obtain the device representation. To accommodate the potentially variable action space (i.e., the number of available devices may vary), a shared MLP will process each device representation separately to obtain a confidence score, followed by a Softmax layer to produce action probabilities. This design allows $\pi$ to generalize across different numbers of devices. Appendix B.2 provides more details.
107
+
108
+ Training and inference. Algorithm 1 summarizes the training procedure of DreamShard, which iteratively executes the following: 1) collect cost data from GPUs based on the placements generated by the current policy, 2) update the cost network with the previously collected cost data, and 3) update the policy network by interacting with the current estimated MDP. Throughout the training process, the estimated MDP gradually becomes more accurate, and the resultant policy network tends to generate better placements. Appendix B.4.2 provides more details of the training procedure. For the inference, the trained cost network and policy network can be directly applied to unseen tasks to generate placements without GPU execution, which is summarized by Algorithm 2 in Appendix B.4.3.
109
+
110
+ # 4 Experiments
111
+
112
+ Our experiments aim to answer the following research questions. RQ1: How does DreamShard compare with the existing human expert and RL-based placement strategies? RQ2: Can DreamShard generalize to placement tasks with different numbers of tables and/or devices? RQ3: How efficient is the training of DreamShard? RQ4: How do the hyperparameters influence the performance of DreamShard? RQ5: How does each component of DreamShard contribute to the performance? RQ6: How accurate is the estimated MDP and to what extent can it accelerate the training and inference?
113
+
114
+ # 4.1 Experimental Setup
115
+
116
+ Datasets. Academic recommendation datasets are often too small to enable a meaningful evaluation because the cost will always be very small no matter how the tables are placed. Thus, we use two industrial-scale datasets. DLRM $^2$ is a large-scale synthetic dataset with 856 tables, recently released by Meta. It shares memory access reuse patterns similar to those arising in Meta production workloads. Prod is an internal large-scale dataset for production recommendation models. It has a similar scale as DLRM. The main difference is that DLRM only has a fixed dimension for all the tables, while Prod is more challenging with diverse table dimensions, ranging from 4 to 768. For reproducibility, we mainly focus on the DLRM dataset since it is open-sourced. We only report the main results on the Prod dataset for verification purposes. We provide more details in Appendix C.
117
+
118
+ Baselines. We compare DreamShard against human expert strategies from previous work [27, 8, 28], including size-based, dim-based, lookup-based, size-lookup-based greedy balancing strategies. We also include an RNN-based RL algorithm [13], which uses RNN architecture to map operators to devices. Since the feature extraction layers of the RNN-based method were designed for other operations instead of embedding tables, for a fair comparison, we adapt [13] by making it have the same feature extraction layers as in DreamShard. We provide more details in Appendix D.
119
+
120
+ Configurations. To evaluate the generalizability of DreamShard, we randomly divide the tables into a training pool $\mathcal{E}^{\mathrm{train}}$ and a testing pool $\mathcal{E}^{\mathrm{test}}$ . The two pools have the same number of tables but they are not overlapped. A sharding task $T_{i}$ is constructed by randomly sampling a subset of $|\mathcal{E}_i|$ tables from a pool, where the number of tables $|\mathcal{E}_i| \in \{10, 20, 30, 40, 50, 60, 70, 80, 90, 100\}$ for the DLRM dataset, and $|\mathcal{E}_i| \in \{20, 40, 80\}$ for the Prod dataset. For all the experiments, we randomly sample 50 training and 50 testing tasks from $\mathcal{E}^{\mathrm{train}}$ and $\mathcal{E}^{\mathrm{test}}$ , respectively. DreamShard is trained on the training tasks and will be evaluated on unseen tables in the testing tasks. We denote placement tasks with different numbers of tables and devices using the format of dataset-num_tables (num Devices). For example, DLRM-30 (4) suggests that there are 30 tables sampled from the DLRM dataset in each training/testing task with 4 available devices. We provide more details in Appendix E.
121
+
122
+ Implementation Details. We use the same hyperparameters for all the experiments with $N_{\mathrm{collect}} = 10$ , $N_{\mathrm{cost}} = 300$ , $N_{\mathrm{batch}} = 64$ , $N_{\mathrm{RL}} = 10$ , $N_{\mathrm{episode}} = 10$ , 10 training iterations, and an entropy weight of 0.001 in the policy gradient. 2080 Ti GPUs and V100 GPUs are used for the DLRM (except that we use V100 for experiments with 8 GPUs) and Prod datasets, respectively. All the experiments are run 5 times, and we report the mean and the standard deviation. Appendix B provides more details.
123
+
124
+ # 4.2 Results and Analysis
125
+
126
+ Evaluation of DreamShard against baselines (RQ1). We perform qualitative and quantitative comparisons of DreamShard against the baselines. Qualitatively, Figure 1 visualizes the traces of DreamShard and the baselines on one of the tasks from DLRM-50 (4). DreamShard achieves significant better overall cost than the best baseline (35.95 vs. 42.8) with 1) a better balance of forward and backward commutation workloads, and 2) less communication time, possibly due to a better balance of table dimensions. Quantitatively, Table 1 presents comprehensive evaluations on tasks with different numbers of tables and devices on the DLRM and the Prod datasets. Observations: 1) DreamShard outperforms the baselines on all the tasks. 2) DreamShard shows strong generalizability on unseen tables, achieving the same level of performance on all the testing and training tasks. 3) DreamShard appears to be more advantageous on harder tasks. Specifically, DreamShard achieves more improvement over the baselines on tasks with more tables/devices on the Prod dataset. In particular, DreamShard achieves $19\%$ improvement over the strongest baseline on Prod-80 (8). 4)
127
+
128
+ Table 1: Overall cost comparison in milliseconds and relative speedups over random placement, averaged over 50 different randomly sampled tasks. The placement tasks are denoted as datasetnum_tables (num/devices). For example, DLRM-30 (4) suggests that 30 tables are sampled from the DLRM dataset for each task with 4 GPUs. More results are provided in Appendix F.
129
+
130
+ <table><tr><td rowspan="2" colspan="2">Task</td><td colspan="2">No strategy</td><td colspan="5">Human Experts</td><td colspan="2">RL</td></tr><tr><td colspan="2">Random</td><td>Size-based</td><td>Dim-based</td><td>Lookup-based</td><td colspan="2">Size-lookup-based</td><td>RNN-based</td><td>DreamShard</td></tr><tr><td rowspan="2">DLRM-20 (4)</td><td>Train</td><td>24.0±0.6</td><td>22.7±0.0 (+5.7%)</td><td>21.3±0.0 (+12.7%)</td><td>19.1±0.0 (+25.7%)</td><td>19.1±0.0 (+25.7%)</td><td colspan="2">22.4±0.5 (+7.1%)</td><td colspan="2">18.6±0.2 (+29.0%)</td></tr><tr><td>Test</td><td>23.0±0.5</td><td>21.7±0.0 (+6.0%)</td><td>19.9±0.0 (+15.6%)</td><td>18.3±0.0 (+25.7%)</td><td>18.4±0.0 (+25.0%)</td><td colspan="2">20.9±0.3 (+10.0%)</td><td colspan="2">17.6±0.2 (+30.7%)</td></tr><tr><td rowspan="2">DLRM-40 (4)</td><td>Train</td><td>41.3±0.2</td><td>39.6±0.0 (+4.3%)</td><td>37.4±0.1 (+10.4%)</td><td>33.6±0.0 (+22.9%)</td><td>33.6±0.1 (+22.9%)</td><td colspan="2">39.2±0.7 (+5.4%)</td><td colspan="2">32.8±0.3 (+25.9%)</td></tr><tr><td>Test</td><td>41.1±0.5</td><td>40.3±0.0 (+2.0%)</td><td>37.3±0.0 (+10.2%)</td><td>33.0±0.1 (+24.5%)</td><td>33.2±0.0 (+23.8%)</td><td colspan="2">39.2±1.1 (+4.8%)</td><td colspan="2">32.4±0.3 (+26.9%)</td></tr><tr><td rowspan="2">DLRM-60 (4)</td><td>Train</td><td>57.7±0.8</td><td>56.6±0.1 (+1.9%)</td><td>52.9±0.0 (+9.1%)</td><td>49.2±0.1 (+17.3%)</td><td>49.3±0.0 (+17.0%)</td><td colspan="2">55.5±0.9 (+4.0%)</td><td colspan="2">47.6±0.4 (+21.2%)</td></tr><tr><td>Test</td><td>58.1±0.6</td><td>59.6±0.1 (-2.5%)</td><td>53.7±0.0 (+8.2%)</td><td>48.7±0.2 (+19.3%)</td><td>49.1±0.1 (+18.3%)</td><td colspan="2">56.0±0.7 (+3.8%)</td><td colspan="2">47.9±0.7 (+21.3%)</td></tr><tr><td rowspan="2">DLRM-80 (4)</td><td>Train</td><td>75.7±1.0</td><td>76.0±0.0 (-0.4%)</td><td>70.0±0.3 (+8.1%)</td><td>64.8±0.0 (+16.8%)</td><td>65.3±0.1 (+15.9%)</td><td colspan="2">73.2±2.7 (+3.4%)</td><td colspan="2">62.2±0.2 (+21.7%)</td></tr><tr><td>Test</td><td>74.5±0.8</td><td>77.7±0.2 (-4.1%)</td><td>69.9±0.4 (+6.6%)</td><td>64.1±0.2 (+16.2%)</td><td>65.1±0.0 (+14.4%)</td><td colspan="2">72.9±2.4 (+2.2%)</td><td colspan="2">62.7±0.3 (+18.8%)</td></tr><tr><td rowspan="2">DLRM-100 (4)</td><td>Train</td><td>91.8±1.7</td><td>94.1±0.3 (-2.4%)</td><td>86.7±0.3 (+5.9%)</td><td>81.2±0.4 (+13.1%)</td><td>82.2±0.2 (+11.7%)</td><td colspan="2">94.5±10.7 (-2.9%)</td><td colspan="2">78.4±0.6 (+17.1%)</td></tr><tr><td>Test</td><td>94.5±6.5</td><td>95.4±0.0 (-0.9%)</td><td>84.7±0.4 (+11.6%)</td><td>79.5±0.3 (+18.9%)</td><td>80.8±0.3 (+17.0%)</td><td colspan="2">94.8±13.0 (-0.3%)</td><td colspan="2">77.8±0.8 (+21.5%)</td></tr><tr><td rowspan="2">DLRM-40 (8)</td><td>Train</td><td>15.6±0.4</td><td>14.1±0.0 (+10.6%)</td><td>13.4±0.1 (+16.4%)</td><td>9.8±0.0 (+59.2%)</td><td>9.9±0.0 (+57.6%)</td><td colspan="2">16.2±0.8 (-3.7%)</td><td colspan="2">9.8±0.6 (+59.2%)</td></tr><tr><td>Test</td><td>15.2±0.2</td><td>14.5±0.0 (+4.8%)</td><td>13.2±0.0 (+15.2%)</td><td>9.5±0.0 (+60.0%)</td><td>9.5±0.0 (+60.0%)</td><td colspan="2">16.0±1.1 (-5.0%)</td><td colspan="2">9.4±0.5 (+61.7%)</td></tr><tr><td rowspan="2">DLRM-80 (8)</td><td>Train</td><td>25.0±0.2</td><td>24.0±0.0 (+4.2%)</td><td>21.7±0.0 (+15.2%)</td><td>17.1±0.0 (+46.2%)</td><td>17.5±0.0 (+42.9%)</td><td colspan="2">51.4±3.9 (-51.4%)</td><td colspan="2">16.1±0.3 (+55.3%)</td></tr><tr><td>Test</td><td>25.2±1.3</td><td>25.6±0.5 (-1.6%)</td><td>20.8±0.0 (+21.2%)</td><td>16.7±0.2 (+50.9%)</td><td>16.9±0.1 (+49.1%)</td><td colspan="2">53.4±4.6 (-52.8%)</td><td colspan="2">16.1±0.4 (+56.5%)</td></tr><tr><td rowspan="2">DLRM-120 (8)</td><td>Train</td><td>34.0±0.3</td><td>32.3±0.0 (+5.3%)</td><td>29.8±0.0 (+14.1%)</td><td>24.5±0.0 (+38.8%)</td><td>25.3±0.0 (+34.4%)</td><td colspan="2">58.6±2.7 (-42.0%)</td><td colspan="2">23.3±0.2 (+45.9%)</td></tr><tr><td>Test</td><td>33.5±0.5</td><td>35.0±0.0 (-4.3%)</td><td>29.2±0.0 (+14.7%)</td><td>23.7±0.0 (+41.4%)</td><td>24.5±0.0 (+36.7%)</td><td colspan="2">58.7±3.1 (-42.9%)</td><td colspan="2">22.8±0.2 (+46.9%)</td></tr><tr><td rowspan="2">DLRM-160 (8)</td><td>Train</td><td>42.8±0.3</td><td>41.6±0.0 (+2.9%)</td><td>39.0±0.0 (+9.7%)</td><td>32.0±0.0 (+33.7%)</td><td>32.7±0.0 (+30.9%)</td><td colspan="2">58.3±3.5 (-26.6%)</td><td colspan="2">30.3±0.2 (+41.3%)</td></tr><tr><td>Test</td><td>41.1±0.0</td><td>42.4±0.0 (-3.1%)</td><td>36.4±0.0 (+12.9%)</td><td>30.8±0.0 (+33.4%)</td><td>31.6±0.0 (+30.1%)</td><td colspan="2">59.3±5.4 (-30.7%)</td><td colspan="2">29.6±0.2 (+38.9%)</td></tr><tr><td rowspan="2">DLRM-200 (8)</td><td>Train</td><td>51.5±1.2</td><td>48.2±0.0 (+6.8%)</td><td>48.0±0.0 (+7.3%)</td><td>38.9±0.0 (+32.4%)</td><td>39.9±0.0 (+29.1%)</td><td colspan="2">68.7±2.4 (-25.0%)</td><td colspan="2">37.2±0.2 (+38.4%)</td></tr><tr><td>Test</td><td>50.7±0.2</td><td>50.8±0.0 (-0.2%)</td><td>44.8±0.0 (+13.2%)</td><td>38.0±0.0 (+33.4%)</td><td>38.6±0.0 (+31.3%)</td><td colspan="2">70.4±2.8 (-28.0%)</td><td colspan="2">36.4±0.3 (+39.3%)</td></tr><tr><td rowspan="2">Prod-20 (2)</td><td>Train</td><td>41.3±0.7</td><td>43.4±0.0 (-4.8%)</td><td>37.0±0.0 (+11.6%)</td><td>44.2±0.0 (-6.6%)</td><td>45.8±0.0 (-9.8%)</td><td colspan="2">38.0±0.3 (+8.7%)</td><td colspan="2">36.3±0.3 (+13.8%)</td></tr><tr><td>Test</td><td>42.8±0.4</td><td>46.1±0.0 (-7.2%)</td><td>39.5±0.0 (+8.4%)</td><td>45.9±0.0 (-6.8%)</td><td>45.7±0.0 (-6.3%)</td><td colspan="2">39.3±0.6 (+8.9%)</td><td colspan="2">37.5±0.2 (+14.1%)</td></tr><tr><td rowspan="2">Prod-40 (4)</td><td>Train</td><td>35.1±0.3</td><td>39.4±0.0 (-10.9%)</td><td>31.3±0.0 (+12.1%)</td><td>36.4±0.0 (-3.6%)</td><td>38.8±0.0 (-9.5%)</td><td colspan="2">33.9±2.5 (+3.5%)</td><td colspan="2">28.3±0.3 (+24.0%)</td></tr><tr><td>Test</td><td>38.3±0.3</td><td>43.6±0.0 (-12.2%)</td><td>33.5±0.0 (+14.3%)</td><td>37.4±0.0 (+2.4%)</td><td>40.1±0.0 (-4.5%)</td><td colspan="2">36.7±2.8 (+4.4%)</td><td colspan="2">30.4±0.7 (+26.0%)</td></tr><tr><td rowspan="2">Prod-80 (8)</td><td>Train</td><td>43.2±0.2</td><td>44.3±0.0 (-2.5%)</td><td>39.0±0.0 (+10.8%)</td><td>43.7±0.0 (-1.1%)</td><td>49.3±0.0 (-12.4%)</td><td colspan="2">56.6±6.8 (-23.7%)</td><td colspan="2">33.6±0.9 (+28.6%)</td></tr><tr><td>Test</td><td>47.7±0.4</td><td>53.9±0.0 (-11.5%)</td><td>41.9±0.0 (+13.8%)</td><td>46.1±0.0 (+3.5%)</td><td>49.6±0.0 (-3.8%)</td><td colspan="2">62.5±4.2 (-23.7%)</td><td colspan="2">35.2±0.8 (+35.5%)</td></tr></table>
131
+
132
+ Table 2: Generalization performance of DreamShard on target tasks w.r.t. to different numbers of tables (top) and devices (bottom), averaged over 50 randomly sampled tasks. Appendix G provides the results of more challenging tasks, such as mixed table-wise and device-wise transferring scenarios.
133
+
134
+ <table><tr><td>Source Task → Target Task</td><td>Random</td><td>Best baseline strategy</td><td>DreamShard (trained on target task)</td><td>DreamShard (trained on source task)</td></tr><tr><td>DLRM-20 (4) → DLRM-100 (4)</td><td>94.5±6.5</td><td>79.5±0.3 (+18.9%)</td><td>77.8±0.8 (+21.5%)</td><td>77.9±0.4 (+21.3%)</td></tr><tr><td>DLRM-40 (4) → DLRM-80 (4)</td><td>74.5±0.8</td><td>64.1±0.2 (+16.2%)</td><td>62.7±0.3 (+18.8%)</td><td>62.7±0.5 (+18.8%)</td></tr><tr><td>DLRM-80 (4) → DLRM-40 (4)</td><td>41.1±0.5</td><td>33.0±0.1 (+24.5%)</td><td>32.4±0.3 (+26.9%)</td><td>32.4±0.2 (+26.9%)</td></tr><tr><td>DLRM-100 (4) → DLRM-20 (4)</td><td>23.0±0.5</td><td>18.3±0.0 (+25.7%)</td><td>17.6±0.2 (+30.7%)</td><td>17.7±0.3 (+29.9%)</td></tr><tr><td>DLRM-20 (4) → DLRM-20 (2)</td><td>29.9±0.4</td><td>26.0±0.0 (+15.0%)</td><td>25.8±0.2 (+15.9%)</td><td>25.8±0.1 (+15.9%)</td></tr><tr><td>DLRM-40 (4) → DLRM-40 (2)</td><td>58.6±0.7</td><td>52.4±0.0 (+11.8%)</td><td>51.9±0.1 (+12.9%)</td><td>52.0±0.3 (+12.7%)</td></tr><tr><td>DLRM-20 (2) → DLRM-20 (4)</td><td>23.0±0.5</td><td>18.3±0.0 (+25.7%)</td><td>17.6±0.2 (+30.7%)</td><td>17.8±0.3 (+29.2%)</td></tr><tr><td>DLRM-40 (2) → DLRM-40 (4)</td><td>41.1±0.5</td><td>33.0±0.1 (+24.5%)</td><td>32.4±0.3 (+26.9%)</td><td>32.6±0.3 (+26.1%)</td></tr></table>
135
+
136
+ RNN-based method is only better than the random strategy on tasks with few tables/devices, but is worse on harder tasks. A possible reason is that RNN-based algorithm does not have a cost network, and using RL alone could lead to unstable performance. 5) Lookup-based strategy is the best baseline on the DLRM dataset, while dim-based strategy is better on the Prod dataset. A potential reason is that the tables in the Prob dataset have very diverse table dimensions, while the tables in the DLRM dataset have the same dimension. As such, the dimensions on Prod tasks can more easily become imbalanced, leading to poor communication efficiency. Dim-based strategy can better balance the dimensions, which leads to a better overall performance. DreamShard outperforms the baselines on both the DLRM and the Prod datasets, showing its flexibility in dealing with different scenarios.
137
+
138
+ Analysis of generalizability (RQ2). In Table 2, we directly apply a DreamShard model trained from one task to another task without any fine-tuning (the rightmost column), where the source and the target tasks have different numbers of tables and/or devices. DreamShard shows negligible performance drop, suggesting that it is generalizable across different numbers of tables and/or devices.
139
+
140
+ ![](images/c3d3487482dbd66d22029b963ac2d3b9eaf92bf2e462a43fff35acc4809146e4.jpg)
141
+ Figure 5: Performance $(\downarrow)$ of DreamShard on the DLRM-50 (4) datasets w.r.t. the numbers of iterations (left) and running time (right). Curves for other tasks are in Appendix H.
142
+
143
+ ![](images/b1da580fc0211d0eeca852c6a22f00613a5ae6e3c91e95b512ee9f14b73d7887.jpg)
144
+ Figure 6: Impacts of the number of RL update steps $N_{RL}$ (left) and cost network update steps $N_{\mathrm{cost}}$ (right) on the DLRM-50 (4) dataset. Curves for other tasks are in Appendix I.
145
+
146
+ Table 3: Ablation study of DreamShard. Results on other tasks are in Appendix J.
147
+
148
+ <table><tr><td colspan="2">Task</td><td>w/o dim</td><td>w/o hash size</td><td>w/o pooling factor</td><td>w/o table size</td><td>w/o distribution</td><td>w/o cost</td><td>w/ RNN</td><td>DreamShard</td></tr><tr><td rowspan="2">DLRM-50 (4)</td><td>Train</td><td>40.8±0.4</td><td>40.7±0.1</td><td>46.3±0.3</td><td>40.8±0.4</td><td>40.6±0.2</td><td>47.5±1.2</td><td>40.5±0.2</td><td>40.4±0.5</td></tr><tr><td>Test</td><td>40.9±0.6</td><td>40.6±0.3</td><td>47.2±0.1</td><td>40.6±0.7</td><td>40.5±0.2</td><td>46.3±0.1</td><td>40.5±0.1</td><td>40.4±0.6</td></tr></table>
149
+
150
+ Analysis of training efficiency (RQ3). Figure 5 plots the performance of DreamShard w.r.t. the number of iterations and running time in seconds on four 1080Ti GPUs. The training of DreamShard is highly efficient. On DLRM-50 (4), it can achieve strong performance in less than 5 iterations or 200 seconds. Note that we only need to re-train or fine-tune DreamShard when the table pools have significant changes. Once trained, it only needs a forward pass for inference.
151
+
152
+ Hyperparameter study (RQ4). We study the impacts of two key hyperparameters: 1) $N_{\mathrm{RL}}$ , which controls the RL update frequency, and 2) $N_{\mathrm{cost}}$ , which determines the cost network update frequency. We vary one of them with the other fixed, shown in Figure 6. Increasing $N_{\mathrm{RL}}$ or $N_{\mathrm{cost}}$ will both lead to improvement, suggesting that both the cost network and the policy network need to be sufficiently trained. However, when $N_{\mathrm{RL}}$ and $N_{\mathrm{cost}}$ are large enough, increasing them will not bring more improvement. Considering that larger values will lead to more computational costs, we set $N_{\mathrm{RL}} = 10$ or $N_{\mathrm{cost}} = 300$ as a trade-off between the performance and the training efficiency.
153
+
154
+ Ablation study (RQ5). We study the importance of each table feature and check whether the RNN architecture helps, with the following ablations. 1) We remove each of the features in the state. 2) We add an RNN upon the device representation in the policy network. We makes several observations from the results in Table 3. 1) Cost features play a significant role, which demonstrates the effectiveness of our proposed augmented state. 2) The most contributing table features are the pooling factor and the dimension, which aligns with our intuitions since these two features are the determining factors of computation and communication workloads. 3) Using more features leads to consistently good performance. 4) While the policy makes decisions sequentially, RNN does not provide clear benefits. This is why we have kept the architecture simple with only MLP in DreamShard.
155
+
156
+ Study of the estimated MDP (RQ6). First, we study how many data points are required to train an accurate cost network, and how accurate the cost network needs to be to enable a strong policy. Specifically, we randomly sample 10,000 cost data points from the DLRM-50 (4) dataset. Then we use $20\%$ for testing, and vary the size of the training data to train the cost network. Further, we fully train a policy network with 100 iterations based on each of the trained cost networks. We make two observations from the results in Figure 7. 1) As expected, more data points lead to a more accurate cost network. 2) Interestingly, after around 100 data points, the policy network does not keep improving even though the cost network becomes more accurate. Thus, we only need a sufficiently (but not perfectly) accurate cost estimation to achieve the best performance. This also partially explains why DreamShard can generalize: even though the cost network could be not very accurate on unseen tables, DreamShard can still find strong placements with the policy network. Second, we study the necessity of the estimated MDP. We consider a variant that obtains the cost features and rewards directly from GPUs, shown in Figure 8. Using the estimated MDP can make the training and the inference orders of magnitudes faster, while achieving the same level of performance. In particular, the inference time is less than one second even with a hundred tables.
157
+
158
+ ![](images/862f5b84d2e016d20fefbc1ef4930d45cec96bc0ee2b5dae003b5ab55b39a2f9.jpg)
159
+ Figure 7: MSE of the cost network w.r.t. the number of training data points collected from GPUs (left), and the corresponding performance of a fully trained policy network based on the trained cost network (right) on the DLRM-50 (4) dataset.
160
+
161
+ ![](images/5dde0766d434a140ef4ac8c3cb40052beb82e112c129d9a3b993e0de4e2b311a.jpg)
162
+ Figure 8: Training curves w/ or w/o the estimated MDP on DLRM-50 (4) dataset (left), and their inference times w.r.t. the number of tables (right). Using cost network to estimate the MDP leads orders of magnitudes faster training and inference.
163
+
164
+ ![](images/313510c15511575a11ee24e8806f3ea86553a673b93e162834bbbc4143a8395f.jpg)
165
+
166
+ ![](images/d2df1638cf3782bb97c253d44f879749cd2634c36164069b6d955ce8365a11a4.jpg)
167
+
168
+ # 5 Related Work
169
+
170
+ **Embedding tables.** Embedding tables are commonly used to deal with sparse features in recommendation models [1, 2, 3, 4, 5, 29, 30, 31]. However, the extremely large embedding tables are often the storage and efficiency bottlenecks [6, 7, 8, 3, 6, 9, 10, 11, 32]. To our knowledge, the only two studies that target the embedding table placement problem are RecShard [27] and our previous work AutoShard [33]. RecShard approaches table placement at a per-row granularity through exploitation of the underlying feature distributions. RecShard leverages these distributions, along with characteristics of the training system, to shard embedding tables across a tiered memory hierarchy using a mixed integer linear program, with more frequent rows placed in GPU HBM and the remaining placed in CPU DRAM. In contrast, our work develops a neural cost network for cost estimation and an RL-based optimization algorithm, and focuses on sharding across a single memory layer as opposed to a tiered memory hierarchy. AutoShard also leverages RL for embedding table sharding. However, it only balances the computational costs, which will lead to sub-optimal solutions since communication also accounts for significant costs. In addition, our DreamShard is more efficient in training than AutoShard due to the design of the estimated MDP. Another line of work focuses on reducing the embedding table sizes [34, 35, 36, 37, 38, 39, 40], which is orthogonal to our work since DreamShard is also applicable to compressed tables.
171
+
172
+ Device placement optimization. The existing device placement techniques can be mainly grouped into two categories: RL-based algorithms, and cost modeling methods. 1) RL-based algorithms treat the device placement as a black box and optimize the cost objective in a trial-and-error fashion [13, 14, 15, 16, 17, 18, 19, 20]. Unfortunately, these methods are computationally expensive and often require training from scratch on unseen tasks. While Placeto [16] shows generalizability on computational graphs with graph embeddings, it can not deal with various table combinations since there is no graph structure, and it can not handle different numbers of devices. 2) Cost modeling methods build a cost model to reflect the real performance and adopt offline algorithms (e.g., scheduling, and dynamic programming) to optimize the placement [41, 42, 43, 44, 45]. However, the cost model could be inaccurate. In particular, they can not deal with the operation fusion of embedding tables. Whereas, DreamShard combines the advances of RL with a neural cost model for accurate cost prediction.
173
+
174
+ Deep RL. Deep RL has recently made significant progress in games [46, 47, 48, 49, 50, 51, 52, 53, 54]. Our work is related to using RL to optimize machine learning model designs, such as neural architecture search [55, 56, 57, 58, 59], data augmentation [60], data sampling [61, 62], pipeline search [63, 64, 65]. However, these methods often only focus on one task and can not generalize to unseen tasks. Our work is related to meta-learning [66, 67, 68]. Instead of performing meta-learning for machine learning tasks, we focus on machine learning system design. Our work is also related to solving combinational optimization problems with RL [24, 69]. Unlike the above studies, we show that RL can tackle a practical problem of embedding table placement and the learned policy is generalizable.
175
+
176
+ # 6 Conclusions and Future Work
177
+
178
+ We present DreamShard for embedding table placement in recommender systems. We formulate the problem as an MDP which places the tables one by one at each step. Then we leverage RL to
179
+
180
+ solve the MDP. To accelerate the training and the inference, we build an estimated MDP by training a cost network to approximate the state features (i.e., computation and communication times) and the reward (i.e., the overall cost), leading to orders of magnitudes faster training and inference speeds. Extensive experiments on the open-sourced DLRM dataset and our production dataset demonstrate the superiority of DreamShard over the existing algorithms. Moreover, DreamShard shows strong generalizability, making it a desirable choice in real-world applications. In the future, we will extend DreamShard to tiered memory hierarchy and large-scale training clusters with complex topologies.
181
+
182
+ # Acknowledgements
183
+
184
+ The work is, in part, supported by NSF (#IIS-2224843). The views and conclusions in this paper are those of the authors and should not be interpreted as representing any funding agencies. We would also like to thank the helpful feedback from the anonymous reviewers.
185
+
186
+ # References
187
+
188
+ [1] Shuai Zhang, Lina Yao, Aixin Sun, and Yi Tay. Deep learning based recommender system: A survey and new perspectives. ACM Computing Surveys (CSUR), 52(1):1-38, 2019.
189
+ [2] Heng-Tze Cheng, Levent Koc, Jeremiah Harmsen, Tal Shaked, Tushar Chandra, Hrishi Aradhye, Glen Anderson, Greg Corrado, Wei Chai, Mustafa Ispir, et al. Wide & deep learning for recommender systems. In DLRS Workshop, 2016.
190
+ [3] Maxim Naumov, Dheevatsa Mudigere, Hao-Jun Michael Shi, Jianyu Huang, Narayanan Sundaraman, Jongsoo Park, Xiaodong Wang, Udit Gupta, Carole-Jean Wu, Alisson G Azzolini, et al. Deep learning recommendation model for personalization and recommendation systems. arXiv preprint arXiv:1906.00091, 2019.
191
+ [4] Xiangnan He, Lizi Liao, Hanwang Zhang, Liqiang Nie, Xia Hu, and Tat-Seng Chua. Neural collaborative filtering. In WWW, 2017.
192
+ [5] Weiping Song, Chence Shi, Zhiping Xiao, Zhijian Duan, Yewen Xu, Ming Zhang, and Jian Tang. Autoint: Automatic feature interaction learning via self-attentive neural networks. In CIKM, 2019.
193
+ [6] Weijie Zhao, Deping Xie, Ronglai Jia, Yulei Qian, Ruiquan Ding, Mingming Sun, and Ping Li. Distributed hierarchicalgpu parameter server for massive scale deep learning ads systems. In MLSys, 2020.
194
+ [7] Paul Covington, Jay Adams, and Emre Sargin. Deep neural networks for youtube recommendations. In RecSys, 2016.
195
+ [8] Bilge Acun, Matthew Murphy, Xiaodong Wang, Jade Nie, Carole-Jean Wu, and Kim Hazelwood. Understanding training efficiency of deep learning recommendation models at scale. In HPCA, 2021.
196
+ [9] Amazon dsstne: Deep scalable sparse tensor network engine. https://github.com/amazon-archives/amazon-dsstne.
197
+ [10] Udit Gupta, Carole-Jean Wu, Xiaodong Wang, Maxim Naumov, Brandon Reagen, David Brooks, Bradford Cottel, Kim Hazelwood, Mark Hempstead, Bill Jia, et al. The architectural implications of facebook's dnn-based personalized recommendation. In HPCA, 2020.
198
+ [11] Maxim Naumov, John Kim, Dheevatsa Mudigere, Srinivas Sridharan, Xiaodong Wang, Whitney Zhao, Serhat Yilmaz, Changkyu Kim, Hector Yuen, Mustafa Ozdal, et al. Deep learning training in facebook data centers: Design of scale-up and scale-out systems. arXiv preprint arXiv:2003.09518, 2020.
199
+ [12] Wikipedia. Partition problem — Wikipedia, the free encyclopedia. http://en.wikipedia.org/w/index.php?title=Partition%20problem&oldid=1085673119, 2022. [Online; accessed 05-May-2022].
200
+ [13] Azalia Mirhoseini, Hieu Pham, Quoc V Le, Benoit Steiner, Rasmus Larsen, Yuefeng Zhou, Naveen Kumar, Mohammad Norouzi, Samy Bengio, and Jeff Dean. Device placement optimization with reinforcement learning. In ICML, 2017.
201
+
202
+ [14] Azalia Mirhoseini, Anna Goldie, Hieu Pham, Benoit Steiner, Quoc V Le, and Jeff Dean. A hierarchical model for device placement. In ICLR, 2018.
203
+ [15] Yuanxiang Gao, Li Chen, and Baochun Li. Spotlight: Optimizing device placement for training deep neural networks. In ICML, 2018.
204
+ [16] Ravichandra Addanki, Shaileshh Bojla Venkatakrishnan, Shreyan Gupta, Hongzi Mao, and Mohammad Alizadeh. Placeto: learning generalizable device placement algorithms for distributed machine learning. In NeurIPS, 2019.
205
+ [17] Yanqi Zhou, Sudip Roy, Amirali Abdolrashidi, Daniel Wong, Peter C Ma, Qiumin Xu, Ming Zhong, Hanxiao Liu, Anna Goldie, Azalia Mirhoseini, et al. Gdp: Generalized device placement for dataflow graphs. arXiv preprint arXiv:1910.01578, 2019.
206
+ [18] Aditya Paliwal, Felix Gimeno, Vinod Nair, Yujia Li, Miles Lubin, Pushmeet Kohli, and Oriol Vinyals. Reinforced genetic algorithm learning for optimizing computation graphs. In ICLR, 2019.
207
+ [19] Yuanxiang Gao, Li Chen, and Baochun Li. Post: Device placement with cross-entropy minimization and proximal policy optimization. In NeurIPS, 2018.
208
+ [20] Anna Goldie and Azalia Mirhoseini. Placement optimization with deep reinforcement learning. In ISPD, 2020.
209
+ [21] Wei Niu, Jiexiong Guan, Yanzhi Wang, Gagan Agrawal, and Bin Ren. Dnnfusion: accelerating deep neural networks execution with advanced operator fusion. In PLDI, 2021.
210
+ [22] Daya Khudia, Jianyu Huang, Protonu Basu, Summer Deng, Haixin Liu, Jongsoo Park, and Mikhail Smelyanskiy. Fbgemm: Enabling high-performance low-precision deep learning inference. arXiv preprint arXiv:2101.05615, 2021.
211
+ [23] github. Embedding lookup synthetic dataset, 2021.
212
+ [24] Irwan Bello, Hieu Pham, Quoc V Le, Mohammad Norouzi, and Samy Bengio. Neural combinatorial optimization with reinforcement learning. arXiv preprint arXiv:1611.09940, 2016.
213
+ [25] David Ha and Jürgen Schmidhuber. World models. arXiv preprint arXiv:1803.10122, 2018.
214
+ [26] Danijar Hafner, Timothy Lillicrap, Jimmy Ba, and Mohammad Norouzi. Dream to control: Learning behaviors by latent imagination. In ICLR, 2019.
215
+ [27] Geet Sethi, Bilge Acun, Niket Agarwal, Christos Kozyrakis, Caroline Trippel, and Carole-Jean Wu. Recshard: Statistical feature-based memory optimization for industry-scale neural recommendation. In ASPLOS, 2022.
216
+ [28] Michael Lui, Yavuz Yetim, Özgür Özkan, Zhuoran Zhao, Shin-Yeh Tsai, Carole-Jean Wu, and Mark Hempstead. Understanding capacity-driven scale-out neural recommendation inference. In ISPASS, 2021.
217
+ [29] Jizhe Wang, Pipei Huang, Huan Zhao, Zhibo Zhang, Binqiang Zhao, and Dik Lun Lee. Billion-scale commodity embedding for e-commerce recommendation in alibaba. In KDD, 2018.
218
+ [30] Fuzheng Zhang, Nicholas Jing Yuan, Defu Lian, Xing Xie, and Wei-Ying Ma. Collaborative knowledge base embedding for recommender systems. In KDD, 2016.
219
+ [31] Weijie Zhao, Jingyuan Zhang, Deping Xie, Yulei Qian, Ronglai Jia, and Ping Li. ABox: Ctr prediction model training on a single node. In CIKM, 2019.
220
+ [32] Xiangru Lian, Binhang Yuan, Xuefeng Zhu, Yulong Wang, Yongjun He, Honghuan Wu, Lei Sun, Haodong Lyu, Chengjun Liu, Xing Dong, et al. Persia: A hybrid system scaling deep learning based recommenders up to 100 trillion parameters. arXiv preprint arXiv:2111.05897, 2021.
221
+ [33] Daochen Zha, Louis Feng, Bhargav Bhushanam, Dhruv Choudhary, Jade Nie, Yuandong Tian, Jay Chae, Yinbin Ma, Arun Kejariwal, and Xia Hu. Autoshard: Automated embedding table sharding for recommender systems. In KDD, 2022.
222
+ [34] Caojin Zhang, Yicun Liu, Yuanpu Xie, Sofia Ira Ktena, Alykhan Tejani, Akshay Gupta, Pranay Kumar Myana, Deepak Dilipkumar, Suvadip Paul, Ikuhiro Ihara, et al. Model size reduction using frequency based double hashing for recommender systems. In RecSys, 2020.
223
+
224
+ [35] Hao-Jun Michael Shi, Dheevatsa Mudigere, Maxim Naumov, and Jiyan Yang. Compositional embeddings using complementary partitions for memory-efficient recommendation systems. In KDD, 2020.
225
+ [36] Xiangyu Zhao, Chong Wang, Ming Chen, Xudong Zheng, Xiaobing Liu, and Jiliang Tang. Autoemb: Automated embedding dimensionality search in streaming recommendations. In SIGIR, 2020.
226
+ [37] Manas R Joglekar, Cong Li, Mei Chen, Taibai Xu, Xiaoming Wang, Jay K Adams, Pranav Khaitan, Jiahui Liu, and Quoc V Le. Neural input search for large scale recommendation models. In KDD, 2020.
227
+ [38] Siyi Liu, Chen Gao, Yihong Chen, Depeng Jin, and Yong Li. Learnable embedding sizes for recommender systems. In ICLR, 2021.
228
+ [39] Wang-Cheng Kang, Derek Zhiyuan Cheng, Ting Chen, Xinyang Yi, Dong Lin, Lichan Hong, and Ed H Chi. Learning multi-granular quantized embeddings for large-vocab categorical features in recommender systems. In WWW, 2020.
229
+ [40] Wang-Cheng Kang, Derek Zhiyuan Cheng, Tiansheng Yao, Xinyang Yi, Ting Chen, Lichan Hong, and Ed H Chi. Learning to embed categorical features without embedding tables for recommendation. In KDD, 2021.
230
+ [41] Eugene L Lawler, Jan Karel Lenstra, Alexander HG Rinnooy Kan, and David B Shmoys. Sequencing and scheduling: Algorithms and complexity. *Handbooks in operations research and management science*, 4:445–522, 1993.
231
+ [42] Zhihao Jia, Matei Zaharia, and Alex Aiken. Beyond data and model parallelism for deep neural networks. In $MLSys$ , 2019.
232
+ [43] Zhihao Jia, Sina Lin, Charles R Qi, and Alex Aiken. Exploring hidden dimensions in parallelizing convolutional neural networks. In ICML, 2018.
233
+ [44] Deepak Narayanan, Aaron Harlap, Amar Phanishayee, Vivek Seshadri, Nikhil R Devanur, Gregory R Ganger, Phillip B Gibbons, and Matei Zaharia. Pipedream: generalized pipeline parallelism for dnn training. In SOSP, 2019.
234
+ [45] Jakub M Tarnawski, Amar Phanishayee, Nikhil Devanur, Divya Mahajan, and Fanny Nina Paravecino. Efficient algorithms for device placement of dnn graph operators. In NeurIPS, 2020.
235
+ [46] Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Alex Graves, Ioannis Antonoglou, Daan Wierstra, and Martin Riedmiller. Playing atari with deep reinforcement learning. arXiv preprint arXiv:1312.5602, 2013.
236
+ [47] David Silver, Julian Schrittwieser, Karen Simonyan, Ioannis Antonoglou, Aja Huang, Arthur Guez, Thomas Hubert, Lucas Baker, Matthew Lai, Adrian Bolton, et al. Mastering the game of go without human knowledge. nature, 550(7676):354-359, 2017.
237
+ [48] Daochen Zha, Jingru Xie, Wenye Ma, Sheng Zhang, Xiangru Lian, Xia Hu, and Ji Liu. Douzero: Mastering doudizhu with self-play deep reinforcement learning. In ICML, 2021.
238
+ [49] John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.
239
+ [50] Daochen Zha, Kwei-Herng Lai, Kaixiong Zhou, and Xia Hu. Simplifying deep reinforcement learning via self-supervision. arXiv preprint arXiv:2106.05526, 2021.
240
+ [51] Timothy P Lillicrap, Jonathan J Hunt, Alexander Pritzel, Nicolas Heess, Tom Erez, Yuval Tassa, David Silver, and Daan Wierstra. Continuous control with deep reinforcement learning. In ICLR, 2016.
241
+ [52] Marcin Andrychowicz, Filip Wolski, Alex Ray, Jonas Schneider, Rachel Fong, Peter Welinder, Bob McGrew, Josh Tobin, OpenAI Pieter Abbeel, and Wojciech Zaremba. Hindsight experience replay. NeurIPS, 2017.
242
+ [53] Daochen Zha, Wenye Ma, Lei Yuan, Xia Hu, and Ji Liu. Rank the episodes: A simple approach for exploration in procedurally-generated environments. In ICLR, 2021.
243
+ [54] Daochen Zha, Kwei-Herng Lai, Songyi Huang, Yuanpu Cao, Keerthana Reddy, Juan Vargas, Alex Nguyen, Ruzhe Wei, Junyu Guo, and Xia Hu. Rlcard: a platform for reinforcement learning in card games. In IJCAI, 2021.
244
+
245
+ [55] Barret Zoph and Quoc V Le. Neural architecture search with reinforcement learning. In ICLR, 2017.
246
+ [56] Yicheng Wang, Xiaotian Han, Chia-Yuan Chang, Daochen Zha, Ulisses Braga-Neto, and Xia Hu. Auto-pinn: Understanding and optimizing physics-informed neural architecture. arXiv preprint arXiv:2205.13748, 2022.
247
+ [57] Yuening Li, Zhengzhang Chen, Daochen Zha, Kaixiong Zhou, Haifeng Jin, Haifeng Chen, and Xia Hu. Automated anomaly detection via curiosity-guided search and self-imitation learning. IEEE Transactions on Neural Networks and Learning Systems, 2021.
248
+ [58] Hieu Pham, Melody Guan, Barret Zoph, Quoc Le, and Jeff Dean. Efficient neural architecture search via parameters sharing. In ICML, 2018.
249
+ [59] Yuening Li, Zhengzhang Chen, Daochen Zha, Kaixiong Zhou, Haifeng Jin, Haifeng Chen, and Xia Hu. Autood: Neural architecture search for outlier detection. In ICDE, 2021.
250
+ [60] Ekin D Cubuk, Barret Zoph, Dandelion Mane, Vijay Vasudevan, and Quoc V Le. Autoaugment: Learning augmentation policies from data. arXiv preprint arXiv:1805.09501, 2018.
251
+ [61] Daochen Zha, Kwei-Herng Lai, Mingyang Wan, and Xia Hu. Meta-aad: Active anomaly detection with deep reinforcement learning. In ICDM, 2020.
252
+ [62] Daochen Zha, Kwei-Herng Lai, Qiaoyu Tan, Sirui Ding, Na Zou, and Xia Hu. Towards automated imbalanced learning with deep hierarchical reinforcement learning. In CIKM, 2022.
253
+ [63] Iddo Drori, Yamuna Krishnamurthy, Remi Rampin, Raoni de Paula Lourenco, Jorge Piazentin Ono, Kyunghyun Cho, Claudio Silva, and Juliana Freire. Alphad3m: Machine learning pipeline synthesis. arXiv preprint arXiv:2111.02508, 2021.
254
+ [64] Daochen Zha, Zaid Pervaiz Bhat, Yi-Wei Chen, Yicheng Wang, Sirui Ding, Anmoll Kumar Jain, Mohammad Qazim Bhat, Kwei-Herng Lai, Jiaben Chen, et al. Autovideo: An automated video action recognition system. In IJCAI, 2022.
255
+ [65] Kwei-Herng Lai, Daochen Zha, Guanchu Wang, Junjie Xu, Yue Zhao, Devesh Kumar, Yile Chen, Purav Zumkhawaka, Minyang Wan, Diego Martinez, et al. Tods: An automated time series outlier detection system. In AAAI, 2021.
256
+ [66] Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In ICML, 2017.
257
+ [67] Yue Zhao, Ryan Rossi, and Leman Akoglu. Automatic unsupervised outlier model selection. NeurIPS, 2021.
258
+ [68] Yue Zhao and Leman Akoglu. Towards unsupervised hpo for outlier detection. arXiv preprint arXiv:2208.11727, 2022.
259
+ [69] Thomas Barrett, William Clements, Jakob Foerster, and Alex Lvovsky. Exploratory combinatorial optimization with reinforcement learning. In AAAI, 2020.
260
+ [70] Guorui Zhou, Na Mou, Ying Fan, Qi Pi, Weijie Bian, Chang Zhou, Xiaogiang Zhu, and Kun Gai. Deep interest evolution network for click-through rate prediction. In AAAI, 2019.
261
+ [71] David C Liu, Stephanie Rogers, Raymond Shiau, Dmitry Kislyuk, Kevin C Ma, Zhigang Zhong, Jenny Liu, and Yushi Jing. Related pins at pinterest: The evolution of a real-world recommender system. In WWW, 2017.
262
+ [72] Carlos A Gomez-Uribe and Neil Hunt. The netflix recommender system: Algorithms, business value, and innovation. ACM Transactions on Management Information Systems (TMIS), 6(4):1-19, 2015.
263
+ [73] Ronald J Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine learning, 8(3):229-256, 1992.
264
+
265
+ # Checklist
266
+
267
+ 1. For all authors...
268
+
269
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper's contributions and scope? [Yes]
270
+ (b) Did you describe the limitations of your work? [Yes] We have described the limitations in the future work.
271
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] Our work does have any potential negative societal impacts to our knowledge.
272
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
273
+
274
+ 2. If you are including theoretical results...
275
+
276
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A]
277
+ (b) Did you include complete proofs of all theoretical results? [N/A]
278
+
279
+ 3. If you ran experiments...
280
+
281
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] The datasets are public. All the codes will be open-sourced.
282
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] We provide all the details in the appendix.
283
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] We have run all the experiments five times. The mean and the standard deviation are reported.
284
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] We have described the hardware in the appendix.
285
+
286
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
287
+
288
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
289
+ (b) Did you mention the license of the assets? [No] But it is mentioned in the link we provided.
290
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
291
+ (d) Did you discuss whether and how consent was obtained from people whose data you're using/curating? [Yes]
292
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes]
293
+
294
+ 5. If you used crowdsourcing or conducted research with human subjects...
295
+
296
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
297
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
298
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
dreamshardgeneralizableembeddingtableplacementforrecommendersystems/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f800b8e1a24eca2e3956c439ad654304dce39d0cb0f3d8700c903aa12cda59c8
3
+ size 541298
dreamshardgeneralizableembeddingtableplacementforrecommendersystems/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1e54022019d1e3d80284ad5c3964cb449ac61ff79c49afb1c889d6ffc8390a1d
3
+ size 458943
dropcovasimpleyeteffectivemethodforimprovingdeeparchitectures/91a0e411-0419-4d5c-bce3-b3bc7a6abb08_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:494a36e22981f83935b421385d1bb45a6fdcee8b1af512a9f1f0bd2bbca9af2b
3
+ size 84262
dropcovasimpleyeteffectivemethodforimprovingdeeparchitectures/91a0e411-0419-4d5c-bce3-b3bc7a6abb08_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ceb447e46c742434d957f00ded658a1319c1079cc34aae91a441eb1b10861f33
3
+ size 106157
dropcovasimpleyeteffectivemethodforimprovingdeeparchitectures/91a0e411-0419-4d5c-bce3-b3bc7a6abb08_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a9e9f84c9a0fcb0a9a9234c1e31374c85d6108488e95da149b50d845906c95e8
3
+ size 520449
dropcovasimpleyeteffectivemethodforimprovingdeeparchitectures/full.md ADDED
@@ -0,0 +1,301 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DropCov: A Simple yet Effective Method for Improving Deep Architectures
2
+
3
+ Qilong Wang $^{1,3}$ , Mingze Gao $^{1}$ , Zhaolin Zhang $^{1}$ , Jiangtao Xie $^{2}$ , Peihua Li $^{2}$ , Qinghua Hu $^{1,3,*}$
4
+
5
+ $^{1}$ Tianjin University, China, $^{2}$ Dalian University of Technology, China, $^{3}$ Haihe Laboratory of Information Technology Application Innovation, Tianjin, China qlwang@tju.edu.cn, gaomingze@tju.edu.cn, zzl9@tju.edu.cn jiangtaoxie@mail.dlut.edu.cn, peihuali@dlut.edu.cn, huqinghua@tju.edu.cn
6
+
7
+ # Abstract
8
+
9
+ Previous works show global covariance pooling (GCP) has great potential to improve deep architectures especially on visual recognition tasks, where post-normalization of GCP plays a very important role in final performance. Although several post-normalization strategies have been studied, these methods pay more close attention to effect of normalization on covariance representations rather than the whole GCP networks, and their effectiveness requires further understanding. Meanwhile, existing effective post-normalization strategies (e.g., matrix power normalization) usually suffer from high computational complexity (e.g., $O(d^3)$ for $d$ -dimensional inputs). To handle above issues, this work first analyzes the effect of post-normalization from the perspective of training GCP networks. Particularly, we for the first time show that effective post-normalization can make a good trade-off between representation decorrelation and information preservation for GCP, which are crucial to alleviate over-fitting and increase representation ability of deep GCP networks, respectively. Based on this finding, we can improve existing post-normalization methods with some small modifications, providing further support to our observation. Furthermore, this finding encourages us to propose a novel pre-normalization method for GCP (namely DropCov), which develops an adaptive channel dropout on features right before GCP, aiming to reach trade-off between representation decorrelation and information preservation in a more efficient way. Our DropCov only has a linear complexity of $O(d)$ , while being free for inference. Extensive experiments on various benchmarks (i.e., ImageNet-1K, ImageNet-C, ImageNet-A, Stylized-ImageNet, and iNat2017) show our DropCov is superior to the counterparts in terms of efficiency and effectiveness, and provides a simple yet effective method to improve performance of deep architectures involving both deep convolutional neural networks (CNNs) and vision transformers (ViTs).
10
+
11
+ # 1 Introduction
12
+
13
+ Global covariance pooling (GCP) has shown remarkable potential to improve performance of deep architectures in a variety of tasks, especially visual recognition [31, 23, 29, 30, 8, 48, 36, 47, 51]. One of core differences among various deep GCP methods is post-normalization for covariance representations, which plays a crucial role in final performance. The existing post-normalization approaches can be roughly categorized into element-wise post-normalization methods [31, 25, 2] and structure-wise ones [23, 29, 28, 25, 36, 47], which concentrate on normalizing entries and
14
+
15
+ eigenvalues of covariance matrices, respectively. Some researches (e.g., [30]) perform two kinds of normalizations simultaneously. Although several post-normalization strategies have been studied, behavior of different approaches seem vary significantly and there is a lack of an intuitive and unified interpretation. Therefore, the true mechanism lying behind these post-normalization methods (especially under deep architectures) is still an open problem.
16
+
17
+ Existing works understand the effect of post-normalization methods of GCP from different aspects. Specifically, [31, 25] claim that their element-wise normalization strategies can suppress the burstiness of covariance representations as in the classical bag-of-words [37] or actually perform a kind of whitening on representations. $\mathrm{DeepO}_2\mathrm{P}$ [23] and MPN-COV [29] develop post-normalization methods to exploit geometry of covariances by considering the fact that space of covariance forms a Riemannian manifold [1, 34]. Besides, MPN-COV shows that matrix square-root (sqrt) normalization accounts for a robust covariance estimation [45], while [30] claims spectral normalization compensates for burstiness of eigenvalues and shows effectiveness of matrix sqrt normalization via empirical comparisons. Although many efforts are made, the aforementioned researches try to explain why GCP works by studying how post-normalizations affect covariance representations, which lack a full view on the whole GCP networks. Therefore, this work analyzes effect of post-normalization approaches on optimizing deep GCP networks. Particularly, by taking matrix power normalization [29] as an example, we find that post-normalization tries to handle a paradox between representation decorrelation and information preservation for GCP, which are crucial to alleviate over-fitting and increase representation ability of deep GCP networks, respectively. Particularly, effective post-normalization approaches can achieve a good trade-off, and so lead to a better performance. Based on this finding, we introduce some modified versions of existing post-normalization methods (e.g., adaptive power normalization for MPN-COV, I-LogM for $\mathrm{DeepO}_2\mathrm{P}$ , and linear transformation for B-CNN [31]), which achieve further improvement, providing support to our observation.
18
+
19
+ Another issue of existing post-normalization methods is high computational complexity. Particularly, effective structure-wise post-normalization strategies usually involve singular value decomposition (SVD) of covariance matrices or sequential matrix multiplications, resulting in the computational complexity of $O(d^3)$ for $d$ -dimensional inputs. Inspired by finding above, this paper proposes an efficient pre-normalization method for GCP (namely DropCov) based on dropout [26], as it has the natural ability to perform feature decorrelation [4] and reduce over-fitting of training neural networks [26]. Specifically, our DropCov develops an adaptive channel dropout on features right before computation of covariance representations, where probability of dropout is adaptively decided by seeking a good trade-off between representation decorrelation and information preservation. Compared to existing post-normalization methods, our DropCov achieves superior or competitive performance with a linear computational complexity of $O(d)$ , while it is only used for training.
20
+
21
+ To verify the effectiveness of our proposed DropCov, we conduct experiments using various deep architectures including CNNs [17] and vision transformers (ViT) [43, 32, 50] on ImageNet-1K [7], ImageNet-C [18], ImageNet-A [19], Stylized-ImageNet [13], and long-tailed iNat2017 [20]. The contributions of this work are summarized as follows: (1) To our best knowledge, this work for the first time analyzes the effect of post-normalization on GCP from the perspective of optimizing neural networks, and we show that effective post-normalization methods can make a good trade-off between representation decorrelation (w.r.t over-fitting reduction) and information preservation (w.r.t increase of representation ability) for GCP (w.r.t deep GCP networks); (2) Based on our finding, we make some small modifications to existing post-normalization methods (Sec. 2.2), e.g., adaptive power normalization and I-LogM & linear transformation. The comparisons in Sec. 5.2 show our modifications can bring further improvement, giving support on our observation; (3) Profiting from our finding, we propose a novel DropCov method by developing an adaptive channel dropout as pre-normalization of GCP, which has a linear complexity of $O(d)$ and is only used for training. Extensive experiments show our DropCov is superior or competitive to existing post-normalization approaches and provides a simple yet effective method to improve deep architectures.
22
+
23
+ # 2 Effect of Post-normalization on Deep GCP Networks
24
+
25
+ In this section, we first analyze the effect of post-normalization on optimizing deep GCP networks by taking matrix power normalization as an example. To further verify our finding, we spread it to existing post-normalization approaches, and make some modifications according to our observations.
26
+
27
+ ![](images/458395d77c2c0180c000e3ee98e9004cf42398899b3ac3a8b995c2e371863fbc.jpg)
28
+ (a) Convergence curves of various $\alpha$
29
+
30
+ ![](images/82e257b3e12918d91f8a3100370b43a3e9785b80c92d010af9a39df7516dbea2.jpg)
31
+ (b) Generalization vs. representation ability
32
+ Figure 1: Results of GCP networks with matrix power normalization (MPN) using the backbone of ResNet-18 ( $d = 128$ ) on ImageNet-1K. (a) Convergence curves of various $\alpha \in (0,1]$ ; (b) Comparison of generalization and representation abilities for various $\alpha$ . From them we can see that larger values of $\alpha$ result in higher training accuracies indicated by blue solid line in (b), w.r.t better representation or approximation ability, but suffer from heavier over-fitting (w.r.t worse generalization), aka larger differences of training accuracy over test one indicated by $\Delta$ . In contrast, smaller values of $\alpha$ have better generalization (aka smaller $\Delta$ ), while obtaining lower classification accuracies (w.r.t weaker representation ability). Particularly, $\alpha = 0.5$ achieves the best trade-off and so leads the best results.
33
+
34
+ # 2.1 How Does Matrix Power Normalization Impact GCP
35
+
36
+ Matrix Power Normalization Both previous works [47, 36] and our experiments show structure-wise post-normalization methods are generally superior to element-wise ones, where matrix power normalization (MPN) usually performs the most competitively. Let $\mathbf{X} \in \mathbb{R}^{N \times d}$ be $N$ $d$ -dimensional features with zero-mean those outputted by the last convolution layer of deep CNNs or the last transformer block of ViT (i.e., final word tokens), GCP computes $\mathbf{X}^T\mathbf{X}$ with post-normalization to generate a covariance representation $\mathbf{Z}$ . Specifically, GCP with MPN is calculated as
37
+
38
+ $$
39
+ \mathbf {Z} = \left(\mathbf {X} ^ {T} \mathbf {X}\right) ^ {\alpha} = \mathbf {U} \boldsymbol {\Lambda} ^ {\alpha} \mathbf {U} ^ {T}, \tag {1}
40
+ $$
41
+
42
+ where $\mathbf{Z} \in \mathbb{R}^{d \times d}$ is used for final classification. $\alpha > 0$ is a parameter of power. $\mathbf{U}$ and $\boldsymbol{\Lambda}$ are the matrix of eigenvectors and the diagonal matrix of eigenvalues of $\mathbf{X}^T\mathbf{X}$ , respectively.
43
+
44
+ Effect of Power For MPN, power $\alpha$ has a significant effect on the final results. Previous works [29, 30] conduct empirical comparison of $\alpha$ , and choose the best one (e.g., $\alpha = 0.5$ ). However, the effect brought by $\alpha$ is still not very clear. In this work, we first analyze the effect of $\alpha \in (0,1]$ on optimizing deep GCP networks. It is clear from Eqn. (1) that $\alpha$ has the following effect on GCP from the mathematical perspective:
45
+
46
+ $$
47
+ \left\{ \begin{array}{l} \mathbf {Z} \longmapsto \mathbf {I}, \quad \text {i f} \quad \alpha \longmapsto 0: \text {R e p r e s e n t a t i o n D e c o r r e l a t i o n} \\ \mathbf {Z} \longmapsto \mathbf {X} ^ {T} \mathbf {X}, \quad \text {i f} \quad \alpha \longmapsto 1: \text {I n f o r m a t i o n P r e s e r v a t i o n} \end{array} \right. \tag {2}
48
+ $$
49
+
50
+ Specifically, when $\alpha \longmapsto 0$ , the normalized representation $\mathbf{Z}$ will be decorrelated and tend to be an identity matrix $\mathbf{I}$ . Such representation decorrelation can help optimization of neural networks [27, 22, 4] (in particular for combating over-fitting [5]), which, however, will lead to information loss for $\mathbf{X}^T\mathbf{X}$ , hurting representation ability of covariances. Particularly, $\mathbf{Z}$ with MPN of $\alpha = 0$ becomes an identity matrix, and the information lying in $\mathbf{X}^T\mathbf{X}$ completely loses. When $\alpha \longmapsto 1$ , information of $\mathbf{X}^T\mathbf{X}$ will be gradually preserved, maintaining the correlations as characterized in the covariance matrices, which makes training of neural networks difficult (e.g., over-fitting). To further verify above observation, we conduct experiments using ResNet-18 on ImageNet-1K (more results can refer to supplementary materials). By observing Figs. 1(a) and 1(b), we draw the following conclusion:
51
+
52
+ - When $\alpha < 0.5$ , post-normalization (i.e., MPN) tends to decorrelate representation. According to red line of Fig. 1(b), smaller values of $\alpha$ reduce over-fitting more significantly and have better generalization (aka smaller differences of training accuracy over test one [3, 5]). Meantime, indicated by blue lines of Fig. 1(b), smaller $\alpha$ leads lower accuracies (w.r.t weaker representation or approximation ability [35, 47]) due to information loss.
53
+
54
+ - When $\alpha > 0.5$ , post-normalization (i.e., MPN) tends to preserve information. The training accuracies (w.r.t representation or approximation ability) of deep GCP networks indicated by blue solid line of Fig. 1(b) increase along values of $\alpha$ enlarge, but heavier over-fitting (aka larger values of $\Delta$ ) occur because effect of representation decorrelation decreases.
55
+
56
+ According to Eqn. (2) and above observation, we have
57
+
58
+ Corollary 1. Effective post-normalization (e.g., matrix power normalization (MPN) with $0 < \alpha \leq 1$ ) can achieve a good trade-off between representation decorrelation and information preservation for GCP, which are crucial to alleviate over-fitting and increase representation ability of deep GCP networks, respectively. Particularly, MPN with $\alpha = 0.5$ achieves the best trade-off for $\alpha \in (0,1]$ (without considering other factors), which is proved to be the widely used choice of $\alpha$ [29, 30].
59
+
60
+ The Corollary 1 illuminates the effect of MPN on deep GCP networks from the perspective of model training, and gives an intuitive explanation about the choice of parameter $\alpha$ .
61
+
62
+ # 2.2 Extension of Corollary 1 to Existing Post-normalization Methods
63
+
64
+ To further verify Corollary 1, we extend it to analyze behavior of existing post-normalization. Accompanied by these analyses, we can improve previous methods with some small modifications.
65
+
66
+ Adaptive Power Normalization (APN) Above all, Corollary 1 shows MPN with $\alpha = 0.5$ is the best trade-off for $\alpha \in (0,1]$ if no other factor is considered. To further verify the effect of trade-off, we propose an adaptive power normalization (APN) by considering the effect of inputs (i.e., eigenvalues $\Lambda$ of covariances). Specifically, we formulate the trade-off between representation decorrelation and information preservation as the following objective function:
67
+
68
+ $$
69
+ \min _ {\alpha} \log \left(\frac {\lambda_ {m a x} ^ {\alpha}}{\lambda_ {m i n} ^ {\alpha}}\right), \quad s. t. \max _ {\alpha} \sum_ {i} \frac {\lambda_ {i} ^ {\alpha}}{\sum_ {i} \lambda_ {i} ^ {\alpha}} \log \left(\frac {\lambda_ {i} ^ {\alpha}}{\sum_ {i} \lambda_ {i} ^ {\alpha}}\right), \tag {3}
70
+ $$
71
+
72
+ where $\lambda_{max}$ and $\lambda_{min}$ are maximum and minimum of $\Lambda$ , respectively. Particularly, we minimize the ratio of $\lambda_{max}^{\alpha}$ to $\lambda_{min}^{\alpha}$ (in logarithmic coordinates) to enforce representation decorrelation. Here, smaller values of the objective function indicate stronger decorrelation, and $\alpha = 0$ achieves minimum (i.e., zero). On the other hand, we maximize negative entropy of normalized eigenvalues to keep discrepancy among eigenvalues and so preserve information, which achieves maximum value (i.e., zero) for $\alpha \rightarrow +\infty$ . By considering that previous works [29, 30] show relation between performance and $\alpha$ is generally convex, we exploit a grid search strategy to obtain a suboptimal solution for $\alpha \in (0,1]$ with the interval of $0.01^{2}$ . However, $\lambda_{min}$ is usually nearby zero, leading to computational instability. Therefore, we optimize the objective function (3) as
73
+
74
+ $$
75
+ \min _ {\alpha} \left[ \underbrace {\alpha \left(\log \left(\lambda_ {m a x}\right) - \log \left(\max \left(C , \lambda_ {m i n}\right)\right)\right)} _ {\text {r e p r e s e n t a t i o n d e c o r r e l a t i o n}} - \tau \sum_ {i = 1} ^ {K} \left(\lambda_ {i} ^ {\alpha} / \sum_ {i = 1} ^ {K} \lambda_ {i} ^ {\alpha}\right) \log \left(\lambda_ {i} ^ {\alpha} / \sum_ {i = 1} ^ {K} \lambda_ {i} ^ {\alpha}\right) \right], \tag {4}
76
+ $$
77
+
78
+ where we set minimum of $\lambda_{min}$ to a constant $C$ (e.g., 1e-2), and compute the entropy using Top-K eigenvalues. $\tau$ is a balance parameter, which is set to 1.2. Note that Eqn. (4) is computed efficiently for small $K$ ( $K \leq 3$ in our work) using about a hundred trials, given the eigenvalues $\Lambda$ .
79
+
80
+ MPN with $\alpha > 1$ Theoretically, $\alpha$ of MPN could be larger than one, which, however, violates the principle of representation decorrelation. Meanwhile, it disrupts equilibrium between eigenvalues, hurting information inherent in covariances. As illustrated in Fig. 2, MPN with $\alpha = 2$ suffers from heavy over-fitting, and is clearly worse than one with $\alpha = 0.5$ .
81
+
82
+ Matrix Logarithm Normalization (LogM) LogM [23] is one another popular structure-wise postnormalization. Mathematically, logarithm has similar behavior with power function of $\alpha = 0.3$ when eigenvalues $\lambda > 1$ , but reverses amplitudes of eigenvalues $\lambda < 1$ (i.e., neither decorrelation nor information preservation). However, small eigenvalues frequently occur in deep models [29], especially for large feature dimension $(d)$ . Accordingly, as shown in Fig. 2, LogM achieves similar
83
+
84
+ results with MPN of $\alpha = 0.3$ for $d = 128$ . For $d = 256$ , GCP network with LogM fails to converge due to side effect brought by small eigenvalues ( $\lambda < 1$ ). Therefore, we modified LogM with a shift operation (namely I-LogM) to make all inputs of LogM be larger than one, i.e., $\log (\lambda_i)\longrightarrow \epsilon \log ((\lambda_i + \epsilon) / \epsilon)$ . Our I-LogM brings promising gains when $d = 256$ (see Sec. 5.2 and Table 6).
85
+
86
+ Element-wise Normalization (EwN) EwN could be roughly written in a unified formulation: $\beta \frac{f(\mathbf{z}) - \mu}{\|f(\mathbf{z}) - \mu\|_{*}} + \gamma$ , where $\mathbf{z}$ is vectorization of $\mathbf{X}^T\mathbf{X}$ . $f$ is a mapping function and $\|\mathbf{a}\|_*$ indicates a certain norm of $\mathbf{a}$ . $\beta$ and $\gamma$ perform a linear transformation (LT). Particularly, for element-wise power normalization (EPN) [31], $f$ is a signed power function and $\mu = 0$ . $\|\mathbf{a}\|_*$ is a $\ell_2$ norm, and no LT is performed. For LN [2], $f$ is an identity mapping and $\mu$ is mean of $f(\mathbf{z})$ . $\|\mathbf{a}\|_*$ is a $\ell_2$ norm. According to above formulation and Corollary 1, EwN performs representation decorrelation based on zero-mean (i.e., $f(\mathbf{z}) - \mu$ ) and standardization (i.e., normalized by $\|f(\mathbf{z}) - \mu\|_*$ ), while LT
87
+
88
+ ![](images/6fc5c0d0a3522e84b0d4c0a5ee98ae8ef7741e9ffa3bfd7fe82bc8f39c6a1845.jpg)
89
+ Figure 2: Results of $\alpha >1$ & LogM
90
+
91
+ operation aims to recover information. Compared to MPN, element-wise normalization lacks an effective mechanism to balance representation decorrelation and information preservation. Particularly, as shown in Sec. 5.2, EPN does not work well, since only representation decorrelation is performed. Therefore, we introduce a LT for EPN, and it achieves promising improvement (see Table 6).
92
+
93
+ # 3 DropCov: A Simple yet Effective Normalization
94
+
95
+ # 3.1 Normalizing GCP via Dropout
96
+
97
+ Corollary 1 shows the core effect of effective post-normalization (e.g., MPN) lies in a good trade-off between representation decorrelation and information preservation for optimizing deep GCP networks. However, MPN suffers from high computational complexity (i.e., $O(d^{3})$ of $d$ -dimensional features), especially for high-dimensional inputs. Previous works [41, 5, 4] show that dropout can reduce correlation among features. Therefore, one question is naturally raised up: Could we use efficient dropout to perform representation decorrelation for GCP? Given probability $\rho$ of dropout, $\rho \rightarrow 1$ leading to sparser, less correlated features but more information loss. On the contrary, $\rho \rightarrow 0$ preserves more information while performing less decorrelation. Above observations show consistence with Corollary 1. However, there exist two issues to apply dropout for normalizing GCP: (1) how to perform dropout and (2) how to choose probability $\rho$ of dropout. A naive method is to perform dropout with a fixed $\rho$ after covariance representations (as compared in Table 2), but it has several limitations: first, dropout after covariance representations will break their structures (e.g., row $i$ of covariance means correlations among $i$ -th channel and all ones); second, fixed $\rho$ hardly achieves trade-off between representation decorrelation and information preservation; third, complexity of such strategy is quadratic to feature dimension $d$ (i.e., $O(d^{2})$ ), and is still high for large $d$ .
98
+
99
+ # 3.2 Pre-Normalization via Adaptive Channel Dropout (ACD)
100
+
101
+ To handle above issues, this work proposes a pre-normalization method (namely DropCov) by performing channel dropout with an adaptive probability $\rho$ on features $\mathbf{X}$ before GCP, which aims to reach a good trade-off between representation decorrelation and information preservation. Since DropCov performs representation decorrelation via an adaptive dropout operation on channel features before GCP, it can maintain structure of covariance representations, while having a more efficient, linear computational complexity of $O(d)$ . To reach the trade-off with adaptive probability $\rho$ , we compute it by considering two factors: (1) feature dimension $(d)$ and (2) relationship between feature correlation and feature importance. Then, we have
102
+
103
+ $$
104
+ \rho = 1 - \frac {D}{\log (d)} \left(\frac {\boldsymbol {\omega} ^ {T} \boldsymbol {\pi}}{\| \boldsymbol {\omega} \| \| \boldsymbol {\pi} \|}\right), \tag {5}
105
+ $$
106
+
107
+ $$
108
+ \boldsymbol {\omega} = \sigma (\mathrm {C 1 D} _ {3} (\operatorname {G A P} (\mathbf {X})), \quad \boldsymbol {\pi} = \operatorname {S U M} _ {\operatorname {r o w}} (\mathbf {X} ^ {T} \mathbf {X}),
109
+ $$
110
+
111
+ where $\omega$ and $\pi$ represent feature importance and feature correlation, respectively. $D$ is a scaling parameter, which is set to 10 throughout all experiments. Since self-attention mechanisms [21, 46] are
112
+
113
+ Table 1: Comparison of our DropCov with close related works in terms of formulation, computational complexity of post-normalization and usage mode. Please refer to Sec. 4 for the details of symbols.
114
+
115
+ <table><tr><td></td><td>Method</td><td>Formulation</td><td>Complexity</td><td>Train</td><td>Infer.</td></tr><tr><td rowspan="3">Element-wise Post-Norm.</td><td>B-CNN [31]</td><td>\(\ell_{2}(sqrt(V(X^{T}X)))\)</td><td>\(O(d^{2})\)</td><td>✓</td><td>✓</td></tr><tr><td>SigmE [25]</td><td>\(2/(1+e^{-\beta \cdot V(X^{T}X)})-1\)</td><td>\(O(d^{2})\)</td><td>✓</td><td>✓</td></tr><tr><td>LN [2]</td><td>\(\beta \odot (V(X^{T}X)-\mu)/\sigma) \oplus \gamma\)</td><td>\(O(d^{2})\)</td><td>✓</td><td>✓</td></tr><tr><td rowspan="5">Structure-wise Post-Norm.</td><td>DeepO2P [23]</td><td>\(V(LogM(X^{T}X))\)</td><td>\(O(d^{3})\)</td><td>✓</td><td>✓</td></tr><tr><td>MPN-COV [29]</td><td>\(V((X^{T}X)^{\alpha})\)</td><td>\(O(d^{3})\)</td><td>✓</td><td>✓</td></tr><tr><td>IB-CNN [30]</td><td>\(\ell_{2}(sqrt(V(X^{T}X)^{1/2}))\)</td><td>\(O(d^{3})\)</td><td>✓</td><td>✓</td></tr><tr><td>iSQRT-COV [28]</td><td>\(V(\approx (X^{T}X)^{1/2})\)</td><td>\(O(d^{3})\)</td><td>✓</td><td>✓</td></tr><tr><td>MaxExp [25]</td><td>\(I-(I-X^{T}X/(X^{T}X+\varepsilon))^{\alpha}\)</td><td>\(O(d^{3})\)</td><td>✓</td><td>✓</td></tr><tr><td>Ours</td><td>DropCov</td><td>\(V(Y^{T}Y)\), \(Y=\delta_{\rho}(X)\)</td><td>\(O(d)\)</td><td>✓</td><td>×</td></tr></table>
116
+
117
+ *: Note $\beta$ and $\varepsilon$ are parameters. $\odot$ and $\oplus$ indicate element-wise multiplication and addition, respectively.
118
+
119
+ usually used to search important features, we measure feature importance by modifying a light-weight channel attention module [46], which involves global average pooling (GAP), a 1D convolution with kernel size of 3 $(\mathrm{C1D}_3)$ , and softmax function $(\sigma)$ . As covariance $\mathbf{X}^T\mathbf{X}$ naturally characterizes correlation among different features, we compute feature correlation by summarizing the elements along row of $\mathbf{X}^T\mathbf{X}$ (i.e., $\mathrm{SUM}_{\mathrm{row}}(\mathbf{X}^T\mathbf{X})$ ). Note that we restrict $\rho$ of Eqn. (5) belongs to $(0,1)$ .
120
+
121
+ As for Eqn. (5), we adaptively decide probability $\rho$ of channel dropout for reaching a good trade-off between representation decorrelation and information preservation, where $\frac{D}{\log(d)}$ and inner product of $\langle \pmb{\omega}, \pmb{\pi} \rangle$ are designed to consider effect of feature dimension $(d)$ and relationship between feature correlation and feature importance, respectively. In particular, larger feature dimension $d$ usually requires larger dropout probability $\rho$ . Meanwhile, feature correlation (i.e., $\pi$ ) and feature importance (i.e., $\omega$ ) are closely related to representation decorrelation and information preservation, respectively. Clearly, larger feature correlation results in stronger representation correlation, while features with larger channel weights contain more important information. Therefore, relationship between feature correlation and feature importance is good indicator to perform channel dropout. Intuitively, if feature correlation is closely related to (i.e., seriously decoupled with) feature importance, it is hard to select features for reaching a good trade-off between representation decorrelation and information preservation, and so we need to carefully adopt dropout for channel features under the random setting, leading to a small $\rho$ . Otherwise, we can perform dropout more safely to achieve a trade-off, and adopt a large $\rho$ . Note that we show behavior of $\rho$ during training in supplementary materials. Based on Eqn. (5), our DropCov is achieved by
122
+
123
+ $$
124
+ \mathbf {z} = \mathbf {V} \left(\mathbf {Y} ^ {T} \mathbf {Y}\right), \mathbf {Y} = \delta_ {\rho} (\mathbf {X}), \tag {6}
125
+ $$
126
+
127
+ where $\delta_{\rho}$ is a channel dropout operation with the probability of $\rho$ . $\mathbf{V}$ is a vectorization operation followed by triangulation, leading to a $d(d + 1) / 2$ -dimensional covariance representation $\mathbf{z}$ . Note that our DropCov (6) is only adopted to train GCP networks, which can be easily implemented by standard back-propagation. During inference stage, we simply use $\mathrm{V}(\mathbf{X}^T\mathbf{X})$ for final classification.
128
+
129
+ # 4 Related Works
130
+
131
+ In this section, we review some works closely related to our DropCov. Table 1 gives a detailed comparison of our DropCov with existing post-normalization methods in terms of formulation, computational complexity of post-normalization and usage mode. For element-wise post-normalization methods, B-CNN $^3$ [31] performs element-wise signed square-root (sqrt) followed by a $\ell_2$ normalization on covariance representations. [25] proposes to use some surrogate functions (e.g., SigmE) to handle issue of negative evidence inherent in power function. Layer normalization (LN) [2] is proposed to normalize each feature with its mean ( $\mu$ ) and variance ( $\gamma$ ) followed by a linear transformation. Since these
132
+
133
+ methods perform normalization on each element of covariance representations, they have the computational complexity of $O(d^{2})$ for $d$ -dimensional features $\mathbf{X}$ . For structure-wise post-normalization methods, $\mathrm{DeepO}_2\mathrm{P}$ and MPN-COV [29] perform matrix logarithm (LogM) and matrix power function for covariance representations, respectively. IB-CNN [30] combines matrix square-root normalization with element-wise one, while iSQRT-COV [28] proposes an approximate matrix square-root normalization via fast iterative matrix multiplications. Song et al. further analyze the effect of iSQRT-COV [38] and develop a faster variant [39]. [25] introduces several spectral power functions (e.g., MaxExp) for normalizing covariance matrices. These structure-wise approaches involve SVD of covariances or sequential matrix multiplications, having the computational complexity of $O(d^{3})$ . ReDro [36] proposes a relation dropout scheme to divide a large-sized covariance into a group of small-sized ones, aiming to mitigate the computational issue of matrix normalization [29, 30, 28, 11]. ReDro reduces computational complexity of structure-wise approaches from $O(d^{3})$ to $O(d^{3} / G^{2})$ , where $G$ is the number of groups. Besides, all existing works perform post-normalization methods during both training and inference (Infer.) stages. Different from aforementioned works, our DropCov performs adaptive channel dropout $\delta$ on features $\mathbf{X}$ right before GCP, which has a linear complexity $O(d)$ and is free during inference stage. Experimental results in Sec. 5.3 show our DropCov with much less computational complexity is superior or competitive to previous works.
134
+
135
+ # 5 Experiments
136
+
137
+ In this section, we conduct experiments to evaluate effectiveness of our DropCov in improving deep architectures on image classification tasks. Specifically, we first describe implementation details, and then make ablation study on ImageNet-1K (IN-1K) [7] using backbone of ResNet-18. Additionally, we apply our DropCov to both ResNets [17] and ViT models [43, 32, 50], while comparing them on several benchmarks (i.e., IN-1K, ImageNet-C (IN-C) [18], ImageNet-A (IN-A) [19] and Stylized-ImageNet (Sty.-IN) [13]) to assess generalization and robustness of our DropCov. Finally, we assess generalization of DropCov models by transferring them to long-tailed species classification [20].
138
+
139
+ Table 2: Comparisons (% in Top-1 accuracy) of adaptive normalization methods with the fixed ones using ResNet-18 on ImageNet-1K.
140
+
141
+ <table><tr><td>Method</td><td>d = 64</td><td>d = 128</td><td>d = 256</td></tr><tr><td>DropElement (ρ = 0.5)</td><td>73.4</td><td>74.6</td><td>74.0</td></tr><tr><td>DropChannel (ρ = 0.5)</td><td>70.1</td><td>73.1</td><td>75.1</td></tr><tr><td>ACD (Ours)</td><td>73.5</td><td>75.0</td><td>75.2</td></tr><tr><td>MPN (α = 0.5)</td><td>73.1</td><td>74.4</td><td>74.9</td></tr><tr><td>APN (Ours)</td><td>73.3</td><td>74.5</td><td>75.0</td></tr></table>
142
+
143
+ Table 4: Comparisons (% in Top-1 accuracy) of various dropout variants using ResNet-18 on ImageNet-1K.
144
+
145
+ <table><tr><td>Method</td><td>dim=64</td><td>dim=256</td></tr><tr><td>Maxout [15]</td><td>72.1</td><td>73.7</td></tr><tr><td>Dropconnect [44]</td><td>70.6</td><td>72.5</td></tr><tr><td>Decov [5]</td><td>72.7</td><td>74.0</td></tr><tr><td>Maxdropout [9]</td><td>72.0</td><td>70.1</td></tr><tr><td>DropBlock [14]</td><td>72.3</td><td>74.1</td></tr><tr><td>ACD(Ours)</td><td>73.5</td><td>75.2</td></tr></table>
146
+
147
+ Table 3: Comparisons (% in Top-1 accuracy) of several specific dropout strategies using ResNet-18 on ImageNet-1K.
148
+
149
+ <table><tr><td rowspan="2">Method</td><td colspan="2">d = 64</td><td colspan="2">d = 256</td></tr><tr><td colspan="2">Element Channel</td><td colspan="2">Element Channel</td></tr><tr><td>Large (ρ = 0.5)</td><td>72.2</td><td>71.3</td><td>71.4</td><td>70.9</td></tr><tr><td>Small (ρ = 0.5)</td><td>68.4</td><td>71.2</td><td>66.4</td><td>71.5</td></tr><tr><td>Uniform (ρ = 0.5)</td><td>72.8</td><td>72.1</td><td>74.0</td><td>74.4</td></tr><tr><td>ACD (Ours)</td><td colspan="2">73.5</td><td colspan="2">75.2</td></tr></table>
150
+
151
+ Table 5: Comparisons (% in Top-1 accuracy) of DropElement and DropChannel with various drop rates $(\rho)$ using ResNet-18 on ImageNet-1K.
152
+
153
+ <table><tr><td></td><td colspan="2">Channel Dropout</td><td colspan="2">Element Dropout</td></tr><tr><td>ρ</td><td>dim = 64</td><td>dim = 256</td><td>dim = 64</td><td>dim = 256</td></tr><tr><td>0.1</td><td>72.5</td><td>71.9</td><td>72.3</td><td>70.8</td></tr><tr><td>0.3</td><td>72.8</td><td>74.7</td><td>72.8</td><td>72.3</td></tr><tr><td>0.5</td><td>70.1</td><td>75.1</td><td>73.4</td><td>74.0</td></tr><tr><td>0.7</td><td>65.7</td><td>72.1</td><td>72.1</td><td>74.2</td></tr><tr><td>0.9</td><td>20.5</td><td>54.7</td><td>68.2</td><td>73.8</td></tr><tr><td>ACD (Ours)</td><td>73.5</td><td>75.2</td><td>73.5</td><td>75.2</td></tr></table>
154
+
155
+ # 5.1 Implementation Details
156
+
157
+ In this work, we apply our DropCov to several ResNets [17] and ViT models [43, 32, 50]. Specifically, we construct DropCov models based on ResNet following exactly the same schemes in [29, 47]. Given a CNN backbone, we first introduce a $1 \times 1$ convolution after the last convolution layer for reducing dimension of features to $d$ , and then replace the original GAP by our DropCov followed by
158
+
159
+ a fully-connected (FC) layer and softmax for classification. All models are optimized using the same hyper-parameter settings and data augmentations as suggested in [17, 29], where stochastic gradient descent (SGD) with initial learning rate $(lr)$ of 0.1 is used to train the networks within 100 epochs and $lr$ is decayed by 10 every 30 epochs. We combine DropCov with ViT models as in [49], where one FC layer is employed to reduce dimension of final word tokens, and our DropCov replaces GAP and classification token for Swin Transformers [32] and DeiT/T2T-ViT [43, 50], respectively. These models are trained by using the same hyper-parameter settings in [43, 32, 50]. All programs run a sever equipped with eight Nvidia RTX 3090 GPUs and 128G RAM. Source code (e.g., PyTorch [33], PaddlePaddle and Mindspace) will be available at https://github.com/mingzeG/DropCov.
160
+
161
+ # 5.2 Ablation Study
162
+
163
+ In this subsection, we conduct experiments on ImageNet-1K using lightweight ResNet-18 to assess effect of adaptive probability $\rho$ of dropout on our method, while compare with several dropout strategies, and finally assess effect of our modifications on existing post-normalization approaches.
164
+
165
+ Fixed $\rho$ vs. ACD. Our DropCov performs pre-normalization for GCP by using an adaptive channel dropout (ACD) method, which automatically determines probability $\rho$ of dropout by considering trade-off between representation decorrelation and information preservation. We compare with two kinds of baseline dropout methods using fixed $\rho = 0.5$ , i.e., element-wise dropout for covariance representations (DropElement) and channel dropout for input features (DropChannel). As shown in the upper part of Table 2, our ACD achieves the best results for various feature dimensions $(d)$ and clearly outperforms the naive DropElement in Sec. 3.1. Besides, we compare with DropElement and DropChannel with various dropout ratios. As compared in Table 5, our ACD is superior to DropElement and DropChannel for all dropout ratios. Particularly, the best dropout ratios are quite different for two methods and various feature dimensions. In contrast, our ACD can adaptively determine probability $\rho$ of dropout by balancing representation decorrelation and information preservation, while always achieving the best performance, clearly verifying ACD can achieve a better trade-off.
166
+
167
+ Comparison of Various Dropout Strategies. To verify the effectiveness of our ACD, we compare with several dropout strategies. First, we perform element-wise (Element) dropout on some specific entries of covariance with $\rho = 0.5$ . Specifically, we rank all entries of covariance in a descending order, and then perform dropout on top/bottom/uniform half of the ordered entries (namely Large/Small/Uniform). We adopt similar strategies to feature channels (Channel), where channel indicators are decided by attention module of our ACD. Note that 'Element' dropout preforms dropout on elements of covariance representations based on values of elements $([\mathbf{X}^T\bar{\mathbf{X}}]_{ij})$ , which indicates correlation between $i$ -th channel and $j$ -th channel. Therefore, it only considers feature correlation. For 'Channel' dropout, it preforms dropout on feature channels based on their weights, which are obtained by attention module of ACD (i.e., $\omega$ ). Therefore, it only considers feature importance. Based on above discussion, 'Element' and 'Channel' dropout methods can be regarded as special cases of ACD, where only feature correlation or feature importance are considered, respectively. As compared in Table 3, uniform dropout clearly outperforms those only focus on largest and smallest entries, indicating equilibrium of feature correlation or importance is crucial to final performance. Furthermore, our ACD is superior to uniform dropout by a clear margin. Besides, we compare with several existing Dropout variants, including Maxout [15], DropConnect [44], Decov [5], maxdropout [9] and DropBlock [14]. As shown in Table 4, our ACD clearly outperforms them. Although these methods can prevent overfitting, they are not good at making a balance between representation decorrelation and information preservation. These results further demonstrate the effectiveness of our ACD.
168
+
169
+ Effect of Modifications. According to Corollary 1, we make several modifications to existing post-normalization approaches. Beyond MPN, we propose an APN method by considering eigenvalues $\Lambda$ of inputs (see Eqns. (3) and(4)). The results are compared in the bottom part of Table 2, where our APN determines $\alpha$ by considering effect of inputs while average values of $\alpha$ are 0.53, 0.49 and 0.45 for $d = 256$ , $d = 128$ and $d = 64$ , respectively. Clearly, average values of $\alpha$ achieved by APN are nearby 0.5, which further account for why 0.5 is the widely used choice of $\alpha$ for MPN. Besides, APN brings $0.1\% \sim 0.2\%$ gains over MPN with $\alpha = 0.5$ by considering effect of inputs. We would like to clarify they are non-trivial gains on ImageNet over strong MPN, and the recent works [38, 40] also bring similar gains ( $0.1\% \sim 0.3\%$ ) over MPN. Besides, as discussed in Sec.2.2, we introduce an I-LogM and a linear transform (LT) based on BN [22] for improving LogM normalization (DeepO $_2$ P)
170
+
171
+ Table 6: Comparison of DropCov with several post-normalization in terms of Top-1 accuracy (Acc.) and running speed using ResNet-18 on ImageNet-1K. $\star$ : According to Sec.2.2 and Corollary 1, we modify B-CNN and IB-CNN with a linear transform (LT), while modifying $\mathrm{DeepO}_2\mathrm{P}$ with I-LogM.
172
+
173
+ <table><tr><td rowspan="2">Method</td><td colspan="3">d = 64</td><td colspan="3">d = 256</td></tr><tr><td>Top-1 Acc. (%)</td><td>Train (μs)</td><td>Test (μs)</td><td>Top-1 Acc. (%)</td><td>Train (μs)</td><td>Test (μs)</td></tr><tr><td>Plain GCP</td><td>71.1</td><td>3.45</td><td>1.04</td><td>70.0</td><td>35.08</td><td>11.89</td></tr><tr><td>B-CNN [31]</td><td>38.3</td><td>4.31</td><td>1.23</td><td>41.1</td><td>44.97</td><td>14.38</td></tr><tr><td>B-CNN + LT*</td><td>68.3</td><td>4.45</td><td>1.28</td><td>73.2</td><td>47.37</td><td>15.24</td></tr><tr><td>LN [2]</td><td>71.7</td><td>4.10</td><td>1.13</td><td>70.2</td><td>40.79</td><td>13.59</td></tr><tr><td>DeepO2P [23]</td><td>70.1</td><td>922.50</td><td>910.95</td><td>Not Converge</td><td>9731.71</td><td>9638.71</td></tr><tr><td>I-LogM*</td><td>71.2</td><td>922.53</td><td>910.98</td><td>72.0</td><td>9732.46</td><td>9639.65</td></tr><tr><td>MPN-COV [29]</td><td>73.1</td><td>925.16</td><td>913.87</td><td>74.9</td><td>9735.11</td><td>9642.43</td></tr><tr><td>iSQRT-COV [28]</td><td>73.4</td><td>12.35</td><td>4.94</td><td>75.2</td><td>193.65</td><td>77.46</td></tr><tr><td>IB-CNN [30]</td><td>Not Converge</td><td>13.93</td><td>5.16</td><td>36.1</td><td>202.38</td><td>80.55</td></tr><tr><td>IB-CNN + LT*</td><td>70.0</td><td>14.16</td><td>5.21</td><td>72.8</td><td>207.48</td><td>82.98</td></tr><tr><td>DropCov (Ours)</td><td>73.5</td><td>3.54</td><td>1.04</td><td>75.2</td><td>36.20</td><td>11.89</td></tr></table>
174
+
175
+ : Note we compute running speed $(\mu s)$ of single GCP module with post-normalization on a 2080Ti GPU. The original ResNet-18 with GAP achieves $70.2\%$ in Top-1 accuracy.
176
+
177
+ and element-wise post-normalization (i.e., B-CNN and IB-CNN), respectively. As shown in Table 6, $\mathrm{DeepO}_2\mathrm{P}$ performs poorly troubled by small eigenvalues (especially for $d = 256$ ), while our I-LogM obtains promising gains for both low- and high-dimensional features. Furthermore, B-CNN and IB-CNN achieve very unsatisfied results; in contrast, our simple modification brings significant improvement for B-CNN and IB-CNN. Above results clearly verify our finding in Corollary 1.
178
+
179
+ # 5.3 Comparisons with Counterparts
180
+
181
+ Here, we conduct experiments on ImageNet-1K using ResNet-18 for comparing with existing post-normalization methods in terms of Top-1 accuracy and running speed, including B-CNN [31], LN [2], DeepO $_2$ P [23], MPN-COV [29] with $\alpha = 0.5$ , iSQRT-COV [28] and IB-CNN [30]. The results of all compared methods are listed in Table 6, where we can see that our DropCov outperforms plain GCP (i.e., GCP without normalization) by $2.4\%$ ( $5.2\%$ ) for $d = 64$ ( $d = 256$ ) with similar running time. Compared with element-wise post-normalization (i.e., LN, B-CNN and IB-CNN), our DropCov achieves significant performance gains while requiring less running time. For structure-wise post-normalization, our DropCov is remarkably superior to matrix logarithm normalization (DeepO $_2$ P) in terms of both accuracy and running speed. Meanwhile, DropCov is superior or comparable to MPN-COV and iSQRT-COV using much less running time, especially during inference stage. Above results show our DropCov performs better or on par with the counterparts in terms of efficiency and effectiveness, providing an very promising normalization method for deep GCP networks.
182
+
183
+ # 5.4 Comparisons with Various Deep Architectures
184
+
185
+ CNNs. Here we apply our DropCov with $d = 128$ to various CNNs, including ResNet-34, ResNet-50 and ResNet-101. Meanwhile, we compare DropCov with the original CNNs on IN-1K, IN-C, IN-A and Sty.-IN. As shown in the upper part of Table 7, DropCov respectively brings about $2.6\%$ , $2.2\%$ and $1.8\%$ gains over ResNet-34, ResNet-50 and ResNet-101 on IN-1K, while showing stronger robustness on IN-C, IN-A and Sty.-IN. Particularly, DropCov with ResNet-50 and ResNet-101 are respectively superior to the original ResNet-101 and ResNet-152, but having less model complexity.
186
+
187
+ ViT. For ViT models, we apply our DropCov with $d = 128$ to DeiT-S [43], Swin-T [32] and T2T-ViT-14 [50], and compare the original models as well as ConViT [6]. As shown in the bottom part of Table 7, DropCov brings about $2.6\%$ , $1.3\%$ and $1.2\%$ gains over DeiT-S, Swin-T and T2T-ViT-14 on IN-1K, respectively. Meanwhile, it shows stronger robustness on IN-C, IN-A and Sty.-IN. Particularly, DropCov with DeiT-S is superior to DeiT-B and ConViT-B, but having less model complexity. Above results show our DropCov provides a simple yet effective method to improve deep architectures, and deep architectures with DropCov achieve better trade-off between accuracy and model complexity.
188
+
189
+ Table 7: Comparison of our DropCov with various ResNet and ViT models on four datasets, where results in terms of mCE and Top-1 accuracy (\%) are reported on IN-C and reminding ones, receptively.
190
+
191
+ <table><tr><td>Method</td><td>Params.</td><td>FLOPs</td><td>IN-1K (↑)</td><td>IN-C (↓)</td><td>IN-A (↑)</td><td>Sty.-IN (↑)</td></tr><tr><td>ResNet-34 [17]</td><td>21.8 M</td><td>3.66 G</td><td>74.19</td><td>77.9</td><td>1.63</td><td>7.59</td></tr><tr><td>ResNet-50 [17]</td><td>25.6 M</td><td>3.86 G</td><td>76.02</td><td>76.7</td><td>2.47</td><td>7.15</td></tr><tr><td>ResNet-101 [17]</td><td>44.6 M</td><td>7.57 G</td><td>77.67</td><td>70.3</td><td>4.15</td><td>9.51</td></tr><tr><td>ResNet-152 [17]</td><td>60.2 M</td><td>11.28 G</td><td>78.13</td><td>69.3</td><td>5.98</td><td>10.09</td></tr><tr><td>ResNet-34+DropCov (Ours)</td><td>29.6 M</td><td>5.56 G</td><td>76.81(2.62)</td><td>71.1(6.8)</td><td>3.45(1.82)</td><td>11.16(3.57)</td></tr><tr><td>ResNet-50+DropCov (Ours)</td><td>32.0 M</td><td>6.19 G</td><td>78.19(2.17)</td><td>69.8(6.9)</td><td>5.08(2.61)</td><td>9.90(2.75)</td></tr><tr><td>ResNet-101+DropCov (Ours)</td><td>51.0 M</td><td>9.90 G</td><td>79.51(1.84)</td><td>65.8(4.5)</td><td>7.54(3.39)</td><td>11.41(1.90)</td></tr><tr><td>DeiT-S [43]</td><td>22.1 M</td><td>4.6 G</td><td>79.8</td><td>54.6</td><td>18.9</td><td>14.91</td></tr><tr><td>Swin-T [32]</td><td>28.3 M</td><td>4.5 G</td><td>81.2</td><td>62.0</td><td>21.6</td><td>13.40</td></tr><tr><td>T2T-ViT-14 [50]</td><td>21.5 M</td><td>5.2 G</td><td>81.5</td><td>53.2</td><td>23.9</td><td>15.80</td></tr><tr><td>DeiT-B [43]</td><td>86.6 M</td><td>17.6 G</td><td>82.0</td><td>48.5</td><td>27.4</td><td>17.94</td></tr><tr><td>ConViT-B [6]</td><td>86.5 M</td><td>17.7 G</td><td>82.4</td><td>46.9</td><td>29.0</td><td>19.67</td></tr><tr><td>DeiT-S+DropCov (Ours)</td><td>25.6 M</td><td>5.5 G</td><td>82.4(2.6)</td><td>52.6(2.0)</td><td>31.2(12.3)</td><td>17.10(2.19)</td></tr><tr><td>Swin-T+DropCov (Ours)</td><td>31.6 M</td><td>6.0 G</td><td>82.5(1.3)</td><td>54.8(7.2)</td><td>33.1(11.5)</td><td>14.13(0.73)</td></tr><tr><td>T2T-ViT-14+DropCov (Ours)</td><td>24.9 M</td><td>5.4 G</td><td>82.7(1.2)</td><td>52.1(1.1)</td><td>31.7(7.8)</td><td>18.81(3.01)</td></tr></table>
192
+
193
+ # 5.5 Comparisons on Long-tailed Benchmark
194
+
195
+ Finally, we transfer our DropCov models to iNat2017 [20], and compare with several deep architectures, i.e., ResNet-101, ResNet-152, Inception V3 (IncV3) [42] with SE [21] as well as the recently proposed ViT [10] and TransFG [16]. Specifically, we perform fine-tuning of our DropCov models with backbones of ResNet-101 and DeiT-S on iNat2017, namely DropCov (ResNet-101) and DropCov (DeiT-S). As shown in Table 8, our DropCov (ResNet-101) obtains $5.5\%$ gains over the original ResNet-101, while outperforming ResNet-152 and IncV3 SE. Besides, our DropCov (DeiT-S) respectively outperforms ViT-B and TransFG by $3.7\%$ and
196
+
197
+ Table 8: Comparisons (%) on iNat2017.
198
+
199
+ <table><tr><td>Method</td><td>Top-1</td><td>Top-5</td></tr><tr><td>ResNet-101</td><td>62.4</td><td>84.1</td></tr><tr><td>ResNet-152</td><td>64.2</td><td>85.5</td></tr><tr><td>IncV3 SE</td><td>66.3</td><td>86.7</td></tr><tr><td>ViT-B_16 (IN-21K) [10]</td><td>68.7</td><td>N/A</td></tr><tr><td>TransFG (IN-21K) [16]</td><td>71.7</td><td>N/A</td></tr><tr><td>DropCov (ResNet-101)</td><td>67.9</td><td>87.3</td></tr><tr><td>DropCov (DeiT-S)</td><td>72.4</td><td>90.3</td></tr></table>
200
+
201
+ $0.7\%$ , which are pre-trained on ImageNet-21K. The results clearly verify generalization of DropCov.
202
+
203
+ # 6 Conclusion
204
+
205
+ In this paper, we first analyze the effect of post-normalization on GCP from the perspective of optimizing deep GCP networks. Particularly, we find that effective post-normalization methods have a good ability to balance representation decorrelation and information preservation, which can reduce over-fitting and increase representation ability of deep GCP networks, respectively. According to our finding, we introduce some strategies to improve existing normalization methods, further verifying our finding. More importantly, we propose a novel pre-normalization for GCP (namely DropCov) based on adaptive channel dropout, which achieves very competitive performance with a linear complexity and training-only mode. Extensive experiments identify that our DropCov provides a simple yet effective solution to improve existing deep architectures on image classification tasks.
206
+
207
+ GCP normally produces a high-dimensional covariance representation, bringing a certain amount of computational cost, but our work makes use of high-dimensional GCP more flexible. Meanwhile, our DropCov can achieve clear gains for low-dimensional GCP with little extra computational cost (refer to Table 6). Additionally, our DropCov is potentially applicable to compact GCP methods [12, 24] and encourages exploration of other effective dropout strategies, which will be studied in future work.
208
+
209
+ # Acknowledgment
210
+
211
+ The work was sponsored by National Natural Science Foundation of China (Grant No.s 62276186, 61925602, 61971086 and 61732011), CCF-Baidu Open Fund (NO.2021PP15002000), CAAIXSJLJJ-2022-010C and Haihe Lab of ITAI (NO. 22HHXCJC00002).
212
+
213
+ # References
214
+
215
+ [1] V. Arsigny, P. Fillard, X. Pennec, and N. Ayache. Fast and simple calculus on tensors in the Log-Euclidean framework. In MICCAI, 2005.
216
+ [2] L. J. Ba, J. R. Kiros, and G. E. Hinton. Layer normalization. CoRR, abs/1607.06450, 2016.
217
+ [3] C. M. Bishop. Pattern recognition and machine learning, 5th Edition. Information science and statistics. Springer, 2007.
218
+ [4] G. Chen, P. Chen, Y. Shi, C. Hsieh, B. Liao, and S. Zhang. Rethinking the usage of batch normalization and Dropout in the training of deep neural networks. CoRR, abs/1905.05928, 2019.
219
+ [5] M. Cogswell, F. Ahmed, R. B. Girshick, L. Zitnick, and D. Batra. Reducing overfitting in deep networks by decorrelating representations. In ICLR, 2016.
220
+ [6] S. d'Ascoli, H. Touvron, M. L. Leavitt, A. S. Morcos, G. Biroli, and L. Sagun. ConViT: Improving vision transformers with soft convolutional inductive biases. In ICML, 2021.
221
+ [7] J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. ImageNet: A large-scale hierarchical image database. In CVPR, 2009.
222
+ [8] A. Diba, V. Sharma, and L. Van Gool. Deep temporal linear encoding networks. In CVPR, 2017.
223
+ [9] C. F. G. dos Santos, D. Colombo, M. Roder, and J. P. Papa. Maxdropout: Deep neural network regularization based on maximum output values. In ICPR, 2020.
224
+ [10] A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In ICLR, 2021.
225
+ [11] M. Engin, L. Wang, L. Zhou, and X. Liu. DeepKSPD: Learning kernel-matrix-based SPD representation for fine-grained image recognition. In ECCV, 2018.
226
+ [12] Y. Gao, O. Beijbom, N. Zhang, and T. Darrell. Compact bilinear pooling. In CVPR, 2016.
227
+ [13] R. Geirhos, P. Rubisch, C. Michaelis, M. Bethge, F. A. Wichmann, and W. Brendel. ImageNet-trained CNNs are biased towards texture; increasing shape bias improves accuracy and robustness. In ICLR, 2019.
228
+ [14] G. Ghiasi, T. Lin, and Q. V. Le. DropBlock: A regularization method for convolutional networks. In NeurIPS, 2018.
229
+ [15] I. J. Goodfellow, D. Warde-Farley, M. Mirza, A. C. Courville, and Y. Bengio. Maxout networks. In ICML, 2013.
230
+ [16] J. He, J.-N. Chen, S. Liu, A. Kortylewski, C. Yang, Y. Bai, C. Wang, and A. Yuille. TransFG: A transformer architecture for fine-grained recognition. In AAAI, 2022.
231
+ [17] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In CVPR, 2016.
232
+ [18] D. Hendrycks and T. G. Dietterich. Benchmarking neural network robustness to common corruptions and perturbations. In ICLR, 2019.
233
+ [19] D. Hendrycks, K. Zhao, S. Basart, J. Steinhardt, and D. Song. Natural adversarial examples. In CVPR, 2021.
234
+ [20] G. V. Horn, O. M. Aodha, Y. Song, Y. Cui, C. Sun, A. Shepard, H. Adam, P. Perona, and S. J. Belongie. The iNaturalist species classification and detection dataset. In CVPR, 2018.
235
+ [21] J. Hu, L. Shen, S. Albanie, G. Sun, and E. Wu. Squeeze-and-excitation networks. IEEE Trans. Pattern Anal. Mach. Intell., 42(8):2011-2023, 2020.
236
+ [22] S. Ioffe and C. Szegedy. Batch Normalization: Accelerating deep network training by reducing internal covariate shift. In ICML, 2015.
237
+ [23] C. Ionescu, O. Vantzos, and C. Sminchisescu. Matrix backpropagation for deep networks with structured layers. In ICCV, 2015.
238
+ [24] S. Kong and C. C. Fowlkes. Low-rank bilinear pooling for fine-grained classification. In CVPR, 2017.
239
+ [25] P. Koniusz, H. Zhang, and F. Porikli. A deeper look at power normalizations. In CVPR, 2018.
240
+ [26] A. Krizhevsky, I. Sutskever, and G. E. Hinton. ImageNet classification with deep convolutional neural networks. In NIPS, 2012.
241
+ [27] Y. LeCun, I. Kanter, and S. A. Solla. Second order properties of error surfaces. In NIPS, 1990.
242
+ [28] P. Li, J. Xie, Q. Wang, and Z. Gao. Towards faster training of global covariance pooling networks by iterative matrix square root normalization. In CVPR, 2018.
243
+ [29] P. Li, J. Xie, Q. Wang, and W. Zuo. Is second-order information helpful for large-scale visual recognition? In ICCV, 2017.
244
+ [30] T. Lin and S. Maji. Improved bilinear pooling with CNNs. In BMVC, 2017.
245
+ [31] T. Lin, A. RoyChowdhury, and S. Maji. Bilinear CNN models for fine-grained visual recognition. In ICCV, 2015.
246
+ [32] Z. Liu, Y. Lin, Y. Cao, H. Hu, Y. Wei, Z. Zhang, S. Lin, and B. Guo. Swin transformer: Hierarchical vision transformer using shifted windows. In ICCV, 2021.
247
+ [33] A. Paszke, S. Gross, F. Massa, A. Lerer, J. Bradbury, G. Chanan, T. Killeen, Z. Lin, N. Gimelshein, L. Antiga, A. Desmaison, A. Köpf, E. Z. Yang, Z. DeVito, M. Raison, A. Tejani, S. Chilamkurthy, B. Steiner, L. Fang, J. Bai, and S. Chintala. Pytorch: An imperative style, high-performance deep learning library. In NeurlPS, 2019.
248
+
249
+ [34] X. Pennec, P. Fillard, and N. Ayache. A Riemannian framework for tensor computing. *IJCV*, 66(1):41-66, 2006.
250
+ [35] T. Poggio, A. Banburski, and Q. Liao. Theoretical issues in deep networks. Proceedings of the National Academy of Sciences (PNAS), 117(48):30039-30045, 2020.
251
+ [36] S. Rahman, L. Wang, C. Sun, and L. Zhou. ReDro: Efficiently learning large-sized SPD visual representation. In ECCV, 2020.
252
+ [37] J. Sánchez, F. Perronnin, T. Mensink, and J. Verbeek. Image classification with the Fisher Vector: Theory and practice. IJCV, 105(3):222-245, 2013.
253
+ [38] Y. Song, N. Sebe, and W. Wang. Why approximate matrix square root outperforms accurate SVD in global covariance pooling? In ICCV, 2021.
254
+ [39] Y. Song, N. Sebe, and W. Wang. Fast differentiable matrix square root. In ICLR, 2022.
255
+ [40] Y. Song, N. Sebe, and W. Wang. Improving covariance conditioning of the SVD meta-layer by orthogonality. In ECCV, 2022.
256
+ [41] N. Srivastava, G. E. Hinton, A. Krizhevsky, I. Sutskever, and R. Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. J. Mach. Learn. Res., 15(1):1929-1958, 2014.
257
+ [42] C. Szegedy, V. Vanhoucke, S. Ioffe, J. Shlens, and Z. Wojna. Rethinking the inception architecture for computer vision. In CVPR, 2016.
258
+ [43] H. Touvron, M. Cord, M. Douze, F. Massa, A. Sablayrolles, and H. Jégou. Training data-efficient image transformers & distillation through attention. In ICML, 2021.
259
+ [44] L. Wan, M. D. Zeiler, S. Zhang, Y. LeCun, and R. Fergus. Regularization of neural networks using dropconnect. In ICML, 2013.
260
+ [45] Q. Wang, P. Li, W. Zuo, and L. Zhang. RAID-G: Robust estimation of approximate infinite dimensional Gaussian with application to material recognition. In CVPR, 2016.
261
+ [46] Q. Wang, B. Wu, P. Zhu, P. Li, W. Zuo, and Q. Hu. ECA-Net: Efficient channel attention for deep convolutional neural networks. In CVPR, 2020.
262
+ [47] Q. Wang, J. Xie, W. Zuo, L. Zhang, and P. Li. Deep CNNs meet global covariance pooling: Better representation and generalization. IEEE TPAMI, 43(8), 2020.
263
+ [48] T. Winterbottom, S. Xiao, A. McLean, and N. A. Moubayed. Trying bilinear pooling in Video-QA. arXiv preprint arXiv:2012.10285, 2020.
264
+ [49] J. Xie, R. Zeng, Q. Wang, Z. Zhou, and P. Li. So-ViT: Mind visual tokens for vision transformer. CoRR, abs/2104.10935, 2021.
265
+ [50] L. Yuan, Y. Chen, T. Wang, W. Yu, Y. Shi, Z.-H. Jiang, F. E. Tay, J. Feng, and S. Yan. Tokens-to-Token ViT: Training vision transformers from scratch on ImageNet. In ICCV, 2021.
266
+ [51] J. Zhang, L. Wang, L. Zhou, and W. Li. Beyond Covariance: SICE and kernel based visual feature representation. Int. J. Comput. Vis., 129(2):300-320, 2021.
267
+
268
+ # Checklist
269
+
270
+ 1. For all authors...
271
+
272
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper's contributions and scope? [Yes] See Abstract and Section 1.
273
+ (b) Did you describe the limitations of your work? [Yes] See Section 6.
274
+ (c) Did you discuss any potential negative societal impacts of your work? [No]
275
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
276
+
277
+ 2. If you are including theoretical results...
278
+
279
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A]
280
+ (b) Did you include complete proofs of all theoretical results? [N/A]
281
+
282
+ 3. If you ran experiments...
283
+
284
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] See Section 5.1 and Supplemental Material.
285
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 5.1 and Supplemental Material.
286
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] We share the same settings with compared methods.
287
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Section 5.1.
288
+
289
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
290
+
291
+ (a) If your work uses existing assets, did you cite the creators? [Yes] See Section 5.
292
+ (b) Did you mention the license of the assets? [No] All of them are publicly available.
293
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No] We use publicly available datasets.
294
+ (d) Did you discuss whether and how consent was obtained from people whose data you're using/curating? [No] All of them are publicly available.
295
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No] We use publicly available datasets.
296
+
297
+ 5. If you used crowdsourcing or conducted research with human subjects...
298
+
299
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
300
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
301
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
dropcovasimpleyeteffectivemethodforimprovingdeeparchitectures/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1598c1554184102ef5d4e168fb29716ef5be482914cce115d6064023f44c3a61
3
+ size 458499
dropcovasimpleyeteffectivemethodforimprovingdeeparchitectures/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:973a341258530099dd7229314b21dfad3d2d50e3f95e784ab1d724526bcf941b
3
+ size 525961
dualcoopfastadaptationtomultilabelrecognitionwithlimitedannotations/93b11b1a-5d67-437e-801d-520aeff5c6bc_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d06edabff97105de4f9d1d15589aff83c732e80abae2aa8efcc92ee687467620
3
+ size 89731
dualcoopfastadaptationtomultilabelrecognitionwithlimitedannotations/93b11b1a-5d67-437e-801d-520aeff5c6bc_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d4a8cf4733eb0011c7e67884f1c8376b994e8806a6a4706c2786ea12e4740be3
3
+ size 116371
dualcoopfastadaptationtomultilabelrecognitionwithlimitedannotations/93b11b1a-5d67-437e-801d-520aeff5c6bc_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1ea27f21cef6fcdc4bb3bc1131335ed90ebfc4e776ae71b312ca1b3d4da07594
3
+ size 635564
dualcoopfastadaptationtomultilabelrecognitionwithlimitedannotations/full.md ADDED
@@ -0,0 +1,327 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DualCoOp: Fast Adaptation to Multi-Label Recognition with Limited Annotations
2
+
3
+ Ximeng Sun $^{1}$ Ping Hu $^{1}$ Kate Saenko $^{1,2}$
4
+
5
+ $^{1}$ Boston University, $^{2}$ MIT-IBM Watson AI Lab, IBM Research
6
+
7
+ {sunxm,pinghu,saenko}@bu.edu
8
+
9
+ # Abstract
10
+
11
+ Solving multi-label recognition (MLR) for images in the low-label regime is a challenging task that has many real-world applications. Recent work learns an alignment between textual and visual spaces to compensate for insufficient image labels, but loses accuracy because of the limited amount of available MLR annotations. In this work, we utilize the strong alignment of textual and visual features pretrained with millions of auxiliary image-text pairs and propose Dual Context Optimization (DualCoOp) as a unified framework for partial-label MLR and zero-shot MLR. DualCoOp encodes positive and negative contexts with class names as part of the linguistic input (i.e. prompts). Since DualCoOp only introduces a very light learnable overhead upon the pretrained vision-language framework, it can quickly adapt to multi-label recognition tasks that have limited annotations and even unseen classes. Experiments on standard multi-label recognition benchmarks across two challenging low-label settings demonstrate the advantages of our approach over state-of-the-art methods. Project page: https://cs-people.bu.edu/sunxm/DualCoOp/project.htm1
12
+
13
+ # 1 Introduction
14
+
15
+ Image recognition has become a very popular and successful research area in recent years, due to the development of large-scale datasets [12, 28] and advanced model architectures [14, 19, 38, 54]. However, the majority of image recognition approaches have focused on single-label prediction, which ignores the intrinsic multi-label nature of images. Unlike single-label recognition [14, 19, 38, 54], multi-label image recognition aims to recognize all semantic labels present in an image [10, 11, 35, 37, 52, 66, 61], providing a more comprehensive understanding and benefiting applications like image retrieval, video analysis, and recommendation systems.
16
+
17
+ Multi-label recognition typically deals with images of complex scenes and diverse objects. Collecting multi-label annotations becomes difficult to scale up, for two reasons: (i) annotating images with the full semantic label set is laborious and (ii) samples of particular categories can be hard to find. The first challenge can be addressed by multi-label recognition with partial labels, where merely some of the categories are annotated for each training image. Recent works proposed solutions to partial-label MLR based on semi-supervised learning [24, 41], normalized training objectives [15], or label correlations [8, 21, 46]. The second setting involves zero-shot MLR, where novel unseen categories are recognized by transferring knowledge from seen categories, with solutions like principal image features [3, 69], knowledge graphs [29], and attention mechanisms [22, 44]. Despite significant progress on the two settings, existing approaches are not designed to handle both at once. We propose to unify these settings as limited-annotation MLR and design a solution that can handle practical scenarios with either partial or missing labels.
18
+
19
+ Successful solutions to the above problems transfer knowledge from fully-annotated categories to partially-labeled and novel categories by learning an alignment between images and category
20
+
21
+ ![](images/279aac3d76ebe2870db0841b162dfaba89c04b7f210363af1c81271349d11633.jpg)
22
+ Figure 1: A conceptual comparison of previous multi-label recognition (MLR) methods and our approach. In Partial-Label MLR (a) and Zero-Shot MLR (b), previous works learn to model and align the visual and textual inputs as well as explore the correlation between the target label with all/seen labels depending on the limited semantic annotations available on the dataset, which leads to sub-optimal performance and complex model architectures. In contrast, we propose a unified framework to tackle both limited-annotation tasks (c). We rely on the modeling and alignment of visual and textual inputs contained a large-scale pretrained vision-language model, and only learn a pair of positive and negative prompts to this model.
23
+
24
+ names [8, 46, 69]. Recently, vision-language pretraining models are bridging the visual-textual gap via large-scale pretraining, e.g., CLIP [47] is trained with 400 million image-text pairs. In this work, we draw inspiration from the recent success of prompt learning for such models [20, 25, 40, 48, 70, 72]. Prompt learning provides a convenient way to transfer pretrained vision-language models to other tasks. It designs additional textured or learnable prompt tokens for textual input to "inform" the model about downstream tasks and avoids finetuning the entire model which can be inefficient and data-hungry. By doing so, recent works like CoOp [71] have demonstrated CLIP's remarkable generalisation to various zero-shot image tasks [20, 47, 72]. However, these methods mainly focus on matching each image with a single label, hence they are not able to handle the multi-label setting.
25
+
26
+ To adapt the knowledge learned in CLIP to multi-label image recognition, we propose the DualCoOp framework. As shown in Fig. 1 (c), DualCoOp learns a pair of differentiable prompts to provide positive and negative contexts for the target class. Instead of using hand-crafted thresholding to determine positive labels [51], the dual prompts naturally result in a positive and a negative classifier, so the existence of the target class in the image can be easily decided by comparing their scores. Unlike prior models, shown in Fig. 1 (a)(b), we avoid fine-tuning the full vision-language model and only learn the prompts, which are much smaller compared to the entire model. Therefore, our simple framework achieves much higher efficiency when adapting to different datasets. Additionally, we modify the attention mechanism of CLIP to better model spatial information in images, improving its ability to recognize multiple objects in MLR. With these design choices, we achieve a unified framework for addressing the general challenges of multi-label recognition with limited annotations.
27
+
28
+ We summarize our contributions as follows:
29
+
30
+ - We propose DualCoOp to quickly adapt powerful vision-language models to solve multi-label recognition tasks using limited annotations.
31
+ - We propose dual (positive and negative) prompts to drastically reduce the number of learnable parameters, and improve the spatial modeling of the visual encoder to better distinguish multiple objects.
32
+ - We conduct extensive experiments on partial-label MLR (on MS-COCO [34] and VOC2007 [16]) and zero-shot MLR (on MS-COCO and NUS-WIDE [11]). Notably, DualCoOp improves mAP by $6.8\%$ with $10\%$ of labels on VOC2007, and F1-score at Top-3 Prediction by $10.8\%$ for zero-shot MLR on NUS-WIDE.
33
+
34
+ # 2 Related Works
35
+
36
+ Multi-Label Recognition with Limited Annotations. Multi-label image recognition has drawn increasing attention in past years. One straightforward solution to this problem is to individually learn a binary classifier for each category [36, 43, 57], which however does not consider correlations
37
+
38
+ among labels. Hence, recent works have focused on incorporating semantic dependencies among labels via graph neural networks [10, 11, 61] or RNN/LSTM [35, 59, 62, 66]. Some work also considers the spatial distribution of labels in the image, and exploits object proposals [33, 37, 60] or attention mechanism [52, 62, 73] as a regularization to rectify the prediction. However, despite achieving significant progress, these methods require a large-scale and complete annotated dataset to train models [27, 34]. This limits their application to more practical scenarios where data is partially annotated for training [4, 6, 41, 55, 56, 64] and unseen (zero-shot) categories may appear during testing [7, 18, 29, 42, 69].
39
+
40
+ With partially labeled data, where merely some labels of each sample are known, Mahajan et al. [41] and Joulin et al. [24] attempt to use web supervision to automatically generate the pseudo labels, which unfortunately leads to poor performance as the web supervision is noisy and incomplete [67]. To avoid external noise, Durand et al. [15] exploit the proportion of annotated samples for different labels and propose a normalized BCE loss to train models based on the given partial labels. More recent works explicitly transfer information from known labels to complement unknown labels by utilizing category-specific feature blending [46] or label co-occurrences [8] at both instance-level and prototype-level.
41
+
42
+ Unlike partial annotation of the same label set for training and testing, zero-shot multi-label image recognition needs to handle novel categories during testing, hence inspiring a different route based on a joint visual-label embedding space [7, 22, 42, 44, 69]. Zhang et al. [69] propose to find a principal direction that ranks related labels first in the joint embedding space optimized via a tailored zero-shot ranking loss. Cohen et al. [3] further improve the idea by learning multiple principal vectors to support the semantic diversity. Huynh et al. [22] consider the spatial regularization and propose a shared multi-attention model and obviate the need for explicit region proposals [50]. Narayan et al. [44] propose to enhance the region-based features so as to minimize inter-class feature entanglement.
43
+
44
+ Though significant progress has been made in each of the directions, existing methods still require a lot of MLR data and complex architectures/losses. Our approach reduces the need for hard-to-get MLR data by pretraining on unsupervised text-image pairs. While it may seem unfair to compare existing MLR methods with ones based on such pretraining, we point out that the pretraining data is unsupervised and thus easier to obtain. We also provide experiments comparing Dua1Co0p to baselines using the same pretraining. Importantly, previous methods are designed for only one task, hence have limitations in practical applications. In contrast, our proposed framework can be easily adapted with small data and can address both partial and zero-shot tasks at the same time.
45
+
46
+ Prompt Learning for Vision-Language Models. Vision-Language Models [23, 47] based on contrastive learning have demonstrated impressive ability to learn generic visual representations. As a milestone, CLIP [47] is trained with 400 million curated image-text pairs, and shows remarkable transfer capability for over 30 classification datasets. With such powerful vision-language models, several follow-ups [17, 63, 65, 68] have been proposed to explore the training strategies for training downstream classification tasks. Instead of fine-tuning the entire model [13, 19], which may damage the learned representation space, recent approaches adopt the prompt-based paradigm that formalizes NLP tasks as masked language modeling (prompt templates) [30, 32, 53]. Zhou et al. [71] propose to tune prompts for downstream classification tasks, and further introduce input-conditional prompts for better generalization ability [72]. Lu et al. [39] learn the distribution of diverse prompts to handle the varying visual representations. Huang et al. [20] generate pseudo labels for images to learn prompts in an unsupervised way. Though achieving promising improvements for downstream tasks, these methods address the multi-class zero-shot image recognition, assuming each image has one label, hence lacking the ability to handle the multi-label setting. In this paper, we present a novel framework to efficiently transfer VLMs to address multi-label image recognition with limited annotations.
47
+
48
+ # 3 Method
49
+
50
+ Problem Definition. We formally define multi-label recognition with limited annotations as follows: Consider $M$ as the set of categories which describe objects or attributes in images. Given a training image $I$ , the existence of a category $m \in M$ can be positive, negative or unknown, corresponding to the label $y_{m} = 1, -1$ or 0 respectively. During inference, we predict each label of interest for an input image.
51
+
52
+ ![](images/0519b4467a7df19ecd1e2458133f04d9a6a77c09a14e2bbcbdd69005eba44d2b.jpg)
53
+ Figure 2: Illustration of our proposed approach. DualCoOp learns a pair of positive and negative prompts to quickly adapt powerful pretrained vision-text encoders to the MLR task. For each class, two prompts generate two contrastive (positive and negative) textual embeddings as the input to the text encoder. Furthermore, we propose Class-Specific Region Feature Aggregation to first project each region's feature to the textual space and then aggregate the spatial logits by the magnitude of class-specific semantic responses. During training, we apply the ASL loss [51] to optimize learnable prompts while keeping other network components frozen. During inference, we compare the positive and negative logits to make a prediction for each class.
54
+
55
+ Many existing MLR problems fit into this broad definition. In this paper, we consider the settings with partial or missing labels: (1) Partial-label MLR [8, 15, 46], in which only a subset of labels are known (+1 or -1) for each training image and we are interested in predicting all existing labels during inference. (2) Zero-shot MLR [3, 22, 49], in which each label is either known (seen) or unknown (unseen) for all images during training and we are interested in predicting either all labels or only unknown (unseen) labels during inference. In this paper, we propose a unified setting that includes both scenarios, which we call limited-annotation MLR.
56
+
57
+ Approach Overview. To compensate for insufficient or missing image labels, it is important to learn how the meanings of category names are related to each other, so that we can transfer knowledge between related categories. This is usually done by learning an alignment between the visual and textual spaces. However, our dataset is too limited to learn a broad and generalizable mapping. We propose to instead leverage the strong alignment of visual and textual feature spaces learned by large-scale vision-language pretraining (CLIP [48]) with a light-weight learnable overhead which quickly adapts to the MLR task with limited semantic annotations. Figure 2 provides an overview of our proposed approach. Dua1Co0p learns a pair of "prompt" contexts in the form of two learnable sequences of word vectors, to provide positive and negative contexts of a given category name $m$ . This generates positive and negative textual features $(F_{t}^{m})_{+}$ and $(F_{t}^{m})_{-}$ that are fed into the pretrained text encoder. Furthermore, to better recognize multiple objects, which can be located at different locations in the image, the spatial aggregation step is modified. We first compute the similarity score of each projected visual feature $F_{v}^{i}$ at location $i$ with $(F_{t}^{m})_{+} / (F_{t}^{m})_{-}$ to obtain prediction logits over regions. For each class, we perform aggregation of all spatial logits, in which the weight for each logit is determined by its relative magnitude. We call this Class-Specific Region Feature Aggregation. During training, we optimize the learnable prompts via the ASL loss [51] while keeping all other network components frozen. During inference, we directly compare the final positive and negative logits to make a prediction for each label $y_{m}$ .
58
+
59
+ Dual Learnable Prompts. Instead of learning a single prompt for a class [71], we propose Dual Context Optimization (DualCo0p) which learns two contrastive prompts' contexts for each class. The learnable part in dual prompts carries positive and negative contextual surroundings individually and can be optimized end-to-end from data via binary classification loss. Specifically, we define the pair of prompts given to the text encoder as follows:
60
+
61
+ $$
62
+ \operatorname {P r o m p t} ^ {+} = \left[ V _ {1} ^ {+}, V _ {2} ^ {+}, \dots , V _ {N ^ {+}} ^ {+}, \mathrm {C L S} \right], \tag {1}
63
+ $$
64
+
65
+ $$
66
+ \text {P r o m p t} ^ {-} = \left[ V _ {1} ^ {-}, V _ {2} ^ {-}, \dots , V _ {N ^ {-}} ^ {-}, \mathrm {C L S} \right] \tag {2}
67
+ $$
68
+
69
+ where each $V$ is a learnable word embedding vector (e.g. with dimension 512 in CLIP [48]) and CLS is the given category name. $N^{+}$ and $N^{-}$ are the numbers of word tokens learned in the positive and
70
+
71
+ negative prompts respectively. For simplicity, we set $N^{+} = N^{-}$ in our experiments. We learn a pair of positive and negative prompts for each class (i.e. class-specific prompt pair) when solving MLR with partial labels, and learn a pair of prompts shared for all classes in zero-shot MLR. With a pair of prompts, we compute the binary classification output $p$ with the following form:
72
+
73
+ $$
74
+ p = \frac {\exp \left(< A \left(E _ {v} (I)\right) , E _ {t} \left(\text {P r o m p t} ^ {+}\right) > / \tau\right)}{\exp \left(< A \left(E _ {v} (I)\right) , E _ {t} \left(\text {P r o m p t} ^ {+}\right) > / \tau\right) + \exp \left(< A \left(E _ {v} (I)\right) , E _ {t} \left(\text {P r o m p t} ^ {-}\right) > / \tau\right)}, \tag {3}
75
+ $$
76
+
77
+ where $< \cdot, \cdot >$ represents cosine similarity and $p$ is the predicted probability for a given (image, label) pair as positive example. $E_v(\cdot)$ and $E_t(\cdot)$ are the visual and textual encoders from the vision-language pretraining. $A(\cdot)$ is our new aggregation function to adaptively reduce the spatial dimension of visual features for each class, which will be discussed next.
78
+
79
+ Class-Specific Region Feature Aggregation. In multi-label image recognition, it is common that multiple objects appear in different regions of the image. Pooling to produce a single image-level feature vector for all classes gives sub-optimal performance since spatial information is reduced and different objects are mixed. In this work, we reformulate the last multi-headed attention pooling layer of the visual encoder in CLIP [48] and apply class-specific pooling to adaptively aggregate region features in the multi-label setting. The original attention pooling layer in CLIP pools the visual feature map first, and then projects the global feature vector into text space as follows:
80
+
81
+ $$
82
+ \begin{array}{l} \operatorname {A t t n P o o l} (x) = \operatorname {P r o j} _ {v \rightarrow t} (\sum_ {i} \operatorname {s o f t m a x} (\frac {q (\bar {x}) k (x _ {i}) ^ {T}}{C}) \cdot v (x _ {i})) \\ = \sum_ {i} \operatorname {s o f t m a x} \left(\frac {q (\bar {x}) k (x _ {i}) ^ {T}}{C}\right) \cdot \operatorname {P r o j} _ {v \rightarrow t} (v (x _ {i})) = \operatorname {P o o l} \left(\operatorname {P r o j} _ {v \rightarrow t} (v (x _ {i}))\right), \\ \end{array}
83
+ $$
84
+
85
+ where $q, v$ and $k$ are independent linear embedding layers and $x = E_v(I)$ is the output feature map of the visual encoder. By removing the pooling operation, we can project the visual feature $x_i$ of each region $i$ to the textual space [70]:
86
+
87
+ $$
88
+ F _ {v} ^ {i} = \operatorname {P r o j} _ {v \rightarrow t} (v \left(x _ {i}\right)). \tag {4}
89
+ $$
90
+
91
+ For each region $i$ and each class $m$ , we compute cosine similarity between $F_{v}^{i}$ and $(F_{t}^{m})^{+} = E_{t}(\mathrm{Prompt}^{+})$ as $S_{i,m}^{+} = < F_{v}^{i}, (F_{t}^{m})^{+}>$ , and compute $S_{i,m}^{-}$ in the same way. In order to make a single prediction for the whole image, we aggregate $S_{i,m}^{+}$ and $S_{i,m}^{-}$ into $S_{m}^{+}$ and $S_{m}^{-}$ according to the magnitude of $S_{i,m}^{+}$ , i.e.:
92
+
93
+ $$
94
+ S _ {m} ^ {+} = A \left(S _ {i, m} ^ {+}\right) = \sum_ {i} \left(\operatorname {s o f t m a x} \left(S _ {i, m} ^ {+}\right) \cdot S _ {i, m} ^ {+}\right), \tag {5}
95
+ $$
96
+
97
+ $$
98
+ S _ {m} ^ {-} = A \left(S _ {i, m} ^ {-}\right) = \sum_ {i} \left(\operatorname {s o f t m a x} \left(S _ {i, m} ^ {+}\right) \cdot S _ {i, m} ^ {-}\right). \tag {6}
99
+ $$
100
+
101
+ Notably, we do not introduce any new parameters in our re-formulation of the spatial aggregation function. All parameters used to project visual features to the textual space are inherited from the original multi-headed attention pooling layer in CLIP.
102
+
103
+ **Optimization.** We apply the Asymmetric Loss (ASL) [51] to handle the inherent positive-negative imbalance in the optimization of multi-label recognition. Specially, we compute losses for a positive (image, label) pair $\mathcal{L}_{+}$ and a negative (image, label) pair $\mathcal{L}_{-}$ as follows:
104
+
105
+ $$
106
+ \mathcal {L} _ {+} = (1 - p) ^ {\gamma_ {+}} \log (p), \tag {7}
107
+ $$
108
+
109
+ $$
110
+ \mathcal {L} _ {-} = \left(p _ {c}\right) ^ {\gamma_ {-}} \log \left(1 - p _ {c}\right), \tag {8}
111
+ $$
112
+
113
+ where $p_c = \max(p - c, 0)$ is the probability for negative examples shifted by hard thresholding via the margin $c$ . We set the hyper-parameters $\gamma_{-} \geq \gamma_{+}$ , so that ASL down-weighs and hard-thresholds easy negative samples. The pair of learnable prompts are updated by back-propagating ASL through the frozen text encoder.
114
+
115
+ # 4 Experiments
116
+
117
+ # 4.1 Multi-Label Recognition with Partial Labels
118
+
119
+ Datasets. We conduct experiments on MS-COCO [34], VOC2007 [16] and BigEarth [5] to evaluate multi-label recognition with partial labels. MS-COCO [34] contains 80 common object categories
120
+
121
+ Table 1: Multi-label Recognition on MS-COCO and VOC2007 with partial labels. DualCoOp achieves the best performance over all SOTA methods. * indicates previous models using weights pretrained by CLIP [47]
122
+
123
+ <table><tr><td>Methods</td><td>#P</td><td>10%</td><td>20%</td><td>30%</td><td>40%</td><td>50%</td><td>60%</td><td>70%</td><td>80%</td><td>90%</td><td>Avg.</td></tr><tr><td colspan="12">MS-COCO [34]</td></tr><tr><td>SSGRL [9]</td><td>64.7M</td><td>62.5</td><td>70.5</td><td>73.2</td><td>74.5</td><td>76.3</td><td>76.5</td><td>77.1</td><td>77.9</td><td>78.4</td><td>74.1</td></tr><tr><td>GCN-ML [10]</td><td>44.9M</td><td>63.8</td><td>70.9</td><td>72.8</td><td>74.0</td><td>76.7</td><td>77.1</td><td>77.3</td><td>78.3</td><td>78.6</td><td>74.4</td></tr><tr><td>KGGR [7]</td><td>≥ 25M</td><td>66.6</td><td>71.4</td><td>73.8</td><td>76.7</td><td>77.5</td><td>77.9</td><td>78.4</td><td>78.7</td><td>79.1</td><td>75.6</td></tr><tr><td>Curriculum labeling [15]</td><td>≥ 38M</td><td>26.7</td><td>31.8</td><td>51.5</td><td>65.4</td><td>70.0</td><td>71.9</td><td>74.0</td><td>77.4</td><td>78.0</td><td>60.7</td></tr><tr><td>Patial BCE [15]</td><td>≥ 38M</td><td>61.6</td><td>70.5</td><td>74.1</td><td>76.3</td><td>77.2</td><td>77.7</td><td>78.2</td><td>78.4</td><td>78.5</td><td>74.7</td></tr><tr><td>SST [8]</td><td>33.5M</td><td>68.1</td><td>73.5</td><td>75.9</td><td>77.3</td><td>78.1</td><td>78.9</td><td>79.2</td><td>79.6</td><td>79.9</td><td>76.7</td></tr><tr><td>SST*</td><td>33.5M</td><td>69.1</td><td>78.5</td><td>79.3</td><td>79.9</td><td>80.1</td><td>80.5</td><td>81.1</td><td>80.7</td><td>80.7</td><td>78.9</td></tr><tr><td>SARB [46]</td><td>29.6M</td><td>71.2</td><td>75.0</td><td>77.1</td><td>78.3</td><td>78.9</td><td>79.6</td><td>79.8</td><td>80.5</td><td>80.5</td><td>77.9</td></tr><tr><td>SARB*</td><td>29.6M</td><td>75.5</td><td>78.5</td><td>79.0</td><td>79.5</td><td>80.4</td><td>80.2</td><td>80.8</td><td>80.6</td><td>80.8</td><td>79.4</td></tr><tr><td>DualCoOp (ours)</td><td>1.3M</td><td>78.7</td><td>80.9</td><td>81.7</td><td>82.0</td><td>82.5</td><td>82.7</td><td>82.8</td><td>83.0</td><td>83.1</td><td>81.9</td></tr><tr><td colspan="12">PASCAL VOC 2007 [16]</td></tr><tr><td>SSGRL [9]</td><td>66.6M</td><td>77.7</td><td>87.6</td><td>89.9</td><td>90.7</td><td>91.4</td><td>91.8</td><td>91.9</td><td>92.2</td><td>92.2</td><td>89.5</td></tr><tr><td>GCN-ML [10]</td><td>44.9M</td><td>74.5</td><td>87.4</td><td>89.7</td><td>90.7</td><td>91.0</td><td>91.3</td><td>91.5</td><td>91.8</td><td>92.0</td><td>88.9</td></tr><tr><td>KGGR [7]</td><td>≥ 25M</td><td>81.3</td><td>88.1</td><td>89.9</td><td>90.4</td><td>91.2</td><td>91.3</td><td>91.5</td><td>91.6</td><td>91.8</td><td>89.7</td></tr><tr><td>Curriculum labeling [15]</td><td>≥ 38M</td><td>44.7</td><td>76.8</td><td>88.6</td><td>90.2</td><td>90.7</td><td>91.1</td><td>91.6</td><td>91.7</td><td>91.9</td><td>84.1</td></tr><tr><td>Patial BCE [15]</td><td>≥ 38M</td><td>80.7</td><td>88.4</td><td>89.9</td><td>90.7</td><td>91.2</td><td>91.8</td><td>92.3</td><td>92.4</td><td>92.5</td><td>90.0</td></tr><tr><td>SST [8]</td><td>32.4M</td><td>81.5</td><td>89.0</td><td>90.3</td><td>91.0</td><td>91.6</td><td>92.0</td><td>92.5</td><td>92.6</td><td>92.7</td><td>90.4</td></tr><tr><td>SARB [46]</td><td>29.6M</td><td>83.5</td><td>88.6</td><td>90.7</td><td>91.4</td><td>91.9</td><td>92.2</td><td>92.6</td><td>92.8</td><td>92.9</td><td>90.7</td></tr><tr><td>DualCoOp (ours)</td><td>0.3M</td><td>90.3</td><td>92.2</td><td>92.8</td><td>93.3</td><td>93.6</td><td>93.9</td><td>94.0</td><td>94.1</td><td>94.2</td><td>93.2</td></tr></table>
124
+
125
+ and we use the official train2014 (82K images) and val2014 (40K images) splits for training and test. VOC2007 [16] contains 20 object categories and we use the official trainval (5K images) and test (5K images) splits for training and test. Furthermore, since CLIP pretraining data is not publicly available and it is plausible that CLIP pretraining data covers many coarse and fine-grained visual domains since it performs well in the zero-shot evaluation for many downstream tasks, we also experiment on a Remote Sensing Image dataset BigEarth [5], whose domain is far from the domains of the datasets in the mainstream papers (i.e. PASCAL VOC, MS-COCO, and NUS-WIDE). To create the training set with partial labels, we randomly mask out labels from the fully annotated training set<sup>1</sup> and use the remaining labels for training by following standard practice [8, 15, 46]. In this work, we vary the proportion of kept labels from $10\%$ to $90\%$ [8, 46].
126
+
127
+ Evaluation. On all datasets, we follow [8, 15, 46] to report the mean average precision (mAP) for each proportion of labels available for optimization (from $10\%$ to $90\%$ ) and its average value for all proportions. We count the learnable parameters (#P) of each baseline and Dua1Co0p to measure the complexity of optimization<sup>2</sup>. We also report the per-class and the average overall precision (CP and OP), recall (CR and OR), and F1 (CF1 and OF1) of Dua1Co0p under different proportions of labels for training in the supplementary material due to the page limit.
128
+
129
+ Implementation. We adopt ResNet-101 [19] as the visual encoder in all baselines and DualCoOp for input resolution $448 \times 448$ , and use the same Transformer [48, 58] in CLIP [47] as the text encoder. The visual and text encoders are initialized from the CLIP pretrained model and kept frozen during optimization. For each class/label, we learn two independent context vectors with 16 context tokens $(N = 16)$ following [71], which is the only learnable part in DualCoOp. We use the SGD optimizer with an initial rate of 0.002 which is decayed by the cosine annealing rule. We train context vectors for 50 epochs with a batch-size 32/8/32 for MS-COCO/VOC2007/BigEarth, respectively. For ASL loss, we choose $\gamma_{+} = 1$ , $\gamma_{-} = 2$ and $c = 0.05$ via validation. Training is done with one RTX A6000.
130
+
131
+ Baselines. To evaluate the effectiveness of DualCoOp, we compare with the following baselines: (1).SSGRL [9], GCN-ML [10] and KGGR [7] adopt graph neural networks to model label dependencies. We follow [8] to report their performance in the partial-label setting. (2). Curriculum labeling [15] and SST [8] generate pseudo labels for unknown labels. (3). Partial BCE [15] uses a normalized BCE loss to better exploit partial labels. (4). SARB [46] blends category-specific representation across different images to transfer information of known labels to complement unknown labels.
132
+
133
+ Table 2: Comparison between SARB and DualCoOp. Both use parameters pretrained by CLIP [47].
134
+
135
+ <table><tr><td>Method</td><td>10%</td><td>30%</td><td>50%</td><td>70%</td><td>90%</td><td>Avg.</td></tr><tr><td>SARB*</td><td>77.2</td><td>83.6</td><td>87.4</td><td>91.6</td><td>93.5</td><td>86.7</td></tr><tr><td>DualCoOp</td><td>88.2</td><td>93.1</td><td>93.7</td><td>94.2</td><td>94.7</td><td>92.8</td></tr></table>
136
+
137
+ Table 3: Computations Cost Comparison between SARB [46] and DualCoOp. * indicates previous models using weights pretrained by CLIP [47]
138
+
139
+ <table><tr><td>Methods</td><td>Training Latency (ms/img)</td><td>Training Memory (GB/img)</td><td>Testing Latency (ms/img)</td><td>Testing Memory (GB/img)</td><td>Avg. mAP (%)</td></tr><tr><td>SARB*</td><td>4.7</td><td>0.21</td><td>4.0</td><td>0.13</td><td>79.4</td></tr><tr><td>DualCoOp</td><td>5.3</td><td>0.22</td><td>4.0</td><td>0.06</td><td>81.9</td></tr></table>
140
+
141
+ Results. Table 1 shows the comparison of mAP between DualCoOp and all baselines optimized with $10\%$ to $90\%$ of labels. For the two most recent works (SST [8] and SARB [46]), we further substitute the ImageNet pretrained weights [19] with the CLIP pretrained weights [47] when initializing of their visual encoders, which results in $\mathrm{SST}^*$ and $\mathrm{SARB}^*$ in Table 1. Since we learn class-specific prompts, DualCoOp on MS-COCO adopts more learnable parameters than VOC2007. Our proposed DualCoOp achieves the best performance across all proportions of labels available during the training with the smallest learnable overhead (1.3M vs. 29.6M in $\mathrm{SARB}^*$ on MS-COCO and 0.3M vs. 29.6M in $\mathrm{SARB}^*$ on VOC2007). Notably, DualCoOp yields a great improvement over the second-best method, $3.2\%$ on MS-COCO and $6.8\%$ on VOC2007, especially when only providing $10\%$ of labels during the training. This indicates that DualCoOp can quickly adapt to the multi-label recognition task with a few labels. On BigEarth, we compare DualCoOp with the strong baseline SARB. Table 2 shows that DualCoOp consistently improves over SARB by $11.0\%$ when only providing $10\%$ of labels and $6.1\%$ for average performance which proves DualCoOp boosts the performance in various visual domains by taking advantage of the powerful vision-language pretraining.
142
+
143
+ Full Label Training. On MS-COCO, we use $100\%$ of training labels and finetune the visual encoder, DualCoOp achieves $85.2\%$ mAP, outperforming previous SOTA approaches like ASL [51] ( $85.0\%$ mAP) and CSRA [74] ( $83.5\%$ mAP) with the same ResNet-101 backbone. Without finetuning the visual encoder, we notice that our performance drops to $83.2\%$ mAP, which is still comparable to the performance of ASL and CSRA. Such a performance drop may be due to the noise in the image-text pairs used for pre-training the CLIP model and the misalignment of the objectives between the pre-training task and MLR task. This also shows that it is non-trivial to address the MLR task with the pretrained CLIP model, even though it is pre-trained with larger-scale data.
144
+
145
+ Computational Cost. We compare the computational cost between DualCoOp and SARB [46] in terms of training/testing latency and memory (see Table 3) using the same device (one Nvidia A100 GPU). For the current multi-label recognition task, the categories are pre-set before inference, (i.e. we already know which class we would like to consider during inference.) In this case, we compute the text features for each class from the learned prompts and the class name ahead of the inference. Then we use the pre-computed text features to predict each image during the test. Since the text features are pre-computed (very light-weighted computing overhead), the text encoder is not executed during inference. For inference, the latency time and memory consumption of DualCoOp are the same as other baselines when using the same backbone for the image encoder. During training, CLIP-based methods slightly raise latency time and memory consumption since image and text encoders are both executed during the forward, and only prompts are updated in DualCoOp.
146
+
147
+ # 4.2 Zero-shot Multi-Label Recognition
148
+
149
+ Datasets. Following [3, 22], we conduct experiments on MS-COCO [34] and NUS-WIDE [11] to perform zero-shot multi-label recognition. On MS-COCO, we follow [2, 3] to split the dataset into 48 seen classes and 17 unseen classes. NUS-WIDE [11] dataset includes 270K images. Following [3, 22] we use 81 human-annotated categories as unseen classes and an additional set of 925 labels obtained from Flickr tags as seen classes.
150
+
151
+ Evaluation. We follow [3] and report precision, recall, and F1 score at Top-3 predictions in each image on MS-COCO. We also follow [3, 22] to report mAP over all categories as well as precision, recall, and F1 score at Top-3 and Top-5 predictions in each image on NUS-WIDE. We evaluate all
152
+
153
+ Table 4: Zero-Shot Multi-Label Recognition on MS-COCO[34]. DualCoOp achieves the best F1 score in both ZSL and GZSL settings.
154
+
155
+ <table><tr><td rowspan="2">Methods</td><td rowspan="2">#P</td><td colspan="3">ZSL</td><td colspan="3">GZSL</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td></tr><tr><td>CONSE [45]</td><td>-</td><td>11.4</td><td>28.3</td><td>16.2</td><td>23.8</td><td>28.8</td><td>26.1</td></tr><tr><td>Fast0Tag [69]</td><td>0.61M</td><td>24.7</td><td>61.4</td><td>25.3</td><td>38.5</td><td>46.5</td><td>42.1</td></tr><tr><td>Deep0Tag [49]</td><td>≥ 23M</td><td>26.5</td><td>65.9</td><td>37.8</td><td>43.2</td><td>52.2</td><td>47.3</td></tr><tr><td>SDL (M=2) [3]</td><td>30.6M</td><td>26.3</td><td>65.3</td><td>37.5</td><td>59.0</td><td>60.8</td><td>59.9</td></tr><tr><td>DualCoOp (ours)</td><td>0.02M</td><td>35.3</td><td>87.6</td><td>50.3</td><td>58.4</td><td>68.1</td><td>62.9</td></tr></table>
156
+
157
+ Table 5: Zero-Shot Multi-label Recognition on NUS-WIDE [11]. DualCoOp achieves the best F1 score over all SOTA methods at Top-3/Top-5 predictions in both ZSL and GZSL settings.
158
+
159
+ <table><tr><td rowspan="2">Methods</td><td rowspan="2">#P</td><td colspan="3">Top-3</td><td colspan="3">Top-5</td><td rowspan="2">mAP</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td></tr><tr><td colspan="9">Zero-Shot Learning (ZSL)</td></tr><tr><td>CONSE [45]</td><td>-</td><td>17.5</td><td>28.0</td><td>21.6</td><td>13.9</td><td>37.0</td><td>20.2</td><td>9.4</td></tr><tr><td>LabelEM [1]</td><td>-</td><td>15.6</td><td>25.0</td><td>19.2</td><td>13.4</td><td>35.7</td><td>19.5</td><td>7.1</td></tr><tr><td>Fast0Tag [69]</td><td>0.61M</td><td>22.6</td><td>36.2</td><td>27.8</td><td>18.2</td><td>48.4</td><td>26.4</td><td>15.1</td></tr><tr><td>One Attention per Label [26]</td><td>≥ 12.8M</td><td>20.9</td><td>33.5</td><td>25.8</td><td>16.2</td><td>43.2</td><td>23.6</td><td>10.4</td></tr><tr><td>LESAM (M=10) [22]</td><td>≥ 0.45M</td><td>25.7</td><td>41.1</td><td>31.6</td><td>19.7</td><td>52.5</td><td>28.7</td><td>19.4</td></tr><tr><td>BiAM [44]</td><td>3.8M</td><td>-</td><td>-</td><td>33.1</td><td>-</td><td>-</td><td>30.7</td><td>26.3</td></tr><tr><td>SDL (M=7) [3]</td><td>33.6M</td><td>24.2</td><td>41.3</td><td>30.5</td><td>18.8</td><td>53.4</td><td>27.8</td><td>25.9</td></tr><tr><td>DualCoOp (ours)</td><td>0.02M</td><td>37.3</td><td>46.2</td><td>41.3</td><td>28.7</td><td>59.3</td><td>38.7</td><td>43.6</td></tr><tr><td colspan="9">Generalized Zero-Shot Learning (GZSL)</td></tr><tr><td>CONSE [45]</td><td>-</td><td>11.5</td><td>5.1</td><td>7.0</td><td>9.6</td><td>7.1</td><td>8.1</td><td>2.1</td></tr><tr><td>LabelEM [1]</td><td>-</td><td>15.5</td><td>6.8</td><td>9.5</td><td>13.4</td><td>9.8</td><td>11.3</td><td>2.2</td></tr><tr><td>Fast0Tag [69]</td><td>0.61M</td><td>18.8</td><td>8.3</td><td>11.5</td><td>15.9</td><td>11.7</td><td>13.5</td><td>3.7</td></tr><tr><td>One Attention per Label [26]</td><td>≥ 12.8M</td><td>17.9</td><td>7.9</td><td>10.9</td><td>15.6</td><td>11.5</td><td>13.2</td><td>3.7</td></tr><tr><td>LESAM (M=10) [22]</td><td>≥ 0.45M</td><td>23.6</td><td>10.4</td><td>14.4</td><td>19.8</td><td>14.6</td><td>16.8</td><td>5.6</td></tr><tr><td>BiAM [44]</td><td>3.8M</td><td>-</td><td>-</td><td>16.1</td><td>-</td><td>-</td><td>19.0</td><td>9.3</td></tr><tr><td>SDL (M=7) [3]</td><td>33.6M</td><td>27.7</td><td>13.9</td><td>18.5</td><td>23.0</td><td>19.3</td><td>21.0</td><td>12.1</td></tr><tr><td>DualCoOp (ours)</td><td>0.02M</td><td>31.9</td><td>13.9</td><td>19.4</td><td>26.2</td><td>19.1</td><td>22.1</td><td>12.0</td></tr></table>
160
+
161
+ methods with both zero-shot setting (test only on unseen classes) and generalized zero-shot setting (test on both seen and unseen classes).
162
+
163
+ Implementation. We adopt ResNet-50 [19] similar to [3] as the visual encoder in DualCoOp for input resolution 224. Instead of learning class-specific prompts, we learn the class-agnostic context vectors with 64 context tokens $(\mathrm{N} = 64)$ for all classes, which is the only learnable part in DualCoOp. We optimize context vectors for 50 epochs with a batch-size 32/192 for MS-COCO/NUS-WIDE, respectively. During inference, we combine the learnt pair of context vectors with the class name for each class (either base class or novel class) and compute the text features. Other implementation details are the same as in Sec. 4.1
164
+
165
+ Baselines. To evaluate the effectiveness of DualCoOp in the zero-shot setting, we compare with the following baselines: (1). CONSE [45] adopts an ensemble of classifiers for unseen classes. (2). LabelEM [1] learns a joint image-label embedding. (3). Fast0Tag [69] and SDL [3] estimate one or multiple diverse principal directions of the input images. (4). Deep0Tag [49] and LESA [22] estimate the relevant regions via region proposals and attention techniques respectively. (5). BiAM [44] enhances the region-based features to minimize inter-class feature entanglement.
166
+
167
+ Results. Table 4-5 shows the comparison between DualCoOp and all SOTA methods of zero-shot learning and generalized zero-shot learning on MS-COCO and NUS-WIDE datasets. DualCoOp achieves the best F1 score in all cases with a very light learnable overhead (0.02M) and improves the performance of zero-shot learning (unseen labels) with a significant margin: F1 score improves by 12.5 @Top-3 on MS-COCO, and by 10.8 @Top-3 and 10.9 @Top-5 on NUS-WIDE. This shows the power of exploiting the pretrained alignment of textual and visual spaces in CLIP via DualCoOp to solve multi-label recognition.
168
+
169
+ # 4.3 Ablation Studies
170
+
171
+ Effectiveness of Text Supervision. To show the effectiveness of text supervision from label space, we compare the model learned with discrete label space ("Discrete Label") with four methods (SST [8], SARB [46], CoOp [71] and DualCoOp) which introduce the textual space to utilize the contextual correlation of labels in Table 6. We find that methods with text supervision usually perform better
172
+
173
+ Table 6: Comparison among methods on MS-COCO using partial labels with the same initialization. All methods use parameters pretrained by CLIP [47].
174
+
175
+ <table><tr><td>Method</td><td>Text Supervision</td><td>10%</td><td>30%</td><td>50%</td><td>70%</td><td>90%</td></tr><tr><td>Discrete Label</td><td>✘</td><td>70.6</td><td>75.1</td><td>76.5</td><td>77.3</td><td>78.0</td></tr><tr><td>SST</td><td>✓</td><td>69.1</td><td>79.3</td><td>80.1</td><td>81.1</td><td>80.7</td></tr><tr><td>SARB</td><td>✓</td><td>75.5</td><td>79.0</td><td>80.4</td><td>80.8</td><td>80.8</td></tr><tr><td>CoOp</td><td>✓</td><td>63.0</td><td>68.5</td><td>69.2</td><td>71.5</td><td>75.0</td></tr><tr><td>DualCoOp</td><td>✓</td><td>78.4</td><td>81.0</td><td>82.0</td><td>82.5</td><td>82.8</td></tr></table>
176
+
177
+ Table 7: Ablation on Linguistic Inputs for Zero-Shot Learning of MS-COCO.
178
+
179
+ <table><tr><td rowspan="2" colspan="2">Linguistic Input</td><td rowspan="2">#P</td><td colspan="3">ZSL</td><td colspan="3">GZSL</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td></tr><tr><td>M0</td><td>Contextless Classname</td><td>0</td><td>5.2</td><td>12.9</td><td>7.4</td><td>3.5</td><td>4.1</td><td>3.8</td></tr><tr><td>M1</td><td>Hand-crafted Pos./Neg. Templates + ClassName</td><td>0</td><td>25.6</td><td>63.6</td><td>36.5</td><td>31.0</td><td>36.2</td><td>33.4</td></tr><tr><td>M2</td><td>Pos. Learnable Prompt + ClassName (N=64)</td><td>0.01M</td><td>31.2</td><td>77.5</td><td>44.5</td><td>55.7</td><td>65.0</td><td>60.0</td></tr><tr><td>M3</td><td>Neg. Learnable Prompt + ClassName (N=64)</td><td>0.01M</td><td>9.3</td><td>23.0</td><td>13.2</td><td>2.6</td><td>3.0</td><td>2.8</td></tr><tr><td>M4</td><td>Dual Learnable Prompts + ClassName (N=64)</td><td>0.02M</td><td>35.3</td><td>87.6</td><td>50.3</td><td>58.4</td><td>68.1</td><td>62.9</td></tr><tr><td>M5</td><td>Dual Learnable Prompts + ClassName (N=32)</td><td>0.01M</td><td>35.8</td><td>88.9</td><td>51.0</td><td>57.4</td><td>67.0</td><td>61.9</td></tr></table>
180
+
181
+ than the method only using discrete labels. However, when the semantic annotations are limited, text supervision sometimes yields worse performance (e.g. mAP of SST is $1.5\%$ lower than Discrete Labels with only $10\%$ of labels). CoOp [71] utilizes the visual-textual alignment. However, with the original multi-head attention and single positive prompt, it yields worse performance than Discrete Labels. To better utilize the well-pretrained alignment, DualCoOp learns dual context pairs and adopts class-specific region feature aggregation, which leads to great performance (e.g. $7.8\%$ higher than Discrete Labels with $10\%$ of labels) and quickly adapts to the dataset even with limited labels.
182
+
183
+ Ablation of Prompt Design. We compare our proposed dual learnable prompts with two hand-crafted prompts and one prompt learning method on the MS-COCO dataset with the zero-shot setting (see Table 7). Hand-crafted prompts can use either contextless class names [31] or manually designed prompt templates. In our experiments, we carefully choose the positive and negative prompt templates as "a photo of a [classname]" and "a photo without a [classname]". In contrast with performing the binary classification for each class with dual learnable prompts as the input, we also experiment with learning a single prompt of positive or negative contexts and use a chosen threshold (0.5 in our experiment) to make the prediction for each class. As we can see, the single positive prompt learning method (M2) performs better than non-learnable methods (M0 and M1), and a single negative learnable prompt (M3) achieves much worse accuracy than its positive counterpart (M2). However, when we include both positive and negative prompts, dual prompts (M4) performs even better than a single prompt, which indicates that DualCoOp learns complementary and beneficial information in the dual prompt pair. M4 also outperforms M2 in terms of mAP with both ZSL (77.53% vs. 64.74%) and GZSL (69.8% vs. 63.1%). To keep the same amount of learnable parameters as in single prompt settings, we also halve the token size (M5), and find that DualCoOp still outperforms two single prompts in M2 and M3 by large gaps, demonstrating the effectiveness of our dual-prompt design.
184
+
185
+ Multi-Headed Attention vs. Class-Specific Region Aggregation. In Table 8, we compare the adaptive ability of these two visual aggregation methods when training/testing with a larger resolution (see Table 8), which is crucial in multi-label recognition as spatial details matter. For a fair comparison, we only replace the class-specific region aggregation in DualCoOp with the original multi-headed attention layer in CLIP [48] at the end of the visual encoder. We adaptively resize the input feature map to match the input dimension of the multi-headed attention layer.
186
+
187
+ Table 8: Comparison between multi-headed attention and class-specific feature aggregation on MS-COCO
188
+
189
+ <table><tr><td>Visual Aggregation</td><td>Finetune.</td><td>Train Res.</td><td>Test Res.</td><td>10%</td><td>30%</td><td>50%</td><td>70%</td><td>90%</td></tr><tr><td rowspan="4">Multi-Headed Attention</td><td>X</td><td>224</td><td>224</td><td>70.4</td><td>74.1</td><td>74.8</td><td>75.4</td><td>75.7</td></tr><tr><td>X</td><td>224</td><td>448</td><td>65.9</td><td>70.2</td><td>71.2</td><td>72.0</td><td>72.1</td></tr><tr><td>X</td><td>448</td><td>448</td><td>72.1</td><td>75.5</td><td>76.5</td><td>77.1</td><td>77.3</td></tr><tr><td>✓</td><td>448</td><td>448</td><td>74.1</td><td>77.6</td><td>78.2</td><td>78.5</td><td>78.4</td></tr><tr><td rowspan="5">Class-Specific Feature Aggregation (DualCoOp)</td><td>X</td><td>224</td><td>224</td><td>73.1</td><td>76.4</td><td>77.7</td><td>78.2</td><td>78.4</td></tr><tr><td>X</td><td>224</td><td>448</td><td>76.0</td><td>78.1</td><td>79.5</td><td>80.3</td><td>80.5</td></tr><tr><td>X</td><td>448</td><td>448</td><td>78.4</td><td>81.1</td><td>82.0</td><td>82.5</td><td>82.8</td></tr><tr><td>✓(Aggre. Func.)</td><td>448</td><td>448</td><td>79.4</td><td>82.2</td><td>83.1</td><td>83.7</td><td>84.0</td></tr><tr><td>✓(Image Enc.)</td><td>448</td><td>448</td><td>57.8</td><td>69.0</td><td>73.7</td><td>80.9</td><td>84.2</td></tr></table>
190
+
191
+ As shown in Table 8, multi-headed attention is bonded to the pre-training image resolution (224 in CLIP), while our class-specific region aggregation benefits from the increased input resolution either during training or in inference. Our class-specific feature aggregation uses original weights, but actually performs better than finetuning the original multi-headed attention layer.
192
+
193
+ Ablation of Finetuning DualCoOp. To better examine the effectiveness of finetuning for DualCoOp, we have implemented two different finetuning mechanisms for DualCoOp: (1). only finetune the weights in Class-Specific Region Feature Aggregation, (2). finetune all weights in the CLIP image-encoder. As shown in Table 8, finetuning aggregation function can stably improve the performance over the non-finetuning setting with different amounts of labels available. However, finetuning the entire visual encoder does not always outperform the non-finetuning baseline, especially under limited annotations ( $\leq 70\%$ labels).
194
+
195
+ ![](images/02dca2e3b476f21a401a593c4026ce2bc3469cb605ca365fb5a9451a779b3541.jpg)
196
+ Figure 3: Comparison among different aggregations on MS-COCO using partial labels.
197
+
198
+ Ablation of Aggregation Function. We experiment with
199
+
200
+ different functions to aggregate the regional logits for each class in Fig. 3. We compute final logits in three ways: (1) taking the average of logits at all spatial locations ("Ave"), (2) taking the region with the largest positive logit ("Max"), and (3) generating aggregating weights for all spatial locations via a softmax function over the positive logits ("Ours"). "Max" performs better than "Ave", which indicates the regional feature is more informative than the global feature in multi-label recognition. Furthermore, by taking account of both the regional and the global features, "Ours" gives the best performance.
201
+
202
+ # 5 Conclusion
203
+
204
+ In this paper, we propose a unified framework, DualCo0p, for two types of multi-label recognition with limited annotations: partial-label and zero-shot. DualCo0p utilizes powerful vision-language pretraining obtained from a web-scale dataset. By introducing a lightweight learnable overhead, it can quickly adapt to solve multi-label recognition after receiving a small amount of labels. In DualCo0p, we learn a pair of positive and negative prompts followed by the target class name as the linguistic input. Furthermore, to better aggregate visual region features for each class, we reformulate the original visual attention in the pretraining model as a class-specific region feature aggregation. We conduct extensive experiments for both partial-label MLR and Zero-Shot MLR across MS-COCO, VOC2007, and NUS-WIDE datasets, showing the efficacy of our proposed approach over state-of-the-art methods.
205
+
206
+ Limitations. Since the vision-language pretraining adopts a large Transformer-based language model and all labels need to be feed-forward through the text encoder, the large language model limits the size of the label set. Also, compared to training the model with both seen and unseen labels, we still get worse performance for the zero-shot unseen classes even though we have used 400M auxiliary samples in the pretraining. This highlights the difficulty of zero-shot MLR.
207
+
208
+ Negative Societal Impacts. Negative impacts of our research are difficult to predict, however, they are likely to be the usual pitfalls associated with deep learning models. These include susceptibility to adversarial attacks and data poisoning, dataset bias, and lack of interpretability. Other risks associated with the deployment of computer vision systems include privacy violations when images are captured without consent, or used to track individuals for profit, or increased automation resulting in job losses. While we believe that these issues should be mitigated, they are beyond the scope of this paper. Furthermore, we should be cautious of potential failures of the approach which could impact the performance/user experience of any high-level AI systems based on our research.
209
+
210
+ # Acknowledgement
211
+
212
+ This work is supported by NSF and DARPA LwLL. It reflects the opinions and conclusions of its authors, but not necessarily the funding agents.
213
+
214
+ # References
215
+
216
+ [1] Zeynep Akata, Florent Perronnin, Zaid Harchaoui, and Cordelia Schmid. Label-embedding for image classification. IEEE Trans. on PAMI, 38(7):1425–1438, 2015.
217
+ [2] Ankan Bansal, Karan Sikka, Gaurav Sharma, Rama Chellappa, and Ajay Divakaran. Zero-shot object detection. In ECCV, 2018.
218
+ [3] Avi Ben-Cohen, Nadav Zamir, Emanuel Ben-Baruch, Itamar Friedman, and Lihi Zelnik-Manor. Semantic diversity learning for zero-shot multi-label classification. In ICCV, 2021.
219
+ [4] Serhat Selcuk Bucak, Rong Jin, and Anil K Jain. Multi-label learning with incomplete class assignments. In CVPR, 2011.
220
+ [5] Bindita Chaudhuri, Begum Demir, Subbasis Chaudhuri, and Lorenzo Bruzzone. Multilabel remote sensing image retrieval using a semisupervised graph-theoretic method. IEEE Transactions on Geoscience and Remote Sensing, 56(2):1144-1158, 2018.
221
+ [6] Minmin Chen, Alice Zheng, and Kilian Weinberger. Fast image tagging. In ICML, 2013.
222
+ [7] Tianshui Chen, Liang Lin, Xiaolu Hui, Riquan Chen, and Hefeng Wu. Knowledge-guided multi-label few-shot learning for general image recognition. IEEE Trans. on PAMI, 2020.
223
+ [8] Tianshui Chen, Tao Pu, Hefeng Wu, Yuan Xie, and Liang Lin. Structured semantic transfer for multi-label recognition with partial labels. 2022.
224
+ [9] Tianshui Chen, Muxin Xu, Xiaolu Hui, Hefeng Wu, and Liang Lin. Learning semantic-specific graph representation for multi-label image recognition. In ICCV, 2019.
225
+ [10] Zhao-Min Chen, Xiu-Shen Wei, Peng Wang, and Yanwen Guo. Multi-label image recognition with graph convolutional networks. In CVPR, 2019.
226
+ [11] Tat-Seng Chua, Jinhui Tang, Richang Hong, Haojie Li, Zhiping Luo, and Yantao Zheng. Nus-wide: a real-world web image database from national university ofsingapore. In ICIVR, 2009.
227
+ [12] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In CVPR. IEEE, 2009.
228
+ [13] Li Dong, Nan Yang, Wenhui Wang, Furu Wei, Xiaodong Liu, Yu Wang, Jianfeng Gao, Ming Zhou, and Hsiao-Wuen Hon. Unified language model pre-training for natural language understanding and generation. NeurIPS, 2019.
229
+ [14] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv:2010.11929, 2020.
230
+ [15] Thibaut Durand, Nazanin Mehrasa, and Greg Mori. Learning a deep convnet for multi-label classification with partial labels. In CVPR, 2019.
231
+ [16] Mark Everingham, Luc Van Gool, Christopher KI Williams, John Winn, and Andrew Zisserman. The pascal visual object classes (voc) challenge. IJCV, 88(2):303-338, 2010.
232
+ [17] Peng Gao, Shijie Geng, Renrui Zhang, Teli Ma, Rongyao Fang, Yongfeng Zhang, Hongsheng Li, and Yu Qiao. Clip-adapter: Better vision-language models with feature adapters. arXiv preprint arXiv:2110.04544, 2021.
233
+ [18] Akshita Gupta, Sanath Narayan, Salman Khan, Fahad Shahbaz Khan, Ling Shao, and Joost van de Weijer. Generative multi-label zero-shot learning. arXiv preprint arXiv:2101.11606, 2021.
234
+ [19] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016.
235
+ [20] Tony Huang, Jack Chu, and Fangyun Wei. Unsupervised prompt learning for vision-language models. arXiv preprint arXiv:2204.03649, 2022.
236
+ [21] Dat Huynh and Ehsan Elhamifar. Interactive multi-label cnn learning with partial labels. In CVPR, 2020.
237
+ [22] Dat Huynh and Ehsan Elhamifar. A shared multi-attention framework for multi-label zero-shot learning. In CVPR, 2020.
238
+
239
+ [23] Chao Jia, Yinfei Yang, Ye Xia, Yi-Ting Chen, Zarana Parekh, Hieu Pham, Quoc Le, Yun-Hsuan Sung, Zhen Li, and Tom Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. In ICML, 2021.
240
+ [24] Armand Joulin, Laurens van der Maaten, Allan Jabri, and Nicolas Vasilache. Learning visual features from large weakly supervised data. In ECCV, 2016.
241
+ [25] Chen Ju, Tengda Han, Kunhao Zheng, Ya Zhang, and Weidi Xie. Prompting visual-language models for efficient video understanding. arXiv preprint arXiv:2112.04478, 2021.
242
+ [26] Jin-Hwa Kim, Jaehyun Jun, and Byoung-Tak Zhang. Bilinear Attention Networks. In NIPS, 2018.
243
+ [27] Ranjay Krishna, Yuke Zhu, Oliver Groth, Justin Johnson, Kenji Hata, Joshua Kravitz, Stephanie Chen, Yannis Kalantidis, Li-Jia Li, David A Shamma, et al. Visual genome: Connecting language and vision using crowdsourced dense image annotations. IJCV, 123(1):32-73, 2017.
244
+ [28] Alina Kuznetsova, Hassan Rom, Neil Alldrin, Jasper Uijlings, Ivan Krasin, Jordi Pont-Tuset, Shahab Kamali, Stefan Popov, Matteo Malloci, Alexander Kolesnikov, et al. The open images dataset v4. IJCV, 128(7):1956-1981, 2020.
245
+ [29] Chung-Wei Lee, Wei Fang, Chih-Kuan Yeh, and Yu-Chiang Frank Wang. Multi-label zero-shot learning with structured knowledge graphs. In CVPR, 2018.
246
+ [30] Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. arXiv preprint arXiv:2104.08691, 2021.
247
+ [31] Ang Li, Allan Jabri, Armand Joulin, and Laurens Van Der Maaten. Learning visual n-grams from web data. In ICCV, 2017.
248
+ [32] Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. arXiv preprint arXiv:2101.00190, 2021.
249
+ [33] Yining Li, Chen Huang, Chen Change Loy, and Xiaou Tang. Human attribute recognition by deep hierarchical contexts. In ECCV, 2016.
250
+ [34] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dólar, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In ECCV, 2014.
251
+ [35] Feng Liu, Tao Xiang, Timothy M Hospedales, Wankou Yang, and Changyin Sun. Semantic regularisation for recurrent image annotation. In CVPR, 2017.
252
+ [36] Weiwei Liu and Ivor Tsang. On the optimality of classifier chain for multi-label classification. NIPS, 28, 2015.
253
+ [37] Yongcheng Liu, Lu Sheng, Jing Shao, Junjie Yan, Shiming Xiang, and Chunhong Pan. Multi-label image classification via knowledge distillation from weakly-supervised detection. In ACM MM, 2018.
254
+ [38] Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. In ICCV, 2021.
255
+ [39] Yuning Lu, Jianzhuang Liu, Yonggang Zhang, Yajing Liu, and Xinmei Tian. Prompt distribution learning. arXiv preprint arXiv:2205.03340, 2022.
256
+ [40] Timo Lüddecke and Alexander S. Ecker. Prompt-based multi-modal image segmentation. arXiv preprint arXiv:2112.10003, 2021.
257
+ [41] Dhruv Mahajan, Ross Girshick, Vignesh Ramanathan, Kaiming He, Manohar Paluri, Yixuan Li, Ashwin Bharambe, and Laurens Van Der Maaten. Exploring the limits of weakly supervised pretraining. In ECCV, 2018.
258
+ [42] Thomas Mensink, Efstratios Gavves, and Cees GM Snoek. Costa: Co-occurrence statistics for zero-shot classification. In CVPR, 2014.
259
+ [43] Ishan Misra, C Lawrence Zitnick, Margaret Mitchell, and Ross Girshick. Seeing through the human reporting bias: Visual classifiers from noisy human-centric labels. In CVPR, 2016.
260
+ [44] Sanath Narayan, Akshita Gupta, Salman Khan, Fahad Shahbaz Khan, Ling Shao, and Mubarak Shah. Discriminative region-based multi-label zero-shot learning. In ICCV, 2021.
261
+
262
+ [45] Mohammad Norouzi, Tomas Mikolov, Samy Bengio, Yoram Singer, Jonathon Shlens, Andrea Frome, Greg S Corrado, and Jeffrey Dean. Zero-shot learning by convex combination of semantic embeddings. arXiv preprint arXiv:1312.5650, 2013.
263
+ [46] Tao Pu, Tianshui Chen, Hefeng Wu, and Liang Lin. Semantic-aware representation blending for multi-label image recognition with partial labels. In AAAI, 2022.
264
+ [47] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In ICML, 2021.
265
+ [48] Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 2019.
266
+ [49] Shafin Rahman and Salman Khan. Deep multiple instance learning for zero-shot image tagging. In ACCV, 2018.
267
+ [50] Shafin Rahman, Salman Khan, and Nick Barnes. Deep0tag: Deep multiple instance learning for zero-shot image tagging. IEEE Trans. on MM, 22(1):242-255, 2019.
268
+ [51] Tal Ridnik, Emanuel Ben-Baruch, Nadav Zamir, Asaf Noy, Itamar Friedman, Matan Protter, and Lihi Zelnik-Manor. Asymmetric loss for multi-label classification. In ICCV, 2021.
269
+ [52] Nikolaos Sarafianos, Xiang Xu, and Ioannis A Kakadiaris. Deep imbalanced attribute classification using visual attention aggregation. In ECCV, 2018.
270
+ [53] Taylor Shin, Yasaman Razeghi, Robert L Logan IV, Eric Wallace, and Sameer Singh. Autoprompt: Eliciting knowledge from language models with automatically generated prompts. arXiv preprint arXiv:2010.15980, 2020.
271
+ [54] Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014.
272
+ [55] Chen Sun, Abhinav Shrivastava, Saurabh Singh, and Abhinav Gupta. Revisiting unreasonable effectiveness of data in deep learning era. In ICCV, 2017.
273
+ [56] Yu-Yin Sun, Yin Zhang, and Zhi-Hua Zhou. Multi-label learning with weak label. In AAAI, 2010.
274
+ [57] Grigorios Tsoumakas and Ioannis Katakis. Multi-label classification: An overview. International Journal of Data Warehousing and Mining, 3(3):1-13, 2007.
275
+ [58] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. NIPS, 2017.
276
+ [59] Jiang Wang, Yi Yang, Junhua Mao, Zhiheng Huang, Chang Huang, and Wei Xu. Cnn-rnn: A unified framework for multi-label image classification. In CVPR, 2016.
277
+ [60] Meng Wang, Changzhi Luo, Richang Hong, Jinhui Tang, and Jiashi Feng. Beyond object proposals: Random crop pooling for multi-label image recognition. IEEE Trans on IP, 25(12):5678-5688, 2016.
278
+ [61] Ya Wang, Dongliang He, Fu Li, Xiang Long, Zhichao Zhou, Jinwen Ma, and Shilei Wen. Multi-label classification with label graph superimposing. In AAAI, 2020.
279
+ [62] Zhouxia Wang, Tianshui Chen, Guanbin Li, Ruijia Xu, and Liang Lin. Multi-label image recognition by recurrently discovering attentional regions. In ICCV, 2017.
280
+ [63] Mitchell Wortsman, Gabriel Ilharco, Mike Li, Jong Wook Kim, Hannaneh Hajishirzi, Ali Farhadi, Hongseok Namkoong, and Ludwig Schmidt. Robust fine-tuning of zero-shot models. arXiv preprint arXiv:2109.01903, 2021.
281
+ [64] Ming-Kun Xie and Sheng-Jun Huang. Partial multi-label learning. In AAAI, 2018.
282
+ [65] Yuan Yao, Ao Zhang, Zhengyan Zhang, Zhiyuan Liu, Tat-Seng Chua, and Maosong Sun. Cpt: Colorful prompt tuning for pre-trained vision-language models. arXiv preprint arXiv:2109.11797, 2021.
283
+ [66] Vacit Oguz Yazici, Abel Gonzalez-Garcia, Arnau Ramisa, Bartlomiej Twardowski, and Joost van de Weijer. Orderless recurrent models for multi-label classification. In CVPR, 2020.
284
+ [67] Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning (still) requires rethinking generalization. Communications of the ACM, 64(3):107-115, 2021.
285
+
286
+ [68] Renrui Zhang, Rongyao Fang, Peng Gao, Wei Zhang, Kunchang Li, Jifeng Dai, Yu Qiao, and Hongsheng Li. Tip-adapter: Training-free clip-adapter for better vision-language modeling. arXiv preprint arXiv:2111.03930, 2021.
287
+ [69] Yang Zhang, Boqing Gong, and Mubarak Shah. Fast zero-shot image tagging. In CVPR, 2016.
288
+ [70] Chong Zhou, Chen Change Loy, and Bo Dai. Denseclip: Extract free dense labels from clip. arXiv preprint arXiv:2112.01071, 2021.
289
+ [71] Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Learning to prompt for vision-language models. arXiv preprint arXiv:2109.01134, 2021.
290
+ [72] Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Conditional prompt learning for vision-language models. arXiv preprint arXiv:2203.05557, 2022.
291
+ [73] Feng Zhu, Hongsheng Li, Wanli Ouyang, Nenghai Yu, and Xiaogang Wang. Learning spatial regularization with image-level supervisions for multi-label image classification. In CVPR, 2017.
292
+ [74] Ke Zhu and Jianxin Wu. Residual attention: A simple but effective method for multi-label recognition. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 184-193, 2021.
293
+
294
+ # Checklist
295
+
296
+ 1. For all authors...
297
+
298
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper's contributions and scope? [Yes]
299
+ (b) Did you describe the limitations of your work? [Yes] Please refer to the limitations in the conclusion
300
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] Please refer to the Negative Societal Impacts. in the conclusion
301
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
302
+
303
+ 2. If you are including theoretical results...
304
+
305
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A]
306
+ (b) Did you include complete proofs of all theoretical results? [N/A]
307
+
308
+ 3. If you ran experiments...
309
+
310
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] Please check our project page included in the abstract and https://github.com/sunxm2357/DualCoOp for our code. We use public datasets which can downloaded directly and provide the details for the hyperparameters in the training see Sec. 4
311
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] Please check implementation details in Sec. 4
312
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No]
313
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] Please check implementation details in Sec. 4
314
+
315
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
316
+
317
+ (a) If your work uses existing assets, did you cite the creators? [N/A]
318
+ (b) Did you mention the license of the assets? [N/A]
319
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
320
+ (d) Did you discuss whether and how consent was obtained from people whose data you're using/curating? [N/A]
321
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
322
+
323
+ 5. If you used crowdsourcing or conducted research with human subjects...
324
+
325
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
326
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
327
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
dualcoopfastadaptationtomultilabelrecognitionwithlimitedannotations/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:37bffb13ae9186422d8dec96b06dae79a87d06d95bb0a69fa6168fa7229f2b96
3
+ size 593811
dualcoopfastadaptationtomultilabelrecognitionwithlimitedannotations/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f9623fd68ac6940a3da233ff0aa69cee505e91bf4a5c884cd1ea4cb30157f67
3
+ size 424042
dualcurriculumcontrastivemultiinstancelearningforcancerprognosisanalysiswithwholeslideimages/5b1c0314-65cc-4c15-ad5e-c31a6e0ab1b5_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6a3d1e937a136b5791759d61ef9cc7813267b0b008025c9ebac375fde9f4bf84
3
+ size 88880
dualcurriculumcontrastivemultiinstancelearningforcancerprognosisanalysiswithwholeslideimages/5b1c0314-65cc-4c15-ad5e-c31a6e0ab1b5_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b549d592b518aa0376ac80fc405ad5cbd72b7810fd0ce3b0433b58c3ae9f58ec
3
+ size 109897
dualcurriculumcontrastivemultiinstancelearningforcancerprognosisanalysiswithwholeslideimages/5b1c0314-65cc-4c15-ad5e-c31a6e0ab1b5_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:95f64f2fcd37573a1c37614b6b5fc69783309ffe0918b996910461e7778e4ce8
3
+ size 1647357
dualcurriculumcontrastivemultiinstancelearningforcancerprognosisanalysiswithwholeslideimages/full.md ADDED
@@ -0,0 +1,370 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dual-Curriculum Contrastive Multi-Instance Learning for Cancer Prognosis Analysis with Whole Slide Images
2
+
3
+ Chao Tu $^{1,2,3}$ , Yu Zhang $^{1,2,3,*}$ , Zhenyuan Ning $^{1,2,3,*}$
4
+
5
+ $^{1}$ School of Biomedical Engineering, $^{2}$ Guangdong Provincial Key Laboratory of Medical Image Processing, $^{3}$ Guangdong Province Engineering Laboratory for Medical Imaging and Diagnostic Technology, Southern Medical University, Guangzhou 510515, China {tchaoc17@smu.edu.cn, yuzhang@smu.edu.cn, jonnyning@foxmail.com} *Corresponding authors.
6
+
7
+ # Abstract
8
+
9
+ The multi-instance learning (MIL) has advanced cancer prognosis analysis with whole slide images (WSIs). However, current MIL methods for WSI analysis still confront unique challenges. Previous methods typically generate instance representations via a pre-trained model or a model trained by the instances with bag-level annotations, which, however, may not generalize well to the downstream task due to the introduction of excessive label noises and the lack of fine-grained information across multi-magnification WSIs. Additionally, existing methods generally aggregate instance representations as bag ones for prognosis prediction and have no consideration of intra-bag redundancy and inter-bag discrimination. To address these issues, we propose a dual-curriculum contrastive MIL method for cancer prognosis analysis with WSIs. The proposed method consists of two curriculums, i.e., saliency-guided weakly-supervised instance encoding with cross-scale tiles and contrastive-enhanced soft-bag prognosis inference. Extensive experiments on three public datasets demonstrate that our method outperforms state-of-the-art methods in this field. The code is available at https://github.com/YuZhang-SMU/CancerPrognosis-Analysis/tree/main/DC_MIL%20Code.
10
+
11
+ # 1 Introduction
12
+
13
+ Cancer prognosis analysis is of great significance for risk-benefit assessment and clinical decision [1]. Computational whole slide image (WSI), which entails the quantitative profiling of spatial patterns and tumor microenvironments in tissue slides, has advanced the application of deep learning in cancer prognosis analysis [2, 3]. However, deep learning in WSIs is often hindered by the gigapixel size and the lack of pixel-level annotations [4]. Recently, multi-instance learning (MIL) methods have attracted increasing attention to performing inference in a weakly-supervised manner and have been successfully applied to WSI analysis [5, 6, 7].
14
+
15
+ In general, the MIL consists of two stages, i.e., instance encoding stage and instance aggregation stage [8, 9]. In the encoding stage, several methods have utilized the pre-trained model (e.g., ResNet on ImageNet) to extract instance representations in an unsupervised way (i.e., without the reference of outcome labels) [10, 11, 12]. However, recent studies have demonstrated that the pre-trained model may not generalize well to the downstream tasks as it is task-agnostic<sup>1</sup> and inclined to overfit
16
+
17
+ the pretraining objective [13, 14, 15]. Alternatively, some work directly assigned each instance the bag-level annotation (i.e., the survival time of patient) for network training, which introduces task-specific supervision and improves model's generalisability [16, 17, 18]. Actually, the prognosis evaluation is primarily and comprehensively determined by certain representative regions, yet those regions might only occupy a small portion of WSI [17]. As a result, the strong supervision on all instances, especially on prognosis-irrelevant tiles, will introduce excessive label noises and limit model's performance [19, 20]. For alleviating this issue, a feasible way is to supervise the instance encoding in a weak and easy-to-hard manner. On the other hand, existing methods often generate mono-scale instance representations [11, 21] or typically concatenate multi-scale information from multi-magnification WSIs [22, 23], which may cause feature redundancy and ignore fine-grained details across multi-magnification images.
18
+
19
+ In the aggregation stage, most previous studies aggregated instance representations within a bag for prognosis estimation by certain fusion strategies (e.g., pooling operation and attention mechanism) [24, 25]. However, it may overwhelm prognosis-relevant information, cause intra-bag redundancy, and reduce inter-bag discrimination, if many instances from irrelevant regions are enrolled [12, 26]. To address the aforementioned issues, we arm MIL with a dual-curriculum strategy and propose a dual-curriculum contrastive MIL method for cancer prognosis analysis with WSIs. The proposed method consists of two easy-to-hard curriculums, i.e., saliency-guided weakly-supervised instance encoding with cross-scale tiles and contrastive-enhanced soft-bag prognosis inference. The main contributions are summarized as follows:
20
+
21
+ 1) We present a dual-curriculum contrastive MIL method which includes two easy-to-hard curriculums. We first conduct a preliminary task to learn instance representations by considering risk stratification status (degraded from survival time) as annotation, followed by the prognosis inference with survival time as supervision.
22
+ 2) We design the first curriculum of saliency-guided weakly-supervised instance encoding with cross-scale tiles. It is supervised by relatively weak annotations so as to reduce label noises and maintain prognosis-related guidance. Additionally, to imitate the reviewing procedure of pathologists, we leverage the low-magnification saliency map to guide the encoding of high-magnification instances for exploring fine-grained information across multi-magnification WSIs.
23
+ 3) We develop the second curriculum of contrastive-enhanced soft-bag prognosis inference. Instead of enrolling all instances, we adaptively identify and integrate representative instances within a bag (as the soft-bag) for prognosis inference and leverage the constrained self-attention strategy to obtain extra sparseness for soft-bag representations, which can help reduce intra-bag redundancy in both instance and feature levels. Meanwhile, we improve the Cox loss with two-tier contrastive learning for enhancing intra-bag and inter-bag discrimination.
24
+ 4) We evaluate the proposed method on three public cancer datasets, and extensive experiments demonstrate its superiority in cancer prognosis analysis with WSIs.
25
+
26
+ # 2 Related Work
27
+
28
+ # 2.1 WSI-based Cancer Prognosis Model
29
+
30
+ In recent years, many methods, especially convolutional neural networks (CNNs), have been developed for cancer prognosis evaluation with WSIs [27, 28, 29]. Due to the gigapixel size of WSI, some methods took small-size ROIs selectively sampled from WSIs as network's input for training and inference, in which all ROIs were assigned with patient-level outcome labels [30, 31]. However, these methods generally require prior knowledge from pathologists, which is experience-dependent and may suffer from high inter-observer variation. Therefore, current researches have proposed to crop the entire WSI into many tiles for model's input so as to make full use of available information contained by WSI [10, 32, 33]. However, these methods often confront the lack of tile-level annotations and may result in a sub-optimal solution. To this end, MIL methods have been introduced to perform cancer prognosis analysis in a weakly-supervised manner and have shown promising performance in this field [5, 28].
31
+
32
+ # 2.2 Multi-instance Learning in WSI Analysis
33
+
34
+ The MIL methods in WSI analysis can be roughly divided into two categories according to the way instances are leveraged in the model [12, 17]. The one infers bag-level prediction from instance-level probabilities via average pooling, maximum pooling, or other ensemble strategies [34, 35]. By comparison, the other one, referred to as the bag embedding method, aggregates instance representations as bag ones, upon which a model is constructed for bag-level prediction [36, 37]. The former is simple and straightforward but empirically proven to be inferior to the latter in terms of generalization performance. Therefore, the bag embedding method has attracted extensive attention in WSI analysis [17]. For example, Courtiol et al. [6] developed a MIL method based on CNN, called MesoNet, to accurately predict the overall survival of mesothelioma patients with WSIs. Yao et al. [5] proposed a deep attention multi-instance survival model to efficiently learn features from WSIs and fuse them for prognosis prediction. Our method essentially belongs to the bag embedding method. Different from previous work, the proposed method consists of two easy-to-hard curriculums, comprehensively considering fine-grained information across multi-magnification WSIs, intra-bag redundancy, and inter-bag discrimination.
35
+
36
+ # 3 Method
37
+
38
+ # 3.1 Problem Formulation
39
+
40
+ Denote the triplet $\{\mathbf{X}_n, \mathbf{T}_n, \delta_n\}_{n=1}^N$ as the dataset consisting of $N$ patients, where $\mathbf{X}_n$ is the $n$ -th patient with one or more WSIs, and $\mathbf{T}_n$ and $\delta_n$ are respectively its observed survival time and event indicator (viz. equals to 1 and 0 for uncensored and censored samples, respectively). Prognosis analysis is an ordinal regression task that models time-to-event distribution, which is formulated as
41
+
42
+ $$
43
+ \hat {\mathbf {T}} _ {n} = \mathbb {S} (\mathbf {X} _ {n}), \tag {1}
44
+ $$
45
+
46
+ where $\mathbb{S}$ and $\hat{\mathbf{T}}_n$ denote the prognosis inference function and the estimated survival time, respectively. In practice, it is difficult to directly feed the WSI into the model due to its gigapixel size. Accordingly, many studies [10, 32, 33] have cropped the WSI into a large amount of tiles and generated a bag $\mathbf{X}_n = \{\mathbf{x}_{n,i}\}_{i = 1}^{N_n}$ that contains $N_{n}$ instances (tiles) for the $n$ -th patient. Then, MIL is leveraged to construct the prognosis model as follows:
47
+
48
+ $$
49
+ \hat {\mathbf {T}} _ {n} = \mathbb {S} (\mathbb {A} \left\{\mathbb {E} \left(\mathbf {x} _ {n, i}\right): \mathbf {x} _ {n, i} \in \mathbf {X} _ {n} \right\}), \tag {2}
50
+ $$
51
+
52
+ where $\mathbb{E}$ is an instance encoding function that extracts feature representation for each instance, and $\mathbb{A}$ is a permutation-invariant instance aggregation function that pools the instance representations into the bag ones. However, previous studies [10, 11, 12, 16, 17, 18] typically generate instance representations via a pre-trained model or a model trained by the instances with bag-level annotations, which may not generalize well to the downstream task. As a result, we decompose the model into two easy-to-hard curriculums, including (1) Curriculum I (C-I): instance encoding (via $\mathbb{E}$ ) during preliminary risk stratification (via $\mathbb{C}$ , a risk stratification function), and (2) Curriculum II (C-II): prognosis inference (via $\mathbb{S}$ ) after instance aggregation (via $\mathbb{A}$ ). Formally, the optimization process can be formulated as
53
+
54
+ $$
55
+ \left\{ \begin{array}{l} \mathrm {C - I}: \hat {\mathbb {E}}, \hat {\mathbb {C}} = \arg \min _ {\mathbb {E}, \mathbb {C}} \sum_ {n = 1} ^ {N} \dagger (\mathbf {Y} _ {n} = = 1 \| 0) \sum_ {i = 1} ^ {N _ {n}} [ \mathbb {C} \{\mathbb {E} (\mathbf {x} _ {n, i}): \mathbf {x} _ {n, i} \in \mathbf {X} _ {n} \}, \mathbf {Y} _ {n} ] _ {\mathcal {L} _ {1}} \\ \mathrm {C - I I}: \hat {\mathbb {S}}, \hat {\mathbb {A}} = \arg \min _ {\mathbb {S}, \mathbb {A}} \sum_ {n = 1} ^ {N} [ \mathbb {S} (\mathbb {A} \{\hat {\mathbb {E}} (\mathbf {x} _ {n, i}): \mathbf {x} _ {n, i} \in \mathbf {X} _ {n} \}), \mathbf {T} _ {n}, \boldsymbol {\delta} _ {n} ] _ {\mathcal {L} _ {\mathrm {I I}}} \end{array} , \right. \tag {3}
56
+ $$
57
+
58
+ where $\dagger(\cdot)$ outputs 1 (0) if true (false), and $\mathcal{L}_{\mathrm{I}}$ and $\mathcal{L}_{\mathrm{II}}$ denote the loss functions for C-I and C-II, respectively. The risk stratification status $\mathbf{Y}_n$ is determined by $\{\mathbf{T}_n, \pmb{\delta}_n\}$ with a three-year time threshold (denoted as $\mathbf{T}_r$ ) as follows:
59
+
60
+ $$
61
+ \mathbf {Y} _ {n} = \left\{ \begin{array}{l l} 1 & , \mathbf {T} _ {n} \leq \mathbf {T} _ {r} \& \& \delta_ {n} = = 1 \\ 0 & , \mathbf {T} _ {n} > \mathbf {T} _ {r} \\ - & , \text {o t h e r s} \end{array} . \right. \tag {4}
62
+ $$
63
+
64
+ ![](images/59c7c9a9fab345136ffab8eb699eda21562e4feedf313d347d3493b210724e6e.jpg)
65
+ Figure 1: The pipeline of the proposed dual-curriculum contrastive MIL method for cancer prognosis analysis with WSIs. The left is saliency-guided weakly-supervised instance encoding with cross-scale tiles (Curriculum I), while the right one is contrastive-enhanced soft-bag prognosis inference (Curriculum II).
66
+
67
+ # 3.2 Curriculum I: Saliency-guided Weakly-supervised Instance Encoding with Cross-scale Tiles
68
+
69
+ In this section, we introduce the first curriculum of saliency-guided weakly-supervised instance encoding with cross-scale tiles, as shown in Figure 1. Given the input instance with $S$ magnifications $\{\mathbf{x}_{n,i}^s\}_{s=1}^S$ ( $S = 3$ in this work), the proposed method contains $S$ branches and each branch takes different-magnification tiles as input, which aims to explore multi-scale information from multi-magnification images. For the $s$ -th branch, it mainly consists of a feature extractor $\mathbb{F}^s$ , a feature aggregator $\mathbb{G}^s$ and a classifier $\mathbb{C}^s$ . And $\{\mathbb{F}^s\}_{s=1}^S$ and $\{\mathbb{G}^s\}_{s=1}^S$ form $\mathbb{E}$ , while $\{\mathbb{C}^s\}_{s=1}^S$ constitute $\mathbb{C}$ in Eq.(3). The feature extractor $\mathbb{F}^s$ contains $s$ residual modules with the parameters $\{\pmb{\theta}_{\mathbb{F}^s}^1, \dots, \pmb{\theta}_{\mathbb{F}^s}\}$ , and the first $s-1$ modules share the same architecture with $\mathbb{F}^{s-1}$ if $s > 1$ . Figure 2 illustrates the architecture details. Different from previous studies [22, 23] that separately feed $\{\mathbf{x}_{n,i}^s\}_{s=1}^S$ into the network and ignore fine-grained details across multi-magnification images, we encourage the network to focus on salient regions by utilizing the prior knowledge of the $(s-1)$ -th branch to highlight the input $\mathbf{x}_{n,i}^s$ , which can be formulated as
70
+
71
+ $$
72
+ \hat {\mathbf {x}} _ {n, i} ^ {s} = \left\{ \begin{array}{l l} \mathbf {x} _ {n, i} ^ {s} & , s = 1 \\ \mathbf {m} _ {n, i} ^ {s - 1} \otimes \mathbf {x} _ {n, i} ^ {s} & , s > 1 \end{array} , \right. \tag {5}
73
+ $$
74
+
75
+ where $\otimes$ denotes the element-wise multiplication operator, and $\mathbf{m}_{n,i}^{s-1}$ is the salient mask indicating high-risk regions. For convenience, we introduce how to acquire $\mathbf{m}_{n,i}^{s}$ , which is easily generalized to $\mathbf{m}_{n,i}^{s-1}$ . Specifically, $\mathbf{m}_{n,i}^{s}$ is computed by Class Activation Map [38] as follows:
76
+
77
+ $$
78
+ \mathbf {m} _ {n, i} ^ {s} = \boldsymbol {\omega} ^ {s} \odot \mathbb {F} ^ {s} \left(\hat {\mathbf {x}} _ {n, i} ^ {s}\right), \tag {6}
79
+ $$
80
+
81
+ where $\odot$ is the channel-wise multiplication operator, and $\omega^s$ indicates the importance of channel of feature maps for risk stratification prediction in the $s$ -th branch. To obtain $\omega^s$ , we first generate an instance embedding vector $\mathbf{z}_{n,i}^s$ by
82
+
83
+ $$
84
+ \mathbf {z} _ {n, i} ^ {s} = \mathbb {G} ^ {s} \left(\mathbb {F} ^ {s} \left(\hat {\mathbf {x}} _ {n, i} ^ {s}\right)\right), \tag {7}
85
+ $$
86
+
87
+ where $\mathbb{G}^s$ is a feature aggregator that performs channel-direction attention (as shown in Figure 2).
88
+
89
+ Incorporating comprehensive information from current and previous branches, we subsequently feed instance embeddings $\{\mathbf{z}_{n,i}^j\}_{j=1}^s$ into the classifier $\mathbb{C}^s$ for predicting the high-risk probability $\mathbf{p}_{n,i}^s$ , which is computed by
90
+
91
+ $$
92
+ \mathbf {p} _ {n, i} ^ {s} = \mathbb {C} ^ {s} \left(\left\{\mathbf {z} _ {n, i} ^ {j} \right\} _ {j = 1} ^ {s}\right) = \phi \left(\overline {{\boldsymbol {\omega}}} ^ {s} \times \left[ \mathbf {z} _ {n, i} ^ {1}, \dots , \mathbf {z} _ {n, i} ^ {s - 1} \right] ^ {T} + \boldsymbol {\omega} ^ {s} \times \left[ \mathbf {z} _ {n, i} ^ {s} \right] ^ {T}\right), \tag {8}
93
+ $$
94
+
95
+ ![](images/c3e393922c0d62d8edd9b99a0a70cf2f6f75f6e65f3c57918874b2b86439051c.jpg)
96
+
97
+ ![](images/d7a688c044fecc9efe35490aa876165cc0c9dc0f3cfde27d273dc4a8f1c90dc2.jpg)
98
+ Figure 2: The detailed architectures of some modules in the model. The first row shows the architectures of feature extractor $\mathbb{F}$ , feature aggregator $\mathbb{G}$ and classifier $\mathbb{C}$ in Curriculum I, while the second row illustrates the architectures of soft-bag learning model $\mathbb{B}$ , the constrained self-attention module $\mathbb{D}$ and contrastive-enhanced prognosis inference function $\mathbb{S}$ in Curriculum II.
99
+
100
+ where $\mathbb{C}^s$ is implemented by a linear layer with the parameters $\{\overline{\omega}^s, \omega^s\}$ (as shown in Figure 2), and $\phi$ and $T$ denote softmax activation function and transposition operation, respectively.
101
+
102
+ We introduce a hierarchical transfer strategy to leverage the prior from different-magnification images, accelerate network convergence, and maintain the specificity of current branch. Specifically, as shown in Figure 1, the parameter $\theta_{\mathbb{F}^s}^s$ (for any $s$ ) of the $s$ -th module in $\mathbb{F}^s$ is completely learnable and has not any constraints, while $\theta_{\mathbb{F}^s}^{s-1}$ (for $s > 1$ ) is also learnable but constrained to approximate $\theta_{\mathbb{F}^{s-1}}^{s-1}$ by the structural loss $\mathcal{L}_{\Omega}$ as follows:
103
+
104
+ $$
105
+ \mathcal {L} _ {\Omega} = \left\| \boldsymbol {\theta} _ {\mathbb {F} ^ {s}} ^ {s - 1} - \boldsymbol {\theta} _ {\mathbb {F} ^ {s - 1}} ^ {s - 1} \right\| _ {2}. \tag {9}
106
+ $$
107
+
108
+ For the remaining parameters $\{\pmb{\theta}_{\mathbb{F}^s}^1,\dots ,\pmb{\theta}_{\mathbb{F}^s}^{s - 2}\}$ (for $s > 2$ ) in $\mathbb{F}^s$ , they are first initialized with $\{\pmb{\theta}_{\mathbb{F}^{s - 1}}^1,\dots ,\pmb{\theta}_{\mathbb{F}^{s - 1}}^{s - 2}\}$ , and then are frozen. Furthermore, we propose a hybrid loss function $\mathcal{L}_{\mathrm{I}}$ that contains two parts, i.e., empirical loss $\mathcal{L}_{\ell}$ and structural loss $\mathcal{L}_{\Omega}$ , to train the network:
109
+
110
+ $$
111
+ \mathcal {L} _ {1} = \mathcal {L} _ {\ell} + \beta_ {\Omega} \mathcal {L} _ {\Omega}, \tag {10}
112
+ $$
113
+
114
+ where $\beta_{\Omega}$ is the weight coefficient, and $\mathcal{L}_{\ell}$ is defined as
115
+
116
+ $$
117
+ \mathcal {L} _ {\ell} = - \frac {1}{N N _ {n}} \sum_ {n = 1} ^ {N} \sum_ {i = 1} ^ {N _ {n}} \mathbf {y} _ {n, i} ^ {s} \log \left(\mathbf {p} _ {n, i} ^ {s}\right) + \left(1 - \mathbf {y} _ {n, i} ^ {s}\right) \log \left(1 - \mathbf {p} _ {n, i} ^ {s}\right), \tag {11}
118
+ $$
119
+
120
+ where $\mathbf{y}_{n,i}^{s}\in \mathbf{Y}_{n}$ denotes the risk stratification status of the $i$ -th instance in the $n$ -th bag.
121
+
122
+ Finally, we can obtain the multi-scale instance representation $\mathbf{z}_{n,i}$ for subsequent prognosis inference task by $\mathbf{z}_{n,i} = [\mathbf{z}_{n,i}^{1},\dots ,\mathbf{z}_{n,i}^{S}]$ .
123
+
124
+ # 3.3 Curriculum II: Contrastive-enhanced Soft-bag Prognosis Inference
125
+
126
+ In this section, we develop the second curriculum of contrastive-enhanced soft-bag prognosis inference, as shown in Figure 1. Given a set of instance representations from the $n$ -th bag, i.e., $\mathbf{Z}_n = [\mathbf{z}_{n,1};\mathbf{z}_{n,2};\dots ;\mathbf{z}_{n,N_n}]^T\in \mathbb{R}^{N_n\times C}$ , where $C$ denotes the feature dimension, the proposed method mainly consists of a soft-bag learning module $\mathbb{B}$ , a constrained self-attention module $\mathbb{D}$ , a contrastive-enhanced prognosis inference function $\mathbb{S}$ , where $\mathbb{B}$ and $\mathbb{D}$ form $\mathbb{A}$ in Eq.(3).
127
+
128
+ For the soft-bag learning module $\mathbb{B}$ (as shown in Figure 2), it first learns new bag representation $\mathbf{E}_n\in \mathbb{R}^{N_n\times D}$ (where $\bar{D}$ denotes the feature dimension) from $\mathbf{Z}_n$ via a linear layer. Instead of enrolling all instances, we adaptively identify and integrate representative instances within a bag by introducing the function $\mathbb{H}$ :
129
+
130
+ $$
131
+ \hat {\mathbf {E}} _ {n} = \mathbb {H} \left(\mathbf {E} _ {n}, \hat {\mathbf {h}} _ {n}\right) = \phi \left(d i a g \left\{\hat {\mathbf {h}} _ {n} \right\} \times \mathbf {W} _ {n}\right) ^ {T} \times \left(d i a g \left\{\hat {\mathbf {h}} _ {n} \right\} \times \mathbf {E} _ {n}\right), \tag {12}
132
+ $$
133
+
134
+ where $\hat{\mathbf{E}}_n\in \mathbb{R}^{N_B\times D}$ ( $N_{B}$ is the number of selected instances in each bag, and $N_B\ll N_n$ ) is the feature representation of those selected instances, and $\mathbf{W}_n\in \mathbb{R}^{N_n\times N_B}$ denotes the weight matrix
135
+
136
+ that is generated by feeding $\mathbf{E}_n$ into two linear layers (as shown in Figure 2). And $\hat{\mathbf{h}}_n\in \mathbb{R}^{N_n\times 1}$ is an indicator vector that adaptively selects $N_B$ representative instances and is computed by
137
+
138
+ $$
139
+ \hat {\mathbf {h}} _ {n} = \arg \max _ {\mathbf {h} _ {n}} \mathbb {S} \left(\mathbb {D} \left(\mathbb {H} \left(\mathbf {E} _ {n}, \mathbf {h} _ {n}\right)\right)\right), \quad s. t. \sum_ {i = 1} ^ {N _ {n}} \mathbf {h} _ {n, i} = N _ {B}. \tag {13}
140
+ $$
141
+
142
+ The constrained self-attention module $\mathbb{D}$ and contrastive-enhanced prognosis inference function $\mathbb{S}$ are introduced below.
143
+
144
+ We leverage $\mathbb{D}$ to obtain extra sparseness for soft-bag representations. Given the input $\hat{\mathbf{E}}_n$ , it first linearly projects $\hat{\mathbf{E}}_n$ into three feature spaces (i.e., $\mathbf{Q}_n \in \mathbb{R}^{N_B \times \hat{D}}$ , $\mathbf{K}_n \in \mathbb{R}^{N_B \times \hat{D}}$ , and $\mathbf{V}_n \in \mathbb{R}^{N_B \times \hat{D}}$ , and $\hat{D}$ is the feature dimension) via three mapping matrices (i.e., $\mathbf{W}_Q \in \mathbb{R}^{D \times \hat{D}}$ , $\mathbf{W}_K \in \mathbb{R}^{D \times \hat{D}}$ , and $\mathbf{W}_V \in \mathbb{R}^{D \times \hat{D}}$ ), in which the mapping matrices are constrained by
145
+
146
+ $$
147
+ \mathcal {L} _ {s} = \left(\| \mathbf {W} _ {Q} \| _ {1} + \| \mathbf {W} _ {K} \| _ {1} + \| \mathbf {W} _ {V} \| _ {1}\right). \tag {14}
148
+ $$
149
+
150
+ Then, the sparse soft-bag representation $\mathbf{B}_n\in \mathbb{R}^{1\times D_B}$ (where $D_B$ is the feature dimension) can be obtained by the correlation-based activation mechanism [39], as illustrated in Figure 2. It is worth mentioning that the collaboration of $\mathbb{B}$ and $\mathbb{D}$ can significantly help reduce intra-bag redundancy in both instance and feature levels so as to improve model's generalization.
151
+
152
+ For $\mathbb{S}$ , it takes $\mathbf{B}_n$ as input to infer the relative risk $\hat{\mathbf{T}}_n$ via a linear projection matrix $\mathbf{W}_{\mathbb{S}} \in \mathbb{R}^{D_B \times 1}$ , as shown in Figure 2. In order to boost the ability of soft-bag inference, we perform two-tier contrastive learning (TCL) to enhance intra-bag and inter-bag discrimination. We assume that a bag $\mathbf{B}_n$ is sampled from the distribution $\mathcal{O} = \{\mathcal{O}^+, \mathcal{O}^-\}$ , where the positive source $\mathcal{O}^+$ denotes the distribution of high-hazard samples (i.e., those with survival time $\leq \mathbf{T}_r$ ), while the negative source $\mathcal{O}^-$ presents the distribution of low-hazard samples (i.e., those with survival time $>\mathbf{T}_r$ ). We first focus on inter-bag discrimination. Let $\mathcal{B}_n = \{\mathbf{B}_1, \dots, \mathbf{B}_{N_{B_n}}\} / \mathbf{B}_n$ present the collection of bags (except $\mathbf{B}_n$ ) from the same source $\mathcal{O}^+$ (or $\mathcal{O}^-$ ) as $\mathbf{B}_n$ , where $N_{B_n}$ denotes the number of such bags. We can obtain the representation of $\mathcal{B}_n$ (denoted as $\hat{\mathbf{B}}_n$ ) by merging the representations of all bags in $\mathcal{B}_n$ via an attention function $\mathbb{K}$ (as illustrated in Figure 2). Inspired by [40], inter-bag discrimination can be enhanced by maximally preserving the mutual information between $\mathbf{B}_n$ and $\hat{\mathbf{B}}_n$ as follows:
153
+
154
+ $$
155
+ \sum_ {n \in [ N ]} \mathbb {I} \left(\mathbf {B} _ {n}, \hat {\mathbf {B}} _ {n}\right) = \sum_ {n \in [ N ]} p \left(\mathbf {B} _ {n}, \hat {\mathbf {B}} _ {n}\right) \log \frac {p \left(\mathbf {B} _ {n} \mid \hat {\mathbf {B}} _ {n}\right)}{p \left(\mathbf {B} _ {n}\right)}. \tag {15}
156
+ $$
157
+
158
+ According to Eq.(12), partial instances within a bag are adaptively discarded, and the rest remained. However, all instances within the bag belong to homologous tissues sampled from the same patient, which means that it should show potential correlation among these instances. Therefore, similar to Eq.(15), we maximize the following mutual information to improve intra-bag discrimination:
159
+
160
+ $$
161
+ \sum_ {n \in [ N ]} \mathbb {I} \left(\mathbf {B} _ {n}, \overline {{\mathbf {B}}} _ {n}\right) = \sum_ {n \in [ N ]} p \left(\mathbf {B} _ {n}, \overline {{\mathbf {B}}} _ {n}\right) \log \frac {p \left(\mathbf {B} _ {n} \mid \overline {{\mathbf {B}}} _ {n}\right)}{p \left(\mathbf {B} _ {n}\right)}, \tag {16}
162
+ $$
163
+
164
+ where $\overline{\mathbf{B}}_n$ is obtained via $\mathbb{K}$ to merge the representations of those discarded instances $\overline{\mathbf{E}}_n$ that has the definition of $\overline{\mathbf{E}}_n = \mathbb{H}(\mathbf{E}_n, \mathbf{1} - \hat{\mathbf{h}}_n)$ , as illustrated in Figure 2. To this end, we propose to jointly maximize Eq.(15) and (16), i.e., $\max \left( \sum_{n \in [N]} \mathbb{I}(\mathbf{B}_n, \hat{\mathbf{B}}_n) + \mathbb{I}(\mathbf{B}_n, \overline{\mathbf{B}}_n) \right)$ , which is formulated by
165
+
166
+ $$
167
+ \max \left(\sum_ {n \in [ N ]} \log \frac {p \left(\mathbf {B} _ {n} \mid \hat {\mathbf {B}} _ {n}\right)}{p \left(\mathbf {B} _ {n}\right)} + \log \frac {p \left(\mathbf {B} _ {n} \mid \overline {{\mathbf {B}}} _ {n}\right)}{p \left(\mathbf {B} _ {n}\right)}\right) = \max \left(\sum_ {n \in [ N ]} \log \frac {p \left(\mathbf {B} _ {n} \mid \hat {\mathbf {B}} _ {n}\right) p \left(\mathbf {B} _ {n} \mid \overline {{\mathbf {B}}} _ {n}\right)}{p \left(\mathbf {B} _ {n}\right) p \left(\mathbf {B} _ {n}\right)}\right). \tag {17}
168
+ $$
169
+
170
+ Instead of constructing a generative model $p(\mathbf{B}_n|\hat{\mathbf{B}}_n)p(\mathbf{B}_n|\overline{\mathbf{B}}_n)$ , we leverage a log-bilinear function $\mathbb{L}$ to model the density ratio which preserves the mutual information:
171
+
172
+ $$
173
+ \begin{array}{l} \mathbb {L} \left(\mathbf {B} _ {n}, \hat {\mathbf {B}} _ {n}, \overline {{\mathbf {B}}} _ {n}\right) = e x p \left(\mathbf {B} _ {n} ^ {T} \mathbf {W} _ {\mathbb {L}} \hat {\mathbf {B}} _ {n}\right) e x p \left(\mathbf {B} _ {n} ^ {T} \mathbf {V} _ {\mathbb {L}} \overline {{\mathbf {B}}} _ {n}\right) (18) \\ = \exp \left(\mathbf {B} _ {n} ^ {T} \mathbf {W} _ {\mathbb {L}} \hat {\mathbf {B}} _ {n} + \mathbf {B} _ {n} ^ {T} \mathbf {V} _ {\mathbb {L}} \overline {{\mathbf {B}}} _ {n}\right) \propto \frac {p \left(\mathbf {B} _ {n} \mid \hat {\mathbf {B}} _ {n}\right) p \left(\mathbf {B} _ {n} \mid \overline {{\mathbf {B}}} _ {n}\right)}{p \left(\mathbf {B} _ {n}\right) p \left(\mathbf {B} _ {n}\right)}, (19) \\ \end{array}
174
+ $$
175
+
176
+ where $\mathbf{W}_{\mathbb{L}}$ and $\mathbf{V}_{\mathbb{L}}$ are trainable parameters. Motivated by [41], we design the TCL loss based on the InfoNCE function, which has the following definition:
177
+
178
+ $$
179
+ \mathcal {L} _ {t c l} = - \underline {{\boldsymbol {E}}} \left[ \log \frac {\mathbb {L} \left(\mathbf {B} _ {n} , \hat {\mathbf {B}} _ {n} , \overline {{\mathbf {B}}} _ {n}\right)}{\sum_ {i \in [ N ] , i \neq n} \mathbb {L} \left(\mathbf {B} _ {n} , \hat {\mathbf {B}} _ {i} , \overline {{\mathbf {B}}} _ {i}\right)} \right], \tag {20}
180
+ $$
181
+
182
+ where $\mathcal{B}$ denotes the collection of all bags. Additionally, we utilize the negative log-partial likelihood of Cox proportional hazard regression model [42] to train the network, which is computed by
183
+
184
+ $$
185
+ \mathcal {L} _ {c o x} = - \log (\prod_ {n: \boldsymbol {\delta} _ {n} = 1} \frac {e x p (\mathbf {B} _ {n} \mathbf {W} _ {\mathbb {S}})}{\sum_ {j \in R (\mathbf {T} _ {n})} e x p (\mathbf {B} _ {j} \mathbf {W} _ {\mathbb {S}})}) = - \sum_ {n: \boldsymbol {\delta} _ {n} = 1} (\mathbf {B} _ {n} \mathbf {W} _ {\mathbb {S}} - \log (\sum_ {j \in R (\mathbf {T} _ {n})} e x p (\mathbf {B} _ {j} \mathbf {W} _ {\mathbb {S}}))),
186
+ $$
187
+
188
+ where $\mathbf{W}_{\mathbb{S}}$ is the linear projection matrix in $\mathbb{S}$ , and $R(\mathbf{T}_n) = \{i:\mathbf{T}_i\geq \mathbf{T}_n\}$ is the collection of all samples (including censored and uncensored ones) with survival time being longer than $\mathbf{T}_n$ . Finally, the loss function $\mathcal{L}_{\mathrm{II}}$ for the second curriculum can be defined as
189
+
190
+ $$
191
+ \mathcal {L} _ {\mathrm {I I}} = \mathcal {L} _ {c o x} + \mathcal {L} _ {t c l} + \beta_ {s} \mathcal {L} _ {s}, \tag {21}
192
+ $$
193
+
194
+ where $\beta_{s}$ is the weight coefficient.
195
+
196
+ # 4 Experiments and Results
197
+
198
+ In this section, we briefly describe datasets, preprocessing, and implementation details, followed by experimental results.
199
+
200
+ # 4.1 Datasets and Preprocessing
201
+
202
+ In this work, we evaluated the proposed method on three datasets from The Cancer Genome Atlas (TCGA) database, including colon adenocarcinoma (COAD) $(N = 365)$ , hepatocellular carcinoma (LIHC) $(N = 334)$ , and bladder urothelial carcinoma (BLCA) $(N = 396)$ . Each dataset contained WSIs stained with hematoxylin and eosin (H&E) and clinical information (i.e., survival time and event status). After segmenting tissue areas via the Otsus method, a set of tiles under different magnifications $(20\times, 10\times, 5\times)$ were non-overlappingly sampled from each segmented tissue area, and the window sizes were set to $512\times 512$ , $256\times 256$ , and $128\times 128$ , respectively.
203
+
204
+ # 4.2 Implementation Details
205
+
206
+ In our experiments, we adopted the 5-fold cross-validation strategy to comprehensively evaluate our proposed method and the ratio of training and validation sets was set to 4:1. Specifically, we divided the entire dataset into five folds, among which four folds for model training while the remaining one for model evaluation. Notably, the cross-validation strategy was conducted on patient level to prevent data leakage, which means that the WSI of each patient only appeared in one of these subsets. During the training stage, we selected the best model in terms of two specific evaluation metrics for different curriculums. That is, the model with the highest accuracy was selected for Curriculum I, while the model with the highest C-index for Curriculum II. The concordance index (CI), the receiver operating characteristic (ROC) curve, the area under ROC curve (AUC), and Kaplan-Meier (KM) curve were used to assess model's performance. We chose three-year time as threshold for risk stratification status and AUC calculation, which lies on two reasons as follows: 1) Three-year survival time is an important indicator for clinically evaluating the prognosis of patients, especially for three cancer types studied in our work [43, 44, 45]. 2) For the used datasets, using three-year survival time as threshold can make the distribution of positive and negative samples relatively balanced, which is beneficial to network training. We implemented all competing methods using the Pytorch1.9 library on Python3.6. All intensive calculations were offloaded to a 12 GB NVIDIA Pascal Titan X GPU.
207
+
208
+ Curriculum I. We adopted Adam optimizer with the weight decay of 0.2 for network training. For different magnifications $s \in \{1,2,3\}$ , the learning rate, batch size and epoch number were set to $\{10^{-5}, 3 \times 10^{-6}, 3 \times 10^{-6}\}$ , $\{32,16,16\}$ and $\{50,50,50\}$ , respectively. The weight coefficient $\beta_{\Omega}$ was set to $10^{-5}$ .
209
+
210
+ Curriculum II. We adopted SGD optimizer with the momentum of 0.9 for network training. The learning rate, batch size and epoch number were set to $10^{-4}$ , 16 and 1000, respectively. The soft-bag size $N_B$ was set to 3 and the weight coefficient $\beta_{s}$ was set to $10^{-3}$ .
211
+
212
+ Table 1: The results achieved by all competing methods on three datasets (i.e., COAD, LIHC, and BLCA). The boldface denotes the best result.
213
+
214
+ <table><tr><td rowspan="2"></td><td colspan="2">COAD</td><td colspan="2">LIHC</td><td colspan="2">BLCA</td><td colspan="2">Overall</td></tr><tr><td>CI</td><td>AUC</td><td>CI</td><td>AUC</td><td>CI</td><td>AUC</td><td>CI</td><td>AUC</td></tr><tr><td>WSISA [46]</td><td>0.641±0.027</td><td>0.673±0.037</td><td>0.661±0.022</td><td>0.700±0.071</td><td>0.639±0.018</td><td>0.651±0.043</td><td>0.647</td><td>0.675</td></tr><tr><td>DeepGraphSurv [47]</td><td>0.629±0.054</td><td>0.639±0.038</td><td>0.613±0.027</td><td>0.633±0.047</td><td>0.620±0.015</td><td>0.687±0.046</td><td>0.620</td><td>0.653</td></tr><tr><td>MesoNet [6]</td><td>0.643±0.039</td><td>0.684±0.052</td><td>0.629±0.022</td><td>0.667±0.042</td><td>0.630±0.021</td><td>0.648±0.052</td><td>0.634</td><td>0.666</td></tr><tr><td>DeepAttnMISL [5]</td><td>0.683±0.025</td><td>0.654±0.045</td><td>0.672±0.027</td><td>0.676±0.019</td><td>0.642±0.020</td><td>0.661±0.076</td><td>0.666</td><td>0.663</td></tr><tr><td>Patch-GCN [10]</td><td>0.650±0.013</td><td>0.562±0.010</td><td>0.565±0.024</td><td>0.630±0.061</td><td>0.571±0.041</td><td>0.542±0.027</td><td>0.595</td><td>0.578</td></tr><tr><td>DC_MIL(our)</td><td>0.717±0.012</td><td>0.754±0.031</td><td>0.705±0.015</td><td>0.745±0.012</td><td>0.672±0.029</td><td>0.720±0.039</td><td>0.698</td><td>0.740</td></tr></table>
215
+
216
+ ![](images/7315df1fdd745eda6d9c674c7ed5437fe2e7795e4238adcbe20c0c953ae1b9ea.jpg)
217
+
218
+ ![](images/647137466895111478c5b0e7d266e68c09d9d6acafc9889980d64d18b23ba94d.jpg)
219
+
220
+ ![](images/17b5a811d9b6950947ae68d96e8f1139687c1a9771c82734bfa2e2e1053e117a.jpg)
221
+ Figure 3: The KM curves with the $p$ -values of all competing methods on three datasets. The farther apart the two curves are, the better the model works.
222
+
223
+ # 4.3 Comparison with State-of-the-Art Methods
224
+
225
+ We compared our method with other weakly-supervised methods in cancer prognosis analysis, including clustering approaches [46], graph networks [10, 47], and multi-instance learning methods [5, 6]. Table 1 presents the 5-fold cross-validation results (in terms of CI and AUC) of all competing methods. The KM curves as well as $p$ -values, are provided in Figure 3. We can observe that the proposed method outperforms others in head-to-head comparisons, achieving an overall CI of 0.698 and AUC of 0.740. It may benefit from several potential advantages in DC_MIL: 1) Unlike some methods that leverage the dimension reduction technique [46] or pre-trained model [5, 6, 10, 47], it encodes instances in a weakly-supervised manner so as to reduce label noises and maintain prognosis-related guidance. 2) It utilizes the low-magnification saliency map to guide the encoding of high-magnification instances for exploring fine-grained information across multi-magnification WSIs. 3) It introduces a soft-bag learning method and a constrained self-attention strategy to help reduce intra-bag redundancy in both instance and feature levels, respectively. 4) It equips the Cox loss with two-tier contrastive learning for enhancing intra-bag and inter-bag discrimination. Additionally, we also find that WSISA [46], MesoNet [6], and DeepAttnMISL [5] outperform DeepGraphSurv [47] and Patch-GCN [10], which may owe to the selection of discriminative tiles. More results can refer to Appendix D.
226
+
227
+ # 4.4 Ablation Study
228
+
229
+ Ablation on Curriculum I. We validated the efficacy of each crucial component in Curriculum I. From Table 2, we can observe several key points: 1) Compared with pre-trained ResNet-34 (regardless with MM or not), the proposed model shows significant performance improvement, which demonstrates the effectiveness of Curriculum I. 2) The model with MM outperforms the one without MM and gets CI gain of 0.039 and AUC gain of 0.061, which benefits from the utilization
230
+
231
+ Table 2: The results of ablation experiments on three datasets (i.e., COAD, LIHC, and BLCA). The boldface denotes the best result.
232
+
233
+ <table><tr><td colspan="4">DC_MIL: C-I + C-II</td><td colspan="2">COAD</td><td colspan="2">LIHC</td><td colspan="2">BLCA</td></tr><tr><td>MM</td><td>SG</td><td>HT</td><td>C-II</td><td>CI</td><td>AUC</td><td>CI</td><td>AUC</td><td>CI</td><td>AUC</td></tr><tr><td>X</td><td>X</td><td>X</td><td>✓</td><td>0.676±0.031</td><td>0.696±0.055</td><td>0.662±0.021</td><td>0.659±0.032</td><td>0.640±0.038</td><td>0.680±0.046</td></tr><tr><td>✓</td><td>X</td><td>✓</td><td>✓</td><td>0.692±0.049</td><td>0.705±0.091</td><td>0.671±0.045</td><td>0.720±0.050</td><td>0.647±0.019</td><td>0.678±0.037</td></tr><tr><td>✓</td><td>✓</td><td>X</td><td>✓</td><td>0.707±0.033</td><td>0.714±0.061</td><td>0.699±0.019</td><td>0.721±0.018</td><td>0.654±0.016</td><td>0.700±0.043</td></tr><tr><td>PT</td><td>w/o</td><td>MM</td><td>✓</td><td>0.642±0.030</td><td>0.643±0.022</td><td>0.644±0.030</td><td>0.640±0.018</td><td>0.618±0.013</td><td>0.635±0.028</td></tr><tr><td>PT</td><td>w/</td><td>MM</td><td>✓</td><td>0.660±0.017</td><td>0.683±0.025</td><td>0.662±0.021</td><td>0.691±0.036</td><td>0.633±0.015</td><td>0.639±0.020</td></tr><tr><td>C-I</td><td>SB</td><td>CSA</td><td>TCL</td><td>CI</td><td>AUC</td><td>CI</td><td>AUC</td><td>CI</td><td>AUC</td></tr><tr><td>✓</td><td>X</td><td>X</td><td>X</td><td>0.651±0.020</td><td>0.697±0.040</td><td>0.653±0.028</td><td>0.680±0.022</td><td>0.621±0.023</td><td>0.630±0.029</td></tr><tr><td>✓</td><td>✓</td><td>X</td><td>X</td><td>0.670±0.034</td><td>0.715±0.066</td><td>0.673±0.031</td><td>0.717±0.063</td><td>0.655±0.024</td><td>0.668±0.033</td></tr><tr><td>✓</td><td>✓</td><td>X</td><td>✓</td><td>0.709±0.025</td><td>0.729±0.063</td><td>0.693±0.033</td><td>0.736±0.029</td><td>0.669±0.017</td><td>0.696±0.030</td></tr><tr><td>✓</td><td>✓</td><td>✓</td><td>X</td><td>0.678±0.031</td><td>0.721±0.047</td><td>0.680±0.046</td><td>0.731±0.044</td><td>0.659±0.031</td><td>0.680±0.063</td></tr><tr><td>✓</td><td>✓</td><td>✓</td><td>✓</td><td>0.717±0.012</td><td>0.754±0.031</td><td>0.705±0.015</td><td>0.745±0.012</td><td>0.672±0.029</td><td>0.720±0.039</td></tr></table>
234
+
235
+ C-I, Curriculum I; MM, multi-magnification strategy; SG, saliency-guided method; HT, hierarchical transfer strategy; PT, pre-trained strategy; C-II, Curriculum II; SB, soft-bag learning; CSA, constrained self-attention module; TCL, two-tier contrastive learning.
236
+
237
+ of multi-magnification information. 3) The model without SG or FT suffers from performance degradation (average CI drops of 0.028 and 0.011 and AUC drops of 0.039 and 0.028). It indicates that fine-grained information across multi-scale tiles and hierarchical transfer strategy can help significantly improve the performance of model. More results can refer to Appendix D.
238
+
239
+ Ablation on Curriculum II. We also investigated the efficacy of each key component in Curriculum II. From Table 2, we have the following observations: 1) The baseline method performed prognosis prediction with the Cox model, which achieves average CI of 0.642 and AUC of 0.669. Compared to the baseline method, the model with soft-bag strategy achieves average CI gain of 0.024 and AUC gain of 0.031, which mainly profits by adaptively identifying and integrating the representative instances within a bag. 2) The models with CSA, TCL, and both of them show better performance with average CI gains of 0.006, 0.024, and 0.032 and AUC gains of 0.011, 0.02, and 0.04, respectively, which benefits from the reduction of intra-bag redundancy and the enhancement of intra-bag and inter-bag discrimination. More results can refer to Appendix D.
240
+
241
+ # 4.5 Parameter Analysis
242
+
243
+ Influence of the Soft-bag Size $N_B$ . To explore the influence of the soft-bag size $N_B$ , we conducted a set of experiments by varying $N_B$ within the set of $\{1,2,3,4,5\}$ . Note that $N_B = 1$ corresponds to the standard MIL method. From Table 3, we can observe that the model shows the best performance when $N_B$ equals to 3 (for COAD and LIHC) or 4 (for BLAC). It indicates that the top $3\sim 4$ instances are adequate to represent the bag. Besides, the model with $N_B > 1$ works better than the standard MIL method, indicating the effectiveness of the soft-bag strategy for prognosis inference.
244
+
245
+ Influence of the Magnification Number $S$ . We conducted experiments to investigate the influence of the magnification number $S$ by varying $S$ in the range of $\{1, 2, 3, 4\}$ . Note that $S = 1$ corresponds to the mono-magnification input and $S = 4$ corresponds to the multi-magnification input with $\{20\times, 10\times, 5\times, 2.5\times\}$ . As shown in Table 3, the model's performance is improved as $S$ increases. And the model can achieve the best performance on all datasets and reach a stable state after $S = 3$ .
246
+
247
+ Influence of the Weight Coefficients $\beta_{\Omega}$ and $\beta_{s}$ . We turned to the influence of the weight coefficients $\beta_{\Omega}$ and $\beta_{s}$ by varying them within the sets of $\{2e - 4,5e - 5,1e - 5,2e - 6\}$ and $\{2e - 2,5e - 3,1e - 3,2e - 4\}$ , respectively. As we can observe from Table 4, the performance of the model fluctuates slightly when both $\beta_{\Omega}$ and $\beta_{s}$ vary, which verifies the robustness of the proposed method to the weight coefficients.
248
+
249
+ # 4.6 Visualization
250
+
251
+ This section exhibits the salient maps output by the proposed method for some samples. As illustrated in Figure 4, the model mainly focuses on the fine-grained regions (under $20 \times$ WSIs) that are wrapped by the salient regions under $10 \times$ WSIs, indicating the proposed method can effectively guide the
252
+
253
+ Table 3: Results (CI) achieved by the proposed model with different $N_B$ and $S$ .
254
+
255
+ <table><tr><td></td><td>NB=1</td><td>NB=2</td><td>NB=3</td><td>NB=4</td><td>NB=5</td><td>S=1</td><td>S=2</td><td>S=3</td><td>S=4</td></tr><tr><td>COAD</td><td>0.660</td><td>0.679</td><td>0.717</td><td>0.671</td><td>0.705</td><td>0.663</td><td>0.700</td><td>0.708</td><td>0.703</td></tr><tr><td>LIHC</td><td>0.631</td><td>0.691</td><td>0.705</td><td>0.704</td><td>0.705</td><td>0.667</td><td>0.686</td><td>0.703</td><td>0.697</td></tr><tr><td>BLCA</td><td>0.648</td><td>0.657</td><td>0.672</td><td>0.686</td><td>0.667</td><td>0.628</td><td>0.645</td><td>0.658</td><td>0.650</td></tr></table>
256
+
257
+ Table 4: Results (CI) achieved by the proposed model with different weight coefficients ${\beta }_{\Omega }$ and ${\beta }_{s}$ .
258
+
259
+ <table><tr><td></td><td>βΩ=2e-4</td><td>βΩ=5e-5</td><td>βΩ=1e-5</td><td>βΩ=2e-6</td><td>βs=2e-2</td><td>βs=5e-3</td><td>βs=1e-3</td><td>βs=2e-4</td></tr><tr><td>COAD</td><td>0.703</td><td>0.711</td><td>0.709</td><td>0.706</td><td>0.700</td><td>0.708</td><td>0.709</td><td>0.708</td></tr><tr><td>LIHC</td><td>0.692</td><td>0.696</td><td>0.695</td><td>0.691</td><td>0.689</td><td>0.692</td><td>0.695</td><td>0.686</td></tr><tr><td>BLCA</td><td>0.669</td><td>0.672</td><td>0.672</td><td>0.671</td><td>0.667</td><td>0.672</td><td>0.672</td><td>0.670</td></tr></table>
260
+
261
+ ![](images/4c4f97dd641cf627fcf042caaa2b84597e403156c7c125a71a0fb89ae8c27333.jpg)
262
+
263
+ ![](images/43265fef21760291a94e461b7c9b446c1c474edc3f25464a7f38726fa42c6bce.jpg)
264
+
265
+ ![](images/be49a8c64ec0b040b92e63297b39fe399a5939e04d9fc7a0e8a2d865bcb4f765.jpg)
266
+ Low RISK High
267
+
268
+ ![](images/659c7f618773afdeff535e2dc3225442804f45cd1b0b452e75d89cf67a43440f.jpg)
269
+ Figure 4: Visualization of salient maps output by the proposed method. The first column shows the original WSIs, and the second and third columns exhibit the salient maps under $10\times$ and $20\times$ magnifications, respectively.
270
+
271
+ ![](images/c4fba82d0fb19bc5ab8806ee8e8f3f0301e0d36b32194d1f1c4761a0c212db37.jpg)
272
+
273
+ ![](images/47153fdd32dad8eb187f61670ee2347b50877650b78735d00414597e74a97a84.jpg)
274
+
275
+ encoding of high-magnification instances so as to encourage the network to focus on more fine-grained information. We have provided more intuitive results and analyses in Appendix D.
276
+
277
+ # 5 Conclusion
278
+
279
+ In this paper, we present a dual-curriculum contrastive MIL method for cancer prognosis analysis with WSIs, which contains two easy-to-hard curriculums, i.e., saliency-guided weakly-supervised instance encoding with cross-scale tiles and contrastive-enhanced soft-bag prognosis inference. The proposed network is easy to train in each curriculum and can be applied to gigapixel WSI analysis with good visualization. Besides, the proposed method outperforms state-of-the-art methods in cancer prognosis analysis over three public datasets.
280
+
281
+ # Acknowledgments
282
+
283
+ This work was supported in part by the National Natural Science Foundation of China under Grant 61971213 and Grant 61671230, in part by the Basic and Applied Basic Research Foundation of Guangdong Province under Grant 2019A1515010417, and in part by the Guangdong Provincial Key Laboratory of Medical Image Processing under Grant No.2020B1212060039. We would like to express our gratitude to The Cancer Genome Atlas (TCGA) database for the open-source data and to anonymous reviewers for their insightful comments.
284
+
285
+ # References
286
+
287
+ [1] Ole-Johan Skrede et al. Deep learning for prediction of colorectal cancer outcome: a discovery and validation study. The Lancet, 395(10221):350-360, 2020.
288
+ [2] Richard Colling et al. Artificial intelligence in digital pathology: a roadmap to routine use in clinical practice. The Journal of Pathology, 249(2):143-150, 2019.
289
+ [3] Chetan L Srinidhi, Ozan Ciga, and Anne L Martel. Deep neural network models for computational histopathology: a survey. Medical Image Analysis, 67:101813, 2021.
290
+ [4] Jana Lipkova et al. Deep learning-enabled assessment of cardiac allograft rejection from endomyocardial biopsies. Nature Medicine, 28(3):575-582, 2022.
291
+ [5] Jiawen Yao, Xinliang Zhu, Jitendra Jonnagaddala, Nicholas Hawkins, and Junzhou Huang. Whole slide images based cancer survival prediction using attention guided deep multiple instance learning networks. Medical Image Analysis, 65:101789, 2020.
292
+ [6] Pierre Courtiol et al. Deep learning-based classification of mesothelioma improves prediction of patient outcome. Nature Medicine, 25(10):1519-1525, 2019.
293
+ [7] Hassan Muhammad et al. Epic-survival: end-to-end part inferred clustering for survival analysis, with prognostic stratification boosting. In Medical Imaging with Deep Learning, 2021.
294
+ [8] Bin Li, Yin Li, and Kevin W Eliceiri. Dual-stream multiple instance learning network for whole slide image classification with self-supervised contrastive learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 14318-14328, 2021.
295
+ [9] Gabriele Campanella et al. Clinical-grade computational pathology using weakly supervised deep learning on whole slide images. Nature Medicine, 25(8):1301-1309, 2019.
296
+ [10] Richard J Chen et al. Whole slide images are 2d point clouds: context-aware survival prediction using patch-based graph convolutional networks. In International Conference on Medical Image Computing and Computer-Assisted Intervention, pages 339-349, 2021.
297
+ [11] Ming Y Lu, Drew FK Williamson, Tiffany Y Chen, Richard J Chen, Matteo Barbieri, and Faisal Mahmood. Data-efficient and weakly supervised computational pathology on whole-slide images. Nature Biomedical Engineering, 5(6):555-570, 2021.
298
+ [12] Zhuchen Shao et al. Transmil: transformer based correlated multiple instance learning for whole slide image classification. In Advances in Neural Information Processing Systems, volume 34, 2021.
299
+ [13] Chetan L Srinidhi and Anne L Martel. Improving self-supervised learning with hardness-aware dynamic curriculum learning: an application to digital pathology. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 562-571, 2021.
300
+ [14] Chetan L Srinidhi, Seung Wook Kim, Fu-Der Chen, and Anne L Martel. Self-supervised driven consistency training for annotation efficient histopathology image analysis. Medical Image Analysis, 75:102256, 2022.
301
+ [15] Xueting Yan, Ishan Misra, Abhinav Gupta, Deepti Ghadiyaram, and Dhruv Mahajan. Clusterfit: improving generalization of visual representations. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 6509-6518, 2020.
302
+ [16] Noriaki Hashimoto et al. Multi-scale domain-adversarial multiple-instance cnn for cancer subtype classification with unannotated histopathological images. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3852-3861, 2020.
303
+ [17] Hongrun Zhang et al. Dtdf-mil: double-tier feature distillation multiple instance learning for histopathology whole slide image classification. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 18802-18812, 2022.
304
+
305
+ [18] Trung Vu, Phung Lai, Raviv Raich, Anh Pham, Xiaoli Z Fern, and UK Arvind Rao. A novel attribute-based symmetric multiple instance learning for histopathological image analysis. IEEE Transactions on Medical Imaging, 39(10):3125-3136, 2020.
306
+ [19] Pierre Courtiol, Eric W Tramel, Marc Sanselme, and Gilles Wainrib. Classification and disease localization in histopathology using only global labels: a weakly-supervised approach. arXiv preprint arXiv:1802.02212, 2018.
307
+ [20] Weixin Li and Nuno Vasconcelos. Multiple instance learning for soft bags via top instances. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 4277-4285, 2015.
308
+ [21] Wei Shao, Tongxin Wang, Zhi Huang, Zhi Han, Jie Zhang, and Kun Huang. Weakly supervised deep ordinal cox model for survival prediction from whole-slide pathological images. IEEE Transactions on Medical Imaging, 40(12):3739-3747, 2021.
309
+ [22] Nima Hatami, Mohsin Bilal, and Nasir Rajpoot. Deep multi-resolution dictionary learning for histopathology image analysis. arXiv preprint arXiv:2104.00669, 2021.
310
+ [23] Hiroki Tokunaga, Yuki Teramoto, Akihiko Yoshizawa, and Ryoma Bise. Adaptive weighting multi-field-of-view cnn for semantic segmentation in pathology. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 12597-12606, 2019.
311
+ [24] Naofumi Tomita, Behnaz Abdollahi, Jason Wei, Bing Ren, Arief Suriawinata, and Saeed Hassanpour. Attention-based deep neural networks for detection of cancerous and precancerous esophagus tissue on histopathological slides. JAMA Network Open, 2(11):e1914645-e1914645, 2019.
312
+ [25] Nikhil Naik et al. Deep learning-enabled breast cancer hormonal receptor status determination from base-level h&E stains. Nature Communications, 11(1):1-8, 2020.
313
+ [26] Shujun Wang et al. Rmdl: recalibrated multi-instance deep learning for whole slide gastric image classification. Medical Image Analysis, 58:101549, 2019.
314
+ [27] Dmitrii Bychkov et al. Deep learning based tissue analysis predicts outcome in colorectal cancer. Scientific Reports, 8(1):1-11, 2018.
315
+ [28] Richard J Chen et al. Multimodal co-attention transformer for survival prediction in gigapixel whole slide images. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 4015–4025, 2021.
316
+ [29] Charlie Saillard et al. Predicting survival after hepatocellular carcinoma resection using deep learning on histological slides. Hepatology, 72(6):2000-2013, 2020.
317
+ [30] Pooya Mobadersany et al. Predicting cancer outcomes from histology and genomics using convolutional networks. Proceedings of the National Academy of Sciences, 115(13):E2970-E2979, 2018.
318
+ [31] Richard J Chen et al. Pathomic fusion: an integrated framework for fusing histopathology and genomic features for cancer diagnosis and prognosis. IEEE Transactions on Medical Imaging, 2020.
319
+ [32] Shuai Jiang, George J Zanazzi, and Saeed Hassanpour. Predicting prognosis and idh mutation status for patients with lower-grade gliomas using whole slide images. Scientific Reports, 11(1):1-9, 2021.
320
+ [33] David Tellez, Geert Litjens, Jeroen van der Laak, and Francesco Ciompi. Neural image compression for gigapixel histopathology image analysis. IEEE Transactions on Pattern Analysis and Machine Intelligence, 43(2):567-578, 2019.
321
+ [34] Gang Xu et al. Camel: a weakly supervised learning framework for histopathology image segmentation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 10682-10691, 2019.
322
+
323
+ [35] Fahdi Kanavati et al. Weakly-supervised learning for lung carcinoma classification using deep learning. Scientific Reports, 10(1):1-11, 2020.
324
+ [36] Chensu Xie et al. Beyond classification: whole slide tissue histopathology analysis by end-to-end part learning. In Medical Imaging with Deep Learning, pages 843-856, 2020.
325
+ [37] Yash Sharma, Aman Shrivastava, Lubaina Ehsan, Christopher A Moskaluk, Sana Syed, and Donald Brown. Cluster-to-conquer: a framework for end-to-end multi-instance learning for whole slide image classification. In Medical Imaging with Deep Learning, pages 682-698, 2021.
326
+ [38] Bolei Zhou, Aditya Khosla, Agata Lapedriza, Aude Oliva, and Antonio Torralba. Learning deep features for discriminative localization. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 2921-2929, 2016.
327
+ [39] Ashish Vaswani et al. Attention is all you need. In Advances in Neural Information Processing Systems, volume 30, 2017.
328
+ [40] Aaron Van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018.
329
+ [41] Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In International Conference on Machine Learning, pages 1597-1607, 2020.
330
+ [42] John Fox and Sanford Weisberg. Cox proportional-hazards regression for survival data. An R and S-PLUS Companion to Applied Regression, 2002, 2002.
331
+ [43] Daniel J Sargent et al. Disease-free survival versus overall survival as a primary end point for adjuvant colon cancer studies: individual patient data from 20,898 patients on 18 randomized trials. Journal of Clinical Oncology, 23(34):8664-8670, 2005.
332
+ [44] Josep M Llovet, Andrew Burroughs, and Jordi Bruix. Hepatocellular carcinoma. The Lancet, 362(9399):1907-1917, 2003.
333
+ [45] Ashish M Kamat et al. Bladder cancer. The Lancet, 388(10061):2796-2810, 2016.
334
+ [46] Xinliang Zhu, Jiawen Yao, Feiyun Zhu, and Junzhou Huang. Wsisa: making survival prediction from whole slide histopathological images. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 7234-7242, 2017.
335
+ [47] Ruoyu Li, Jiawen Yao, Xinliang Zhu, Yeqing Li, and Junzhou Huang. Graph cnn for survival analysis on whole slide pathological images. In International Conference on Medical Image Computing and Computer-Assisted Intervention, pages 174–182, 2018.
336
+
337
+ # Checklist
338
+
339
+ 1. For all authors...
340
+
341
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper's contributions and scope? [Yes] See the claimed contributions in Introduction and Abstract.
342
+ (b) Did you describe the limitations of your work? [Yes] See Appendix.
343
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] This work has no negative societal impacts.
344
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] We have read it and ensured that our paper conforms to them.
345
+
346
+ 2. If you are including theoretical results...
347
+
348
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A]
349
+ (b) Did you include complete proofs of all theoretical results? [N/A]
350
+
351
+ 3. If you ran experiments...
352
+
353
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] See Section 4.1, and the code is available at GitHub.
354
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 4.2 and Section 4.5.
355
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] We have used 5-fold cross-validation strategy to evaluate the proposed method and the results with mean and standard deviation are reported.
356
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Section 4.2.
357
+
358
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
359
+
360
+ (a) If your work uses existing assets, did you cite the creators? [Yes] See Section 4.1.
361
+ (b) Did you mention the license of the assets? [Yes] See Section 4.1. The used datasets are publicly available.
362
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
363
+ (d) Did you discuss whether and how consent was obtained from people whose data you're using/curating? [Yes] See Section 4.1. The used datasets are publicly available. The patient/participant consent has been obtained by the organizer.
364
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] See Section 4.1. The used datasets are publicly available, but the personally identifiable information is shielded.
365
+
366
+ 5. If you used crowdsourcing or conducted research with human subjects...
367
+
368
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
369
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
370
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
dualcurriculumcontrastivemultiinstancelearningforcancerprognosisanalysiswithwholeslideimages/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a307909e5fcb4d824f1c11915176d8a4957bcaa1617e38449e7a94eac780b7f1
3
+ size 700781
dualcurriculumcontrastivemultiinstancelearningforcancerprognosisanalysiswithwholeslideimages/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f2c4eb631f9014dc1c32a734b58e36400df8bd14b4965fe4c32595a2faf5bf6d
3
+ size 541861
dualdiscriminativegraphneuralnetworkforimbalancedgraphlevelanomalydetection/43b450fc-7716-499c-9a02-4761f33f68d2_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f798a2920967a6e40484baaec170a6d2ad414aaed6a940474fbf2d054a9f83d
3
+ size 89290
dualdiscriminativegraphneuralnetworkforimbalancedgraphlevelanomalydetection/43b450fc-7716-499c-9a02-4761f33f68d2_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e9a2902fca46be12d4d5b4f79e6d3bbf02c82d95bcf51bfefade357e67de4192
3
+ size 115551
dualdiscriminativegraphneuralnetworkforimbalancedgraphlevelanomalydetection/43b450fc-7716-499c-9a02-4761f33f68d2_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c488b8519775a1083e6cf40557c64607a741817501b36468e52a30e5ea8fe5ba
3
+ size 565959
dualdiscriminativegraphneuralnetworkforimbalancedgraphlevelanomalydetection/full.md ADDED
@@ -0,0 +1,371 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dual-discriminative Graph Neural Network for Imbalanced Graph-level Anomaly Detection
2
+
3
+ Ge Zhang<sup>1</sup> Zhenyu Yang<sup>1</sup>
4
+
5
+ Jia Wu $^{1*}$ Jian Yang $^{1}$ Xue Shan $^{2}$ Hao Peng $^{3}$ Jianlin Su $^{4}$
6
+
7
+ Chuan Zhou<sup>5</sup> Quan Z. Sheng<sup>1</sup> Leman Akoglu<sup>6</sup> Charu C. Aggarwal<sup>7</sup>
8
+
9
+ $^{1}$ Macquarie University $^{2}$ University of Wollongong $^{3}$ Beihang University
10
+
11
+ $^{4}$ Zhuiyi Technology $^{5}$ AMSS, Chinese Academy of Sciences
12
+
13
+ $^{6}$ Carnegie Mellon University $^{7}$ IBM T. J. Watson Research Center
14
+
15
+ {ge.zhang5, zhenyu.yang3}@students.mq.edu.au,
16
+
17
+ {jia.wu, jian.yang}@mq.edu.au, sxue@uow.edu.au,
18
+
19
+ penghao@buaa.edu.cn, bojonesu@wezhuiyi.com, zhouchuan@amss.ac.cn,
20
+
21
+ michael.sheng@mq.edu.au, lakoglu@andrew.cmu.edu, charu@us.ibm.com
22
+
23
+ # Abstract
24
+
25
+ Graph-level anomaly detection aims to distinguish anomalous graphs in a graph dataset from normal graphs. Anomalous graphs represent a very few but essential patterns in the real world. The anomalous property of a graph may be referable to its anomalous attributes of particular nodes and anomalous substructures that refer to a subset of nodes and edges in the graph. In addition, due to the imbalance nature of anomaly problem, anomalous information will be diluted by normal graphs with overwhelming quantities. Various anomaly notions in the attributes and/or substructures and the imbalance nature together make detecting anomalous graphs a non-trivial task. In this paper, we propose a graph neural network for graph-level anomaly detection, namely iGAD. Specifically, an anomalous graph attribute-aware graph convolution and an anomalous graph substructure-aware deep Random Walk Kernel (deep RWK) are welded into a graph neural network to achieve the dual-discriminative ability on anomalous attributes and substructures. Deep RWK in iGAD makes up for the deficiency of graph convolution in distinguishing structural information caused by the simple neighborhood aggregation mechanism. Further, we propose a Point Mutual Information (PMI)-based loss function to target the problems caused by imbalance distributions. PMI-based loss function enables iGAD to capture essential correlation between input graphs and their anomalous/normal properties. We evaluate iGAD on four real-world graph datasets. Extensive experiments demonstrate the superiority of iGAD on the graph-level anomaly detection task.
26
+
27
+ # 1 Introduction
28
+
29
+ Graphs have been used as an indispensable tool to describe relational data, such as chemical compounds, transport networks, and social networks. For instance, in a graph that models a chemical compound, nodes represent atoms and edges describe chemical bonds between atoms. Learning graphs to understand the world has been drawing considerable attention in recent years [5, 14, 15, 51]. Given a graph dataset containing a set of graphs, graph-level anomaly detection aims to identify graphs with anomalous information. Generally, these anomalous graphs with special characteristics or functions are the minority in a graph dataset. For example, among all antibody molecules, only
30
+
31
+ a few of them exhibit anti-cancer activity on a specific type of cancer cell line [55]. Graph-level anomaly detection is a research topic of great practical value, say, it can support cancer drug discovery by identifying molecules with anti-cancer activity from other antibody molecules [48]. Also, the research can help to reveal pathogenic brain mechanisms by distinguishing the brain structures of patients with neurological disorders from healthy individuals [21].
32
+
33
+ In practice, the attributes of particular nodes are a contributing factor to a graph's anomalous properties. For example, the hydrogen and oxygen atoms at the end of molecules are the key to discriminating between Alcohol and Alkane [45]. Graph substructures can be another factor for a graph's anomalous properties. For instance, pharmacophores composed of some particular substructures can induce molecular toxicity. These graph attributes and substructures that are essential for distinguishing anomalous graphs from normal graphs are regarded as anomalous attributes and anomalous substructures, respectively. Most existing graph mining methods, especially those graph convolution-based models which have achieved state-of-the-art performance [54, 59, 20, 3], focus on the aggregation of neighborhood-structured information. However, the anomalous structure information could be all possible substructures. In addition, anomalous attributes and substructures will be diluted by the information of normal graphs with overwhelming quantities, which is the imbalance nature of the anomaly problem. In summary, various anomaly notions in attributes and/or substructures and the imbalance nature make graph-level anomaly detection an important yet challenging problem.
34
+
35
+ In this paper, we propose a dual-discriminative graph neural network for imbalanced Graph-level Anomaly Detection (iGAD). Specifically, iGAD investigates a novel anomalous attribute-aware graph convolution. The final node representation is the concatenation of the independent encoding on a node itself and the independent encoding on its neighborhoods from different hops. In this way, the attributes of center nodes can evolve independently over the graph convolution process and the anomalous attributes on particular nodes can get exposure. However, it is intractable to enable graph convolution to be aware of anomalous substructures. Due to the high dependence on neighborhood aggregation, graph convolution can only capture very limited substructures in graphs. Moreover, even the simple substructures such as triangles, graph convolution cannot count them in a graph [3]. RWK [47], as one type of Graph Kernels (GKs), learns graphs by exploring common random walk sequences among all input graphs, which naturally involves the comparison about diverse substructures in different graphs. To embed the information of anomalous substructures into graph representations, we propose to compare random walk sequences of input graphs against anomalous substructures. By modeling anomalous substructures as parameters, they became learnable and can get updated through back-propagation. We entitle this design anomalous substructure-aware deep RWK. In addition, we propose a new loss function to target the imbalance distribution caused by the great difference in the number of normal and anomalous graphs. The newly proposed loss function models the PMI between graphs and their normal/anomalous properties and enables iGAD to capture anomalous information from an imbalanced graph dataset. Welding three designs mentioned above into a graph neural network, the graph-level anomaly detection model iGAD is achieved. We conclude the contributions of iGAD as follows:
36
+
37
+ - The anomalous attribute-aware graph convolution exposes anomalous attributes by keeping the independent evolution of center node's attributes.
38
+ - Anomalous substructures are modeled as learnable parameters. Substructure-aware deep RWK embeds the information of anomalous substructures into graph representations by comparing the random walk sequences from input graphs and anomalous substructures.
39
+ - The PMI-based loss function addresses issues brought by the imbalance nature of the anomaly problem and enables iGAD to learn anomalous graphs as a minority effectively.
40
+ - Comprehensive experiments demonstrate the effectiveness of iGAD, which outperforms state-of-the-art graph convolution-based graph classification models and graph-level anomaly detection algorithms on four real-world graph datasets. The code is available at https://github.com/graph-level-anomalies/iGAD.
41
+
42
+ # 2 Related Work
43
+
44
+ Anomaly Detection. The task aims to identify anomalies that deviate from the majority of samples. Early anomaly detection algorithms use different metrics, such as distance-based [18] and density-
45
+
46
+ based [7], to measure the deviation degree among samples to detect anomalies. For example, isolation forest-based algorithms [25, 26] identify anomalous by building the binary search tree structure to isolate samples. In addition, anomaly detection algorithms based on one-class classification [40, 39, 37, 63] and autoencoder [2, 64] have also been in the spotlight. For the graph-structured data, most graph anomaly detection algorithms dedicate to detect anomalies (e.g., anomalous nodes [44, 13, 58] and edges [36, 57]) in a single graph [1].
47
+
48
+ The anomaly notions of graph-level anomalies are more diversified than those of node-level anomalies. For example, node-level anomaly detection methods usually regard nodes that betray network homophily<sup>1</sup> as anomalies [44]. However, at the graph level, nodes that can achieve an anomalous graph go far beyond the nodes that do not meet homophily. Node-level anomaly detection methods identify anomaly nodes from a micro perspective (e.g., neighborhood structures) while identifying anomalous graphs needs learning graphs at the macro level. Employing node-level anomaly detection methods to detect graph-level anomalies could capture some anomalies, but only a small part. Moreover, graph-level anomaly detection algorithms need to consider anomaly notions related to graph substructures. Hence, it is necessary to propose anomaly detection methods that are specialized in detecting graph-level anomalies.
49
+
50
+ Graph-level Anomaly Detection. To the best of our knowledge, there are only several preliminary research on graph-level anomaly detection. Zhao et al. [62] investigate a research question of "should we use the data for the graph classification task to evaluate graph-level anomaly detection models?", followed by which two graph-level anomaly detection algorithms [27, 35] combine Graph Neural Networks (GNNs) with knowledge distillation and one-class classification respectively to detect anomalous graphs.
51
+
52
+ Graph-level anomaly detection can be regarded as a special case of graph classification. There is a huge gap between the number of graphs belonging to the normal class versus the anomalous ones. But, graph classification algorithms usually assume that the number of graphs in each class is close. GKs [47, 16, 42, 6, 41] used to be the mainstream graph classification methods. Generally, GKs use the kernel function to calculate kernel values (i.e., similarity) between pair-wised graphs. Afterward, an off-the-shelf classifier is applied to the graph similarity matrix to perform the classification task. Graph classification algorithms based on GKs cannot learn graph representations explicitly and be optimized in an end-to-end fashion. In recent years, graph mining practitioners pay more attention to GNNs [8, 11, 4, 38]. GNNs with spatial graph convolution [20, 46, 19] are summarized as message-passing framework (MPNNs) [17, 54, 59, 56, 52]. In general, MPNNs update the representation of each node by iteratively aggregating information coming from their neighbors. To represent a graph, MPNNs apply the readout function or pooling operation on node embeddings. The spatial graph convolution that mix the representation of nodes and their neighborhoods to represent nodes will smooth node attributes [61, 4]. In addition, [31, 28, 60] proved that spatial graph convolution has limited power in distinguishing graph structures. Performing message passing between subgraphs can enable spatial graph convolution to capture more graph structural information. But such a solution exponentially consumes memory resources and computation complexities [3].
53
+
54
+ Graph classification methods mentioned above are likely to underfit anomalous graphs since they do not have any intrinsic mechanism to target the imbalanced distributions. In iGAD, a novel loss is presented for the imbalanced distributions by modeling PMI. In addition, different from existing graph-level anomaly methods [62, 27, 35] that employ the off-the-shelf MPNNs (e.g., GIN [54]) to represent graphs, iGAD can embed the information of anomalous attributes and substructures into graph representations.
55
+
56
+ Imbalanced Learning. Learning data with imbalanced distribution can be divided into data- and algorithm-level approaches. The former alleviates the imbalanced distribution of the original data by either under-sampling the majority [49] or over-sampling the minority [9]. However, modifying the original distribution of data will bring a lot of drawbacks inevitably, such as over-fitting and discarding important samples. There are different types of approaches to address the issue at the algorithm level. The typical approaches include employing post-hoc correction [30], aligning data distribution, [53], and modifying the loss function [24, 22]. In the real-world application, considering the different consequences of false-positive identification (e.g., predicting an inactive chemical compound to be
57
+
58
+ active) and false-negative identification (e.g., predicting a cancer patient as a healthy individual), the situation will be more complicated [33]. In this paper, iGAD introduces PMI to the cross-entropy loss function to solve this problem.
59
+
60
+ # 3 Preliminaries
61
+
62
+ Notations. A graph dataset consisting of $N$ graphs can be denoted as $\mathcal{G} = \{G_1, \dots, G_N\}$ , where $G_i = \{V_i, E_i\}$ is an unweighted and undirected graph in $\mathcal{G}$ , $V_i$ and $E_i$ are the node and the edge set, respectively. The topology of $G_i$ can be modeled as an adjacency matrix $\mathbf{A}_i \in \{0, 1\}^{n \times n}$ , where $\mathbf{A}_i(u, v) = 1$ if there is an edge between nodes $u$ and $v$ , otherwise $0$ . $\mathbf{A}_i$ does not consider the self-loop, $\mathbf{A}_i(u, u) = 0, \forall u \in V_i$ . We use $\mathbf{x}_u \in \mathbb{R}^c$ to denote the attribute vector of node $u \in V_i$ . $\mathbf{X}_i \in \mathbb{R}^{n \times c}$ is the attribute matrix of $G_i$ . $G_i' = \{V_i', E_i'\}$ can be regarded as a substructure in $G_i$ , iff $V_i' \subseteq V_i$ and $E_i' \subseteq E_i$ . $\mathcal{Y}$ is the label set of $\mathcal{G}$ . $G_i$ is labeled by $y_i \in \{0, 1\}$ , where 1 represents anomalous and 0 represents normal.
63
+
64
+ Problem Definition. This paper concentrates on the supervised graph-level anomaly detection problem. Given the training set $\mathcal{T} = \{(G_1, y_1), (G_2, y_2), \ldots\}$ , we aim to train a model to predict the normal/anomalous properties of unseen graphs. $\mathcal{T}$ contains $N_1$ anomalous graphs and $N_0$ normal graphs ( $N_1 \ll N_0$ ). The imbalanced ratio of $\mathcal{T}$ is defined as $\delta$ ( $\delta = \frac{N_1}{N_0 + N_1}$ ).
65
+
66
+ Spatial Graph Convolution. A graph convolution layer updates node representations by iteratively aggregating information coming from its one-hop neighborhood. The formulation is:
67
+
68
+ $$
69
+ \mathbf {h} ^ {(k + 1)} (u) = \sigma \left(f _ {\text {C o m b i n e}} \left(\mathbf {h} ^ {(k)} (u), f _ {\text {A G G R E G A T E}} \left(\{\mathbf {h} ^ {(k)} (v), v \in \mathcal {N} (u) \}\right)\right)\right), \mathbf {h} ^ {(0)} (u) = \mathbf {x} _ {u}, \tag {1}
70
+ $$
71
+
72
+ where $0 \leq k \leq K - 1$ , $\mathcal{N}(u)$ denotes the 1-hop neighborhood of node $u$ . $f_{\mathrm{AGGREGATE}}$ denotes how to aggregate neighbors of node $u$ , and $f_{\mathrm{COMBINE}}$ defines how to combine the immediate representations of node $u$ and its neighbors. $\sigma$ is the activation function. Generally, the final representation of the node $u$ is $\mathbf{h}^{(K)}(u)$ .
73
+
74
+ Random Walk Kernels (RWK). RWK measures graph similarities by counting common random walk sequences among graphs. There are two graphs $G_{1} = \{V_{1}, E_{1}\}$ and $G_{2} = \{V_{2}, E_{2}\}$ . $G_{\times} = \{V_{\times}, E_{\times}\}$ denotes the direct product graph about $G_{1}$ and $G_{2}$ , where $V_{\times} = \{(u, u') | u \in V_{1}, u' \in V_{2}\}$ and $E_{\times} = \{((u, u'), (v, v')) | (u, v) \in E_{1}, (u', v') \in E_{2}\}$ . Performing random walking on $G_{\times}$ is equivalent to doing random walking on $G_{1}$ and $G_{2}$ simultaneously. The adjacency matrix of direct product graph $\mathbf{A}_{\times}$ can be obtained by the Kronecker product operation $\otimes$ on $\mathbf{A}_{1}$ and $\mathbf{A}_{2}$ , that is $\mathbf{A}_{\times} = \bar{\mathbf{A}}_{1} \otimes \mathbf{A}_{2}$ . The number of $l$ -length common walk sequences between $G_{1}$ and $G_{2}$ is $\kappa^{(l)}(G_{1}, G_{2}) = \mathbf{q}_{\times}^{\top}(\mathbf{A}_{\times})^{l}\mathbf{p}_{\times}$ , where $\mathbf{p}_{\times}$ and $\mathbf{q}_{\times}$ are the vector about the starting and stopping probabilities of random walks on $G_{\times}$ , respectively. The elements in $\mathbf{p}_{\times}$ and $\mathbf{q}_{\times}$ are all ones when there is no prior knowledge. Overall, the RWK about $G_{1}$ and $G_{2}$ can be defined as:
75
+
76
+ $$
77
+ \mathcal {K} \left(G _ {1}, G _ {2}\right) := \sum_ {l = 0} ^ {\infty} \kappa^ {(l)} \left(G _ {1}, G _ {2}\right). \tag {2}
78
+ $$
79
+
80
+ # 4 iGAD
81
+
82
+ In this section, we will describe iGAD in detail (see Figure 1 for an illustration). iGAD contains three key designs: (1) anomalous graph attribute-aware graph convolution; (2) anomalous substructure-aware deep RWK; and (3) PMI-based loss function. The first two designs encode the anomalous information on graph attributes and substructures into graph embeddings. The loss function makes the training on iGAD not completely dominated by normal graphs.
83
+
84
+ # 4.1 iGAD: Anomalous Attribute-aware Graph Convolution
85
+
86
+ As aforementioned in Section 1, the attributes of particular nodes can achieve an anomalous graph. The graph convolution which iteratively updates node representations by performing feature transformation on the concatenated information about nodes and their neighborhoods will make node representations over-smoothed [61]. Under such a graph convolution mechanism, only limited anomalous information can be manifest in corresponding node representations. We argue that making each
87
+
88
+ ![](images/3dae79b6ccd9b0c0970c490c30a64aa410fe49440af96ccce79b669f6b32ef25.jpg)
89
+ Figure 1: Taking learning the graph $G_{N}$ in a graph dataset as an example, we illustrate the framework of iGAD with three designs. I. Anomalous Attribute-aware Graph Convolution, which concatenates the independent encoding on nodes and their k-hop neighborhoods to represent nodes in $G_{N}$ . To obtain the graph representation $\mathbf{h}_{G_N}^{\mathrm{CONV}}$ , a readout function is applied to all node representations. II. The Anomalous Substructure-aware Deep RWK, which performs random walks on two learnable anomalous substructures (i.e., $S_{1}$ and $S_{2}$ ) and the input graph $G_{N}$ simultaneously. Deep RWK obtains $\mathbf{h}_{G_N}^{\mathrm{KER}}$ based on kernel values $\kappa^{(l)}(G_N,S_m), l = \{1,\dots,L\}$ , $m = \{1,\dots,M\}$ . III. The PMI-based Loss Function. iGAD concatenates $\mathbf{h}_{G_N}^{\mathrm{CONV}}$ and $\mathbf{h}_{G_N}^{\mathrm{KER}}$ to obtain the final graph representation $\mathbf{h}_{G_N}$ . Finally, a MLP is applied to $\mathbf{h}_{G_N}$ to predict $G_{N}$ . The model training is guided by a PMI-based loss function.
90
+
91
+ node's attributes evolve independently over the graph convolution process is critical for capturing anomalous attributes. To achieve it, anomalous attribute-aware graph convolution concatenates the independent encoding on the node itself and the independent encoding on its $k$ -hop neighborhood $(1 \leq k \leq K)$ to represent each node in a graph. Formally,
92
+
93
+ $$
94
+ \mathbf {h} _ {u} = f _ {\text {C o m b i n e}} \left(\mathbf {h} ^ {(0)} (u), \mathbf {h} ^ {(1)} (u), \dots , \mathbf {h} ^ {(K)} (u)\right), \tag {3}
95
+ $$
96
+
97
+ where $\mathbf{h}_u$ is the final node representation of the node $u$ , $\mathbf{h}^{(k)}(u)$ is the representation of node $u$ 's $k$ -hop neighborhood, and $f_{\mathrm{COMBINE}}$ is the concatenation operation. $\mathbf{h}^{(0)}(u)$ and $\mathbf{h}^{(k)}(u)$ are formulated as:
98
+
99
+ $$
100
+ \mathbf {h} ^ {(0)} (u) = \operatorname {M L P} \left(\mathbf {x} _ {u}\right), \tag {4}
101
+ $$
102
+
103
+ and
104
+
105
+ $$
106
+ \mathbf {h} ^ {(k)} (u) = \sigma \left(\mathbf {A} _ {i} \mathbf {H} _ {i} ^ {(k - 1)} \mathbf {W} ^ {(k)}\right) _ {u}, \tag {5}
107
+ $$
108
+
109
+ respectively, where $\mathbf{H}_i^{(0)} = \mathbf{X}_i$ , MLP denotes a multi-layer perceptron, $\sigma$ represents the activation function, and $\mathbf{W}^{(k)}$ is the trainable weight matrix. To obtain the entire graph representation $\mathbf{h}_{G_i}^{\mathrm{CONV}}$ , we apply the permutation invariant Readout function $\mathcal{R}(\cdot)$ on all nodes in the graph $G_{i}$ . That is,
110
+
111
+ $$
112
+ \mathbf {h} _ {G _ {i}} ^ {\text {C O N V}} = \mathcal {R} \left(\left\{\mathbf {h} _ {u} \mid u \in V _ {i} \right\}\right), \tag {6}
113
+ $$
114
+
115
+ where $\mathcal{R}(\cdot)$ can be the sum-based or mean-based global pooling operation.
116
+
117
+ # 4.2 iGAD: Anomalous Substructure-aware Deep RWK
118
+
119
+ Generally, the neighborhood aggregation mechanism adopted by existing GNNs only depends on local neighborhood structures to perform message passing [60]), which leads to the deficiency of graph convolution in distinguishing substructures [3, 10]. To make iGAD to be aware of anomalous substructures, we resort to RWK that can explore diverse substructures through random walking sequences. There is a pioneering work [32] that represents graphs by calculating RWK values between input graphs and some substructures. It inspires us to embed information about anomalous substructures into graph representations by performing random walks in input graphs and learnable anomalous substructures simultaneously.
120
+
121
+ We present an anomalous substructure-aware deep RWK, which models elements in the adjacency matrices of anomalous substructures as learnable parameters. Supposed that $\{S_1,\dots,S_M\}$ is the set
122
+
123
+ of $M$ anomalous substructures, and the size of $S_{m}$ is $n^{\prime}$ . $\mathbf{P}_m\in \mathbb{R}^{n'\times n'}$ is the adjacency matrix of $S_{m}$ , where the matric element $\mathbf{P}_m(u',v')$ denotes the possibility that an edge exists between nodes $u^{\prime}$ and $v^{\prime}$ in $S_{m}$ . As the adjacency matrix is symmetric, $\mathbf{P}_m$ contains $\frac{n'(n' - 1)}{2}$ parameters. Referring to Eq. 2 and supposing that the starting and the stopping possibilities on each node are all ones, the number of $l$ -length common random walk sequences between the input graph $G_{i}$ and the anomalous substructure $S_{m}$ is:
124
+
125
+ $$
126
+ \kappa^ {(l)} \left(G _ {i}, S _ {m}\right) = \mathbf {1} ^ {\mathsf {T}} \left(\mathbf {A} _ {i} \otimes \mathbf {P} _ {m}\right) ^ {l} \mathbf {1} = \sum_ {i} \sum_ {j} \left[ \left(\mathbf {P} _ {m}\right) ^ {l} \mathbf {E} \left(\mathbf {A} _ {i}\right) ^ {l} \right] _ {i, j}, \tag {7}
127
+ $$
128
+
129
+ where $\mathbf{1} \in \mathbb{R}^{n'n}$ is a column vector full of 1, and $\mathbf{E} \in \mathbb{R}^{n' \times n}$ is a matrix in which all elements are 1. The proof of Eq. 7 can be found in Appendix A.1. RWK with infinite random walk lengths will often meet the halting issue [43]. Therefore, iGAD only considers the random walk length from 1 to $L$ . As the size of anomalous substructures $(n')$ is small, optimizing $(\mathbf{P}_m)^l$ is not necessary. The adjacency matrix $\mathbf{A}_i$ is sparse, and we compute $(\mathbf{A}_i)^l$ by the sparse matrix multiplication in PyTorch [34]. That is $(\mathbf{A}_i^s)^l = \mathbf{A}_i^s (\mathbf{A}_i^s \dots (\mathbf{A}_i^s (\mathbf{A}_i))\dots)$ , where $\mathbf{A}_i^s$ is the sparse version of $\mathbf{A}_i$ . Afterward, deep RWK values $\kappa^{(l)}(G_i, S_m)$ about $G_i$ and $S_m$ , $m = \{1,..,M\}$ , $l = \{1,..,L\}$ will be assembled into a vector $\mathbf{a}_{G_i}$ . That is,
130
+
131
+ $$
132
+ \mathbf {a} _ {G _ {i}} = \left(\kappa^ {(1)} \left(G _ {i}, S _ {1}\right), \dots , \kappa^ {(1)} \left(G _ {i}, S _ {M}\right); \dots ; \kappa^ {(L)} \left(G _ {i}, S _ {1}\right), \dots , \kappa^ {(L)} \left(G _ {i}, S _ {M}\right)\right), \tag {8}
133
+ $$
134
+
135
+ where $\mathbf{a}_{G_i} \in \mathbb{R}^{ML}$ . The graph representation $\mathbf{h}_{G_i}^{\mathrm{KER}}$ based on deep RWK is:
136
+
137
+ $$
138
+ \mathbf {h} _ {G _ {i}} ^ {\mathrm {K E R}} = \operatorname {M L P} \left(\mathbf {a} _ {G _ {i}}\right). \tag {9}
139
+ $$
140
+
141
+ The final graph representation $\mathbf{h}_{G_i}$ for $G_{i} \in \mathcal{G}$ can be obtained by concatenating $\mathbf{h}_{G_i}^{\mathrm{CONV}}$ and $\mathbf{h}_{G_i}^{\mathrm{KER}}$ together. The anomalous attribute-aware graph convolution and anomalous substructure-aware deep RWK are welded into a graph neural network together through $\mathbf{h}_{G_i}$ .
142
+
143
+ # 4.3 iGAD: PMI-based Loss Function
144
+
145
+ The number of normal graphs is much more than that of anomalous graphs. Under the imbalance nature of the anomaly problem, normal graphs will dominate model training. Targeting this issue, we propose a new loss function that can model the PMI between input graphs and their anomalous/normal properties. Specifically, we use $f(\mathcal{G};\Theta)$ to denote the proposed model iGAD, where $\Theta$ represents model parameters. Modeling the PMI between the input graph $G_{i}$ and its anomalous/normal properties can be formulated as:
146
+
147
+ $$
148
+ f _ {y _ {i}} \left(G _ {i}; \Theta\right) \sim \log \frac {P _ {\Theta} \left(G _ {i} , y _ {i}\right)}{P \left(G _ {i}\right) P \left(y _ {i}\right)}, \tag {10}
149
+ $$
150
+
151
+ where the right part represents the PMI between $G_{i}$ and $y_{i}$ , $P(y_{i})$ is the proportion of anomalous graphs or normal graphs in the training set $\mathcal{T}$ . Compared with most existing loss functions, especially the loss function that models the conditional distribution about $y_{i}$ given $G_{i}$ (i.e., $f_{y_i}(G_i;\Theta)\sim P_\Theta (y_i|G_i)$ ), PMI enables iGAD to give priority to learning the information that reveals the essential correlation between graphs and their labels. Eq. 10 can be reformatted as:
152
+
153
+ $$
154
+ \log P _ {\Theta} \left(y _ {i} \mid G _ {i}\right) \sim f _ {y _ {i}} \left(G _ {i}, \Theta\right) + \log P \left(y _ {i}\right). \tag {11}
155
+ $$
156
+
157
+ After softmax normalization, the distribution of $y_{i}$ given $G_{i}$ is formulated as:
158
+
159
+ $$
160
+ P _ {\Theta} \left(y _ {i} \mid G _ {i}\right) = \frac {e ^ {f _ {y _ {i}} \left(G _ {i} ; \Theta\right) + \log P \left(y _ {i}\right)}}{\sum_ {y _ {i}} e ^ {f _ {y _ {i}} \left(G _ {i} ; \Theta\right) + \log P \left(y _ {i}\right)}}. \tag {12}
161
+ $$
162
+
163
+ Incorporating $P_{\Theta}(y_i|G_i)$ in to the framework of the cross-entropy loss function, we can obtain the PMI-based loss function $\mathcal{L}$ :
164
+
165
+ $$
166
+ \mathcal {L} = \frac {1}{N} \sum_ {i = 1} ^ {N} - \log P _ {\Theta} \left(y _ {i} \mid G _ {i}\right). \tag {13}
167
+ $$
168
+
169
+ Specifically, iGAD predict the graph $G_{i}$ :
170
+
171
+ Table 1: Statistical information of four real-world datasets. We regard the one-hot encoding of node labels (e.g., carbon (C), nitrogen (N), oxygen (O)) as node attributes.
172
+
173
+ <table><tr><td>DATASET</td><td>#GRAPHS (N)</td><td>#ANOMALOUS GRAPHS</td><td>δ</td><td>AVG. #NODES (AVG. n)</td><td>AVG. #EDGES (AVG. |E|)</td><td># NODE LABELS (c)</td><td>TUMOR</td></tr><tr><td>SW-620</td><td>40,532</td><td>2,411</td><td>5.95%</td><td>26.05</td><td>28.08</td><td>65</td><td>COLON</td></tr><tr><td>MOLT-4</td><td>39,765</td><td>2,904</td><td>7.90%</td><td>26.07</td><td>28.13</td><td>64</td><td>LEUKEMIA</td></tr><tr><td>MCF-7</td><td>27,770</td><td>2,293</td><td>8.26%</td><td>26.39</td><td>28.52</td><td>46</td><td>BREAST</td></tr><tr><td>PC-3</td><td>27,509</td><td>1,568</td><td>5.70%</td><td>26.35</td><td>28.49</td><td>45</td><td>PROSTATE</td></tr></table>
174
+
175
+ $$
176
+ y _ {i} ^ {*} = \left\{ \begin{array}{l l} \underset {y _ {i}} {\operatorname {a r g m a x}} f _ {y _ {i}} \left(G _ {i}; \Theta\right) + \log P \left(y _ {i}\right), & \text {d u r i n g t r a i n i n g .} \\ \underset {y _ {i}} {\operatorname {a r g m a x}} f _ {y _ {i}} ^ {*} \left(G _ {i}; \Theta\right), & \text {d u r i n g t e s t i n g .} \end{array} \right. \tag {14}
177
+ $$
178
+
179
+ The reason that we use $\operatorname{argmax}_{y_i} f_{y_i}^*(G_i; \Theta)$ to predict a graph in test time can be found in Appendix A.2.
180
+
181
+ Many other loss functions target the difficulties brought by imbalanced distributions, such as the cost-sensitive loss function that assigns or learns different weights to the majority and the minority samples [29, 50, 12]. Compared with them, the PMI-based loss function does not introduce any new parameters that need to be carefully tuned. It comes in the form of the most widely used cross-entropy loss function and gives prediction results that can achieve maximized PMI between inputs and predictions.
182
+
183
+ # 4.4 Algorithm Description & Computational Complexity
184
+
185
+ The pseudocode of iGAD is included in Algorithm 1 in Appendix A.1. We divide graphs in $\mathcal{G}$ into different mini-batches to train iGAD [23]. But for illustrating how iGAD predicts a graph more clearly, the batch size is set as 1 in Algorithm 1. Given the training set, we initialize anomalous substructures and other parameters (Line 1 in Algorithm 1) and calculate the proportion of normal and anomalous graphs (Line 2). For each graph, iGAD learns its graph representation (Lines 3 to 15). Based on the graph representation, a MLP equipped with the PMI-based loss function gives predictions to graphs (Lines 16 and 17). At the back-propagation stage, anomalous substructures and other parameters will get updated. At each epoch, deep RWK performs random walking on input graphs and anomalous substructures that get updated during the previous epoch.
186
+
187
+ Lemma 1 The computational complexity of iGAD is $\mathcal{O}(n + |E|)$ , where $n$ and $|E|$ are the number of nodes and edges, respectively. (The detailed analysis can be found in Appendix A.3).
188
+
189
+ # 5 Experiments
190
+
191
+ In this section, we conduct a series of experiments to study the performance of iGAD on the graph-level anomaly detection task. Specifically, we investigate the following six questions:
192
+
193
+ Q1. How about the performance of iGAD on the graph-level anomaly detection task?
194
+ Q2. Does iGAD benefit from the PMI-based loss function?
195
+ Q3. How about the performance of the anomalous graph attribute-aware graph convolution in iGAD?
196
+ Q4. How about the performance of iGAD when it utilizes pre-defined anomalous substructures?
197
+ Q5. Can the anomalous substructure-aware deep RWK in iGAD learn anomalous substructures?
198
+ Q6. How does the maximum length of random walk sequences affect the performance of iGAD?
199
+
200
+ The questions from Q2 to Q4 can be regarded as the ablation study on our three main design elements, they are: (a). cross-entropy loss function versus the proposed PMI-based loss function; (b). general graph convolution versus the proposed graph convolution; (c). RWK versus the proposed deep RWK.
201
+
202
+ Table 2: Graph-level anomaly detection performance (\%) of five graph classification methods, their GAD variants, iGAD, and iGAD's two variants on four datasets. The value behind $\pm$ denotes the standard deviation (mean $\pm$ std) over different data splits. The best result is highlighted in gray. The description about evaluation metrics AUC, Recall, Recall(A), and $F$ -score is in Appendix B.1.
203
+
204
+ <table><tr><td>DATA</td><td>METRICS</td><td>GCN</td><td>GCN-GAD</td><td>GIN</td><td>GIN-GAD</td><td>DGCNN</td><td>DGCNN-GAD</td><td>SOPOOL</td><td>SOPOOL-GAD</td><td>RWGNN</td><td>RWGNN-GAD</td><td>IGAD-1</td><td>IGAD-2</td><td>IGAD</td></tr><tr><td rowspan="4">SW-620</td><td>AUC</td><td>74.90±0.74</td><td>76.48±1.51</td><td>78.61±2.85</td><td>76.42±2.80</td><td>80.06±0.42</td><td>79.36±1.28</td><td>75.51±5.06</td><td>76.89±2.07</td><td>73.37±0.36</td><td>74.92±1.97</td><td>85.40±0.93</td><td>85.77±0.72</td><td>85.82±0.69</td></tr><tr><td>RECALL</td><td>51.79±0.47</td><td>69.65±1.39</td><td>56.62±3.97</td><td>70.38±2.18</td><td>56.02±1.16</td><td>72.65±0.63</td><td>56.01±2.29</td><td>69.97±1.69</td><td>51.43±0.87</td><td>68.32±1.76</td><td>78.60±0.97</td><td>79.08±1.31</td><td>79.64±0.83</td></tr><tr><td>RECALL(A)</td><td>3.78±0.95</td><td>67.26±1.88</td><td>14.40±8.57</td><td>64.11±6.83</td><td>12.74±2.41</td><td>67.84±1.78</td><td>13.28±5.05</td><td>62.32±6.23</td><td>3.11±1.82</td><td>63.82±5.40</td><td>74.23±3.66</td><td>73.24±2.52</td><td>74.27±2.99</td></tr><tr><td>F-SCORE</td><td>52.00±0.87</td><td>52.44±1.32</td><td>58.47±5.43</td><td>55.00±2.82</td><td>58.73±1.64</td><td>56.11±0.89</td><td>58.11±2.86</td><td>55.63±4.78</td><td>51.31±1.62</td><td>52.47±3.17</td><td>61.82±2.22</td><td>63.36±1.58</td><td>63.68±1.56</td></tr><tr><td rowspan="4">MOT-4</td><td>AUC</td><td>72.55±0.52</td><td>72.88±0.99</td><td>75.86±1.60</td><td>75.43±2.82</td><td>76.50±0.60</td><td>77.43±0.73</td><td>75.11±0.97</td><td>74.50±1.69</td><td>71.30±1.23</td><td>71.51±0.70</td><td>81.59±1.10</td><td>82.73±1.12</td><td>83.59±1.07</td></tr><tr><td>RECALL</td><td>51.26±0.54</td><td>66.84±0.66</td><td>56.87±6.98</td><td>69.40±2.47</td><td>55.35±1.27</td><td>70.14±0.69</td><td>55,31±3.74</td><td>69.12±1.50</td><td>51.39±1.41</td><td>65.84±1.27</td><td>74.97±1.61</td><td>76.33±1.18</td><td>76.82±0.82</td></tr><tr><td>RECALL(A)</td><td>2.74±1.12</td><td>67.32±3.04</td><td>17.71±9.02</td><td>64.36±7.14</td><td>11.69±2.87</td><td>65.76±1.97</td><td>12.23±9.34</td><td>63.44±6.55</td><td>3.18±3.21</td><td>61.24±3.89</td><td>68.18±2.72</td><td>70.54±4.28</td><td>72.10±2.47</td></tr><tr><td>F-SCORE</td><td>50.53±1.03</td><td>51.25±1.50</td><td>55.43±6.52</td><td>55.86±2.01</td><td>57.33±1.76</td><td>56.22±1.32</td><td>56.20±3.64</td><td>56.02±3.17</td><td>50.67±2.64</td><td>52.69±2.60</td><td>62.22±0.48</td><td>63.12±1.31</td><td>63.30±1.17</td></tr><tr><td rowspan="4">PC-3</td><td>AUC</td><td>75.36±2.13</td><td>75.62±1.22</td><td>78.44±1.67</td><td>76.95±1.74</td><td>79.15±1.84</td><td>78.90±1.70</td><td>69.37±1.53</td><td>78.24±1.97</td><td>76.27±0.86</td><td>76.10±1.92</td><td>85.44±1.20</td><td>85.83±1.02</td><td>86.04±1.14</td></tr><tr><td>RECALL</td><td>50.72±0.59</td><td>69.46±1.57</td><td>57.43±4.61</td><td>71.49±1.27</td><td>52.88±0.28</td><td>72.53±1.40</td><td>56.78±3.79</td><td>71.44±1.53</td><td>51.02±1.53</td><td>69.90±1.74</td><td>78.31±0.76</td><td>79.94±0.64</td><td>79.59±0.41</td></tr><tr><td>RECALL(A)</td><td>1.53±1.26</td><td>65.29±5.69</td><td>16.31±10.47</td><td>68.22±6.76</td><td>6.05±0.57</td><td>70.06±5.19</td><td>15.67±8.98</td><td>69.60±9.54</td><td>2.17±3.26</td><td>66.62±3.03</td><td>70.45±3.29</td><td>75.35±0.74</td><td>75.69±1.64</td></tr><tr><td>F-SCORE</td><td>49.99±1.63</td><td>52.76±1.11</td><td>59.07±4.15</td><td>54.09±3.04</td><td>54.01±0.48</td><td>54.46±1.70</td><td>57.80±3.74</td><td>51.76±5.27</td><td>50.44±2.76</td><td>52.72±1.54</td><td>61.17±2.43</td><td>62.97±1.40</td><td>63.50±0.73</td></tr><tr><td rowspan="4">MCF-7</td><td>AUC</td><td>72.70±1.05</td><td>73.89±0.99</td><td>69.54±1.15</td><td>75.90±1.44</td><td>76.41±0.81</td><td>76.83±0.48</td><td>75.64±2.17</td><td>76.69±1.33</td><td>70.47±1.26</td><td>73.25±1.56</td><td>83.02±0.46</td><td>83.49±1.03</td><td>83.22±0.64</td></tr><tr><td>RECALL</td><td>50.42±0.28</td><td>67.14±1.13</td><td>57.08±3.82</td><td>69.40±2.32</td><td>55.11±1.11</td><td>70.74±0.63</td><td>56.82±3.57</td><td>68.88±1.07</td><td>52.09±1.06</td><td>66.99±1.91</td><td>75.80±0.81</td><td>76.81±0.97</td><td>76.77±0.47</td></tr><tr><td>RECALL(A)</td><td>0.96±0.63</td><td>61.79±2.14</td><td>16.69±9.92</td><td>59.48±10.14</td><td>11.07±2.33</td><td>69.37±3.05</td><td>15.34±8.20</td><td>63.92±7.30</td><td>4.97±5.24</td><td>57.73±11.16</td><td>67.67±2.54</td><td>71.59±2.19</td><td>73.38±3.59</td></tr><tr><td>F-SCORE</td><td>48.76±0.59</td><td>53.37±1.89</td><td>58.27±3.20</td><td>58.71±2.53</td><td>56.99±1.70</td><td>55.74±1.54</td><td>56.82±3.57</td><td>54.82±3.00</td><td>51.65±3.46</td><td>56.06±2.93</td><td>61.56±1.89</td><td>63.75±1.18</td><td>64.70±2.58</td></tr></table>
205
+
206
+ # 5.1 Experimental Setup
207
+
208
+ Datasets. SW-610, MOLT-4, PC-3, and MCF-7 are four real-world graph datasets. These datasets are collected from PubChem $^2$ , which records a tremendous amount of chemical compounds and their anti-cancer activity testing results ("active" or "inactive") on different types of cancer cell lines. We regard the chemical compounds with the outcome "active" as anomalous, and "inactive" as normal. For example, the graph dataset SW-620 records 40,532 chemical formulas and their anti-cancer activity testing results on the colon cancer cell line. Chemical compounds that exhibit antibody activity against colon cancer are labeled as anomalous graphs, otherwise normal graphs. The statistical information about these four datasets is shown in Table 1.
209
+
210
+ Baselines & Experimental Settings. To investigate Q1, we compare iGAD with the following baseline models: (1) GCN[20] + Readout function (abbreviated GCN) and GIN [54]. These two algorithms employ spatial graph convolution to learn node representation and apply the readout function to node representations to obtain graph representations and classify graphs; (2) DGCNN [59] and SOPool [52]. In these two models, spatial graph convolution and the graph pooling operation are employed to downsize graphs and complete the graph classification task; (3) RWGNN [32]. It employs
211
+
212
+ Table 3: The performance $(\%)$ of two graphlevel anomaly detection methods (i.e., GLocalKD and OCGTL) and iGAD w.r.t. AUC.
213
+
214
+ <table><tr><td>DATA</td><td>GLOCALKD</td><td>OCGTL</td><td>IGAD</td></tr><tr><td>Sw-620</td><td>64.14±0.92</td><td>67.69±0.02</td><td>85.82±0.69</td></tr><tr><td>MOLT-4</td><td>61.43±1.26</td><td>57.42±2.38</td><td>83.59±1.07</td></tr><tr><td>PC-3</td><td>64.79±1.22</td><td>68.42±1.73</td><td>86.04±1.14</td></tr><tr><td>MCF-7</td><td>61.43±1.26</td><td>64.92±1.92</td><td>83.22±0.64</td></tr></table>
215
+
216
+ random walk sequences to represent graphs and then classify graphs based on graph representations. All the above baselines are supervised and use the cross-entropy loss function; (4) The graph-level anomaly detection methods GLocalKD [27] and OCGTL [35]. The former adopts random distillation to detect the locally- and globally-anomalous graphs and the latter combines the one-class classification and graph transformation learning to identify anomalous graphs. Both of them only use normal graphs to train models. They learn anomaly scores for graphs to measure each graph' anomaly degree and do not provide any criterion to determine whether a graph is anomalous or not.
217
+
218
+ For the fairness of experiments and to answer Q2, we also compare iGAD with GCN-GAD, GINGAD, DGCNN-GAD, SOPool-GAD, and RWGNN-GAD. These algorithms are the graph anomaly detection (GAD) variants of GCN, GIN, DGCNN, SOPool, and RWGNN. We replace the cross-entropy loss in these algorithms with the proposed PMI-based loss function. To answer Q3, we consider a variant of iGAD —iGAD-1 that only utilizes the anomalous graph attribute-aware graph convolution to represent graphs and detect anomalous graphs. To answer Q4, we consider the other variant named iGAD-2 in which the random walking performs on input graphs and pre-defined anomalous graph substructures simultaneously. Specifically, we use 3-star, triangle, tailed triangle,
219
+
220
+ ![](images/4dc83f86580175417d4aac67a8a3b3bf63b0c729225df59f6a646e171ff7b090.jpg)
221
+
222
+ ![](images/da41fb90d463e8d74174e9a28d245fae9da53eaad9baf5760c77cf39d07f64f5.jpg)
223
+
224
+ ![](images/60ff25e9cc1fc4713406866cdfc25c09aa135e75a70c62a7562c1c505dd927cb.jpg)
225
+
226
+ ![](images/1ea2acec5af3a3ea80f33d956a29944ec8d4f132d22edfe0e1ee8d8745708141.jpg)
227
+
228
+ ![](images/ddb712072c722afb4dc7ed233f5187b341d28488fd8d356f6f722c76e2c0b460.jpg)
229
+ Figure 3: The impact of different maximum random walk length $L$ on the performance of iGAD. The first row reports the performance of iGAD under the setting $M = 5$ and $n' = 8$ . The second row reports the performance of iGAD under the setting $M = 5$ and $n' = 10$ .
230
+
231
+ ![](images/6e312f0ab090fbe403365d61f9b4dd0eeaf1f294e66c74d3eb7e6837559cb78e.jpg)
232
+
233
+ ![](images/5acfed03422450cde57e8d624ea282f539c5a0424b0915168aceb419cf1da9a8.jpg)
234
+
235
+ ![](images/78cdcf9407575cd8de4e5e094b87496b8cf3a4ad988f909a2b0c2f9b30ece204.jpg)
236
+
237
+ and 4-cycle graphlets as pre-defined graph anomalous substructures (see Figure 4 in Appendix B for these substructures). Information about parameter setting and algorithm implementation can be found in Appendix B.1. We report experimental results under 5-fold cross-validation.
238
+
239
+ # 5.2 Experimental Results
240
+
241
+ This section answers Q1 - Q6 by A1 - A6, respectively. We put extra experiments in Appendix B.2.
242
+
243
+ A1. iGAD demonstrates superior performance in identifying graph-level anomalies. Observed from Table 2: 1) Compared with the graph classification baselines GCN, GIN, DGCNN, SOPool, and RWGNN, iGAD demonstrates significant advantages on four real world datasets in terms of all evaluation metrics; 2) iGAD also beats the above baselines' GAD variants, GCN-GAD, GIN-GAD, DGCNN-GAD, SOPool-GAD, and RWGNN-GAD in terms of all evaluation metrics. In addition, as shown in Table 3, iGAD outperforms two graph-level anomaly detection methods GLocalKD and OCGTL concerning AUC.
244
+
245
+ ![](images/c8499b4dfb3cabf7df243b5f460a92e32cebcf929861b0808c270355c3082d2f.jpg)
246
+
247
+ A2. PMI-based loss function can capture essential correlations between graphs and their anomalous/normal properties even if the data distribution is imbalanced. As shown in Table 2, compared with GNNs with the cross-entropy loss function (GCN, GIN, DGCNN, SOPOOL, and RWGNN), their GAD variants equipped with the newly
248
+ proposed PMI-based loss function (GCN-GAD, GIN-GAD, DGCNN-GAD, SOPOOL-GAD, and RWGNN-GAD) witness a significant performance improvement regarding Recall and $\text{Recall}(A)$ over all datasets. For example, the value of $\text{Recall}$ and $\text{Recall}(A)$ achieved by DGCNN over the dataset SW-620 are $56.02 \pm 1.16$ and $12.74 \pm 2.41$ respectively. In contrast, $72.65 \pm 0.63$ and $67.84 \pm 1.78$ are reported by DGCNN-GAD. PMI-based loss function can greatly improve GNN-based graph classification model in datasets with highly imbalanced class distributions.
249
+ A3. The anomalous attribute-aware graph convolution can embed anomalous attributes into graph representations and improve graph-level anomaly detection. As shown in Table 2, iGAD-1 significantly outperforms all baseline algorithms on four graph datasets in terms of AUC, Recall, and $F$ -score.
250
+
251
+ Concerning $Recall(A)$ , on the dataset MCF-7, iGAD-1 has a little performance degradation compared with DGCNN-GAD. Specifically, DGCNN-GAD achieves $69.37_{\pm 3.05}$ on MCF-7, while iGAD-1 gets $67.67_{\pm 2.54}$ . But iGAD-1 beats DGCNN-GAD on other datasets in terms of $Recall(A)$ .
252
+
253
+ A4. iGAD is also effective when it is equipped with pre-defined anomalous substructures. As shown in Table 2, iGAD-2 demonstrates significant advantages against all baseline models. Moreover, iGAD-2 also beats iGAD-1 concerning all metrics over datasets MOLT-4, PC-3, and MCF-7. iGAD-2 does not outperform than iGAD on all datasets concerning AUC, Recall(A), and $F$ -score. But, on PC-3 and MCF-7, iGAD-2 has a slight lead over iGAD regarding Recall. The experiment results demonstrate that, in most cases, the performance of iGAD equipped with a deep RWK is better than iGAD-2 using pre-defined anomalous substructures and algorithms that do not consider anomalous substructures. Based on the above analysis, we can conclude that comparing the random walk sequences between the input graph and pre-defined substructure can improve graph-level anomaly detection to a certain extent, but the algorithm that can automatically learn the anomalous substructures is better.
254
+
255
+ A5. The anomalous substructures learned by iGAD are demonstrated in Figure 2. We can observe that anomalous graph substructures on four datasets are composed of the triangle, the tailed triangle, and the 4-cycle graphlets. It explains why iGAD-2 can achieve competitive results compared with iGAD (as shown in Table 2 and A4). We can draw a preliminary conclusion that the graph substructures having the triangle, the tailed triangle, and the 4-cycle graphlets are important for distinguishing anomalous graphs from normal graphs on these four graph datasets.
256
+
257
+ A6. The performance of iGAD under different maximum random walk lengths $L$ is shown in Figure 3. Under the setting that iGAD with 5 anomalous substructures and each of substructures has 8 nodes, on these four graph datasets SW-620, MOLT-4, PC-3, and MCF-7, iGAD can achieve the highest $F$ -score value when the maximum random walk length ranges from 4 to 8. In addition, when each anomalous substructure contains 10 nodes, iGAD can reach the best $F$ -score score at the maximum random walk length from 5 to 9. The results verify that appropriately increasing the maximum length of random walking can improve the performance of iGAD since more much longer random walk sequences can capture more graph structure information.
258
+
259
+ Finally, we discuss the limitations of the proposed graph-level anomaly detection model iGAD. In practice, the nodes and/or substructures at a particular position in a graph can also be the reason for the graph's anomalous properties. For example, an Alcohol compound can be obtained by replacing the hydrogen atom at the end of the Alkane compound with a hydroxy group (i.e., -OH). But, iGAD cannot capture the position information of nodes and substructures in graphs. In addition, iGAD is a supervised algorithm. It may not be able to achieve superior performance in identifying the graph-level anomalies that follow the anomaly distributions that have never been exposed in the training graph anomalies. In the future, we will propose specific solutions to this problem.
260
+
261
+ # 6 Conclusion
262
+
263
+ This paper proposes a method named iGAD for graph-level anomaly detection. We highlight the challenges brought by imbalanced distributions and various anomaly notions in graph attributes and substructures. In addition, the significant differences between detecting anomalous graphs in a graph dataset and identifying anomalous nodes in a single graph are also introduced in detail. iGAD treats graph-level anomaly detection as a special case of graph classification and learns binary labels for graphs. In iGAD, the anomalous attribute-aware graph convolution and anomalous substructure-aware deep RWK embed graph-level anomaly information into graph representations. A PMI-based loss function guides iGAD to identify anomalous samples from a large number of normal samples. We do extensive experiments on four real-world graph datasets, and iGAD achieves superior performance on the graph-level anomaly detection task.
264
+
265
+ # Acknowledge
266
+
267
+ We greatly appreciate the constructive and insightful comments from reviewers. This work is funded by the Australian Research Council Discovery Early Career Researcher Award (ARC DECRA) Project (No. DE200100964) and the NSFC (No. 61872360).
268
+
269
+ # References
270
+
271
+ [1] Leman Akoglu, Hanghang Tong, and Danai Koutra. Graph based anomaly detection and description: a survey. Data Min Knowl Discov, 29(3):626-688, 2015.
272
+ [2] Jinwon An and Sungzoon Cho. Variational autoencoder based anomaly detection using reconstruction probability. *Special Lecture on IE*, 2(1):1-18, 2015.
273
+ [3] Muhammet Balcilar, Pierre Héroux, Benoit Gauzere, Pascal Vasseur, Sébastien Adam, and Paul Honeine. Breaking the limits of message passing graph neural networks. In ICML, pages 599–608, 2021.
274
+ [4] Muhammet Balcilar, Guillaume Renton, Pierre Héroux, Benoit Gaizère, Sébastien Adam, and Paul Honeine. Analyzing the expressive power of graph neural networks in a spectral perspective. In ICLR, 2021.
275
+ [5] John Adrian Bondy, Uppaluri Siva Ramachandra Murty, et al. J. Graph Theory Appl., volume 290. Macmillan London, 1976.
276
+ [6] Karsten M Borgwardt and Hans-Peter Kriegel. Shortest-path kernels on graphs. In ICDM, pages 74-81. IEEE, 2005.
277
+ [7] Markus M Breunig, Hans-Peter Kriegel, Raymond T Ng, and Jorg Sander. Lof: identifying density-based local outliers. In SIGMOD, pages 93-104, 2000.
278
+ [8] Joan Bruna, Wojciech Zaremba, Arthur Szlam, and Yann LeCun. Spectral networks and locally connected networks on graphs. arXiv preprint arXiv:1312.6203, 2013.
279
+ [9] Jonathon Byrd and Zachary Lipton. What is the effect of importance weighting in deep learning? In ICML, pages 872-881, 2019.
280
+ [10] Pim de Haan, Taco S Cohen, and Max Welling. Natural graph networks. In NeurIPS, pages 3636-3646, 2020.
281
+ [11] Michael Defferrard, Xavier Bresson, and Pierre Vandergheynst. Convolutional neural networks on graphs with fast localized spectral filtering. In NeurIPS, pages 3837-3845, 2016.
282
+ [12] Jacek P Dmochowski, Paul Sajda, and Lucas C Parra. Maximum likelihood in cost-sensitive learning: Model specification, approximations, and upper bounds. J. Mach. Learn. Res., 11(12), 2010.
283
+ [13] Yingtong Dou, Zhiwei Liu, Li Sun, Yutong Deng, Hao Peng, and Philip S Yu. Enhancing graph neural network-based fraud detectors against camouflaged fraudsters. In CIKM, pages 315-324, 2020.
284
+ [14] David Duvenaud, Dougal Maclaurin, Jorge Aguilera-Iparraguirre, et al. Convolutional networks on graphs for learning molecular fingerprints. In NeurIPS, pages 2224-2232, 2015.
285
+ [15] Alex Fout, Jonathon Byrd, Basir Shariat, et al. Protein interface prediction using graph convolutional networks. In NeurIPS, pages 6530-6539, 2017.
286
+ [16] Thomas Gartner, Peter Flach, and Stefan Wrobel. On graph kernels: Hardness results and efficient alternatives. In Learning theory and kernel machines, pages 129-143. Springer, 2003.
287
+ [17] Justin Gilmer, Samuel S Schoenholz, Patrick F Riley, Oriol Vinyals, and George E Dahl. Neural message passing for quantum chemistry. In ICML, pages 1263-1272, 2017.
288
+ [18] Markus Goldstein and Seiichi Uchida. A comparative evaluation of unsupervised anomaly detection algorithms for multivariate data. PloS one, 11(4):e0152173, 2016.
289
+ [19] Will Hamilton, Zhitao Ying, and Jure Leskovec. Inductive representation learning on large graphs. In NeurIPS, pages 1024–1034, 2017.
290
+ [20] Thomas N. Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. In ICLR, 2017.
291
+ [21] Tommaso Lanciano, Francesco Bonchi, and Aristides Gionis. Explainable classification of brain networks via contrast subgraphs. In KDD, pages 3308-3318, 2020.
292
+ [22] Buyu Li, Yu Liu, and Xiaogang Wang. Gradient harmonized single-stage detector. In AAAI, pages 8577-8584, 2019.
293
+ [23] Mu Li, Tong Zhang, Yuqiang Chen, and Alexander J Smola. Efficient mini-batch training for stochastic optimization. In KDD, pages 661-670, 2014.
294
+
295
+ [24] Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dólar. Focal loss for dense object detection. In CVPR, pages 2980-2988, 2017.
296
+ [25] Fei Tony Liu, Kai Ming Ting, and Zhi-Hua Zhou. Isolation forest. In ICDM, pages 413-422. IEEE, 2008.
297
+ [26] Fei Tony Liu, Kai Ming Ting, and Zhi-Hua Zhou. Isolation-based anomaly detection. ACM Trans. Knowl. Discov. Data, 6(1):1-39, 2012.
298
+ [27] Rongrong Ma, Guansong Pang, Ling Chen, and Anton van den Hengel. Deep graph-level anomaly detection by glocal knowledge distillation. In WSDM, pages 704-714, 2022.
299
+ [28] Haggai Maron, Heli Ben-Hamu, Hadar Serviansky, and Yaron Lipman. Provably powerful graph networks. In NeurIPS, pages 2153-2164, 2019.
300
+ [29] Hamed Masnadi-Shirazi and Nuno Vasconcelos. Risk minimization, probability elicitation, and cost-sensitive svms. In ICML, pages 759-766, 2010.
301
+ [30] Aditya Krishna Menon, Sadeep Jayasumana, Ankit Singh Rawat, Himanshu Jain, Andreas Veit, and Sanjiv Kumar. Long-tail learning via logit adjustment. In ICLR, 2020.
302
+ [31] Christopher Morris, Martin Ritzert, Matthias Fey, William L Hamilton, Jan Eric Lenssen, Gaurav Rattan, and Martin Grohe. Weisfeiler and leman go neural: Higher-order graph neural networks. In AAAI, pages 4602-4609, 2019.
303
+ [32] Giannis Nikolentzos and Michalis Vazirgiannis. Random walk graph neural networks. In NeurIPS, pages 16211-16222, 2020.
304
+ [33] Shirui Pan, Jia Wu, and Xingquan Zhu. Cogboost: Boosting for fast cost-sensitive graph classification. IEEE Trans. Knowl. Data Eng., 27(11):2933-2946, 2015.
305
+ [34] Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, et al. Pytorch: An imperative style, high-performance deep learning library. NeurIPS, 32, 2019.
306
+ [35] Chen Qiu, Marius Kloft, Stephan Mandt, and Maja Rudolph. Raising the bar in graph-level anomaly detection. In *IJCAI*, pages 2196–2203, 2022.
307
+ [36] Stephen Ranshous, Steve Harenberg, Kshitij Sharma, and Nagiza F Samatova. A scalable approach for outlier detection in edge streams using sketch-based approximations. In SDM, pages 189-197, 2016.
308
+ [37] Lukas Ruff, Robert Vandermeulen, Nico Goernitz, Lucas Deecke, Shoaib Ahmed Siddiqui, Alexander Binder, Emmanuel Müller, and Marius Kloft. Deep one-class classification. In ICML, pages 4393-4402, 2018.
309
+ [38] Saurabh Sawlani, Lingxiao Zhao, and Leman Akoglu. Fast attributed graph embedding via density of states. In ICDM, pages 559-568. IEEE, 2021.
310
+ [39] Bernhard Schölkopf, John C Platt, John Shawe-Taylor, Alex J Smola, and Robert C Williamson. Estimating the support of a high-dimensional distribution. Neural Comput., 13(7):1443-1471, 2001.
311
+ [40] Bernhard Schölkopf, Robert C Williamson, Alex Smola, John Shawe-Taylor, and John Platt. Support vector method for novelty detection. In NeurIPS, pages 582-588, 1999.
312
+ [41] Nino Shervashidze and Karsten Borgwardt. Fast subtree kernels on graphs. In NeurIPS, pages 1660-1668, 2009.
313
+ [42] Nino Shervashidze, SVN Vishwanathan, Tobias Petri, Kurt Mehlhorn, and Karsten Borgwardt. Efficient graphlet kernels for large graph comparison. In AISTATS, pages 488-495, 2009.
314
+ [43] Mahito Sugiyama and Karsten Borgwardt. Halting in random walk kernels. In NeurIPS, pages 1639-1647, 2015.
315
+ [44] Jianheng Tang, Jiajin Li, Ziqi Gao, and Jia Li. Rethinking graph neural networks for anomaly detection. In ICML, pages 21076-21089, 2022.
316
+ [45] Ruo-Chun Tzeng and Shan-Hung Wu. Distributed, egocentric representations of graphs for detecting critical structures. In ICML, pages 6354-6362, 2019.
317
+ [46] Petar Velicković, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua Bengio. Graph attention networks. In ICLR, 2017.
318
+
319
+ [47] S Vichy N Vishwanathan, Nicol N Schraudolph, Risi Kondor, and Karsten M Borgwardt. Graph kernels. J. Mach. Learn. Res., 11:1201-1242, 2010.
320
+ [48] H Gerhard Vogel, Wolfgang H Vogel, H Gerhard Vogel, Günter Müller, Jürgen Sandoi, and Bernward A Scholkens. *Drug discovery and evaluation: pharmacological assays*, volume 2. Springer, 1997.
321
+ [49] Byron C Wallace, Kevin Small, Carla E Brodley, and Thomas A Trikalinos. Class imbalance, remix. In ICDM, pages 754-763, 2011.
322
+ [50] Jiaqi Wang, Wenwei Zhang, Yuhang Zang, Yuhang Cao, Jiangmiao Pang, Tao Gong, Kai Chen, Ziwei Liu, Chen Change Loy, and Dahua Lin. Seesaw loss for long-tailed instance segmentation. In CVPR, pages 9695-9704, 2021.
323
+ [51] Shen Wang, Lifang He, Bokai Cao, Chun-Ta Lu, Philip S Yu, and Ann B Ragin. Structural deep brain network mining. In KDD, pages 475-484, 2017.
324
+ [52] Zhengyang Wang and Shuiwang Ji. Second-order pooling for graph neural networks. IEEE Trans. Pattern Anal. Mach. Intell., 2020.
325
+ [53] Gang Wu and Edward Y Chang. Kba: Kernel boundary alignment considering imbalanced data distribution. IEEE Trans. Knowl. Data Eng., 17(6):786-795, 2005.
326
+ [54] Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? In ICLR, 2019.
327
+ [55] Xifeng Yan, Hong Cheng, Jiawei Han, and Philip S Yu. Mining significant graph patterns by leap search. In SIGMOD, pages 433-444, 2008.
328
+ [56] Zhitao Ying, Jiaxuan You, Christopher Morris, Xiang Ren, Will Hamilton, and Jure Leskovec. Hierarchical graph representation learning with differentiable pooling. NeurIPS, pages 4805-4815, 2018.
329
+ [57] Ge Zhang, Zhao Li, Jiaming Huang, Jia Wu, Chuan Zhou, Jian Yang, and Jianliang Gao. efraudcom: An e-commerce fraud detection system via competitive graph neural networks. ACM Trans Inf Syst, 40(3):1-29, 2022.
330
+ [58] Ge Zhang, Jia Wu, Jian Yang, Amin Beheshti, Shan Xue, Chuan Zhou, and Quan Z Sheng. Fraud: Fraud detection dual-resistant to graph inconsistency and imbalance. In ICDM, pages 867-876. IEEE, 2021.
331
+ [59] Muhan Zhang, Zhicheng Cui, Marion Neumann, et al. An end-to-end deep learning architecture for graph classification. In AAAI, pages 4438-4445, 2018.
332
+ [60] Muhan Zhang and Pan Li. Nested graph neural networks. In NeurIPS, pages 15734-15747, 2021.
333
+ [61] Lingxiao Zhao and Leman Akoglu. Pairnorm: Tackling oversmoothing in gnns. In ICLR, 2020.
334
+ [62] Lingxiao Zhao and Leman Akoglu. On using classification datasets to evaluate graph outlier detection: Peculiar observations and new insights. *Big Data*, 2021.
335
+ [63] Panpan Zheng, Shuhan Yuan, Xintao Wu, Jun Li, and Aidong Lu. One-class adversarial nets for fraud detection. In AAAI, pages 1286-1293, 2019.
336
+ [64] Bo Zong, Qi Song, Martin Renqiang Min, Wei Cheng, Cristian Lumezanu, Daeki Cho, and Haifeng Chen. Deep autoencoding gaussian mixture model for unsupervised anomaly detection. In ICLR, 2018.
337
+
338
+ # Checklist
339
+
340
+ 1. For all authors...
341
+
342
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper's contributions and scope? [Yes]
343
+ (b) Did you describe the limitations of your work? [Yes]
344
+ (c) Did you discuss any potential negative societal impacts of your work? [N/A]
345
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
346
+
347
+ 2. If you are including theoretical results...
348
+
349
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes]
350
+ (b) Did you include complete proofs of all theoretical results? [Yes]
351
+
352
+ 3. If you ran experiments...
353
+
354
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes]
355
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
356
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
357
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes]
358
+
359
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
360
+
361
+ (a) If your work uses existing assets, did you cite the creators? [N/A]
362
+ (b) Did you mention the license of the assets? [N/A]
363
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
364
+ (d) Did you discuss whether and how consent was obtained from people whose data you're using/curating? [N/A]
365
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
366
+
367
+ 5. If you used crowdsourcing or conducted research with human subjects...
368
+
369
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
370
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
371
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
dualdiscriminativegraphneuralnetworkforimbalancedgraphlevelanomalydetection/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dc716234922fc252e3342e8f4d555639cf0a5206b5f0af491d6bdb14b974bc6e
3
+ size 455482
dualdiscriminativegraphneuralnetworkforimbalancedgraphlevelanomalydetection/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:563908961ba64edde8de1b9ded59553f072c01354bffba1db8437a74f5b83fa3
3
+ size 542757
dungeonsanddataalargescalenethackdataset/21cf6cd0-c8cb-46b3-bf74-fb3b6f182a21_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7eb81aa1f409da78ad899a363fcd71acec6b283d4e130db5c8b7d12671056a78
3
+ size 85378
dungeonsanddataalargescalenethackdataset/21cf6cd0-c8cb-46b3-bf74-fb3b6f182a21_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e0dfc3f244740f9ebfb5445b0f07dffdddf82857eda70c305c070f52d7583f9d
3
+ size 111694
dungeonsanddataalargescalenethackdataset/21cf6cd0-c8cb-46b3-bf74-fb3b6f182a21_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1344e4ae58cc7eb649d244107ef8460761a667fa1f4d1d805e2d2b6890b62d69
3
+ size 1640056
dungeonsanddataalargescalenethackdataset/full.md ADDED
@@ -0,0 +1,320 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dungeons and Data: A Large-Scale NetHack Dataset
2
+
3
+ Eric Hambro*
4
+
5
+ Meta AI
6
+
7
+ Roberta Raileanu
8
+
9
+ Meta AI
10
+
11
+ Danielle Rothermel
12
+
13
+ Meta AI
14
+
15
+ Vegard Mella
16
+
17
+ Meta AI
18
+
19
+ Tim Rocktäschel
20
+
21
+ University College London
22
+
23
+ Heinrich Kuttler
24
+
25
+ Inflection $\mathbf{A}\mathbf{I}^{\dagger}$
26
+
27
+ Naila Murray
28
+
29
+ Meta AI
30
+
31
+ # Abstract
32
+
33
+ Recent breakthroughs in the development of agents to solve challenging sequential decision making problems such as Go [50], StarCraft [58], or DOTA [3], have relied on both simulated environments and large-scale datasets. However, progress on this research has been hindered by the scarcity of open-sourced datasets and the prohibitive computational cost to work with them. Here we present the NetHack Learning Dataset (NLD), a large and highly-scalable dataset of trajectories from the popular game of NetHack, which is both extremely challenging for current methods and very fast to run [23]. NLD consists of three parts: 10 billion state transitions from 1.5 million human trajectories collected on the NAO public NetHack server from 2009 to 2020; 3 billion state-action-score transitions from 100,000 trajectories collected from the symbolic bot winner of the NetHack Challenge 2021; and, accompanying code for users to record, load and stream any collection of such trajectories in a highly compressed form. We evaluate a wide range of existing algorithms including online and offline RL, as well as learning from demonstrations, showing that significant research advances are needed to fully leverage large-scale datasets for challenging sequential decision making tasks.
34
+
35
+ # 1 Introduction
36
+
37
+ Recent progress on deep reinforcement learning (RL) methods has led to significant breakthroughs such as training autonomous agents to play Atari [33], Go [50], StarCraft [58], and Dota [3], or to perform complex robotic tasks [24, 44, 26, 35, 16, 41]. In many of these cases, success relied on having access to large-scale datasets of human demonstrations [58, 3, 41, 26]. Without access to such demonstrations, training RL agents to operate effectively in these environments remains challenging due to the hard exploration problem posed by their vast state and action spaces. In addition, having access to a simulator is key for training agents that can discover new strategies not exhibited by human demonstrations. Therefore, training agents using a combination of offline data and online interaction has proven to be a highly successful approach for solving a variety of challenging sequential decision making tasks. However, this requires access to complex simulators and large-scale offline datasets, which tend to be computationally expensive.
38
+
39
+ The NetHack Learning Environment (NLE) was recently introduced as a testbed for RL, providing an environment which is both extremely challenging [15] and exceptionally fast to simulate [23]. NLE is a stochastic, partially observed, and procedurally generated RL environment based on the popular game of NetHack. Due to its long episodes (i.e. tens or hundreds of thousands of steps) and large state and action spaces, NLE poses a uniquely hard exploration challenge for current RL methods. Thus, one of the most promising research avenues towards progress on NetHack is leveraging human or symbolic-bot demonstrations to bootstrap performance, which also proved successful for StarCraft [58] and Dota [3].
40
+
41
+ In this paper, we introduce the NetHack Learning Dataset (NLD), an open and accessible dataset for large-scale offline RL and learning from demonstrations. NLD consists of three parts: first, NLD-NA0: a collection of state-only trajectories from 1.5 million human games of NetHack played on nethack.alt.org (NAO) servers between 2009 and 2020; second, NLD-AA: a collection of state-action-score trajectories from 100,000 NLE games played by the symbolic-bot winner of the 2021 NetHack Challenge [15]; third, TtyrecDataset: a highly-scalable tool for efficient training on any NetHack and NLE-generated trajectories and metadata. NLD, in combination with NLE, enables computationally-accessible research in multiple areas including imitation learning, offline RL, learning from sequences of only observations, as well as combining learning from offline data with learning from online interactions. In contrast with other large-scale datasets of demonstrations, NLD is highly efficient in both memory and compute. NLD-NA0 can fit on a $30 hard drive, after being compressed (by a factor of 160) from 38TB to 229GB. In addition, NLD-NA0 can be processed in under 15 hours, achieving a throughput of 288,000 frames per second with only 10 CPUs. NLD's low memory and computational requirements makes large-scale learning from demonstrations more accessible for academic and independent researchers.
42
+
43
+ To summarize, the key characteristics of NLD are that: it is a scalable dataset of demonstrations (i.e. large and cheap) for a highly-complex sequential decision making challenge; it enables research in multiple areas such as imitation learning, offline RL, learning from observations of demonstrations, learning from both static data and environment interaction; and it has many properties of real-world domains such as partial observability, stochastic dynamics, sparse reward, long trajectories, rich environment, diverse behaviors, and a procedurally generated environment.
44
+
45
+ In this paper, we make the following core contributions: (i) we introduce NLD-NAO, a large-scale dataset of almost 10 billion state transitions, from 1.5 million NetHack games played by humans; (ii) we also introduce NLD-AA, a large-scale dataset of over 3 billion state-action-score transitions, from 100,000 games played by the symbolic-bot winner of the NeurIPS 2022 NetHack Competition; (iii) we open-source code for users to record, load, and stream any collection of NetHack trajectories in a highly compressed form; and (iv) we show that, while current state-of-the-art methods in offline RL and learning from demonstrations can effectively make use of the dataset, playing NetHack at human-level performance remains an open research challenge.
46
+
47
+ # 2 Related Work
48
+
49
+ Offline RL Benchmarks. Recently, there has been a growing interest in developing better offline RL methods [25, 39, 11, 60, 61, 21, 20, 6, 2, 49] which aim to learn from datasets of trajectories. With it, a number of offline RL benchmarks have been released [1, 62, 10, 42, 22, 43]. While these benchmarks focus specifically on offline RL, our datasets enable research on multiple areas including imitation learning, learning from observations only (i.e. without access to actions or rewards), as well as learning from both offline and online interactions. In order to make progress on difficult RL tasks such as NetHack, we will likely need to learn from both human data and environment interaction, as was the case with other challenging games like StarCraft [58] or Dota [3]. In contrast, the tasks proposed in current offline RL benchmarks are much easier and can be solved by training either only online or only offline [10, 62]. In addition, current offline RL benchmarks test agents on the exact same environment where the data was collected. As emphasized by [57], imitation learning algorithms drastically overfit to their environments, so it is essential to evaluate them on new scenarios in order to develop robust methods. In contrast, NLE has long procedurally generated episodes which require both long-term planning and systematic generalization in order to succeed. This is shown in [30], which investigates transfer learning between policies trained on different NLE-based environments.
50
+
51
+ For many real-world applications such as autonomous driving or robotic manipulation, learning from human data is essential due to safety concerns and time constraints [40,10,8,5,27,52,55,17,38,18]. However, most offline RL benchmarks contain synthetic trajectories generated by either random exploration, pretrained RL agents, or simple hard-coded behaviors [10]. In contrast, one of our datasets consists entirely of human replays, while the other one is generated by the winner of the NetHack Competition at NeurIPS 2022 which is a complex symbolic bot with built-in knowledge of the game. Human data (like the set contained in NLD-NAO) is significantly more diverse and messy than synthetic data, as humans can vary widely in their expertise, optimize for different objectives (such as fun or discovery), have access to external information (such as the NetHack Wiki [34]),
52
+
53
+ and even have different observation or action spaces than RL agents. Hence, learning directly from human data is essential for making progress on real-world problems in RL.
54
+
55
+ Large-Scale Human Datasets. A number of large-scale datasets of human replays have been released for StarCraft [59], Dota [3], and MineRL [14]. However, training models on these datasets require massive computational resources, which makes it unfeasible for academic or independent researchers. In contrast, NLD strikes a better balance between scale (i.e. a large number of diverse human demonstrations on a complex task) and efficiency (i.e. cheap to use and fast to run).
56
+
57
+ For many real-world applications such as robotic manipulation, we only have access to the demonstrator's observations and not their actions [29, 48, 40, 8, 51]. Research on this setting has been slower [9, 56, 7], in part due to the lack of efficient large-scale datasets. While there are some datasets containing only observations, they are either much smaller than NLD [32, 57, 48], too computationally expensive [59, 3], or lack a simulator which prevents learning from online interactions [12, 28, 8].
58
+
59
+ # 3 Background: The NetHack Learning Environment
60
+
61
+ The NetHack Learning Environment (NLE) is a gym environment [4] based on the popular " dungeon-crawler" game, NetHack [19]. Despite the visual simplicity, NetHack is widely considered one of the hardest video games in history since it can take years for humans to win the game [54]. Players need to explore the dungeon, manage their resources, as well as learn about the many entities and their dynamics (often by relying on external knowledge sources like the NetHack Wiki [34]). NetHack has a clearly defined goal, namely descend the dungeon, retrieve an amulet, and ascend back to win the game. At the beginning of each game, players are randomly assigned a given multidimensional character defined by role, race, alignment, and gender (which have varying properties and challenges), so they need to master all characters in order to win consistently. Thus, NLE offers a unique set of properties which make it well-positioned to advance research on RL and learning from demonstrations: it is a highly complex environment, containing hundreds of entities with different dynamics; it is procedurally generated, allowing researchers to test generalization; it is partially observed, highly stochastic, and has very long episodes (i.e. one or two orders of magnitude longer than Starcraft II [59]).
62
+
63
+ Following its release, several works have built on NLE to leverage its complexity in different ways. MiniHack [45] allows researchers to design their own environments to test particular capabilities of RL agents, by leveraging the full set of entities and dynamics from NetHack. The NetHack Challenge [15] was a competition at NeurIPS 2021, which sought to incentivise a showdown between symbolic and deep RL methods on NLE. Symbolic bots decisively outperformed deep RL methods, with the best performing symbolic bots surpassing state-of-the-art deep RL methods by a factor of 5.
64
+
65
+ # 4 The NetHack Learning Dataset
66
+
67
+ The NetHack Learning Dataset (NLD) contains three components:
68
+
69
+ 1. NLD-NAO — a directory of ttyrec.bz2 files containing almost 10 billion state trajectories and metadata from 1,500,000 human games of NetHack played on nethack.alt.org.
70
+ 2. NLD-AA — a directory of ttyrec3.bz2 files containing over 3 billion state-action-score trajectories and metadata from 100,000 games collected from the winning bot of the NetHack Challenge [15].
71
+ 3. TtyrecDataset — a Python class that can scalably load directories of ttyrec.bz2 / ttyrec3.bz2 files and their metadata into numpy arrays.
72
+
73
+ We are also releasing a new version of the NetHack environment, NLE v0.9.0, which contains new features and ensures compatibility with NLD (see Appendix C).
74
+
75
+ File Format. The ttyred file format stores sequences of terminal instructions (equivalent to observations in RL), along with the times at which to play them. In NLE v0.9.0, we adapt this format to also store keypress inputs to the terminal (equivalent to actions in RL), and in-game scores over time (equivalent to rewards in RL), allowing a reconstruction of state-action-score trajectories. This
76
+
77
+ adapted format is known as ttyrec3. The ttyrec.bz2 and ttyrec3.bz2 formats, compressed versions of ttyrec and ttyrec3, are the primary data formats used in NLD. Using TtyrecDataset, these compressed files can be written and read on-the-fly, resulting in data compression ratios of more than 138. The files can be decompressed into the state trajectory on a terminal, by using a terminal emulator and querying its screen. For more details see Appendix D.
78
+
79
+ Throughout the paper, we refer to a player's input at a given time as either state or observation. However, note that NetHack is partially observed, so the player doesn't have access to the full state of the game. We also sometimes use the terms score and reward interchangeably, since the increment in in-game score is a natural choice for the reward used to train RL agents on NetHack. Similarly, a human's keypress corresponds to an agent's action in the game.
80
+
81
+ Metadata. NetHack has an optional built-in feature for the logging of game metadata, used for the maintenance of all-time high-score lists. At the end of a game, 26 fields of data are logged to a common xlogfile for posterity. These fields include the character's name, race, role, score, cause of death, maximum dungeon depth, and more. See Appendix E for more details on these fields. With NLE v0.9.0, an xlogfile is generated for all NLE recordings. These files are used to populate all metadata contained in NLD.
82
+
83
+ State-Action-Score Transitions. As mentioned, NLD-AA contains sequences of state-action-score transitions from symbolic-bot plays, while NLD-NAO contains sequences of state transitions from human plays. These transitions are efficiently processed using the TtyrecDataset. The states consist of: ttychars (the characters at each point on the screen), ttyColors (the colors at each point on the screen), tty_cursor (the location of the cursor on the screen), timestamps (when the state was recorded), and gameids (an identifier for the game in question). Additionally, keypresses and score observations are available for ttyrec3 files, as in the NLD-AA dataset. The states, keypresses, and scores from NLD map directly to an agent's observations, actions, and rewards in NLE. More information about these transitions can be found in Appendix F
84
+
85
+ API. The TtyrecDataset follows the API of an IteratorDataset defined in PyTorch. This allows for the batched streaming of ttyrec.bz2 / ttyrec3.bz2 files directly into fixed NumPy arrays of a chosen shape. Episodes are read sequentially in chunks defined by the unroll length, batched with a different game per batch index. The order of these games can be shuffled, predetermined or even looped to provide a never-ending dataset. This class allows users to load any state-action-score trajectory recorded from NLE v0.9.0 onwards.
86
+
87
+ The TtyrecDataset wraps a small sqlite3 database where it stores metadata and the paths to files. This design allows for the simple querying of metadata for any game, along with the dynamic subselection of games streamed from the TtyrecDataset itself. For example, in Figure 1 we generate sub-datasets from NLD-NAO and NLD-AA, selecting trajectories where the player has completed the game ('Ascended') or played a 'Human Monk' character, respectively. Appendix G shows how to load only a subset of trajectories, for example where the player has ascended, or a certain role has been used.
88
+
89
+ Scalability. The TtyrecDataset is designed to make our large-scale NLD datasets accessible even when the computational resources are limited. To that end, several optimizations are made to improve the memory efficiency and throughput of the data. Most notably, TtyrecDataset streams recordings directly from their compressed ttyrec.bz2 files. This format compresses the 30TB of frame data included in NLD-NAO down to 229GB, which can fit on a $30 SSD[5]. This decompression requires on-the-fly unzipping and terminal emulation. The TtyrecDataset performs these in GIL-released C/C++. This process is fast and trivially parallelizable with Python Threadpool, resulting in throughputs of over 1.7 GB/s on 80 CPUs. This performance allows the processing of almost 10 billion frames of NLD-NAO in 15 hours, with 10 CPUs. See Table [T] for a quantitative description of our two datasets.
90
+
91
+ # 5 Dataset Analysis
92
+
93
+ In this section we perform an in-depth analysis of the characteristics of NLD-AA and NLD-NAO.
94
+
95
+ Table 1: NLD-AA and NLD-NAO in numbers.
96
+
97
+ <table><tr><td></td><td>NLD-AA</td><td>NLD-NAO</td></tr><tr><td>Episodes</td><td>109,545</td><td>1,511,228</td></tr><tr><td>Transitions</td><td>3,481,605,009</td><td>9,858,127,896</td></tr><tr><td>Policies (Players)</td><td>1</td><td>48,454</td></tr><tr><td>Policies Type</td><td>symbolic bot</td><td>human</td></tr><tr><td>Transition</td><td>(state, action, score)</td><td>state</td></tr><tr><td>Disk Size (Compressed)</td><td>96.7 GB</td><td>229 GB</td></tr><tr><td>Data Size (Uncompressed)</td><td>13.4 TB</td><td>38.0 TB</td></tr><tr><td>Compression Ratio</td><td>138</td><td>166</td></tr><tr><td>Mean Epiode Score</td><td>10,105</td><td>127,218</td></tr><tr><td>Median Episode Score</td><td>5,422</td><td>836</td></tr><tr><td>Median Episode Transitions</td><td>28,181</td><td>1,724.0</td></tr><tr><td>Median Episode Game Turns</td><td>20,414</td><td>3,766</td></tr><tr><td>Epoch Time (10 CPUs)</td><td>4h 49m</td><td>14h 37m</td></tr></table>
98
+
99
+ # 5.1 NLD-AA
100
+
101
+ To our knowledge, AutoAscend is currently the best open-sourced artificial agent for playing NetHack 3.6.6, having achieved first place in the 2021 NeurIPS NetHack Challenge by a considerable margin [15]. AutoAscend is a symbolic bot, forgoing any neural network and instead relying on a priority list of hard-coded subroutines. These subroutines are complex, context dependant, and make significant use of NetHack domain knowledge and all NetHack actions. For instances, the bot keeps track of multiple properties for encountered entities and can even solve challenging puzzles such as Sokoban. A full description of AutoAscend's algorithm and behavior can be found in the NetHack Challenge Report [15].
102
+
103
+ NLD-AA was generated by running AutoAscend on the NetHackChallenge-v0 [15] task in NLE v0.9.0, utilising its built-in recording feature to generate ttyrec3.bz2 files. It consists of over 3 billion state-action-score transitions, drawn from 100,000 episodes generated by AutoAscend. Of the NLE tasks, NetHackChallenge-v0 most closely reproduces the full game of NetHack 3.6.6, and was introduced in NLE v0.7.0 to grant NetHack Challenge competitors access to the widest possible action space, and force an automated randomisation of the starting character (by race, role, alignment, and gender). By virtue of using ttyrec3.bz2 files, in-game scores and actions (in the form of key presses) are stored along with the states, and metadata about the episodes.
104
+
105
+ Dataset Skill. The AutoAscend trajectories demonstrate a strong and reliable NetHack player, far exceeding all the deep learning based approaches, but still falling short of an expert human player. NetHack broadly defines a character with less than 2000 score as a 'Beginner'. AutoAscend comfortably surpasses the 'Beginner' classification in more than $75\%$ of games for all roles, and in $95\%$ of games for easier roles like Monk (see Figure 1). Given the high variance nature of NetHack games, and the challenge of playing with the more difficult roles, this is an impressive feat.
106
+
107
+ Compared to the human players in NLD-NAO, AutoAscend's policy finds itself just within the top $15\%$ of all players when ranked by mean score. When ranked by median score it comes within the top $7\%$ . However, these metrics are somewhat distorted by the long tail of dilettante players who played only a few games. If instead we define a 'competent' human player as one to have ever advanced beyond the Beginner classification, then AutoAscend ranks in the top $33\%$ of players by mean score, and top $15\%$ by median.
108
+
109
+ The competence of AutoAscend contrasts both with the poor performance of deep RL bots, and with the exceptional performance required to beat the game. As the winning symbolic bot of the NetHack Challenge, AutoAscend beat the winning deep learning bot by almost a factor of 3 in median score, and close to a factor of 5 in mean score. This performance is far outside what deep RL agents can currently achieve, and in some domains NLD-AA may be considered an "expert" dataset. However,
110
+
111
+ ![](images/dacb920f8b517cc91bdb8e3aa4497495c8a1c7619510e020c33a5f3532d3b26c.jpg)
112
+ Figure 1: Box plots of episode scores (left) and episode turns (right) for NLD-NAO and NLD-AA as well as for their corresponding subsets that contain only winning games ('Ascended') or games played with a 'Human Monk' character, respectively. These plots show the distribution in ability in NLD-NAO is heavy-tailed, along with the typical scores and game length needed to win, well above the median. By comparison, NLD-AA games are competent but not expert, even for easy characters like 'Human Monk'.
113
+
114
+ when compared to the distribution of winning games (i.e. those that have 'ascended'), both mean and median score are orders of magnitude short.
115
+
116
+ Dataset Coverage. Thanks to its scale, NLD-AA provides solid coverage of the early-to-mid game of NetHack. NLD-AA also provides good coverage of all possible actions and roles, with episodes that last for tens of thousands of transitions. Nevertheless, the dataset contains many complex and diverse behaviors. For the full breakdown of the symbolic bot's behaviors found in NLD-AA see Appendix E
117
+
118
+ Dataset Noise. Since all trajectories were generated using NLE, these trajectories have no terminal rendering noise. NLE uses a VT100 emulator to record ttyrec3.bz2 files, and NLD uses the same emulator to load them.
119
+
120
+ # 5.2 NLD-NAO
121
+
122
+ The NetHack community has a long history of using public servers, wherein players can play together, stream and rewatch games of NetHack. The nethack.alt.org server, known as NAO is one of the longest running of such servers, having started in 2001, and hosts recordings dating back to 2009. The server attempts to record all games in ttyrec.bz2 format, and hosts them publicly on an S3 bucket. Unlike NLE, NAO offers players the option of saving a game and resuming play later, allowing for games that span multiple sessions, or last potentially days, weeks, months or years.
123
+
124
+ NLD-NAO was collected by downloading and filtering a dump of ttyrec.bz2 recordings and metadata from NAO. It consists of almost 10 billion state transitions, drawn from approximately 1.5 million games played by just under 50,000 humans of mixed ability. These games were played between 2009 and 2020, and span NetHack versions v3.4.0 to 3.6.6. Since NAO provides no link between episode metadata and available ttyrec recordings, we developed an algorithm to assign and correctly order ttyrec recordings to their corresponding episode metadata, and to filter out trivial or empty games. The full procedure is outlined in Appendix H
125
+
126
+ Dataset Skill. The NAO trajectories were generated from humans of very different skill levels, ranging from novice to expert, and cover a vast distribution of outcomes. The distributions of episode scores, episode turns, and average player scores are highly Zipfian, with long correlated tails spanning several orders of magnitude. The correlation of these distributions greatly improves the quality of the dataset. While the median episode score does not progress beyond Beginner status, such short episodes contribute relatively few transitions to the overall dataset. The bulk of the transitions comes from medium-to-high scoring games that last a long time. The NLD-NAO dataset therefore combines two desirable properties: it contains a large number of diverse behaviors with varying levels of performance, as well as many good trajectories from expert demonstrators.
127
+
128
+ Dataset Coverage. Thanks to its size and expert policies, NLD-NAO provides an unparalleled coverage of the game of NetHack. The dataset contains many examples of advanced game sections not yet achievable by symbolic or RL bots, such as descending the dungeon and retrieving the amulet. Most importantly, it includes 22,000 examples of winning the game ("Ascension"), and includes several
129
+
130
+ ```txt
131
+ https://nethackwiki.com/wiki/Public_server
132
+ https://nethackwiki.com/wiki/Nethack.alt.org
133
+ s3://altorg/ttyrec/
134
+ ```
135
+
136
+ examples of doing so with special conducts such as "Nudist" (not wearing any armour). The full distribution of such achievements and conducts can be found in Appendix E.
137
+
138
+ Dataset Noise. Unlike NLE, NAO does not enforce any fixed terminal type on the player, nor any fixed screen dimensions or configuration. Variations in all these can lead to rendering noise that may include odd symbols or cropped layouts. These types of artefacts are common in real-world applications of learning from demonstrations, which makes NLD a suitable dataset for advancing research in this area. More details about these artefacts, as well as other types of noise (e.g. matching of recordings to players), see Appendix H.
139
+
140
+ # 6 Experiments
141
+
142
+ # 6.1 Methods
143
+
144
+ We demonstrate the utility and challenge of NLD by evaluating algorithms from a range of fields including online RL, offline RL, imitation learning, and learning from demonstrations.
145
+
146
+ All methods are implemented using the open-source asynchronous RL library moolib [31], allowing for continual evaluation of agents in order to generate training curves (even in the offline RL setting). In addition, all our methods use the same core model architecture, which is based on a popular open-source Sample Factory baseline adapted to only use tty_* observations but still remain fast to run. Unless specified otherwise, all experiments were evaluated with 1024 episodes from NLE's NetHackChallenge-v0 task after training for 1.5B frames. The mean and standard deviation of the episode return was computed over 10 training seeds. Full details about the algorithms and their hyperparameters can be found in Appendix All our implementations will be open-sourced to enable fast research progress.
147
+
148
+ Online RL. For online RL baselines that do not make use of the NLD datasets, we use Asynchronous Proximal Policy Optimization (APPO) [47, 37] and Deep Q-Networks (DQN-Online). The former is a strong on-policy policy-gradient-based method for NLE, and the latter is a popular off-policy value-based method in the wider literature.
149
+
150
+ Offline RL. Since NLD-AA contains state-action-reward transitions, we can train a number of offline RL baselines on it. More specifically, we use a Deep Q-Network baseline trained on the dataset (DQN-Offline), as well as two state-of-the-art offline RL methods, Conservative Q-Learning (CQL) [21] and Implicit Q-Learning (IQL) [20]. Note that these methods cannot be trained on NLD-NAO since it doesn't contain actions or rewards.
151
+
152
+ Learning from Demonstrations. We also evaluate a number of baselines that do not make use of rewards, but instead use state-action or state-only transitions. For NLD-AA, we use Behavioural Cloning (BC), a popular imitation learning method, which trains a policy to match the corresponding actions in the dataset using a supervised learning objective. For NLD-NAO, we use Behavioral Cloning from Observations (BCO) [56] which is a popular baseline for learning from state-only demonstrations. This method performs BC on a learned inverse dynamics model which was trained to predict the action taken given two consecutive states. We then investigate the use of BC and BCO in an online setting by augmenting our APPO baseline in two ways. First, we add the BC or BCO loss between the agent's policy and the expert's action for observations in the dataset resulting in APPO + BC and APPO + BCO respectively. Second, we add a KL-divergence loss between the agent's policy and a pretrained BC(O) model resulting in Kickstarting BC(O), similar to [46]. These methods make use of state and action data but no rewards.
153
+
154
+ For NLD-AA, we investigate the performance of the above algorithms across two partitions: one with a single character ('Human Monk'), and one with all the characters (i.e. the full dataset). Each of these is evaluated on their corresponding environments. Full details about our experimental setup are available in Appendix I.
155
+
156
+ # 6.2 Results and Discussion
157
+
158
+ As Table 2 and Figure 2 show, NLD-AA poses a difficult challenge to modern offline RL algorithms. While CQL is able to use the offline trajectories to outperform both a random policy, IQL, as well as
159
+
160
+ Table 2: Average episode return across 10 seeds for a number of popular baselines using NLD and / or NLE. First, we evaluate a range of offline RL methods such as DQN-Offline, CQL, IQL and BC trained on NLD-AA and NLD-AA-Monk, as well as BCO trained on NLD-NAO. Second, we evaluate methods that combine offline and online learning such as Kickstarting + BC and APPO + BC trained on NLD-AA and NLD-AA-Monk, as well as Kickstarting + BCO and APPO + BCO trained on NLD-NAO. Finally, we evaluate a few methods that only have access to online interactions from NLE (no external datasets) such as a Random Policy, DQN-Online, and APPO. All evaluations are conducted with NLE's NetHackChallenge-vO task, using Random (@) characters for NLD-AA and NLD-NAO, and a Human Monk character for NLD-AA-Monk. We compare all these to the average episode return in the corresponding datasets. Methods that use both offline and online data outperform all others by a wide margin, but are still significantly worse than humans (by almost two orders of magnitude) and even the symbolic bot (by more than a factor of three). The top online algorithm, APPO, outperforms the top offline approach, BC. These results indicate that NLD poses a substantial challenge to state-of-the-art methods.
161
+
162
+ <table><tr><td></td><td>Character</td><td>NLD-AA
163
+ Random</td><td>NLD-AA-Monk
164
+ Human Monk</td><td>NLD-NAO
165
+ Random</td></tr><tr><td rowspan="4">offline only</td><td>DQN-Offline</td><td>0.0 ± 0.1</td><td>0.0 ± 0.1</td><td>-</td></tr><tr><td>CQL</td><td>704 ± 112</td><td>732 ± 219</td><td>-</td></tr><tr><td>IQL</td><td>341 ± 40</td><td>533 ± 178</td><td>-</td></tr><tr><td>BC(O)</td><td>1220 ± 261</td><td>1728 ± 615</td><td>12.5 ± 2.0</td></tr><tr><td rowspan="2">offline + online</td><td>Kickstarting + BC(O)</td><td>2250 ± 81</td><td>3907 ± 330</td><td>502 ± 62</td></tr><tr><td>APPO + BC(O)</td><td>2767 ± 284</td><td>4779 ± 1116</td><td>1972 ± 180</td></tr><tr><td rowspan="3">online only</td><td>Random Policy</td><td>0.2 ± 0.2</td><td>0.4 ± 0.4</td><td>(see col 1)</td></tr><tr><td>DQN-Online</td><td>159 ± 68</td><td>247 ± 152</td><td>(see col 1)</td></tr><tr><td>APPO</td><td>1799 ± 156</td><td>4006 ± 323</td><td>(see col 1)</td></tr><tr><td></td><td>Dataset Average</td><td>10105</td><td>17274</td><td>127356</td></tr></table>
166
+
167
+ online and offline variants of DQN, it falls short of capturing the average performance of trajectories in the dataset by over an order of magnitude. BC performs better due to the higher quality of the supervised learning signal, which is typically denser and less noisy than the RL one, but it too falls well short of the data generating policy. Prior work has shown that offline RL methods struggle to perform well in stochastic environments [36], and to generalize outside the distribution of state-action pairs in the dataset [13]. These challenges are particularly intensified with NLD, which is highly stochastic, partially observed, procedurally generated, and has a very large state and action space.
168
+
169
+ Methods that combine offline and online training such as Kickstarting + BC(O) or APPO + BC(O) outperform offline-only methods and outperform or match online-only methods, while also speeding up training. In fact, APPO + BC sets a new state-of-the-art for purely Deep RL on NLE, and would have won first place on the Neural Track at the NetHack Challenge 2021, scoring a median of 2110 and beating the hybrid symbolic-deep RL winner by almost 400 points [15]. Despite being our best method, APPO + BC is still significantly worse than the average performance in the dataset, further emphasizing the difficulty of NLD.
170
+
171
+ Finally, our results demonstrate the utility of NLD-NAO while highlighting the challenge of learning from sequences of only observations. Our inverse model is trained with trajectories from a random policy, and therefore experiences an extremely small fraction of the entire state-action space. Even so, BCO on NLD-NAO labeled with these actions is able to yield performance that comfortably exceeds that of a random policy. While APPO + BCO performs similarly to APPO, training appears to be much more stable. Thus, using more sophisticated policies for training the inverse model (e.g. a mix between a pretrained RL policy and a random policy or an exploration method that maximizes the diversity of visited states and actions) could further improve performance.
172
+
173
+ # 7 Conclusion
174
+
175
+ In this paper, we introduce NLD, a large-scale dataset of demonstrations from NetHack, a complex, stochastic, partially observed, procedurally generated video game. NLD enables research in multiple
176
+
177
+ ![](images/0c78be49eeef1e9bb5ec249ff4b588615bf9b3719bdc4f1ebe0cde5659f945ef.jpg)
178
+ Figure 2: Mean episode return (with samples plotted) over 10 seeds during training for APPO, APPO + BC(O), and Kickstarting + BC(O) using NLD-AA (left), NLD-AA-Monk (center), and NLD-NAO (right). NLD-AA and NLD-NAO both are evaluated with Random character (@), while NLD-AA-Monk is evaluated with only the Human Monk character. Some sample curves associated with the pure online APPO methods exhibit a behaviour wherein performance appears to plateau, before bursting rapidly to a new performance level. This is a common pattern in NLE and corresponds to an agent learning a new behaviour that greatly unlocks yet more of the game, such as praying when starving or kicking down locked doors. Since NLE is highly procedurally generated with a vast action and state space, it is hard to predict when an agent will encounter sufficient opportunities to "take off" in this way. Such "taking off" phenomena are less visible when learning from NLD, as useful behaviours are present in the data throughout.
179
+
180
+ ![](images/f6a8dd711344dca4bdfde97c7c11ee891ae7a34feb014f6a1a652568b23a662b.jpg)
181
+ Environment Steps
182
+
183
+ ![](images/9d3e927fbea89cacc6a584d054393ad991cebb78df8dc8c1f95e01ba7bb2fd49.jpg)
184
+
185
+ areas such as imitation learning, offline RL, learning from sequences of observations, and learning from both offline data and online interactions. NLD allows researchers to learn from very large datasets of demonstrations without requiring extensive memory or compute resources. We train a number of state-of-the-art methods in online RL (both on-policy and off-policy), offline RL, imitation learning, as well as learning from observation-only sequences. Our results indicate that significant research advances are needed to fully leverage large-scale datasets in order to solve challenging sequential decision making problems.
186
+
187
+ In many real-world applications such as robotics, it is common to have access to datasets of observations, without corresponding actions or rewards. Thus, one important direction for future research is to learn from trajectories containing only observations. NLD enables this type of research in a safe, cheap, fast, and reproducible environment, while still exhibiting many properties of real-world domains such as partial observability, high stochasticity, and long episodes. Due to NetHack being procedurally generated, in order to consistently win the game, an agent needs to learn a robust policy that generalizes to new scenarios. Our strongest baseline learns from both static data and environment interaction, so a promising avenue for future work is to develop more effective methods that combine offline and online learning. Existing algorithms for offline RL and learning from demonstrations struggle to match the average performance of trajectories in our datasets, suggesting that NLD is a good benchmark to probe the limits of these methods and inspire the development of approaches that are effective in more challenging and realistic domains.
188
+
189
+ # 8 Acknowledgements
190
+
191
+ We would like to thank Drew Streib and the NAO maintainers for their work in the NetHack community and their help throughout this project. We would also like to thank Michal Sypetkowski and Maciej Sypetkowski for their work on the AutoAscend bot.
192
+
193
+ # References
194
+
195
+ [1] Rishabh Agarwal, Dale Schuurmans, and Mohammad Norouzi. Striving for simplicity in off-policy deep reinforcement learning. ArXiv, abs/1907.04543, 2019.
196
+ [2] Rishabh Agarwal, Dale Schuurmans, and Mohammad Norouzi. An optimistic perspective on offline reinforcement learning. In ICML, 2020.
197
+
198
+ [3] Christopher Berner, Greg Brockman, Brooke Chan, Vicki Cheung, Przemyslaw Debiak, Christy Dennison, David Farhi, Quirin Fischer, Shariq Hashme, Christopher Hesse, Rafal Jozefowicz, Scott Gray, Catherine Olsson, Jakub W. Pachocki, Michael Petrov, Henrique Ponde de Oliveira Pinto, Jonathan Raiman, Tim Salimans, Jeremy Schlatter, Jonas Schneider, Szymon Sidor, Ilya Sutskever, Jie Tang, Filip Wolski, and Susan Zhang. Dota 2 with large scale deep reinforcement learning. ArXiv, abs/1912.06680, 2019.
199
+ [4] Greg Brockman, Vicki Cheung, Ludwig Pettersson, Jonas Schneider, John Schulman, Jie Tang, and Wojciech Zaremba. Openai gym. arXiv preprint arXiv:1606.01540, 2016.
200
+ [5] Serkan Cabi, Sergio Gomez Colmenarejo, Alexander Novikov, Ksenia Konyushkova, Scott E. Reed, Rae Jeong, Konrad Zolna, Yusuf Aytar, David Budden, Mel Vecerik, Oleg O. Sushkov, David Barker, Jonathan Scholz, Misha Denil, Nando de Freitas, and Ziyun Wang. A framework for data-driven robotics. ArXiv, abs/1909.12200, 2019.
201
+ [6] Ching-An Cheng, Tengyang Xie, Nan Jiang, and Alekh Agarwal. Adversarily trained actor critic for offline reinforcement learning. ArXiv, abs/2202.02446, 2022.
202
+ [7] Samuel Cohen, Brandon Amos, Marc Peter Deisenroth, Mikael Henaff, Eugene Vinitsky, and Denis Yarats. Imitation learning from pixel observations for continuous control. In Deep RL Workshop NeurIPS 2021, 2021.
203
+ [8] Sudeep Dasari, Frederik Ebert, Stephen Tian, Suraj Nair, Bernadette Bucher, Karl Schmeckpeper, Siddharth Singh, Sergey Levine, and Chelsea Finn. Robonet: Large-scale multi-robot learning. ArXiv, abs/1910.11215, 2019.
204
+ [9] Ashley D. Edwards, Himanshu Sahni, Yannick Schroecker, and Charles Lee Isbell. Imitating latent policies from observation. *ArXiv*, abs/1805.07914, 2019.
205
+ [10] Justin Fu, Aviral Kumar, Ofir Nachum, G. Tucker, and Sergey Levine. D4rl: Datasets for deep data-driven reinforcement learning. ArXiv, abs/2004.07219, 2020.
206
+ [11] Scott Fujimoto, David Meger, and Doina Precup. Off-policy deep reinforcement learning without exploration. In ICML, 2019.
207
+ [12] Andreas Geiger, Philip Lenz, Christoph Stiller, and Raquel Urtasun. Vision meets robotics: The kitti dataset. The International Journal of Robotics Research, 32:1231 - 1237, 2013.
208
+ [13] Caglar Gulcehre, Sergio Gomez Colmenarejo, Jakub Sygnowski, Thomas Paine, Konrad Zolna, Yutian Chen, Matthew Hoffman, Razvan Pascanu, Nando de Freitas, et al. Addressing extrapolation error in deep offline reinforcement learning. 2020.
209
+ [14] William H. Guss, Brandon Houghton, Nicholay Topin, Phillip Wang, Cayden Codel, Manuela M. Veloso, and Ruslan Salakhutdinov. Mineral: A large-scale dataset of minecraft demonstrations. ArXiv, abs/1907.13440, 2019.
210
+ [15] Eric Hambro, Sharada Mohanty, Dmitrii Babaev, Minwoo Byeon, Dipam Chakraborty, Edward Grefenstette, Minqi Jiang, Daejin Jo, Anssi Kanervisto, Jongmin Kim, et al. Insights from the neurips 2021 nethack challenge. arXiv preprint arXiv:2203.11889, 2022.
211
+ [16] Nicolas Manfred Otto Heess, TB Dhruva, Srinivasan Sriram, Jay Lemmon, Josh Merel, Greg Wayne, Yuval Tassa, Tom Erez, Ziyun Wang, S. M. Ali Eslami, Martin A. Riedmiller, and David Silver. Emergence of locomotion behaviours in rich environments. ArXiv, abs/1707.02286, 2017.
212
+ [17] James Henderson, Oliver Lemon, and Kallirroi Georgila. Hybrid reinforcement/supervised learning of dialogue policies from fixed data sets. Computational Linguistics, 34:487-511, 2008.
213
+ [18] Natasha Jaques, Asma Ghandeharioun, Judy Hanwen Shen, Craig Ferguson, Ågata Lapedriza, Noah J. Jones, Shixiang Shane Gu, and Rosalind W. Picard. Way off-policy batch deep reinforcement learning of implicit human preferences in dialog. ArXiv, abs/1907.00456, 2019.
214
+ [19] Kenneth Lorber. NetHack Home Page. https://nethack.org, 2020. Accessed: 2020-05-30.
215
+ [20] Ilya Kostrikov, Ashvin Nair, and Sergey Levine. Offline reinforcement learning with implicit q-learning. ArXiv, abs/2110.06169, 2021.
216
+ [21] Aviral Kumar, Aurick Zhou, G. Tucker, and Sergey Levine. Conservative q-learning for offline reinforcement learning. ArXiv, abs/2006.04779, 2020.
217
+
218
+ [22] Vitaly Kurin, Sebastian Nowozin, Katja Hofmann, Lucas Beyer, and B. Leibe. The atari grand challenge dataset. ArXiv, abs/1705.10998, 2017.
219
+ [23] Heinrich Kuttler, Nantas Nardelli, Alexander H. Miller, Roberta Raileanu, Marco Selvatici, Edward Grefenstette, and Tim Rocktäschel. The nethack learning environment. ArXiv, abs/2006.13760, 2020.
220
+ [24] Joonho Lee, Jemin Hwangbo, Lorenz Wellhausen, Vladlen Koltun, and Marco Hutter. Learning quadrupedal locomotion over challenging terrain. Science Robotics, 5, 2020.
221
+ [25] Sergey Levine, Aviral Kumar, G. Tucker, and Justin Fu. Offline reinforcement learning: Tutorial, review, and perspectives on open problems. ArXiv, abs/2005.01643, 2020.
222
+ [26] Sergey Levine, Peter Pastor, Alex Krizhevsky, and Deirdre Quillen. Learning hand-eye coordination for robotic grasping with deep learning and large-scale data collection. The International Journal of Robotics Research, 37:421 - 436, 2018.
223
+ [27] Lihong Li, Wei Chu, John Langford, and Robert E. Schapire. A contextual-bandit approach to personalized news article recommendation. ArXiv, abs/1003.0146, 2010.
224
+ [28] Jeffrey Mahler, Matthew Matl, Vishal Satish, Michael Danielczuk, Bill DeRose, Stephen McKinley, and Ken Goldberg. Learning ambidextrous robot grasping policies. Science Robotics, 4, 2019.
225
+ [29] Ajay Mandlekar, Danfei Xu, J. Wong, Soroush Nasiriany, Chen Wang, Rohun Kulkarni, Li Fei-Fei, Silvio Savarese, Yuke Zhu, and Roberto Mart'in-Mart'in. What matters in learning from offline human demonstrations for robot manipulation. ArXiv, abs/2108.03298, 2021.
226
+ [30] Michael Matthews, Mikayel Samvelyan, Jack Parker-Holder, Edward Grefenstette, and Tim Rocktäschel. Hierarchical kickstarting for skill transfer in reinforcement learning, 2022.
227
+ [31] Vegard Mella, Eric Hambro, Danielle Rothermel, and Heinrich Kuttler. moolib: A Platform for Distributed RL. 2022.
228
+ [32] Raphael Memmesheimer, Ivanna Mykhalchyshyna, Viktor Seib, and Dietrich Paulus. Simitate: A hybrid imitation learning benchmark. 2019 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pages 5243-5249, 2019.
229
+ [33] Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Alex Graves, Ioannis Antonoglou, Daan Wierstra, and Martin A. Riedmiller. Playing atari with deep reinforcement learning. *ArXiv*, abs/1312.5602, 2013.
230
+ [34] NetHack Wiki. NetHackWiki. https://nethackwiki.com/, 2020. Accessed: 2020-02-01.
231
+ [35] OpenAI, Ilge Akkaya, Marcin Andrychowicz, Maciek Chogiej, Mateusz Litwin, Bob McGrew, Arthur Petron, Alex Paino, Matthias Plappert, Glenn Powell, Raphael Ribas, Jonas Schneider, Nikolas A. Tezak, Jerry Tworek, Peter Welinder, Lilian Weng, Qiming Yuan, Wojciech Zaremba, and Lei M. Zhang. Solving rubik's cube with a robot hand. ArXiv, abs/1910.07113, 2019.
232
+ [36] Keiran Paster, Sheila McIlraith, and Jimmy Ba. You can't count on luck: Why decision transformers fail in stochastic environments. arXiv preprint arXiv:2205.15967, 2022.
233
+ [37] Aleksei Petrenko, Zhehui Huang, Tushar Kumar, Gaurav Sukhatme, and Vladlen Koltun. Sample factory: Egocentric 3d control from pixels at 100000 fps with asynchronous reinforcement learning. In International Conference on Machine Learning, pages 7652-7662. PMLR, 2020.
234
+ [38] Olivier Pietquin, Matthieu Geist, Senthilkumar Chandramohan, and Hervé Frezza-Buet. Sample-efficient batch reinforcement learning for dialogue management optimization. ACM Trans. Speech Lang. Process., 7:7:1-7:21, 2011.
235
+ [39] Rafael Figueiredo Prudencio, Marcos R.O.A. Maximo, and Esther Luna Colombini. A survey on offline reinforcement learning: Taxonomy, review, and open problems. ArXiv, abs/2203.01387, 2022.
236
+ [40] Rongjun Qin, Songyi Gao, Xingyuan Zhang, Zhen Xu, Shengkai Huang, Zewen Li, Weinan Zhang, and Yang Yu. Neorl: A near real-world benchmark for offline reinforcement learning. ArXiv, abs/2102.00714, 2021.
237
+ [41] Aravind Rajeswaran, Vikash Kumar, Abhishek Gupta, John Schulman, Emanuel Todorov, and Sergey Levine. Learning complex dexterous manipulation with deep reinforcement learning and demonstrations. *ArXiv*, abs/1709.10087, 2018.
238
+
239
+ [42] Sabela Ramos, Sertan Girgin, L'essonard Hussenot, Damien Vincent, Hanna Yakubovich, Daniel Toyama, Anita Gergely, Piotr Stanczyk, Raphaël Marinier, Jeremiah Harmsen, Olivier Pietquin, and Nikola Momchev. Rlds: an ecosystem to generate, share and use datasets in reinforcement learning. ArXiv, abs/2111.02767, 2021.
240
+ [43] Stéphane Ross, Geoffrey J. Gordon, and J. Andrew Bagnell. A reduction of imitation learning and structured prediction to no-regret online learning. In AISTATS, 2011.
241
+ [44] Andrei A. Rusu, Matej Vecerik, Thomas Rothörl, Nicolas Manfred Otto Heess, Razvan Pascanu, and Raia Hadsell. Sim-to-real robot learning from pixels with progressive nets. ArXiv, abs/1610.04286, 2017.
242
+ [45] Mikayel Samvelyan, Robert Kirk, Vitaly Kurin, Jack Parker-Holder, Minqi Jiang, Eric Hambro, Fabio Petroni, Heinrich Kuttler, Edward Grefenstette, and Tim Rocktäschel. Minihack the planet: A sandbox for open-ended reinforcement learning research. arXiv preprint arXiv:2109.13202, 2021.
243
+ [46] Simon Schmitt, Jonathan J. Hudson, Augustin Zidek, Simon Osindero, Carl Doersch, Wojciech M. Czarnecki, Joel Z. Leibo, Heinrich Kuttler, Andrew Zisserman, Karen Simonyan, and S. M. Ali Eslami. Kickstarting deep reinforcement learning. *ArXiv*, abs/1803.03835, 2018.
244
+ [47] John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.
245
+ [48] Pratyusha Sharma, Lekha Mohan, Lerrel Pinto, and Abhinav Kumar Gupta. Multiple interactions made easy (mime): Large scale demonstrations data for imitation. In CoRL, 2018.
246
+ [49] Noah Siegel, Jost Tobias Springenberg, Felix Berkenkamp, Abbas Abdelmaleki, Michael Neunert, Thomas Lampe, Roland Hafner, and Martin A. Riedmiller. Keep doing what worked: Behavioral modelling priors for offline reinforcement learning. *ArXiv*, abs/2002.08396, 2020.
247
+ [50] David Silver, Aja Huang, Chris J Maddison, Arthur Guez, Laurent Sifre, George Van Den Driessche, Julian Schrittwieser, Ioannis Antonoglou, Veda Panneershelvam, Marc Lanctot, et al. Mastering the game of go with deep neural networks and tree search. nature, 529(7587):484-489, 2016.
248
+ [51] Bradley C. Stadie, P. Abbeel, and Ilya Sutskever. Third-person imitation learning. *ArXiv*, abs/1703.01703, 2017.
249
+ [52] Alexander L. Strehl, John Langford, Lihong Li, and Sham M. Kakade. Learning from logged implicit exploration data. In NIPS, 2010.
250
+ [53] Michita Imai Takuma Seno. d3rlpy: An offline deep reinforcement library. In NeurIPS 2021 Offline Reinforcement Learning Workshop, December 2021.
251
+ [54] The Telegraph. The 25 hardest video games ever. 2021. Accessed: 2021-05-05.
252
+ [55] Philip S. Thomas, Georgios Theocharous, Mohammad Ghavamzadeh, Ishan Durugkar, and Emma Brunskill. Predictive off-policy policy evaluation for nonstationary decision problems, with applications to digital marketing. In AAAI, 2017.
253
+ [56] Faraz Torabi, Garrett Warnell, and Peter Stone. Behavioral cloning from observation. ArXiv, abs/1805.01954, 2018.
254
+ [57] Sam Toyer, Rohin Shah, Andrew Critch, and Stuart J. Russell. The magical benchmark for robust imitation. ArXiv, abs/2011.00401, 2020.
255
+ [58] Oriol Vinyals, Igor Babuschkin, Wojciech M. Czarnecki, Michael Mathieu, Andrew Dudzik, Junyoung Chung, David H. Choi, Richard Powell, Timo Ewalds, Petko Georgiev, Junhyuk Oh, Dan Horgan, Manuel Kroiss, Ivo Danihelka, Aja Huang, L. Sifre, Trevor Cai, John P. Agapiou, Max Jaderberg, Alexander Sasha Vezhnevets, Rémi Leblond, Tobias Pohlen, Valentin Dalibard, David Budden, Yury Sulsky, James Molloy, Tom Le Paine, Caglar Gulcehre, Ziyun Wang, Tobias Pfaff, Yuhui Wu, Roman Ring, Dani Yogatama, Dario Wünsch, Katrina McKinney, Oliver Smith, Tom Schaul, Timothy P. Lillicrap, Koray Kavukcuoglu, Demis Hassabis, Chris Apps, and David Silver. Grandmaster level in starcraft ii using multi-agent reinforcement learning. Nature, pages 1-5, 2019.
256
+ [59] Oriol Vinyals, Timo Ewalds, Sergey Bartunov, Petko Georgiev, Alexander Sasha Vezhnevets, Michelle Yeo, Alireza Makhzani, Heinrich Kuttler, John P. Agapiou, Julian Schrittwieser, John Quan, Stephen Gaffney, Stig Petersen, Karen Simonyan, Tom Schaul, H. V. Hasselt, David
257
+
258
+ Silver, Timothy P. Lillicrap, Kevin Calderone, Paul Keet, Anthony Brunasso, David Lawrence, Anders Ekermo, Jacob Repp, and Rodney Tsing. Starcraft ii: A new challenge for reinforcement learning. ArXiv, abs/1708.04782, 2017.
259
+ [60] Yifan Wu, G. Tucker, and Ofir Nachum. Behavior regularized offline reinforcement learning. ArXiv, abs/1911.11361, 2019.
260
+ [61] Chi Zhang, Sanmukh Rao Kuppannagari, and Viktor K. Prasanna. Brac+: Improved behavior regularized actor critic for offline reinforcement learning. In ACML, 2021.
261
+ [62] Caglar Güçehre, Ziyun Wang, Alexander Novikov, Tom Le Paine, Sergio Gomez Colmenarejo, Konrad Zolna, Rishabh Agarwal, Josh Merel, Daniel Jaymin Mankowitz, Cosmin Paduraru, Gabriel Dulac-Arnold, Jerry Zheng Li, Mohammad Norouzi, Matthew D. Hoffman, Nicolas Manfred Otto Heess, and Nando de Freitas. Rl unplugged: A collection of benchmarks for offline reinforcement learning. In NeurIPS, 2020.
262
+
263
+ # 9 Checklist
264
+
265
+ 1. For all authors...
266
+
267
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper's contributions and scope? [Yes]
268
+ (b) Did you describe the limitations of your work? [Yes] See Appendix K
269
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes]. See Appendix $\boxed{L}$ .
270
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
271
+
272
+ 2. If you are including theoretical results...
273
+
274
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A]
275
+ (b) Did you include complete proofs of all theoretical results? [N/A]
276
+
277
+ 3. If you ran experiments (e.g. for benchmarks)...
278
+
279
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] Code will be supplied with the dataset at the link provided in Appendix A
280
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Appendix I
281
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] We report standard deviations across seeds for all results.
282
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Appendix I
283
+
284
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
285
+
286
+ (a) If your work uses existing assets, did you cite the creators? [Yes] Although we do not use "assets" per se, we do cite the bot AutoAscend by linking to it and citing the author's own write up in the NetHack Challenge report.[15]
287
+ (b) Did you mention the license of the assets? [Yes] We mention the license of the dataset (same as NLE) in Appendix B
288
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] This is a dataset paper, so the 'assets' are the data, which is of course linked to in Appendix A.
289
+ (d) Did you discuss whether and how consent was obtained from people whose data you're using/curating? [N/A] We do not discuss this in the paper because: 1) some of the data is from an open source bot and 2) the human data is already public and completely anonymous. We did discuss this with the site creator (who collected the data, and put up terms of use) and we obtained his consent, as well as the consent of the creators of the bot.
290
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] We discuss in Appendix H.3
291
+
292
+ 5. If you used crowdsourcing or conducted research with human subjects...
293
+
294
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
295
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
296
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
297
+
298
+ # 10 Datasets Checklist
299
+
300
+ Include extra information in the appendix. This section will often be part of the supplemental material. Please see the call on the NeurIPS website for links to additional guides on dataset publication.
301
+
302
+ 1. Submission introducing new datasets must include the following in the supplementary materials:
303
+
304
+ (a) Dataset documentation and intended uses. Recommended documentation frameworks include datasheets for datasets, dataset nutrition labels, data statements for NLP, and accountability frameworks. [We document the code to use the dataset in the repository and provide many references in the Appendices.]
305
+ (b) URL to website/platform where the dataset/benchmark can be viewed and downloaded by the reviewers. [We provide this in Appendix A]
306
+ (c) Author statement that they bear all responsibility in case of violation of rights, etc., and confirmation of the data license. [We provide this in Appendix B and upon submission to OpenReview]
307
+ (d) Hosting, licensing, and maintenance plan. The choice of hosting platform is yours, as long as you ensure access to the data (possibly through a curated interface) and will provide the necessary maintenance. [We provide this in Appendix A]
308
+
309
+ 2. To ensure accessibility, the supplementary materials for datasets must include the following:
310
+
311
+ (a) Links to access the dataset and its metadata. This can be hidden upon submission if the dataset is not yet publicly available but must be added in the camera-ready version. In select cases, e.g when the data can only be released at a later date, this can be added afterward. Simulation environments should link to (open source) code repositories. [We provide this in Appendix A]
312
+ (b) The dataset itself should ideally use an open and widely used data format. Provide a detailed explanation on how the dataset can be read. For simulation environments, use existing frameworks or explain how they can be used. [We provide example usage, documentation, and detailed specification in how data is stored in several Appendices]
313
+ (c) Long-term preservation: It must be clear that the dataset will be available for a long time, either by uploading to a data repository or by explaining how the authors themselves will ensure this. [We provide a maintenance plan in Appendix A]
314
+ (d) Explicit license: Authors must choose a license, ideally a CC license for datasets, or an open source license for code (e.g. RL environments). [We provide an open license in Appendix B]
315
+ (e) Add structured metadata to a dataset's meta-data page using Web standards (like schema.org and DcAT): This allows it to be discovered and organized by anyone. If you use an existing data repository, this is often done automatically. [We are in the process of building a site to host, but are happy to do this when completed.]
316
+ (f) Highly recommended: a persistent dereferenceable identifier (e.g. a DOI minted by a data repository or a prefix on identifiers.org) for datasets, or a code repository (e.g. GitHub, GitLab,...) for code. If this is not possible or useful, please explain why. [Code and instructions will always live on GitHub].
317
+
318
+ 3. For benchmarks, the supplementary materials must ensure that all results are easily reproducible. Where possible, use a reproducibility framework such as the ML reproducibility checklist, or otherwise guarantee that all results can be easily reproduced, i.e. all necessary datasets, code, and evaluation procedures must be accessible and documented. [We provide access to code for experiments and will tidy and rehost upon release of the dataset.]
319
+
320
+ 4. For papers introducing best practices in creating or curating datasets and benchmarks, the above supplementary materials are not required.
dungeonsanddataalargescalenethackdataset/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:82268bf969ce2b37f887799d789bcf186d246aae2c63c027fb9bed3c7d23e4d6
3
+ size 181866
dungeonsanddataalargescalenethackdataset/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1fc678a9df86522af96e308b140df4bfe2c86bae261064e7bcf59fa3d7a0bbb1
3
+ size 357059
dynamicfairdivisionwithpartialinformation/bfcf9575-ec57-4370-818d-1572738087d3_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:84b885fe0ebf0726aef63373f6dd7f5d811b93051c4fe4f6ea1841c3a00bc522
3
+ size 79554
dynamicfairdivisionwithpartialinformation/bfcf9575-ec57-4370-818d-1572738087d3_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c14275f11319f5d232bdfdd46fdcff2c86a8dfaf397db66c845ad0aebde11965
3
+ size 96501