Downstream Task Guided Masking Learning in Masked Autoencoders Using Multi-Level Optimization

## Abstract

Abstract Masked Autoencoder (MAE) is a notable method for self-supervised pretraining in visual representation learning. It operates by randomly masking image patches and reconstructing these masked patches using the unmasked ones. A key limitation of MAE lies in its disregard for the varying informativeness of different patches, as it uniformly selects patches to mask. To overcome this, some approaches propose masking based on patch informativeness. However, these methods often do not consider the specific requirements of downstream tasks, potentially leading to suboptimal representations for these tasks. In response, we introduce the Multi-level Optimized Mask Autoencoder (MLO-MAE), a novel framework that leverages end-to-end feedback from downstream tasks to learn an optimal masking strategy during pretraining. Our experimental findings highlight MLO-MAE’s significant advancements in visual representation learning. Compared to existing methods, it demonstrates remarkable improvements across diverse datasets and tasks, showcasing its adaptability and efficiency. Our code is available at: https://github.com/Alexiland/MLOMAE

## 1 Introduction

In the rapidly evolving field of self-supervised learning (Balestriero et al., ; Gui et al., ), particularly in visual representation learning, Masked Autoencoder (MAE) (He et al., ) has emerged as a prominent approach, which draws inspiration from the successful masked language models like BERT (Devlin et al., ) and RoBERTa (Liu et al., ).
Similar to how BERT learns textual representations by predicting randomly masked tokens, MAE is designed to learn visual representations by masking random patches of an image and then reconstructing them using the remaining unmasked patches.

Although MAE has shown empirical success, it applies a uniform random approach to masking patches, overlooking the variable distribution of information across different image regions (Chen et al., ; Kong & Zhang, ; Wang et al., ; Liu et al., ). It assumes equal informativeness across all parts of an image, an assumption that does not always hold true. Some image areas (e.g., foreground objects) may hold more critical information than others (e.g., background), a factor not considered in MAE’s current design. Such oversight might hinder the model’s capability and efficiency in learning representations. This lack of distinction between more and less informative regions in the MAE could lead to disproportionate allocations of computational resources. Consequently, the model might spend excessive effort on less significant areas while inadequately processing and capturing the nuances in regions that contain more valuable information.

To mitigate this limitation, various strategies have been suggested for masking patches contingent on their informativeness. Key approaches include masking regions with high attention scores to prioritize areas of interest (Li et al., ; Kakogeorgiou et al., ); employing semantic segmentation to identify and mask regions rich in information (Li et al., ; Chen et al., ); and utilizing adversarial models that generate masks to enhance learning efficiency (Shi et al., ). These approaches aim to refine the masking process by prioritizing patches based on the level of information they contain, rather than treating all patches uniformly.

Although these methods are promising, they mask patches without incorporating feedback from downstream tasks.
Their process involves two separate stages: initially employing a specific masking strategy to pretrain a model, then fine-tuning this model for downstream tasks, with the hope that the model pretrained using this strategy will be effective for these tasks. During this process, the design of the masking strategy is not influenced by the requirements of the downstream tasks. As a result, the representations developed through this strategy may not be well-aligned with the needs of these tasks, which could limit their effectiveness.

To bridge this gap, we propose a downstream task guided masking strategy learning framework based on multi-level optimization (MLO) (Vicente & Calamai, ). Our approach utilizes feedback from downstream tasks to autonomously learn the optimal masking strategy. It integrates model pretraining with fine-tuning in an end-to-end manner, allowing the fine-tuning performance on downstream tasks to directly influence the masking process during pretraining.
Our method learns a masking network to mask patches. It processes an input image to identify specific patches for masking.
Our method consists of three interconnected stages. In the first stage, a preliminary version of the masking network masks certain patches, followed by the pretraining of an image encoder tasked with reconstructing these masked patches. In the second stage, we utilize this encoder to construct a downstream model, which is subsequently trained using the training dataset specific to a downstream task. The final stage involves evaluating the downstream model using a held-out validation dataset. The effectiveness of the masking network is indirectly measured by the downstream model’s validation performance.
An inferior masking network might fail to correctly identify the optimal patches for masking, leading to ineffective pretraining of the image encoder. When applied to the downstream task,
the encoder’s inadequate representation learning capabilities will lead to suboptimal validation performance of the downstream model.
To prevent this, we continuously refine the masking network, ensuring it maximizes downstream validation performance. Each of these stages is formulated as one level of optimization problem in our MLO framework. The three levels of optimization problems are mutually dependent on each other and solved jointly. This enables the three stages to be conducted end-to-end, where the downstream validation performance closely guides the learning of the masking network.

The major contributions of this work include:

- •
We propose a multi-level optimization based end-to-end framework to learn an optimal masking strategy in Masked Autoencoder by leveraging feedback from downstream tasks.
- •
Our approach outperforms a range of leading-edge methods in learning representations, as evidenced across various datasets such as CIFAR-10, CIFAR-100, and ImageNet-1K.
- •
Our method showcases remarkable transfer learning abilities, in fine-grained classification and semantic segmentation tasks, demonstrated on datasets including CUB-200-2011, Stanford Cars, iNaturalist 2019, and ADE20K.

## 2 Related Works

### 2.1 Masked Autoencoders

Following the success of masked language models in the field of natural language processing (Devlin et al., ), various masked image models have been proposed (Chen et al., ; Bao et al., ). Among them, Masked Autoencoder (MAE) has become a promising methodology for generic visual pretraining (He et al., ). MAE is a denoising autoencoder that randomly masks the input image and tries to reconstruct the missing pixels. It uses a high masking ratio (75% in MAE compared to 15% in BERT) and a lightweight decoder architecture that forces the encoder to learn meaningful visual representations. Zhang et al. () propose a theoretical framework to understand the role of masking in MAE, and introduce a Uniformity-enhanced MAE (U-MAE) to address the dimensional collapse issue. Despite MAE’s effectiveness, recent works underscore the importance of replacing the random patch masking method in MAE with more sophisticated masking strategies (Kakogeorgiou et al., ; Shi et al., ). For instance, MST (Li et al., ) utilizes attention maps to guide the masking process, selectively obscuring less attended regions to maintain foreground information. SemMAE (Li et al., ) combines a StyleGAN-based decoder with the MAE decoder and leverages attention maps from the StyleGAN decoder to provide semantic cues for patch masking. Furthermore, some recent methods propose to use a learnable masking module to generate masking strategies and optimize the masking module in the pretraining process. For example, AutoMAE (Chen et al., ) links a differentiable mask generator with MAE using Gumbel-Softmax (Jang et al., ), following a similar two-stage setup as in SemMAE. CL-MAE (Madan et al., ) leverages curriculum learning to enhance MAE by progressively increasing the complexity of the masks generated from a learnable masking module. Compared to these existing methods, the key distinction of our approach lies in the utilization of feedback from downstream tasks to inform the development of masking strategies, a mechanism absent in the current methodologies.

Figure: Figure 1: An overview of MLO-MAE, which consists of three stages performed end-to-end. Modules with learnable parameters are indicated in blue, and those with frozen parameters are in orange.
Refer to caption: x1.png

### 2.2 Bi-level and Multi-level Optimization

Recently, Bi-level Optimization (BLO) and Multi-level Optimization (MLO) techniques have been widely applied for meta-learning (Feurer et al., ; Finn et al., ), neural architecture search (Cai et al., ; Xie et al., ; Xu et al., ; Hosseini et al., ) and hyperparameter tuning (Feurer et al., ; Baydin et al., ). BLO, a formulation that consists of two levels of nested optimization problems, has been broadly applied in numerous machine learning applications (Liu et al., ; Liang et al., ). BLO based methods have enabled automatic and efficient learning of upper-level parameters, such as meta parameters and neural architectures, thereby reducing the need for extensive hyperparameter tuning through manual efforts. Following the success of BLO, MLO - which has more than two levels of nested optimization problems (Hosseini & Xie, ; Hosseini et al., ; Sheth et al., ; Garg et al., ) - has been used to solve machine learning tasks with more complicated dependencies. These works develop multi-stage pipelines, with each stage corresponding to one level of optimization problem (OP). Different stages are executed end-to-end by solving all levels of interdependent OPs jointly. Despite its effectiveness, MLO based methods increase memory and computation costs due to their growing number of optimization levels. To tackle this challenge, Choe et al. () develop software that integrates multiple approximation algorithms to efficiently compute the hypergradients within BLO and MLO problems.

## 3 Methods

### 3.1 Overview

