\documentclass[runningheads]{llncs}
\usepackage{graphicx}

\usepackage{tikz}
\usepackage{comment}
\usepackage{amsmath,amssymb} %
\usepackage{color}

\usepackage{xcolor}
\usepackage{subfig}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{bm}
\usepackage{wasysym}
\usepackage{mathrsfs}
\usepackage{xspace}
\usepackage{bbm}
\usepackage[width=122mm,left=12mm,paperwidth=146mm,height=193mm,top=12mm,paperheight=217mm]{geometry}

\newcommand{\TODOFIG}[1]{\textbf{TODO Figure: #1}}	%
\newcommand{\TODOTAB}[1]{\textbf{TODO Table: #1}}	%
\newcommand{\TODO}[1]{\textbf{TODO: #1}}	%
\newcommand{\bb}[1]{\bm{\mathrm{#1}}}
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}} 

\DeclareRobustCommand\onedot{\futurelet\@let@token\@onedot}
\def\@onedot{\ifx\@let@token.\else.\null\fi\xspace}

\def\eg{\emph{e.g}\onedot} \def\Eg{\emph{E.g}\onedot}
\def\ie{\emph{i.e}\onedot} \def\Ie{\emph{I.e}\onedot}
\def\cf{\emph{c.f}\onedot} \def\Cf{\emph{C.f}\onedot}
\def\etc{\emph{etc}\onedot} \def\vs{\emph{vs}\onedot}
\def\wrt{w.r.t\onedot} \def\dof{d.o.f\onedot}
\def\etal{\emph{et al}.}
\DeclareMathOperator*{\argmin}{argmin}
\makeatletter
\begin{document}
\pagestyle{headings}
\mainmatter
\def\ECCVSubNumber{2}  %

\title{Distilling Visual Priors from \\ Self-Supervised Learning}
\titlerunning{Distilling Visual Priors from Self-Supervised Learning}
\author{Bingchen Zhao\inst{1,2}\and
Xin Wen\inst{2}}
\authorrunning{B. Zhao and X. Wen}
\institute{Megvii Research Nanjing\\
\and
Tongji University, Shanghai, China\\
\email{zhaobc.gm@gmail.com, wx99@tongji.edu.cn}}
\maketitle

\begin{abstract}
Convolutional Neural Networks (CNNs) are prone to overfit small training datasets.
We present a novel two-phase pipeline that leverages self-supervised learning and knowledge distillation to improve the generalization ability of CNN models for image classification under the data-deficient setting. The first phase is to learn a teacher model which possesses rich and generalizable visual representations via self-supervised learning, and the second phase is to distill the representations into a student model in a self-distillation manner, and meanwhile fine-tune the student model for the image classification task. We also propose a novel margin loss for the self-supervised contrastive learning proxy task to better learn the representation under the data-deficient scenario.
Together with other tricks, we achieve competitive performance in the VIPriors image classification challenge.
\keywords{Self-supervised Learning, Knowledge-distillation}
\end{abstract}
\section{Introduction}
\label{sec:intro}

Convolutional Neural Networks (CNNs) have
achieved breakthroughs in image classification~\cite{he2016deep} via supervised training on large-scale datasets, e.g., ImageNet~\cite{deng2009imagenet}.
However, when the dataset is small, the over-parameterized CNNs tend to simply memorize the dataset and can not generalize well to unseen data. To alleviate this over-fitting problem,
several regularization techniques have been proposed, such as Dropout~\cite{srivastava14dropout}, BatchNorm~\cite{ioffe2015batch}. In addition, some works seek to combat with over-fitting by re-designing the CNN building blocks to endow the model with some encouraging properties (e.g., translation invariance~\cite{kayhan2020translation}).

Recently, self-supervised learning has shown a great potential of learning useful representation from data without external label information. In particular, the contrastive learning methods~\cite{he2020momentum,chen2020simple} have demonstrated advantages over other self-supervised learning methods in learning better transferable representations for downstream tasks. Compared to supervised learning, representations learned by self-supervised learning are unbiased to image labels, which can effectively prevent the model from over-fitting the patterns of any object category. Furthermore, the data augmentation in modern contrastive learning~\cite{chen2020simple} typically involves diverse transformation  strategies, which significantly differ from those used by supervised learning. This may also suggest that contrastive learning can better capture the diversity of the data than supervised learning.
In this paper, we go one step further by exploring the capability of contrastive learning under the data-deficient setting. Our key motivation lies in the realization that the label-unbiased and highly expressive representations learned by self-supervised learning can largely prevent the model from over-fitting the small training dataset. Specifically, we design a new two-phase pipeline for data-deficient image classification. The first phase is to utilize self-supervised contrastive learning as a proxy task for learning useful representations, which we regard as visual priors before using the image labels to train a model in a supervised manner. The second phase is use the weight obtained from the first phase as the start point, and leverage the label information to further fine-tune the model to perform classification.

In principle, self-supervised pre-training is an intuitive approach for preventing over-fitting when the labeled data are scarce, yet constructing the pre-training and fine-tuning pipeline properly is critical for good results. Specifically, there are two problems to be solved. First, the common practice in self-supervised learning is to obtain a memory bank for negative sampling. While MoCo~\cite{he2020momentum} has demonstrated accuracy gains with increased bank size, the maximum bank size, however, is limited in the data-deficient setting. To address this issue, we propose a margin loss that can reduce the bank size while maintaining the same performance. We hope that this method can be helpful for fast experiments and evaluation. Second, directly fine-tuning the model on a small dataset still faces the risk of over-fitting, based on the observation that fine-tuning a linear classifier on top of the pre-train representation can yield a good result. We proposed to utilize a recent published feature distillation method~\cite{heo2019comprehensive} to perform self-distillation between the pre-trained teacher model and a student model. This self-distilation module plays a role of regularizing the model from forgetting the visual priors learned from the contrastive learning phase, and thus can further prevent the model from over-fitting on the small dataset.
\section{Related Works}\label{sec:related}
\noindent \textbf{Self-supervised learning}~~
focus on how to obtain good representations of data from heuristically designed proxy tasks, such as image colorization~\cite{zhang2016colorful}, tracking objects in videos~\cite{wang2015unsupervised}, de-noising auto-encoders~\cite{vincent2008extracting} and predicting image rotations~\cite{gidaris2018unsupervised}. Recent works using contrastive learning objectives~\cite{wu2018unsupervised} have achieved remarkable performance, among which MoCo~\cite{he2020momentum,chen2020improved} is the first self-supervised method that outperforms supervised pre-training methods on multiple downstream tasks.
In SimCLR~\cite{chen2020simple}, the authors show that the augmentation policy used by self-supervised method is quite different from the supervised methods, and is often harder. This phenomenon suggests that the self-supervised learned representations can be more rich and diverse than the supervised variants.

\noindent \textbf{Knowledge distillation}~~
aims to distill useful knowledge or representation from a teacher model to a student model~\cite{hinton2015kd}.
Original knowledge distillation uses the predicted logits to transfer knowledge from teacher to student~\cite{hinton2015kd}.
Then, some works found that transferring the knowledge conveyed by the feature map from the teacher to student can lead to better performance~\cite{romero2014fitnets,zagoruyko2016paying}.
Heo~\etal~\cite{heo2019comprehensive} provided a overhaul study of how to effectively distill knowledge from the feature map, which also inspires our design for knowledge distillation. 
Self-distillation uses the same model for both teacher and student~\cite{furlanello2018born}, which has been shown to improve the performance of the model.
We utilize the self-distillation method as a regulation term to prevent our model from over-fitting.

\section{Method}

Our method contains two phases, the first phase is to use the recently published MoCo v2~\cite{chen2020improved} to pre-train the model on the given dataset to obtain good representations. The learned representations can be considered as visual priors before using the label information.
The second phase is to initialize both the teacher and student model used in the self-distillation process with the pre-trained weight. The weight of the teacher is frozen, and the student is updated using a combination of the classification loss and the overhaul-feature-distillation (OFD)~\cite{heo2019comprehensive} loss from the teacher. 
As a result, the student model is regularized by the representation from the teacher when performing the classification task.
The two phases are visualized in Fig.~\ref{fig:distill}.

\begin{figure}
\centering
\includegraphics[height=6cm]{figs/Distill.pdf}
\caption{ The two phases of our proposed method. The first phase is to construct a useful visual prior with self-supervised contrastive learning, and the second phase is to perform self-distillation on the pre-trained checkpoint. The student model is fine-tuned with a distillation loss and a classification loss, while the teacher model is frozen.}
\label{fig:distill}
\end{figure}

\subsection{Phase-1: Pre-Train with Self-Supervised Learning}

The original loss used by MoCo is as follows:

\begin{equation} \label{eq:moco}
    \mathcal{L}_{\text{moco}}=- \log\left[\frac{\exp\left(\mathbf{q} \cdot \mathbf{k^{+}} / \tau\right)}{\exp\left(\mathbf{q} \cdot \mathbf{k^{+}} / \tau\right) + \sum_{\mathbf{k^{-}}} \exp\left(\mathbf{q} \cdot \mathbf{k^{-}} / \tau\right)} \right] \,,
\end{equation}

where $\mathbf{q}$ and $\mathbf{k^{+}}$ is a positive pair (different views of the same image) sampled from the given dataset $\mathcal{D}$, and $\mathbf{k^{-}}$ are negative examples (different images).  
As shown in Fig.~\ref{fig:distill}, MoCo uses a momentum encoder $\theta_{k}$ to encode all the $\mathbf{k}$ and put them in a queue for negative sampling, the momentum encoder is a momentum average of the encoder $\theta_{q}$:
\begin{equation}
    \theta_k \leftarrow \eta\theta_k+(1-\eta)\theta_q.
\end{equation}

As shown in MoCo~\cite{he2020momentum}, the size of the negative sampling queue is crucial to the performance of the learned representation.
In a data-deficient dataset, the maximum size of the queue is limited, we propose to add a margin to the original loss function to help the model obtain a larger margin between data samples thus help the model obtain a similar result with fewer negative examples.
\begin{equation}
    \mathcal{L}_{\text{margin}}=-\log\left[\frac{\exp\left(\left(\mathbf{q} \cdot \mathbf{k^{+}} - m \right) / \tau\right)}{\exp\left(\left(\mathbf{q} \cdot \mathbf{k^{+}} - m \right) / \tau\right) + \sum_{\mathbf{k^{-}}} \exp\left(\mathbf{q} \cdot \mathbf{k^{-}} / \tau\right)} \right] \,.
\end{equation}

\subsection{Phase-2: Self-Distill on Labeled Dataset}

The self-supervised trained checkpoint from phase-1 is then used to initialize the teacher and student for fine-tuning on the whole dataset with labels.
We choose to use OFD~\cite{heo2019comprehensive} to distill the visual priors from teacher to student.
The distillation process can be seen as a regulation to prevent the student from over-fitting the small train dataset and give the student a more diversed representation for classification.

The distillation loss can be formulated as follows:

\begin{equation} \label{eq:distill}
    \mathcal{L}_{\text{distill}}=\sum_{\mathbf{F}}d_{p}\left(\text{StopGrad}\left(\mathbf{F}_{t}\right), r(\mathbf{F}_{s})\right) \,,
\end{equation}
where $\mathbf{F}_t$ and $\mathbf{F}_s$ stands for the feature map of the teacher and student model respectively, the StopGrad means the weight of the teacher will not be updated by gradient descent, the $d_p$ stands for a distance metric, $r$ is a connector function to transform the feature from the student to the teacher.

Along with a cross-entropy loss for classification:
\begin{equation}\label{eq:ce_loss}
    \mathcal{L}_{\text{ce}}=- \log p(y=i|\mathbf{x}) \,,
\end{equation}

the final loss function for the student model is:
\begin{equation}\label{eq:stu_loss}
    \mathcal{L}_{\text{stu}}=\mathcal{L}_{\text{ce}} +\lambda \mathcal{L}_{\text{distill}} \,.
\end{equation}

The student model is then used for evaluation.
\section{Experiments}

\subsubsection{Dataset}
Only the subset of the ImageNet~\cite{deng2009imagenet} dataset given by the VIPrior challenge is used for our experiments, no external data or pre-trained checkpoint is used.
The VIPrior challenge dataset contains 1,000 classes which is the same with the original ImageNet~\cite{deng2009imagenet}, and is split into train, val and test splits, each of the splits has 50 images for each class, resulting in a total of 150,000 images.
For comparison, we use the train split to train the model and test the model on the validation split.

\subsubsection{Implementation Details}
For phase-1, we set the momentum $\eta$ as 0.999 in all the experiments as it yields better performance, and the size of the queue is set to 4,096.
The margin $m$ in our proposed margin loss is set to be 0.6.
We train the model for 800 epochs in phase-1, the initial learning rate is set to 0.03 and the learning rate is dropped by 10x at epoch 120 and epoch 160.
Other hyperparameter is set to be the same with MoCo v2~\cite{chen2020improved},

For phase-2, the $\lambda$ in Eq.~\ref{eq:stu_loss} is set to $10^{-4}$. We also choose to use $\ell_2$ distance as the distance metric $d_p$ in Eq.~\ref{eq:distill}.
We train the model for 100 epochs in phase-2, the initial learning rate is set to 0.1 and is dropped by 10x every 30 epochs.

\subsubsection{Ablation Results}
We first present the overall performance of our proposed two phase pipeline, then show some ablation results.

As shown in Tab.~\ref{tab:r50_phases}, supervised training of ResNet50~\cite{he2016deep} would lead to over-fitting on the train split, thus the validation top-1 accuracy is low.
By first pre-training the model with the phase-1 of our pipeline, and fine-tuning a linear classifier on top of the obtained feature representation~\cite{wu2018unsupervised}, we can reach a 6.6 performance gain in top-1 accuracy. This indicates that the feature learned from self-supervised learning contain more information and can generalize well on the validation set.
We also show that fine-tuning the full model from phase-1 can reach better performance compared to only fine-tuning a linear classifier, which indicates that the weight from phase-1 can also serve as a good initialization, but the supervised training process may still cause the model to suffer from over-fitting.
Finally, by combining phase-1 and phase-2 together, our proposed pipeline achieves 16.7 performance gain in top-1 accuracy over the supervised baseline.

\begin{table}[]
\begin{center}
    
\begin{tabular}{cccc}
\toprule
ResNet50 & \#Pretrain Epoch & \#Finetune Epoch & Val Acc \\
\midrule
Supervised Training                                                            & -                 & 100            & 27.9           \\
Phase-1 + finetune fc                                                            & 800               & 100            & 34.5           \\
Phase-1 + finetune                                                               & 800               & 100            & 39.4           \\

\begin{tabular}[c]{c}Phase-1 + Phase-2\\ (Ours)\end{tabular} & 800               & 100            & 44.6           \\
\bottomrule
\end{tabular}
\vspace{0.2cm}
\caption{\label{tab:r50_phases} Training and Pre-training the model on the train split and evaluate the performance on the validation split on the given dataset. `finetune fc' stands for train a linear classifier on top of the pretrained representation, `finetune' stands for train the weight of the whole model. Our proposed pipeline (Phase-1 + Phase-2) can have 16.7 performance gain in top-1 validation accuracy.}
\end{center}
\end{table}

\subsubsection{The effect of our margin loss}
Tab.~\ref{tab:margin_moco} shows that effect of the number negative samples in contrastive learning loss, the original loss function used by MoCo~v2~\cite{he2020momentum} is sensitive to the number of negatives, the fewer negative, the lower the linear classification result is.
Our modified margin loss can help alleviate the issue with a margin to help the model learn a larger margin between data points.
The experiments show that our margin loss is less sensitive to the number negatives and can be used in a data-deficient setting.

\begin{table}[]
\begin{center}
    
\begin{tabular}{@{}ccccc@{}}
\toprule
                                             & \#Neg & Margin & Val Acc \\
\midrule
\multicolumn{1}{c}{\multirow{3}{*}{MoCo v2~\cite{he2020momentum}}} & 4096        & -      & 34.5    \\
\multicolumn{1}{c}{}                         & 1024        & -      & 32.1    \\
\multicolumn{1}{c}{}                         & 256         & -      & 29.1    \\\midrule
\multirow{3}{*}{Margin loss}              & 4096        & 0.4    & 34.6    \\
                                             & 1024        & 0.4    & 34.2    \\
                                             & 256         & 0.4    & 33.7   
\\\bottomrule
\end{tabular}
\end{center}
\vspace{0.1cm}
\caption{\label{tab:margin_moco} The Val Acc means the linear classification accuracy obtained by fine-tune a linear classifier on top of the learned representation. The original MoCo v2 is sensitive to the number of negative, the performance drops drastically when number negatives is small. Our modified margin loss is less sensitive to the number negatives, as shown in the table, even has 16x less negatives the performance only drops 0.9.}
\end{table}

\vspace{-0.5cm}

\begin{table}[]
\begin{center}
    
\begin{tabular}{lccc}
\toprule
 & \#Pretrain Epoch & \#Finetune Epoch  & Test Acc \\
\midrule
Phase-1 + Phase-2 & 800               & 100            & 47.2           \\
+Input Resolution 448 & 800 & 100 & 54.8 \\ 
+ResNeXt101~\cite{xie2017aggregated} & 800 & 100 & 62.3 \\
+Label-Smooth~\cite{muller2019does} & 800 & 100 & 64.2 \\
+Auto-Aug~\cite{cubuk2019autoaugment} & 800 & 100 & 65.7 \\
+TenCrop & 800 & 100 & 66.2 \\
+Ensemble two models & 800 & 100 & 68.8 \\
\bottomrule
\end{tabular}
\vspace{0.2cm}
\caption{\label{tab:tricks} The tricks used in the competition, our final accuracy is 68.8 which is a competitive result in the challenge. Our code will be made public. Results in this table are obtain by train the model on the combination of train and validation splits.}
\end{center}
\end{table}
\subsubsection{Competition Tricks}
For better performance in the competition, we combine the train and val split to train the model that generate the submission.
Several other tricks and stronger backbone models are used for better performance, such as Auto-Augment~\cite{cubuk2019autoaugment}, ResNeXt~\cite{xie2017aggregated}, label-smooth~\cite{muller2019does}, TenCrop and model ensemble.
Detailed tricks are listed in Tab.~\ref{tab:tricks}.

\section{Conclusion}
This paper proposes a novel two-phase pipeline for image classification using CNNs under the data-deficient setting.
The first phase is to learn a teacher model which obtains a rich visual representation from the dataset using self-supervised learning. 
The second phase is transfer this representation into a student model in a self-distillation manner, meanwhile the student is fine-tuned for downstream classification task.
Experiments shows the effectiveness of our proposed method, Combined with additional tricks, our method achieves a competitive result in the VIPrior Image Classification Challenge.
\bibliographystyle{splncs04}
\bibliography{egbib}
\end{document}


Peer reviews:

content: confidence: 5: The reviewer is absolutely certain that the evaluation is correct and very familiar with the relevant literature
rating: 7: Good paper, accept
review: #### 1. [Summary] In 2-3 sentences, describe the key ideas, experiments, and their significance.
The method has two stages: (i) a teacher network is trained with contrastive learning to obtain feature representation, (ii) the knowledge of the teacher network is transferred to student network by distillation, in the meantime, the student network is also finetuned with labels. 

#### 2. [Strengths] What are the strengths of the paper? Clearly explain why these aspects of the paper are valuable.
- 2-stage method
- Using a margin to overcome the small bank size problem 
#### 3. [Weaknesses] What are the weaknesses of the paper? Clearly explain why these aspects of the paper are weak.
- No conclusion and discussion section.


#### 4. [Overall rating] Paper rating
7

#### 5. [Justification of rating] Please explain how the strengths and weaknesses aforementioned were weighed in for the rating. 


#### 6. [Detailed comments] Additional comments regarding the paper (e.g. typos or other possible improvements you would like to see for the camera-ready version of the paper, if any.)

- How is the margin value chosen? In the text, it is given as 0.6 but in the table, the value is 0.4.
- Related works: Why is there any margin loss part?
- Missing citations:
	> L.29:".. simply memorize the dataset and can not generalize well to unseen data.."
	> L.31:"..some works.." (only given one)

title: Distilling Visual Priors from Self-Supervised Learning

content: confidence: 4: The reviewer is confident but not absolutely certain that the evaluation is correct
rating: 8: Top 50% of accepted papers, clear accept
review: #### 1. [Summary] In 2-3 sentences, describe the key ideas, experiments, and their significance.
The paper proposes to use contrastive pre-training to construct a visal prior (i.e. the model weights) and subsequently initializes both a teacher and student model with the pre-trained weights to finetune the student network on the dataset while  imposing an additional distillation loss between the frozen teacher and unfrozen student networks.

#### 2. [Strengths] What are the strengths of the paper? Clearly explain why these aspects of the paper are valuable.
* The paper is clear and is easy to understand
* The method is interesting and seems to perform well
* The ablation studies clealy show which portion of the performance gain can be accredited to the proposed method and which portion is due to additional tricks, such as data augmentation.

#### 3. [Weaknesses] What are the weaknesses of the paper? Clearly explain why these aspects of the paper are weak.
* It would have been nice to include experiments on an additional (toy) dataset such as MNIST or SVHN to show that the method generalizes to other tasks.
* Conclusion section is missing; the paper is ending rather abruptly.

#### 4. [Overall rating] Paper rating
8: Top 50% of accepted papers, clear accept

#### 5. [Justification of rating] Please explain how the strengths and weaknesses aforementioned were weighed in for the rating.
The method is interesting and seems to perform well. In addition, the paper is well-written. Please consider extending the paper with a "Conclusion" section.

#### 6. [Detailed comments] Additional comments regarding the paper (e.g. typos or other possible improvements you would like to see for the camera-ready version of the paper, if any.)
* What is $\tau$ in equation (1)?
title: Interesting method, well-written paper