We introduce the Multi-level Optimized MAE (MLO-MAE), a self-supervised visual representation learning method that automatically learns an optimal masking strategy in a Masked Autoencoder. As illustrated in Figure 1, the MLO-MAE architecture comprises three key components: a masking network $T$, a Vision Transformer (ViT) (Dosovitskiy et al., ) based image encoder $E$, and a classification head $C$. Given an input image, the masking network identifies the patches to be masked.
The image encoder extracts a representation for an input image. It is pretrained by reconstructing masked patches from unmasked ones. The classification head $C$ predicts a class label from an image representation extracted by the encoder. MLO-MAE leverages an image classification dataset $\mathcal{D}$, comprising pairs of images and their corresponding class labels. This dataset is divided into a training subset $\mathcal{D}^{tr}$ and a validation subset $\mathcal{D}^{val}$. The image encoder is pretrained on unlabeled input images (denoted as $\mathcal{D}_{u}$) from $\mathcal{D}^{tr}$ (excluding labels).

Our method operates in three end-to-end stages. In the first stage, a tentative version of the masking network masks input images from $\mathcal{D}_{u}$. Then the image encoder is pretrained on these masked images. In the second stage, the pretrained encoder extracts representations for images in the training set $\mathcal{D}^{tr}$. These representations, along with their corresponding labels, are used to train the classification head by minimizing classification losses. In the third stage, the pretrained encoder extracts representations for images in the validation set $\mathcal{D}^{val}$. The trained classification head then uses these representations to predict labels. Validation loss is computed by comparing these predictions with the actual labels in $\mathcal{D}^{val}$. As shown later, the validation loss is a function of the masking network $T$. This loss serves as a metric for assessing the effectiveness of $T$. To enhance the functionality of $T$, we focus on minimizing this loss.

Our method employs a multi-level optimization approach, involving several nested optimization problems. Optimal parameters obtained at each lower level serve as inputs for the loss functions at the subsequent upper levels. Conversely, non-optimal parameters from the upper levels are utilized to define the loss functions at lower levels. Each of the three aforementioned stages corresponds to a single level of optimization. Different stages are executed end-to-end by solving problems at different levels jointly.

### 3.2 Multi-level Optimization Framework

The framework of our proposed MLO-MAE is structured into three interconnected stages. These three stages are integrated within a multi-level optimization framework.

##### Stage I: Pretrain Image Encoder.

Given an input image $X\in D_{u}$ divided into $N$ non-overlapping patches of equal size, denoted as $\{P_{i}\}_{i=1}^{N}$, the masking network $T$ takes $X$ as input and generates a probability $\sigma(P_{i},X;T)$ for each patch $P_{i}$, which represents the likelihood that $P_{i}$ should be masked. Given a masking ratio $r$, a hyperparameter dictating the proportion of patches to be masked, we first rank all patches in descending order based on their masking probabilities. We then select the top $N\times r$ patches denoted as $\mathcal{M}(X;T,r)$, those with the highest probabilities, and mask them. The remaining patches, denoted as $X-\mathcal{M}(X;T,r)$, are unmasked.

Then we feed the unmasked patches into an autoencoder (He et al., ), which consists of the image encoder $E$ and a decoder $D$, to reconstruct the masked patches $\mathcal{M}(X;T,r)$. In detail, the unmasked patches are first processed by the image encoder $E$, which is responsible for extracting their representations. Then, these representations are input into the decoder $D$. The decoder’s role is to accurately predict the pixel values of the masked patches. To evaluate the performance of this reconstruction, we employ a reconstruction loss, $\mathcal{L}_{rec}$, defined as the squared differences between the predicted and ground truth pixel values of the masked patches. Importantly, the reconstruction loss for the $j$-th masked patch $\mathcal{M}_{j}(X;T,r)$ is weighted according to its masking probability $\sigma(\mathcal{M}_{j}(X;T,r),X;T)$. This probability reflects the likelihood of a patch being masked and thus, guides the autoencoder to prioritize the reconstruction of patches deemed more likely to be masked.

In this stage, we provisionally hold the masking network $T$ constant, and focus on training the image encoder $E$ and decoder $D$, by solving the following optimization problem:

$$ $\small\begin{array}[]{l}E^{*}(T),D^{*}=\underset{E,D}{\text{argmin}}\sum \limits_{X\in\mathcal{D}_{u}}\sum\limits_{j=1}^{N\times r}\sigma(\mathcal{M}_{ j}(X;T,r),X;T)\times\\ \qquad\qquad\quad\mathcal{L}_{rec}(X-\mathcal{M}(X;T,r),\mathcal{M}_{j}(X;T,r) ;E,D).\end{array}$ (1) $$

The notation $E^{*}(T)$ indicates that the optimal solution $E^{*}$ is a function of $T$, as $E^{*}$ is determined by the loss function which in turn depends on $T$.

##### Stage II: Train Classification Head.

Utilizing the pretrained image encoder $E^{*}(T)$ from Stage I, we develop an image classification model for a downstream task. This model comprises the encoder $E^{*}(T)$ and the classification head $C$. For any given input image, it is first processed by the encoder to generate a representation. This representation is then input into the classification head to determine the class label. In this stage, we keep the encoder parameters fixed and focus on training the classification head. This is achieved by minimizing a cross-entropy classification loss $\mathcal{L}_{cls}$ on the training dataset $\mathcal{D}^{tr}$:

$$ $C^{*}(E^{*}(T))=\underset{C}{\text{argmin}}\;\mathcal{L}_{cls}(\mathcal{D}^{tr };E^{*}(T),C).$ (2) $$

##### Stage III: Update Masking Network.

In Stage III, we assess the classification model developed in Stage II on the validation set $\mathcal{D}^{val}$. This model integrates the image encoder, $E^{*}(T)$, which was pretrained in Stage I, and the classification head, $C^{*}(E^{*}(T))$, trained in Stage II. The validation loss serves as an indirect measure of the efficacy of the masking network $T$. Our objective is to enhance the performance of $T$ by minimizing this validation loss:

$$ $\underset{T}{\text{min}}\;\mathcal{L}_{cls}(\mathcal{D}^{val};E^{*}(T),C^{*}(E ^{*}(T))).$ (3) $$

##### Multi-level Optimization.

Integrating the three optimization problems together, we have the following multi-level optimization problem:

$$ $\small\begin{array}[]{l}\underset{T}{\text{min}}\;\mathcal{L}_{cls}(\mathcal{D }^{val};E^{*}(T),C^{*}(E^{*}(T)))\\ \\ s.t.\;C^{*}(E^{*}(T))=\underset{C}{\text{argmin}}\;\mathcal{L}_{cls}(\mathcal{ D}^{tr};E^{*}(T),C)\\ \quad\;\;E^{*}(T),D^{*}=\underset{E,D}{\text{argmin}}\sum\limits_{X\in\mathcal {D}_{u}}\sum\limits_{j=1}^{N\times r}\sigma(\mathcal{M}_{j}(X;T,r),X;T)\times \\ \quad\;\;\qquad\qquad\quad\;\mathcal{L}_{rec}(X-\mathcal{M}(X;T,r),\mathcal{M} _{j}(X;T,r);E,D)\end{array}$ (4) $$

In this formulation, the three levels of optimization problems are mutually dependent. The first level’s output, $E^{*}(T)$, defines the loss function in the second level. Both the outputs of the first and second levels are fed into the loss function of the third level. Simultaneously, the third level’s optimization variable, $T$, influences the loss functions in the first two levels. By concurrently solving these optimization problems across all three levels, we enable an integrated, end-to-end execution of the three stages.

##### Optimization Algorithm.

Inspired by (Liu et al., ), we develop an efficient hypergradient-based method to solve the problem in Eq.(4). First, we approximate the optimal solutions $E^{*}(T)$ and $D^{*}$ by executing several iterations (termed as unrolling steps) of gradient descent updates of $E$ and $D$ against the loss function at the first level. The approximation of $E^{*}(T)$ is then plugged into the second-level loss, and $C^{*}(E^{*}(T))$ is similarly approximated using multiple steps of gradient descent updates of $C$ against this approximate loss. The approximations of $E^{*}(T)$ and $C^{*}(E^{*}(T))$ are then applied to the third-level loss, enabling the gradient descent update of $T$. This iterative process of updating continues until convergence is achieved.

**Table 1: Top-1 accuracy (%) on the test sets of CIFAR-10, CIFAR-100, and ImageNet, in fine-tuning experiments. Results marked with * are taken from U-MAE (Zhang et al., ) and AutoMAE (Chen et al., ). The baseline methods SemMAE and AutoMAE are not included in the comparison on CIFAR-10 and CIFAR-100, due to the absence of reported results for these datasets in their original publications and the unavailability of their implementation code for conducting evaluations on these datasets.**
|  | (No Pretraining) | (Random Masking) | (Learnable Masking) |  |  |  |
| --- | --- | --- | --- | --- | --- | --- |
|  | ViT | MAE | U-MAE | SemMAE | AutoMAE | MLO-MAE (Ours) |
| CIFAR-100 | 56.4 | 64.0 | 64.6 | – | – | 79.4 |
| CIFAR-10 | 82.3 | 93.7 | 94.3 | – | – | 96.2 |
| ImageNet-1K | 77.9 | ${}^{\text{*}}$82.9 | ${}^{\text{*}}$83.0 | ${}^{\text{*}}$83.3 | ${}^{\text{*}}$83.3 | 84.8 |

## 4 Experiments

### 4.1 Datasets

We evaluated our MLO-MAE method on three benchmark image classification datasets: CIFAR-10 (Krizhevsky et al., ), CIFAR-100 (Krizhevsky et al., ), and ImageNet-1K (Deng et al., ). CIFAR-10 and CIFAR-100 contain 50K training images and 10K test images from 10 and 100 classes, respectively. ImageNet contains 1.3M training images and 50K validation images (used as test set) from 1000 classes.
In our approach, we divide the original training set of each dataset into two subsets with a ratio of 8:2, which are used as the $D^{tr}$ and $D^{val}$ in Eq.(4), respectively. Unlabeled images $D_{u}$ used in MLO-MAE’s first stage are from $D^{tr}$.
Baseline methods are trained on the unsplit original training set. It is important to note that our method does not unfairly utilize more data than the baselines.
To assess the model’s transferability to fine-grained classification tasks, we further tested it on the CUB-200-2011 dataset (Wah et al., ), Stanford Cars dataset (Krause et al., ), and iNaturalist 2019 dataset (Van Horn et al., ). Additionally, we evaluated MLO-MAE’s semantic segmentation capabilities using the ADE20K dataset (Zhou et al., ). For comprehensive details about these datasets, please refer to Appendix B.1. In all experiments, performance on the test set is reported.

### 4.2 Experimental Settings

##### Model Setup and Hyperparameters.

In our method, the masking network is structured with multiple layers. Initially, there is a linear layer, where the input size is determined by the product of the number of patches (196 for ImageNet and 256 for CIFAR) and the embedding dimension (we used the patch embedding method in ViT, with a dimension of 768), and it has a hidden size of 512. This is followed by a ReLU layer. Next, there is another linear layer, which takes an input size of 512 and produces an output size equivalent to the number of patches. Finally, a sigmoid activation function is applied to the output to generate probabilities in the range of 0 to 1. Implementation details are described in Appendix B.2. Following MAE (He et al., ), an asymmetric ViT (Dosovitskiy et al., ) encoder-decoder architecture was used for mask reconstruction. Recognizing the constraints of computational resources, we primarily employed the ViT-B (Dosovitskiy et al., ) as the image encoder, ensuring a balance between efficiency and performance. The classification head consists of a single linear layer. It is intentionally made simple to focus on evaluating the effectiveness of the learned representations. The patch size was set to 2 for CIFAR-10 and CIFAR-100, and 16 for ImageNet. For all experiments, unless otherwise specified, we used the default mask ratio of 75% as suggested in MAE (He et al., ).

The number of unrolling steps in the algorithm for solving the MLO problem was set to 2. We employed the AdamW optimizer (Loshchilov & Hutter, ) with $\beta$ values of 0.9 and 0.95 for optimizing all parameters. The learning rates were set specifically for different components: $1e-4$ for the image encoder, and $4e-5$ for both the classification head and the masking network. We used a batch size of 256. For training, we set the epoch number to 50 for the ImageNet dataset and to 200 for the CIFAR datasets. All experiments were conducted on Nvidia A100 GPUs. Further information on our experimental settings can be found in Appendix B.

##### Baselines.

We conducted comparisons with several baselines, including: 1) vanilla MAE (He et al., ) and U-MAE (Zhang et al., ), which employ uniform random masking of images; 2) SemMAE (Li et al., ) and AutoMAE (Chen et al., ), which mask patches according to their informativeness; and 3) the Vision Transformer (ViT) (Dosovitskiy et al., ) without pretraining by MAE methods (i.e., directly trained for classification from scratch). ViT-B was used as the image encoder in these methods.

##### Evaluation Protocols.

In the literature on self-supervised learning, including MAE methods, there are two standard approaches for evaluating pretrained image encoders in downstream classification tasks (He et al., ). The first one is fine-tuning, which fine-tunes the pretrained encoder (together with training a randomly initialized classification head) by minimizing a classification loss on the downstream training data. The second approach is linear probing, which keeps the pretrained encoder fixed and only trains the classification head.
Our experiments used both protocols. For each dataset $D$, pretraining was conducted on unlabeled images in $D$; fine-tuning and linear probing were conducted on $D$ as well, utilizing both images and their associated labels.

### 4.3 Main Results

##### Fine-tuning Results.

Table 1 shows the results.
On the CIFAR-100 dataset, MLO-MAE demonstrates superior performance, achieving a test accuracy of 79.4%, substantially outperforming MAE’s 64% and U-MAE’s 64.6%. This trend of outperformance is also evident on the CIFAR-10 dataset, where MLO-MAE surpasses both MAE and U-MAE by 2.5% and 1.9% (absolute percentage) respectively. Moreover, on the ImageNet dataset, MLO-MAE performs better than all baseline methods. Specifically, MLO-MAE outperforms AutoMAE and SemMAE by 1.5% (absolute) improvements in top-1 accuracy.

These outcomes underscore MLO-MAE’s strong capability in learning effective visual representations across datasets of varying scales, from the large-scale ImageNet to the smaller-sized CIFAR datasets. The superiority of MLO-MAE over MAE and U-MAE stems from its advanced masking strategy that selectively targets informative patches, a significant enhancement over the indiscriminate, random masking approach of the two baselines. Furthermore, MLO-MAE surpasses AutoMAE and SemMAE by integrating feedback from downstream classification tasks into its masking process.
This dynamic adaptation contrasts with the static masking strategies of AutoMAE and SemMAE, which do not account for the specific requirements of downstream tasks, limiting their effectiveness.

**Table 2: Test accuracy (%) in linear probing experiments. Results marked with * are taken from AutoMAE (Chen et al., ).**
|  | MAE | U-MAE | SemMAE | AutoMAE | MLO-MAE (Ours) |
| --- | --- | --- | --- | --- | --- |
| CIFAR-100 | 46.6 | 50.4 | – | – | 63.8 |
| CIFAR-10 | 73.5 | 77.1 | – | – | 84.3 |
| ImageNet-1K | 55.4 | 58.5 | ${}^{*}$65.0 | ${}^{*}$68.8 | 70.2 |

##### Linear Probing Results.

Table 2 shows the linear probing results. Our method MLO-MAE demonstrates superior performance compared to baselines across various datasets. Specifically, on ImageNet, MLO-MAE achieves an impressive accuracy of 70.2%, substantially surpassing MAE’s accuracy of 55.4% and U-MAE’s 58.5%. Similarly, on the CIFAR-100 dataset, MLO-MAE continues to outperform, attaining an accuracy of 63.8%, significantly higher than the 46.6% accuracy of MAE and 50.4% accuracy of U-MAE.

**Table 3: Accuracy (%) on fine-grained image classification datasets. All methods use ViT-B as the backbone with a patch size of 16. The results of baselines are taken from AutoMAE (Chen et al., ). U-MAE did not report results on these three datasets.**
| Method | iNaturalist | CUB | Cars |
| --- | --- | --- | --- |
| MAE | 79.5 | 83.3 | 92.7 |
| SemMAE | 79.6 | 82.1 | 92.4 |
| AutoMAE | 79.9 | 83.7 | 93.1 |
| MLO-MAE (Ours) | 80.1 | 84.0 | 93.4 |

The superiority of MLO-MAE compared to baseline methods stems from its unique approach of integrating the pretraining of the image encoder and linear probing in a seamless, end-to-end workflow. Specifically, MLO-MAE conducts pretraining at the first level and linear probing at the second level within a unified framework. This integration allows the linear probing performance, evaluated at the third level, to directly inform and enhance the pretraining process. Consequently, this leads to a pretrained encoder that is more effectively tailored for the downstream linear probing task. In contrast, baseline methods handle pretraining and linear probing as distinct, separate stages, where the performance of linear probing does not impact or contribute to the pretraining phase.

### 4.4 Transfer Learning

#### 4.4.1 Fine-grained Image Classification

In MLO-MAE, the masking network is trained using a specific downstream classification dataset, raising concerns about potential overfitting and limited generalizability to other datasets. To address this, we performed transfer learning experiments. Given the ViT-B models pretrained on ImageNet using MLO-MAE and baselines and subsequently fine-tuned on ImageNet, we transferred them to perform fine-grained classification by further fine-tuning them on iNaturalist 2019, CUB-200-2011, and Stanford Cars.
Classification accuracy results, as presented in Table 3, show that MLO-MAE surpasses all baselines across these datasets.
This indicates that the masking network, as learned by MLO-MAE for a particular downstream classification dataset, is capable of generalizing its effectiveness to additional datasets, rather than being overly tailored to that specific downstream classification dataset.

#### 4.4.2 Semantic Segmentation

**Table 4: Semantic segmentation results on ADE20K. The results of baselines are taken from AutoMAE (Chen et al., ).**
| Method | mIoU |
| --- | --- |
| Supervised Pretraining | 45.3 |
| MAE | 46.1 |
| SemMAE | 46.3 |
| AutoMAE | 46.4 |
| MLO-MAE (Ours) | 49.8 |

We also explored the transferability of the masking network, initially learned through a downstream classification task, to a different task domain: semantic segmentation. Given a ViT-B model pretrained on ImageNet using MLO-MAE or a baseline and subsequently fine-tuned on ImageNet, to transfer it for semantic segmentation, we integrated it as a backbone model into the UPerNet (Xiao et al., ) semantic segmentation framework. It was then further fine-tuned on the challenging ADE20K dataset (Zhou et al., ) containing 25K images spanning 150 semantic categories. The fine-tuning was conducted by the AdamW optimizer for over 160,000 iterations, with a batch size of 8 and a learning rate of 0.0001.

In Table 4, MLO-MAE showcases a significant improvement over the baselines. Specifically, MLO-MAE attains enhancements in mean Intersection over Union (mIoU) by margins of 3.7% and 3.4% when compared to these baselines. This performance highlights the capability of MLO-MAE in executing dense prediction tasks.

### 4.5 Ablation Studies

##### Reduction to Two Levels.

To investigate the importance of maintaining three levels in the MLO-MAE framework, we simplified it to two levels, by combining the first and second levels, leading to the following bi-level optimization (BLO) problem (referred to as BLO-MAE):

$$ $\scriptsize\begin{array}[]{l}\underset{T}{\text{min}}\;\mathcal{L}_{cls}( \mathcal{D}^{val};E^{*}(T),C^{*})\\ s.t.\;E^{*}(T),D^{*},C^{*}=\underset{E,D,C}{\text{argmin}}\;\mathcal{L}_{cls}( \mathcal{D}^{tr};E,C)\;+\;\gamma\sum\limits_{X\in\mathcal{D}_{u}}\sum\limits_{ j=1}^{N\times r}\\ \;\;\;\;\;\;\sigma(\mathcal{M}_{j}(X;T,r),X;T)\mathcal{L}_{rec}(X-\mathcal{M}( X;T,r),\mathcal{M}_{j}(X;T,r);E,D),\end{array}$ (5) $$

Figure: Figure 2: Comparison of linear probing performances of the BLO-MAE as per Eq.(5) and MLO-MAE on CIFAR-10.
Refer to caption: extracted/5436726/fig/CIFAR10blo.png

**Table 5: Linear probing accuracy (%) on CIFAR-10, under different unrolling steps.**
| Unrolling steps | 1 | 2 | 5 |
| --- | --- | --- | --- |
| Accuracy (%) | 83.8 | 84.3 | 84.6 |

where $\gamma$ is a tradeoff parameter. Here, the image encoder $E$ is trained using a multi-task learning strategy, which involves minimizing the weighted sum of the pretraining loss and the downstream classification loss.
Figure 2 presents the results. The BLO-MAE method leads to a notable decrease in accuracy by 2.8% compared to MLO-MAE. This highlights the significance of employing a three-stage process over a two-stage one. In the BLO-MAE approach, the lower level addresses a multi-task learning challenge by optimizing a weighted sum of losses from two distinct tasks. This scenario often leads to task competition, where minimizing the loss for one task inadvertently increases the loss for the other. Balancing these competing losses requires meticulous adjustment of the tradeoff parameter $\gamma$, a process that is both challenging and time-consuming.
In contrast, our MLO-MAE method tackles this challenge through a sequential process integrated into an end-to-end framework. Initially, the method involves pretraining the encoder. Following this, the pretrained encoder is transitioned to the next stage, where the classification head is trained.
The pretraining task in MLO-MAE aids the classification task by providing an effective image encoder, instead of competing with the classification task.

##### Unrolling Steps.

In this study, we explored how the number of unrolling steps in the Optimization Algorithm, as detailed in Section 3.2, on the final performance. The study was performed on CIFAR-10, with linear probing as the evaluation protocol. Table 5 shows linear probing accuracy under different unrolling steps. The results reveal that an increase in the unrolling steps leads to a gradual improvement in accuracy.
This enhancement can be attributed to the fact that a higher number of unrolling steps allows for more frequent updates to the image encoder weights (with more iterations in Stage I), prior to any updates being made to the classification head and masking network. Consequently, this yields a more refined gradient estimation for the parameters of the classification head and masking network, as these estimations are based on the image encoder that has undergone more extensive training.
However, it is important to note that increasing the number of unrolling steps also brings in a notable computational overhead. In this context, our observations indicate that while increasing the unrolling step from one to two leads to a 0.5% boost in CIFAR-10 linear probing performance, the gain diminishes to just 0.3% when the unrolling steps are further raised from two to five. This suggests a diminishing return in performance improvement relative to the increased computational demand.

Figure: Figure 3: Impact of different masking ratios on linear probing performance on CIFAR-10.
Refer to caption: extracted/5436726/fig/CIFAR10mask.png

**Table 6: Linear probing accuracy (%) on CIFAR-10, under different patch sizes.**
| Patch size | 2 | 4 | 8 |
| --- | --- | --- | --- |
| Accuracy (%) | 84.3 | 82.1 | 81.9 |

##### Masking Ratios.

We studied how the masking ratio during pretraining affects downstream task performance, using the CIFAR-10 dataset and a linear probing protocol. The results, illustrated in Figure 3, reveal that intermediate masking ratios deliver optimal performance. When the masking ratio is too low, the reconstruction task becomes overly simple, failing to push the image encoder to develop robust representations. Conversely, an excessively high masking ratio makes the task overly challenging, which also impedes the learning of effective representations. Notably, our method demonstrates resilience to changes in masking ratios ranging from 60% to 80%. Within this interval, there is minimal fluctuation in the results of linear probing.

##### Patch Sizes.

In this study, we investigated the impact of different image patch sizes on the performance of our method when applied to the CIFAR-10 dataset, utilizing the linear probing evaluation protocol. Our experiments focused on three patch sizes: $2\times 2$, $4\times 4$, and $8\times 8$. The results, presented in Table 6, show that the $2\times 2$ patch size achieves a linear probing accuracy of 84.3%, which is 2.4% (absolute) higher than that obtained with the larger $8\times 8$ patch size.
These findings suggest that MLO-MAE is more effective when employing a larger number of smaller patches, particularly for small images, such as those in the CIFAR-10 dataset with a size of $32\times 32$. The reason is that smaller patches allow for more precise and detailed candidate masks. This leads to better reconstruction during training and therefore better feature representation learning. Moreover, smaller patches provide a finer grid over the image, allowing the model to capture more detailed and subtle features. This is particularly beneficial for small images, where each pixel can carry significant information.

### 4.6 Visualizations

To better understand the behavior of the masking network in our MLO-MAE framework, we present a visual illustration in Figure 4, depicting how images are masked at various ratios: 10%, 50%, 75%, and 90%. At a lower masking ratio, such as 10%, our network is more effective in masking the foreground (e.g., the chair), compared to a random masking strategy. As we increase the masking ratio, the attention map reveals that a consistent group of patches in the foreground, which display high attention values (indicated by the yellow area), are selectively masked by our masking network. This is in contrast to random masking, where no specific pattern is observed across different masking ratios. This behavior suggests that our masking network is adept at identifying and masking the informative patches, as opposed to the less informative ones, across a range of masking ratios.

### 4.7 Computational Costs

Figure: Figure 4: Examples of random masking and MLO-MAE masking applied to the ImageNet-1K validation set at various masking ratios.
Refer to caption: x2.png

**Table 7: Pretraining time (GPU hours measured on A100).**
|  | MAE | SemMAE | AutoMAE | MLO-MAE (Ours) |
| --- | --- | --- | --- | --- |
| ImageNet-1K | 1066 hrs | 1154 hrs | 1344 hrs | 1083 hrs |

Although MLO-MAE introduces additional computational overhead due to its multi-level optimization, this is balanced by its lower epoch requirement for achieving convergence. In contrast to the 800 epochs needed for standard MAE and SemMAE, MLO-MAE converges in just 50 epochs. This significant reduction in the number of epochs effectively offsets the increased computational demands. The total GPU hours (using Nvidia A100) for MLO-MAE on ImageNet, as shown in Table 7, amount to 1083. This number is comparable to the 1066 hours for MAE and is slightly less than the 1154 hours for SemMAE and the 1344 hours for AutoMAE.

## 5 Conclusion

In this paper, we proposed MLO-MAE, a method that automatically learns an optimal masking strategy in Masked Autoencoder (MAE) by leveraging feedback from downstream tasks. Unlike the vanilla MAE which applies uniform patch masking irrespective of their informativeness, MLO-MAE adaptively concentrates on more informative image regions. Different from other MAE methods that do not utilize feedback from downstream tasks for masking-strategy optimization, MLO-MAE uniquely capitalizes on such feedback to refine its masking approach.
Our experiments across various datasets demonstrate that MLO-MAE outperforms MAE baselines by learning downstream task guided masking strategies. Furthermore, the representations generated by MLO-MAE exhibit high transferability to a range of downstream tasks, including fine-grained classification and semantic segmentation, highlighting our method’s versatility and effectiveness.

## Potential Broader Impact and Ethical Considerations

Our paper presents the Multi-level Optimization for Masked Autoencoders (MLO-MAE) framework, enhancing self-supervised learning in visual data processing. MLO-MAE can have a broad impact across various fields like medical imaging, autonomous vehicles, and content moderation. In the healthcare sector, it could improve disease detection and diagnosis. Similarly, in the realm of autonomous driving, it may enhance object recognition for safer vehicle automation.
However, we also recognize the ethical considerations and potential risks associated with the application of our work. The increased capability of image processing models can lead to concerns around privacy, surveillance, and the potential misuse of technology in unauthorized or harmful ways. The deployment of such technologies must be guided by ethical principles and regulatory frameworks to protect individual privacy and prevent misuse.

## Appendix A Optimization Algorithm

We develop an efficient optimization algorithm to solve the MLO-MAE problem demonstrated in Figure 1. Notations are given in Table 8.

**Table 8: Descriptions of notations used in optimization algorithm in Appendix A.**
| Notation | Description |
| --- | --- |
| $E$ | Backbone encoder that takes in input patches and generates representation embedding |
| $D$ | Backbone decoder that takes in representation embedding and generates the reconstructed image |
| $C$ | Classification head |
| $T$ | Masking network |
| $\mathcal{D}$ | Image classification dataset |
| $\mathcal{D}^{tr}$ | Train set split based on $\mathcal{D}$ |
| $\mathcal{D}^{val}$ | Validation set split based on $\mathcal{D}$ |
| $\mathcal{D}_{u}$ | Unlabeled dataset based on $\mathcal{D}$ |
| $X$ | An arbitrary image from $\mathcal{D}$ |
| $\mathcal{M}(.)$ | Masked image |
| $\mathcal{L}_{rec}(.)$ | MAE image reconstruction loss |
| $\mathcal{L}_{cls}(.)$ | Cross entropy image classification loss |
| $\sigma(.)$ | Sigmoid activation function that produces masking probability given our masking network |
| $\eta_{E}$ | Learning rate for updating the encoder |
| $\eta_{C}$ | Learning rate for updating the classification head |
| $\eta_{T}$ | Learning rate for updating the the masking network |
| $r$ | Masking ratio |

### A.1 Implicit Differentiation for Gradient Computation

In the MLO-MAE framework, we adopt implicit differentiation as a key tool for computing gradients in scenarios characterized by complex, nested optimization structures. This approach is particularly effective when dealing with variables implicitly interconnected. To solve the MLO-MAE optimization problem, we utilize a robust algorithm first introduced in (Choe et al., ). This algorithm is underpinned by a solid theoretical framework, and its convergence properties have been extensively examined in recent scholarly contributions.
Each stage of the optimization process necessitates the identification of an optimal solution, denoted with an asterisk (*) and positioned on the left-hand side of the equation. Computing this exact optimal solution is typically resource-intensive. To manage this efficiently, we apply the strategy proposed in (Liu et al., ), which involves approximating the optimal solution via a one-step gradient descent update. This approximation is then integrated into the next level of the optimization process. In our analysis, the symbol $\frac{\partial\cdot}{\partial\cdot}$ is used to represent partial derivatives, while $\frac{d\cdot}{d\cdot}$ signifies ordinary derivatives. The term $\nabla^{2}f(X,Y)$ denotes the second-order partial derivative of $f(X,Y)$ with respect to $Y$ and $X$, formalized as $\frac{\partial^{2}f(X,Y)}{\partial X\partial Y}$. The initial phase of our methodology involves approximating $E^{*}(T)$ as follows:

$$ $E^{*}(T)\approx E^{\prime}=E-\eta_{E}\cdot\nabla_{E}\sum\limits_{X\in\mathcal{ D}_{u}}\sum\limits_{j=1}^{N\times r}\sigma(\mathcal{M}_{j}(X;T,r),X;T)\mathcal {L}_{rec}(X-\mathcal{M}(X;T,r),\mathcal{M}_{j}(X;T,r);E,D)$ (6) $$

where $\eta_{E}$ denotes the learning rate. Subsequently, $E^{\prime}$ is substituted into $\mathcal{L}_{cls}(E^{\prime}(T),C,\mathcal{D}^{tr})$ to yield an approximated objective function. Similarly, $C^{*}(E^{*}(T))$ is approximated using a single-step gradient descent with respect to this approximated objective:

$$ $C^{*}(E^{*}(T))\approx C^{\prime}=C-\eta_{C}\cdot\nabla_{C}\mathcal{L}_{cls}( \mathcal{D}^{tr};E^{\prime}(T),C)$ (7) $$

Finally, $E^{\prime}(T)$ and $C^{\prime}(E^{\prime}(T))$ are incorporated into $\mathcal{L}_{cls}(E^{\prime}(T),C^{\prime}(E^{\prime}(T)),\mathcal{D}^{val})$ to obtain an approximated version of the objective function. The parameter $T$ is then updated using gradient descent:

$$ $T\leftarrow T-\eta_{T}\cdot\nabla_{T}\mathcal{L}_{cls}(\mathcal{D}^{val};E^{ \prime}(T),C^{\prime}(E^{\prime}(T)))$ (8) $$

By applying the chain rule to this approximation, we obtain:

$$ $\nabla_{T}\mathcal{L}_{cls}(\mathcal{D}^{val};E^{\prime}(T),C^{\prime}(E^{ \prime}(T)))=\frac{\partial\mathcal{L}_{cls}^{val}}{\partial T}+\frac{\partial \mathcal{L}_{cls}^{val}}{\partial E^{\prime}}\frac{\partial E^{\prime}}{ \partial T}+\frac{\partial\mathcal{L}_{cls}^{val}}{\partial C^{\prime}}\frac{ \partial C^{\prime}}{\partial E^{\prime}}\frac{\partial E^{\prime}}{\partial T}$ (9) $$

where:

$$ $\frac{\partial E^{\prime}}{\partial T}=-\eta_{E}\cdot\nabla_{E,T}^{2}\sum \limits_{X\in\mathcal{D}_{u}}\sum\limits_{j=1}^{N\times r}\sigma(\mathcal{M}_{ j}(X;T,r),X;T)\mathcal{L}_{rec}(X-\mathcal{M}(X;T,r),\mathcal{M}_{j}(X;T,r);E,D)$ (10) $$

and

$$ $\frac{\partial C^{\prime}}{\partial E^{\prime}}=\eta_{C}\cdot\nabla_{C,E^{ \prime}}^{2}\mathcal{L}_{cls}^{tr}$ (11) $$

Here, $\mathcal{L}_{cls}^{val}=\mathcal{L}_{cls}(\mathcal{D}^{val};E^{\prime}(T),C^{
\prime}(E^{\prime}(T)))$ and $\mathcal{L}_{cls}^{tr}=\mathcal{L}_{cls}(\mathcal{D}^{tr};E^{\prime}(T),C)$.

### A.2 Finite Difference Approximation for Gradient Estimation

To reduce the complexity of solving MLO-MAE, we utilize the Finite Difference Approximation (FDA) method, particularly in estimating gradients where analytical differentiation is challenging. Specifically, directly computing Jacobian vector multiplication with MLO problems is computationally expensive, which can be efficiently approximated by FDA methods (Choe et al., ).

FDA approximates the gradient of a function by computing the change in the function value for a small perturbation in the input. For example, for a function $f(x)$, the gradient approximation is given by:

$$ $\nabla f(x)\approx\frac{f(x+\delta x)-f(x)}{\delta x}$ (12) $$

In our experimental framework, we extended the formula above to compute hypergradients in MLO problems. Specifically, we incorporated the bi-directional finite difference approximation (FDA) method for gradient estimation within complex, nested optimization contexts. This technique is particularly pertinent in scenarios where traditional analytical gradient computation is either impractical or excessively resource-intensive.

The bi-directional FDA extends the conventional finite difference approach by introducing perturbations in both positive and negative directions relative to the current parameter values. This methodology provides a more nuanced and accurate gradient estimation compared to one-sided finite difference methods.

Each parameter in our current optimization problem undergoes an initial positive perturbation, determined by a predefined small step size $\epsilon$. Post this perturbation, we compute the loss and the corresponding gradients with respect to the preceding optimization problem’s parameters. A subsequent negative perturbation, amounting to double the initial epsilon, shifts the parameters below their original values for a re-evaluation of the loss and re-calculation of gradients.

In our Multi-level Optimization (MLO) framework, the bi-directional FDA offers substantial benefits. It enables efficient gradient estimation in situations where conventional backpropagation may fail, especially in handling the complex, implicit dependencies between parameters. This approach is instrumental in enhancing our optimization techniques within intricate MLO settings.

Our implementation of the bi-directional FDA is finely tuned to strike a balance between computational efficiency and the accuracy of gradient estimation. The selection of the epsilon value is critical, aiming to minimize numerical instability while maintaining sensitivity to changes in parameters. This balance is essential for ensuring the robustness of the gradient estimation process in the stochastic realm of machine learning models.

### A.3 Integration of Methods

Implicit differentiation and finite difference approximation are integrated to balance theoretical accuracy with computational feasibility. This combination enhances the robustness and efficiency of our optimization process in the MLO-MAE framework.
In the application of these optimization methods, several key considerations are taken into account. Firstly, the choice of $\Delta T$ in the finite difference approximation is a critical factor, as it directly influences the accuracy and stability of the gradient estimation. An appropriate value for $\Delta T$ ensures a balance between precision and numerical stability. Secondly, we address the computational complexity problem inherent in implicit differentiation. This aspect is particularly relevant in deep network architectures, where computational resources can be a limiting factor. To mitigate this, we optimize the use of implicit differentiation to balance computational demands with the need for accurate gradient computation. Lastly, maintaining numerical stability is paramount in both methods. Techniques such as gradient normalization and careful arithmetic handling are employed to ensure that the computations remain stable, especially in scenarios where small numerical errors can significantly impact the overall results.

This comprehensive optimization algorithm is pivotal in enabling the efficient training and validation of the MLO-MAE framework.

### A.4 Differentiability of MLO-MAE Framework

In the initial phase of our Multi-level Optimization Masked Autoencoder (MLO-MAE) framework, the focus is on the reconstruction loss and its differentiability relative to the parameters of the learnable masking network. This network is pivotal, as it determines the masking patterns for the input data, directly impacting the autoencoder’s reconstruction loss. The key to effective gradient-based optimization lies in ensuring the differentiability of this reconstruction loss with respect to the masking network’s parameters.
Due to the inherently discrete nature of mask selection, integrating the masking network directly into the MAE’s reconstruction loss initially leads to non-differentiability issues. To circumvent this, our approach employs a sigmoid activation function, denoted as $\sigma(.)$, to generate soft masks. These soft masks assign a continuous value between 0 and 1 to each image patch, indicating the likelihood of that patch being masked. This likelihood is learned from both masked and unmasked patches. In this first phase, we tackle non-differentiability by utilizing the MAE reconstruction loss together with the masking probability. This is achieved as illustrated in Equation (1), which allows the proportional contribution of each patch to influence the overall loss, facilitating differentiation with respect to the network parameters through the application of $\sigma(\cdot)$.

To further address the non-differentiability issue in our MLO-MAE framework incurred by mask selection, the SoftSort (Prillo & Eisenschlos, ) technique—a differentiable approximation of sorting operations—replacing the conventional, non-differentiable ”argsort” operation, can be integrated. SoftSort enables the learning of a continuous relaxation of sorting, vital for gradient-based optimization and for crafting nuanced, performance-enhancing masks. This represents a significant leap in refining the effectiveness of the reconstruction process. However, given the computational demands of SoftSort, we propose a simplified approach that approximates the base Jacobian with an identity matrix similar to  (Choe et al., ), thereby simplifying the gradient during backpropagation and enhancing the efficiency by ”jumping over” the non-differentiable argsort operation. By treating non-differentiable operations as identity functions during backpropagation, this method allows gradients from the reconstruction loss to flow as if the masking operations were inherently differentiable. This strategy significantly speeds up training by enabling the use of standard gradient-based optimization techniques.
In our MLO-MAE, the masking network employs soft masks, which, through a sigmoid activation function $\sigma(.)$, assign each image patch a continuous value from 0 to 1. This assignment reflects the probability of masking, informed by both masked and unmasked patches. By approximating the gradients for non-differentiable functions as identity functions during backpropagation, our method enables the differentiation of the MAE reconstruction loss, $\mathcal{L}_{rec}$, relative to the masking network parameters $T$. This differentiation is facilitated by incorporating the output probabilities of $\sigma(.)$ into the reconstruction loss $\mathcal{L}_{rec}$, as detailed in Equation (1).

## Appendix B Detailed Experimental Settings

### B.1 Datasets

##### CIFAR-10 (Krizhevsky et al., a ) :

CIFAR-10 is a fundamental dataset for image classification, comprising 60,000 32x32 color images across 10 classes, with 6,000 images per class. It is widely used in machine learning research because of its manageable size and diversity of images. CIFAR-10 tests the ability of our MLO-MAE framework to capture essential features in small-scale images and generalize across a variety of everyday objects.

##### CIFAR-100 (Krizhevsky et al., b ) :

CIFAR-100 is similar to CIFAR-10 in image size and total number of images but is significantly more challenging due to its 100 classes, each containing 600 images. The increased number of classes in CIFAR-100 allows us to evaluate the capability of MLO-MAE in a more granular classification context, providing insights into how well the model differentiates between a larger number of categories with fewer examples per category.

##### ImageNet-1K (Deng et al., 2009 ) :

ImageNet, a subset of the larger ImageNet database, is one of the most influential datasets in the field of image classification. It contains 1.3M training images and 50K validation images categorized into 1,000 classes. The dataset’s extensive size and diversity present a rigorous test for any machine learning model. Our use of ImageNet is aimed at assessing the scalability and robustness of the MLO-MAE framework in handling complex, large-scale classification tasks.

##### CUB-200-2011 (Wah et al., 2011 ) :

The CUB-200-2011 dataset is a specialized collection designed for fine-grained bird species classification, developed by the California Institute of Technology. It contains 11,788 images, representing 200 bird species, with a focus on North American birds. Each image in the dataset is accompanied by detailed annotations, including bounding boxes, part locations, and attribute labels, making it ideal for detailed image analysis tasks. The dataset is widely used in computer vision research, particularly in tasks that require distinguishing between visually similar sub-categories.

##### Stanford Cars (Krause et al., 2013 ) :

The Stanford Cars dataset is a large collection of car images created by researchers at Stanford University, it contains 16,185 images of 196 classes of cars. The data is split into 8,144 training images and 8,041 testing images, where each class has been split roughly in a 50-50 split. Classes are typically at the level of Make, Model, Year, ex. 2012 Tesla Model S or 2012 BMW M3 coupe.

##### iNaturalist 2019 (Van Horn et al., 2018 ) :

The iNaturalist 2019 dataset is a comprehensive biodiversity collection used for machine learning and research, created by the iNaturalist project, a collaboration between the California Academy of Sciences and the National Geographic Society. It features over 859,000 high-quality images of 1,010 species, each with detailed metadata including species name, observation location, date, and time. This extensive dataset is crucial for species identification and, distribution modeling, and is utilized in the annual iNaturalist Challenge to enhance automated species recognition technologies.

##### ADE20K (Zhou et al., 2017 ) :

ADE20K is a comprehensive dataset for semantic segmentation, containing more than 20,000 images annotated for a variety of scenes and objects, making it one of the most diverse datasets available for this task. Each image in ADE20K is annotated with pixel-level segmentation masks, encompassing a wide range of objects and scene categories. The complexity and richness of ADE20K make it an ideal choice for testing the efficacy of the MLO-MAE framework in understanding and segmenting complex visual scenes. The dataset challenges the model to not only recognize a diverse array of objects but also understand their spatial relationships and boundaries within various contexts.

**Table 9: MLO-MAE ImageNet Pretraining Settings.**
| MLO-MAE Stage | Config | value |
| --- | --- | --- |
| Stage 1 | model | ViT-B |
| optimizer | AdamW |  |
| base learning rate | $1e-4$ |  |
| weight decay | $0.05$ |  |
| image size | 224 |  |
| patch size | $16\times 16$ |  |
| optimizer momentum | $\beta_{1},\beta_{2}=0.9,0.95$ |  |
| batch size | 256 |  |
| learning rate scheduler | cosine anneal |  |
| unrolling steps | 1 |  |
| mask ratio | 0.75 |  |
| Stage 2 | learning rate | $4e-5$ |
| weight decay | $0.05$ |  |
| image size | 224 |  |
| optimizer momentum | $\beta_{1},\beta_{2}=0.9,0.95$ |  |
| batch size | 256 |  |
| learning rate scheduler | cosine anneal |  |
| unrolling steps | 1 |  |
| Stage 3 | learning rate | $4e-5$ |
| masking network | nn.Linear(num_patches $\times$ emb_dim, 512) |  |
| nn.ReLu |  |  |
| nn.Linear(512, num_patches) |  |  |
| torch.sigmoid() |  |  |
| weight decay | $0.05$ |  |
| image size | 224 |  |
| optimizer momentum | $\beta_{1},\beta_{2}=0.9,0.95$ |  |
| batch size | 256 |  |
| learning rate scheduler | cosine anneal |  |
| unrolling steps | 1 |  |

### B.2 Masking Network

To facilitate the mask generation process, we design a lightweight masking network with two linear layers, one ReLU layer in between, and one sigmoid activation. The first linear layer can be expressed in PyTorch code as nn.Linear(num_patches $\times$ emb_dim, 512), where num_patches is the number of patches from the original image (e.g. ImageNet sample of size $224\times 224$ with patch size of $16\times 16$ will generate $14\times 14=196$ patches) and emb_dim is the embedding dimension from ViT-B (768 in our case). We use a hidden size of 512 for the output dimension of the first and the second linear layer. The ReLU layer is expressed as nn.ReLU(). The second linear layer can be expressed as nn.Linear(512, num_patches) where the output is the masking probability for each image patch with corresponding order. We pass the resulting tensor from the second linear layer through the sigmoid activation to generate values between 0 and 1.

### B.3 ImageNet

We adopt the default ViT-B model that has been employed in the original MAE. In total, we train 50 epochs for all three stages. For ImageNet experiments, we use an image size of $224\times 224$.

##### Pretraining

Detailed three-stage MLO-MAE pretraining setting is in Table 10. We follow MAE settings on data augmentations by only using RandomResizedCrop and RandomHorizontalFlip. For $\text{MLO-MAE}_{pre}$ in Table 1 experiment, we train MLO-MAE using 800 pretrained MAE ViT-B as initialization. For MLO-MAE in Table 1 experiment, we train MLO-MAE using xavier_uniform (Glorot & Bengio, ). We follow the linear lr scaling as used in the MAE. We randomly split the training set of ImageNet by a ratio of 80/20 to be the new training set and the new validation set. We use the same new training set in Stage I and Stage II for training, while use the new validation set in Stage III for training the masking network. We use the original ImageNet validation set to report validation accuracy in Stage II.

##### Linear Probing

Due to the inherent design of our three-level optimization framework, we do not conduct separate linear probing and directly report the Stage II testing accuracy (test dataset not seen in MLO-MAE training). Therefore, we report the training setting as in Stage II shown in Table 10.

##### Fine-tuning

We directly followed the MAE fine-tuning experiments and did not make additional changes. Detailed settings can be found in Table 9 of MAE (He et al., ).

### B.4 CIFAR

We adopt the same ViT-B architecture as in B.3 but change the input image size and patch size to be 32 and 2 respectively. In total, we train MLO-MAE 50 epochs for all three stages.

##### Pretraining

We pretrain our model from scratch (i.e. no pretrained initialization from other datasets) using the MLO-MAE method on two CIFAR datasets. Table 10 shows the detailed training setting for CIFAR-10 and CIFAR-100 experiments. We adopted a similar setting from the ImageNet experiment, with minor modifications on learning rate, data augmentation, image size, and patch size. We use conventional RandomCrop and RandomHorizontalFlip on both CIFAR-10 and CIFAR-100. We pretrain with MLO-MAE for 200 epochs.

##### Linear Probing

Similar to section B.3, we report the training setting as in Stage II shown in Table 10.

##### Fine-tuning

For CIFAR fine-tuning, we use lr=$1e-4$, weight_decay=$5e-5$, optimizer=AdamW, batch_size=64, and epoch=100. We use default data augmentation on CIFAR, including RandomCrop, Resize, and RandomHorizontalFlip. We maintain the image size to be 32. This experiment is performed on top of MLO-MAE CIFAR-10/100 pretrained weights respectively.

### B.5 Classification on fine-grained datasets

We perform image classification using MLO-MAE pretrained ViT-B on CUB-200-2011 (Wah et al., ), Stanford Cars (Krause et al., ), and iNaturalist 2019 (Van Horn et al., ) fine-grained datasets. We follow the setting from section B.3 with minor adjustments on learning rate and epochs. These experiments areis performed on top of MLO-MAE ImageNet-1K pretrained weights respectively.

### B.6 Semantic Segmentation on ADE20K

We use the semantic segmentation code implementation of MAE by MMSegmentation (Contributors, ). We follow the exact same hyperparameter setting as MAE but replacing the encoder with MLO-MAE pretrained ViT-B. We subsequently fine-tuned it on ADE20K for segmentation task with 160K iterations.

## Peer Reviews

confidence: 5
contribution: 3
initial_rating: 3
presentation: 1
questions: - MLO-MAE utilizes learnable masking that is trained to maximize linear probing performance. What is the theoretical background and insight behind this design? Why does this masking improve MAE fine-tuning performance?

- MLO-MAE makes classification-friendly random masking, which can be considered as an easy masking strategy. Can it achieve performance improvement in large models? How about small models like ViT-S?

- In Table 3, improvement in downstream tasks looks smaller than in ImageNet. Does this mean MLO-MAE's improvement is biased toward the pretraining dataset? How about using the downstream dataset as an objective in Stage 2 and Stage 3?

- Even though another learnable masking (SemMAE and AutoMAE) is not effective on benchmarks, MLO-MAE achieves a completely different pattern with a learnable mask. What makes the difference? What are the minimal changes to make learnable masks beneficial?

- Table 5 omits $AP_{mask}$. Does MLO-MAE also improve $AP_{mask}$ of mask-RCNN in COCO?

- It is a surprising result that BLO-MAE has no positive effect on performance. Why is it so different from MLO-MAE? Does BLO-MAE fail to converge on any of Stage?
soundness: 2
strengths: - Learning the mask with multi-level optimization is an interesting approach.
- ImageNet performance in Table 1 is impressive. It is hard to achieve 84.8 accuracy with MAE framework.
summary: The paper proposes a new MAE training framework, Multi-Level Optimization MAE (MLO-MAE). The authors add two additional learning objectives to conventional MAE training: linear probing and mask selector optimization. Linear probing loss trains a classifier using class labels, and the mask selector learns a mask that maximizes classification performance. The mask selector also used for MAE training that is effective for MAE's finetuning performance. The three objectives are optimized by `betty-ml` library's multi-level optimization algorithm.
weaknesses: - The paper lacks motivation and insight explaining the improvement of MLO-MAE. Although MLO-MAE achieves impressive performance, I believe it is hard to contribute to MAE researchers without proper theoretical background or analysis.

- MLO-MAE is not a self-supervised learning (SSL) method. It utilizes image class labels as a multi-objective training method. Since target task-agnostic pre-training is an important characteristic of SSL, MLO-MAE's contribution is significantly limited to conventional SSL.

- The presentation is not good. The main algorithm is hard to understand through formulas in 3.2. It would be better to revise the formula to improve readability.

- The experiment only covers a single model size (ViT-B), which is not enough to validate MAE-variant performance. Validation on various model sizes in ImageNet is required to argue for an improved MAE framework in general.

---

confidence: 5
contribution: 3
initial_rating: 5
presentation: 3
questions: See Weaknesses.
soundness: 2
strengths: 1. This paper addresses a valuable and important problem. Given the inherent differences between images and text, using random masking as in NLP may not be optimal for masked image modeling. 
2. The proposed method is concise and effective, achieving strong performance across multiple benchmarks.
3. The paper is well-organized, making it easy to reproduce and follow.
summary: The paper proposes an interesting pretraining framework, MLO-MAE, which guides the masking process in masked image modeling by leveraging labels from downstream tasks to learn representations that meet task-specific requirements. The pretraining of MLO-MAE involves three main stages: pretraining the image encoder, training the classification head, and updating the masking network. MLO-MAE optimizes these three stages through a multi-level optimization algorithm.
weaknesses: 1. The pretraining of MLO-MAE relies on labels from downstream tasks, which does not align with the self-supervised learning paradigm of learning general representations from the data itself. MLO-MAE resembles a supervised pretraining approach, so the experimental setup that mainly compares it with SSL methods is somewhat inappropriate.
2. The main weakness of this paper lies in the experiments:
    - Although MLO-MAE demonstrates improved fine-tuning and linear probing performance (Sec 4.3), it already leverages class information during pretraining, making comparisons with self-supervised baselines unfair and insufficient to verify MLO-MAE's effectiveness.
    - I notice that in the transfer learning experiments (Sec 4.4), the pretrained model undergoes additional supervised fine-tuning on imagenet, which diverges from the typical transfer learning paradigm. Is this fine-tuning necessary? Can MLO-MAE be transferred to downstream tasks without it? Does the use of different labeled data during pretraining affect the performance of transfer learning?
    - The paper also lacks an analysis of the learned masking patterns. How do the masking patterns learned by MLO-MAE differ from those of other methods? Why do the learned masking patterns help in learning better representations? A more in-depth analysis is needed to support the main claims of this work.

---

confidence: 5
contribution: 2
initial_rating: 5
presentation: 3
questions: - The reviewer still speculates some results, for example, why ImageNet pre-training/fine-tuning requires only 50 epochs to surpass other methods, especially since all steps use the same ImageNet dataset and the pre-training stage even trains on smaller images (80%). Could the authors provide some insights?
- The proposed method appears to adapt specifically to ImageNet when pre-training the classification head on ImageNet in step 2. This may raise issues, such as difficulty handling discrepancies in patch size between pre-training and fine-tuning stages. How can a model trained on ImageNet in this way be effectively applied to downstream tasks like CIFAR?
- The dataset is split into training and validation data for the three-step training proposed in this paper. Can the authors ensure consistent performance when the data split varies due to changes in random seeds or other factors?
soundness: 2
strengths: - The idea of explicitly introducing these three steps to improve downstream task performance is intuitive and reasonable.
- The performance improvements over the baseline looks impressive.
summary: This paper introduces a variant of the masked autoencoder (MAE) designed to explicitly enhance the performance of downstream tasks. The framework consists of three main stages: (1) pretraining an image encoder using the MAE approach based on the mask generator network, (2) training a classification head with the frozen MAE-pretrained encoder on a downstream task, and (3) training a masking network with the trained classification head to minimize the loss to tune the masks. Experimental results demonstrate the effectiveness of the proposed method.
weaknesses: - While the idea appears practical and well-founded, the rationale behind including specific steps and how each contributes to overall performance are missing. Furthermore, it is unclear why the proposed method would outperform SemMAE and AutoMAE, which also use adaptive mask generation. The authors are encouraged to provide some insights into why their approach may offer an advantage over these similar methods.
- The multi-level optimization presented appears to depend heavily on the previous steps. While the problem formulation in Eq. (4) integrates all sub-objectives, each optimization step must wait for the completion of the previous one. This approach seems a bit cumbersome, potentially leading to cache and memory issues (which may not be fully resolved by standard packages) and slowing down the process due to the sequential nature of the steps.
-  There are no analyses of the generated masks during or after training, nor comparisons with the outputs of other mask generators (e.g., SemMAE's and AutoMAE's). The reviewer believes presenting this analysis is crucial, as it could provide insights into training dynamics, specifically which parts of images should be visible or reconstructed to impact performance.
- In training, stages 2 and 3 utilize downstream task data, which seems to be used more extensively than in standard practice, where downstream data is only introduced during the fine-tuning stage. This incurs an unfair evaluation.

---

confidence: 4
contribution: 3
initial_rating: 6
presentation: 3
questions: Please see Weaknesses.
soundness: 2
strengths: The experiments involve multiple benchmark datasets and also validate the transfer learning ability on downstream tasks such as fine-grained classification and semantic segmentation. Additionally, various visualization analyses are provided.
summary: In this submission, the authors aim to improve visual representation learning in self-supervised pretraining. Their motivation is that traditional Masked Autoencoders (MAE) overlook the varying informativeness across different patches. They hope to leverage feedback from downstream tasks to guide the learning of masking strategies during pretraining. The proposed framework, named Multi-level Optimized Mask Autoencoder (MLO-MAE), consists of three interdependent stages: pretraining the image encoder, training the classification head, and updating the masking network. These stages are executed end-to-end through a multi-level optimization (MLO) strategy. Finally, their experiments show performance improvements of MLO-MAE across multiple datasets and tasks.
weaknesses: 1. Considering the additional computational overhead introduced by the multi-level optimization, it is hoped that more comparisons with other baselines can be added, such as ColorMAE.
2. In Section 4.1, the authors mention that they divide the original training set of each dataset into two subsets, D_tr and D_val. From my understanding, this approach is essentially similar to dividing datasets into training, validation, and test sets in machine learning. The validation set is used to monitor the training process. The difference here is that instead of manual adjustments by developers, the authors use multi-level optimization (MLO) to automate the adjustment of model parameters. As I am not very familiar with this field, I am curious about the transferability and applicability of this automated approach.

---

confidence: 4
contribution: 2
initial_rating: 3
presentation: 2
questions: - Q1: Why do the authors choose to use the classification task in Stage 2 for all downstream tasks, instead of tailoring different tasks in Stage 2 to match each specific downstream task?

- Q2: How does the masking strategy in MLO-MAE manage to "mask patches on foreground objects directly relevant to the class labels" (line 1113)?

- Q3: What makes "masking patches on foreground objects directly relevant to the class labels" an optimal masking strategy? If all patches of the foreground objects are masked, does it still qualify as an optimal strategy?

- Q4: Could you elaborate on the implementation of Stage 3? Specifically, how is the masking network updated using the validation loss?

- Q5: Could you provide a more detailed explanation of the unrolling steps?
soundness: 2
strengths: Extensive experiments across eight benchmarks and three different tasks (*i.e.*, classification, object detection, and semantic segmentation) demonstrate the effectiveness of the proposed MLO-MAE, surpassing the performance of the MAE baseline.
summary: Existing Masked Image Modeling (MIM) methods mask patches without considering feedback from downstream tasks. This study introduces a method to utilize such feedback for learning an optimal masking strategy. The authors propose a framework called Multi-level Optimized Mask Autoencoder (MLO-MAE), which leverages downstream task feedback to determine an effective masking strategy during pretraining. Specifically, MLO-MAE operates in three stages: pretraining the image encoder, training the classification head, and updating the masking network. The proposed masking strategy, guided by the feedback from the classification task, tends to mask patches on foreground objects directly related to class labels. Empirical results on eight benchmarks demonstrate the effectiveness of MLO-MAE, showing it outperforms the MAE baseline.
weaknesses: **Deviation from the Motivation:**
The paper's motivation is that "previous MIM methods mask patches without incorporating feedback from downstream tasks (line 053)," and this study seeks to "use feedback from downstream tasks to learn the optimal masking strategy (line 062)." However, the current implementation only utilizes feedback from the classification task to guide the masking strategy, deviating from the original motivation. If downstream tasks were object detection or semantic segmentation, relying solely on a classification task in Stage 2 would likely result in a suboptimal masking strategy.


**Unfair Experimental Comparisons:**
The proposed MLO-MAE method leverages additional knowledge from classification labels in ImageNet-1K, making a direct comparison with the MAE baseline unfair.


**Unconvincing Conclusions:**
- It remains unclear why the masking strategy in MLO-MAE effectively "masks patches on foreground objects directly relevant to the class labels" (line 1113), and further discussion is needed to clarify this aspect.
- The ablation study on the number of unrolling steps was conducted solely on the CIFAR-10 dataset, which shows that ''an increase in the unrolling steps leads to gradual improvement in accuracy'' (line 474). However, given the limited scale of CIFAR-10, the same study should also be performed on ImageNet-1K for a more convincing conclusion.
- The ablation study for patch sizes was restricted to small images (32x32) on CIFAR-10. To strengthen the conclusion, similar studies should be conducted on larger images, such as those in ImageNet-1K.


**Writing Issues:**
- In Stage 3, the method for updating the masking network $T$ remains unclear, even after thoroughly reviewing the method section (lines 222-228) and Figure 1.
- There is no explanation provided for "unrolling steps."