Title: REVISITING BATCH NORMALIZATION FOR PRACTICAL DOMAIN ADAPTATION

Abstract: Deep neural networks (DNN) have shown unprecedented success in various computer vision applications such as image classification and object detection. However, it is still a common annoyance during the training phase, that one has to prepare at least thousands of labeled images to fine-tune a network to a specific domain. Recent study (Tommasi et al., 2015) shows that a DNN has strong dependency towards the training dataset, and the learned features cannot be easily transferred to a different but relevant task without fine-tuning. In this paper, we propose a simple yet powerful remedy, called Adaptive Batch Normalization (AdaBN) to increase the generalization ability of a DNN. By modulating the statistics from the source domain to the target domain in all Batch Normalization layers across the network, our approach achieves deep adaptation effect for domain adaptation tasks. In contrary to other deep learning domain adaptation methods, our method does not require additional components, and is parameter-free. It archives stateof-the-art performance despite its surprising simplicity. Furthermore, we demonstrate that our method is complementary with other existing methods. Combining AdaBN with existing domain adaptation treatments may further improve model performance.

1. INTRODUCTION:

Training a DNN for a new image recognition task is expensive. It requires a large amount of labeled training images that are not easy to obtain. One common practice is to use labeled data from other related source such as a different public dataset, or harvesting images by keywords from a search engine. Because 1) the distributions of the source domains (third party datasets or Internet images) are often different from the target domain (testing images); and 2) DNN is particularly good at capturing dataset bias in its internal representation (Torralba & Efros, 2011) , which eventually leads to overfitting, imperfectly paired training and testing sets usually leads to inferior performance. Known as domain adaptation, the effort to bridge the gap between training and testing data distributions has been discussed several times under the context of deep learning (Tzeng et al., 2014; Long et al., 2015; Tzeng et al., 2015; Ganin & Lempitsky, 2015) . To make the connection between the domain of training and the domain of testing, most of these methods require additional optimization steps and extra parameters. Such additional computational burden could greatly complicate the training of a DNN which is already intimidating enough for most people.

In this paper, we propose a simple yet effective approach called AdaBN for batch normalized DNN domain adaptation. We hypothesize that the label related knowledge is stored in the weight matrix of each layer, whereas domain related knowledge is represented by the statistics of the Batch Normalization (BN) (Ioffe & Szegedy, 2015) layer. Therefore, we can easily transfer the trained model to a new domain by modulating the statistics in the BN layer. This approach is straightforward to implement, has zero parameter to tune, and requires minimal computational resources. Moreover, our AdaBN is ready to be extended to more sophisticated scenarios such as multi-source domain adaptation and semi-supervised settings. Fig. 1 illustrates the flowchart of AdaBN. To summarize, our contributions are as follows: 1. We propose a novel domain adaptation technique called Adaptive Batch Normalization (AdaBN). We show that AdaBN can naturally dissociate bias and variance of a dataset, which is ideal for domain adaptation tasks.

2. We validate the effectiveness of our approach on standard benchmarks for both single source and multi-source domain adaptation. Our method outperforms the state-of-the-art methods.

3. We conduct experiments on the cloud detection for remote sensing images to further demonstrate the effectiveness of our approach in practical use.

2. RELATED WORK:

Domain transfer in visual recognition tasks has gained increasing attention in recent literature (Beijbom, 2012; Patel et al., 2015) . Often referred to as covariate shift (Shimodaira, 2000) or dataset bias (Torralba & Efros, 2011) , this problem poses a great challenge to the generalization ability of a learned model. One key component of domain transfer is to model the difference between source and target distributions. In Khosla et al. (2012) , the authors assign each dataset with an explicit bias vector, and train one discriminative model to handle multiple classification problems with different bias terms. A more explicit way to compute dataset difference is based on Maximum Mean Discrepancy (MMD) (Gretton et al., 2012) . This approach projects each data sample into a Reproducing Kernel Hilbert Space, and then computes the difference of sample means. To reduce dataset discrepancies, many methods are proposed, including sample selections (Huang et al., 2006; Gong et al., 2013) , explicit projection learning (Pan et al., 2011; Gopalan et al., 2011; Baktashmotlagh et al., 2013) and principal axes alignment (Fernando et al., 2013; Gong et al., 2012; Aljundi et al., 2015) .

All of these methods face the same challenge of constructing the domain transfer function -a highdimensional non-linear function. Due to computational constraints, most of the proposed transfer functions are in the category of simple shallow projections, which are typically composed of kernel transformations and linear mapping functions.

In the field of deep learning, feature transferability across different domains is a tantalizing yet generally unsolved topic (Yosinski et al., 2014; Tommasi et al., 2015) . To transfer the learned representations to a new dataset, pre-training plus fine-tuning (Donahue et al., 2014) have become de facto procedures. However, adaptation by fine-tuning is far from perfect. It requires a considerable amount of labeled data from the target domain, and non-negligible computational resources to retrain the whole network.

A series of progress has been made in DNN to facilitate domain transfer. Early works of domain adaptation either focus on reordering fine-tuning samples (Chopra et al., 2013) , or regularizing MMD (Gretton et al., 2012) in a shallow network (Ghifary et al., 2014) . It is only until recently that the problem is directly attacked under the setting of classification of unlabeled target domain using modern convolutional neural network (CNN) architecture. DDC (Tzeng et al., 2014) used the classical MMD loss to regularize the representation in the last layer of CNN. DAN (Long et al., 2015) further extended the method to multiple kernel MMD and multiple layer adaptation. Besides adapting features using MMD, RTN (Long et al., 2016 ) also added a gated residual layer for classifier adaptation. RevGrad (Ganin & Lempitsky, 2015) devised a gradient reversal layer to compensate the back-propagated gradients that are domain specific. Recently, by explicitly modeling both private and shared components of the domain representations in the network, Bousmalis et al. (2016) proposed a Domain Separation Network to extract better domain-invariant features.

Another related work is CORAL (Sun et al., 2016) . This model focuses on the last layer of CNN. CORAL whitens the data in source domain, and then re-correlates the source domain features to target domain. This operation aligns the second order statistics of source domain and target domain distributions. Surprisingly, such simple approach yields state-of-the-arts results in various text classification and visual recognition tasks. Recently, Deep CORAL (Sun & Saenko, 2016 ) also extends the method into DNN by incorporating a CORAL loss.

2.1. BATCH NORMALIZATION:

In this section, we briefly review Batch Normalization (BN) (Ioffe & Szegedy, 2015) which is closely related to our AdaBN. The BN layer is originally designed to alleviate the issue of internal covariate shifting -a common problem while training a very deep neural network. It first standardizes each feature in a mini-batch, and then learns a common slope and bias for each mini-batch.

Formally, given the input to a BN layer X ∈ R n×p , where n denotes the batch size, and p is the feature dimension, BN layer transforms a feature j ∈ {1 . . . p} into:

EQUATION

where x j and y j are the input/output scalars of one neuron response in one data sample; X •j denotes the j th column of the input data; and γ j and β j are parameters to be learned. This transformation guarantees that the input distribution of each layer remains unchanged across different mini-batches. Extensive experiments have shown that Batch Normalization significantly reduces the number of iteration to converge, and improves the final performance at the same time. BN layer has become a standard component in recent top-performing CNN architectures, such as deep residual network (He et al., 2016) , and Inception V3 (Szegedy et al., 2015) .

3. THE MODEL:

In Sec. 3.1, we first analyze the domain shift in deep neural network, and reveal two key observations. Then in Sec. 3.2, we introduce our Adaptive Batch Normalization (AdaBN) method based on these observations.

3.1. A PILOT EXPERIMENT:

The Batch Normalization (BN) technique is originally proposed to help SGD optimization by aligning the distribution of training data. From this perspective, it is interesting to examine the BN parameters (batch-wise mean and variance) over different dataset at different layers of the network.

In this pilot experiment, we use MXNet implementation (Chen et al., 2016b) of the Inception-BN model (Ioffe & Szegedy, 2015) pre-trained on ImageNet classification task (Russakovsky et al., 2015) as our baseline DNN model. Our image data are drawn from (Bergamo & Torresani, 2010) , which contains the same classes of images from both Caltech-256 dataset (Griffin et al., 2007) and Bing image search results. For each mini-batch sampled from one dataset, we concatenate the mean and variance of all neurons from one layer to form a feature vector. Using linear SVM, we can almost perfectly classify whether the mini-batch feature vector is from Caltech-256 or Bing dataset. Both observations motivate us to adapt the representation across different domains by BN layer.

3.2. ADAPTIVE BATCH NORMALIZATION:

Given the pre-trained DNN model and a target domain, our Adaptive Batch Normalization algorithm is as follows1 :

Algorithm 1 Adaptive Batch Normalization (AdaBN)

for neuron j in DNN do Concatenate neuron responses on all images of target domain t:

x j = [. . . , x j (m), . . .]

Compute the mean and variance of the target domain: µ t j = E(x t j ), σ t j = Var(x t j ). end for for neuron j in DNN, testing image m in target domain do

Compute BN output y j (m) := γ j xj (m)-µ t j σ t j + β j end for

The intuition behind our method is straightforward: The standardization of each layer by domain ensures that each layer receives data from a similar distribution, no matter it comes from the source domain or the target domain. Although modulating statistics in one BN layer by AdaBN is a simple translation and scaling operation, such linear transformation in one layer can achieve a highly nonlinear transformation through the whole deep CNN architecture. Thus, we believe this AdaBN process could approximate the intrinsically non-linear domain transfer function.

For K domain adaptation where K > 2, we standardize each sample by the statistics in its own domain. During training, the statistics are calculated for every mini-batch, the only thing that we need to make sure is that the samples in every mini-batch are from the same domain. For (semi-)supervised domain adaptation, we may use the labeled data to fine-tune the weights as well. As a result, our method could fit in all different settings of domain adaptation with minimal effort.

Compared with CORAL (Sun et al., 2016) , one natural question is why we transform the neuron responses independently, not decorrelate and then re-correlate the responses together as suggested in Sun et al. (2016) . Under certain conditions, decorrelation could improve the performance. However, in CNN, the mini-batch size is usually smaller than the feature dimension, leading to singular covariance matrices that is hard to be inversed. As a result, the covariance matrix is always singular. In addition, decorrelation requires to compute the inverse of the covariance matrix which is computationally intensive, especially if we plan to apply AdaBN to all layers of the network.

4. EXPERIMENTS:

In this section, we demonstrate the effectiveness of AdaBN on standard domain adaptation datasets, and empirically analyze our AdaBN model. We also evaluation our method on a practical application with remote sensing images.

4.1. EXPERIMENTAL SETTINGS:

We first introduce our experiments on two standard datasets: Office (Saenko et al., 2010) and Caltech-Bing (Bergamo & Torresani, 2010) .

Office (Saenko et al., 2010 ) is a standard benchmark for domain adaptation, which is a collection of 4652 images in 31 classes from three different domains: Amazon(A), DSRL(D) and Webcam(W). Similar to (Tzeng et al., 2014; Sun et al., 2016; Long et al., 2015) , we evaluate the pairwise domain adaption performance of AdaBN on all six pairs of domains. For the multi-source setting, we evaluate our method on three transfer tasks {A, W} → D, {A, D} → W, {D, W} → A.

Caltech-Bing (Bergamo & Torresani, 2010 ) is a much larger domain adaptation dataset, which contains 30,607 and 121,730 images in 256 categories from two domains Caltech-256(C) and Bing(B). The images in the Bing set are collected from Bing image search engine by keyword search. Apparently Bing data contains noise, and its data distribution is dramatically different from that of Caltech-256.

We compare our approach with a variety of methods, including four shallow methods: SA (Fernando et al., 2013) , LSSA (Aljundi et al., 2015) , GFK (Gong et al., 2012) , CORAL (Sun et al., 2016) , and four deep methods: DDC (Tzeng et al., 2014) , DAN (Long et al., 2015) , RevGrad (Ganin & Lempitsky, 2015) , Deep CORAL (Sun & Saenko, 2016) . Specifically, GFK models domain shift by integrating an infinite number of subspaces that characterize changes in statistical properties from the source to the target domain. SA, LSSA and CORAL align the source and target subspaces by explicit feature space transformations that would map source distribution into the target one. DDC and DAN are deep learning based methods which maximize domain invariance by adding to AlexNet one or several adaptation layers using MMD. RevGrad incorporates a gradient reversal layer in the deep model to encourage learning domain-invariant features. Deep CORAL extends CORAL to perform end-to-end adaptation in DNN. It should be noted that these deep learning methods have the adaptation layers on top of the output layers of DNNs, which is a sharp contrast to our method that delves into early convolution layers as well with the help of BN layers.

We follow the full protocol (Donahue et al., 2014) for the single source setting; while for multiple sources setting, we use all the samples in the source domains as training data, and use all the samples in the target domain as testing data. We fine-tune the Inception-BN (Ioffe & Szegedy, 2015) model on source domain in each task for 100 epochs. The learning rate is set to 0.01 initially, and then is dropped by a factor 0.1 every 40 epochs. Since the office dataset is quite small, following the (Krizhevsky et al., 2012) 61.6 95.4 99.0 63.8 51.1 49.8 70.1 DDC (Tzeng et al., 2014) 61.8 95.0 98.5 64.4 52.1 52.2 70.6 DAN (Long et al., 2015) 68.5 96.0 99.0 67.0 54.0 53.1 72.9 Deep CORAL (Sun & Saenko, 2016) 66.4 95.7 99.2 66.8 52.8 51.5 72.1 RevGrad (Ganin & Lempitsky, 2015) 73.0 96.4 99.2 ----Inception BN (Ioffe & Szegedy, 2015) 70.3 94.3 100 70.5 60.1 57.9 75.5 SA (Fernando et al., 2013) 69.8 95.5 99.0 71.3 59.4 56.9 75.3 GFK (Gong et al., 2012) 66.7 97.0 99.4 70.1 58.0 56.9 74.7 LSSA (Aljundi et al., 2015) 67 best practice in Long et al. (2015) , we freeze the first three groups of Inception modules, and set the learning rate of fourth and fifth group one tenth of the base learning rate to avoid overfitting. For Caltech-Bing dataset, we fine-tune the whole model with the same base learning rate.

Method A → W D → W W → D A → D D → A W → A Avg AlexNet

4.2. RESULTS:



4.2.1. OFFICE DATASET:

Our results on Office dataset is reported in Table 1 and Table 2 for single/multi source(s), respectively. Note that the first 5 models of the Table 1 are pre-trained on AlexNet (Krizhevsky et al., 2012) instead of the Inception-BN (Ioffe & Szegedy, 2015) model, due to the lack of publicly available pre-trained Inception BN model in Caffe (Jia et al., 2014) . Thus, the relative improvements over the baseline (AlexNet/Inception BN) make more sense than the absolute numbers of each algorithm.

From Table 1 , we first notice that the Inception-BN indeed improves over the AlexNet on average, which means that the CNN pre-trained on ImageNet has learned general features, the improvements on ImageNet can be transferred to new tasks. Among the methods based on Inception-BN features, our method improves the most over the baseline. Moreover, since our method is complementary to other methods, we can simply apply CORAL on the top of AdaBN. Not surprisingly, this simple combination exhibits 0.5% increase in performance. This preliminary test reveals further potential of AdaBN if combined with other advanced domain adaptation methods. Finally, we could improve 1.7% over the baseline, and advance the state-of-the-art results for this dataset.

None of the compared methods has reported their performance on multi-source domain adaptation.

To demonstrate the capacity of AdaBN under multi-domain settings, we compare it against CORAL, which is the best performing algorithm in the single source setting. The result is reported in Table 2 . We find that simply combining two domains does not lead to better performance. The result is generally worse compared to the best performing single domain between the two. This phenomenon suggests that if we cannot properly cope with domain bias, the increase of training samples may be reversely affect to the testing performance. This result confirms the necessity of domain adaptation.

In this more challenging setting, AdaBN still outperforms the baseline and CORAL on average. Again, when combined with CORAL, our method demonstrates further improvements. At last, our method archives 2.3% gain over the baseline. (Ioffe & Szegedy, 2015) 90.8 95.4 60.2 82.1 CORAL (Sun et al., 2016) 92 

Method A, D → W A, W → D D, W → A Avg Inception BN

4.2.2. CALTECH-BING DATASET:

To further evaluate our method on the large-scale dataset, we show our results on Caltech-Bing Dataset in Table 3 . Compared with CORAL, AdaBN achieves better performance, which improves 1.8% over the baseline. Note that all the domain adaptation methods show minor improvements over the baseline in the task C → B. One of the hypotheses to this relatively small improvement is that the images in Bing dataset are collected from Internet, which are more diverse and noisier (Bergamo & Torresani, 2010) . Thus, it is not easy to adapt on the Bing dataset from the relatively clean dataset Caltech-256. Combining CORAL with our method does not offer further improvements. This might be explained by the noise of the Bing dataset and the imbalance of the number of images in the two domains.

Method C → B B → C Avg Inception BN (Ioffe & Szegedy, 2015) 35.1 64.6 49.9 CORAL (Sun et al., 2016) 35 

4.3. EMPIRICAL ANALYSIS:

In this section, we the influence of the number of samples in target domain to the performance and empirically analyze the adaptation effect of different BN layers.

4.3.1. SENSITIVITY TO TARGET DOMAIN SIZE.:

Since the key of our method is to calculate the mean and variance of the target domain on different BN layers, it is very natural to ask how many target images is necessary to obtain stable statistics.

In this experiment, we randomly select a subset of images in target domain to calculate the statistics and then evaluate the performance on the whole target set. Fig. 3 illustrates the effect of using different number of batches. The results demonstrate that our method can obtain good results when using only a small part of the target examples. It should also be noted that in the extremal case of one batch of target images, our method still achieves better results than the baseline. This is valuable in practical use since a large number of target images are often not available. In this experiment, we analyze the effect of adapting on different BN layers with our AdaBN method.

According to the structure of Inception-BN network Ioffe & Szegedy (2015) , we categorize the BN layers into 9 blocks: 1, 2, 3a, 3b, 4a, 4b, 4c, 5a, 5b. Since back BN layers are influenced by the outputs of previous BN layers, when adapting a specific block we adapted all the blocks before it. Fig. 4 illustrates the adaptation effect for different BN layers. It shows that adapting BN layers consistently improves the results over the baseline method in most cases. Specifically, when incorporating more BN layers in the adaptation, we could achiever better transfer results.

4.4. PRACTICAL APPLICATION FOR CLOUD DETECTION IN REMOTE SENSING IMAGES:

In this section, we further demonstrate the effectiveness of AdaBN on a practical problem: Cloud Detection in Remote Sensing Images. Since remote sensing images are taken by different satellites with different sensors and resolutions, the captured images are visually different in texture, color, and value range distributions, as shown in Fig. 5 . How to adapt a model trained on one satellite to another satellite images is naturally a domain adaptation problem.

Our task here is to identify cloud from the remote sensing images, which can be regarded as a semantic segmentation task. The experiment is taken under a self-collected dataset, which includes three image sets, from GF2, GF1 and Tianhui satellites. Each image set contains 635, 324 and 113 images with resolution over 6000x6000 pixels respectively. We name the three different datasets following the satellite names. GF2 dataset is used as the training dataset while GF1 and Tianhui datasets are for testing. We use a state-of-art semantic segmentation method (Chen et al., 2016a) as our baseline model.

Method GF1 Tianhui Baseline 38.95% 14.54% AdaBN 64.50% 29.66% The results on GF1 and Tianhui datasets are shown in Table 4 . The relatively low results of the baseline method indicate that there exists large distribution disparity among images from different satellites. Thus, the significant improvement after applying AdaBN reveals the effectiveness of our method. Some of the visual results are shown in Fig. 6 . Since other domain adaptation methods require either additional optimization steps and extra components (e.g. MMD) or post-processing distribution alignment (like CORAL), it is very hard to apply these methods from image classification to this large-size (6000x6000) segmentation problem. Comparatively, besides the effective performance, our method needs no extra parameters and very few computations over the whole adaptation process. 

5. CONCLUSION AND FUTURE WORKS:

In this paper, we have introduced a simple yet effective approach for domain adaptation on batch normalized neural networks. Besides its original uses, we have exploited another functionality of Batch Normalization (BN) layer: domain adaptation. The main idea is to replace the statistics of each BN layer in source domain with those in target domain. The proposed method is easy to implement and parameter-free, and it takes almost no effort to extend to multiple source domains and semi-supervised settings. Our method established new state-of-the-art results on both single and multiple source(s) domain adaptation settings on standard benchmarks. At last, the experiments on cloud detection for large-size remote sensing images further demonstrate the effectiveness of our method in practical use. We believe our method opens up a new direction for domain adaptation.

In contrary to other methods that use Maximum Mean Discrepancy (MMD) or domain confusion loss to update the weights in CNN for domain adaptation, our method only modifies the statistics of BN layer. Therefore, our method is fully complementary to other existing deep learning based methods. It is interesting to see how these different methods can be unified under one framework.

:

In practice we adopt an online algorithm(Donald, 1999) to efficiently estimate the mean and variance.

Figures and Tables:

Figure 1: Illustration of the proposed method. For each convolutional or fully connected layer, we use different bias/variance terms to perform batch normalization for the training domain and the test domain. The domain specific normalization mitigates the domain shift issue.

Figure 2: t-SNE (Van der Maaten & Hinton, 2008) visualization of the mini-batch BN feature vector distributions in both shallow and deep layers, across different datasets. Each point represents the BN statistics in one mini-batch. Red dots come from Bing domain, while the blue ones are from Caltech-256 domain. The size of each mini-batch is 64. This pilot experiment suggests: 1. Both shallow layers and deep layers of the DNN are influenced by domain shift. Domain adaptation by manipulating the output layer alone is not enough. 2. The statistics of BN layer contain the traits of the data domain.

Figure 3: Accuracy when varying the number of mini-batches used for calculating the statistics of BN layers in A → W and B → C, respectively. For B → C, we only show the results of using less than 100 batches, since the results are very stable when adding more examples. The batch size is 64 in this experiment. For even smaller number of examples, the performance may be not consistent and drop behind the baseline (e.g. 0.652 with 16 samples, 0.661 with 32 samples).

Figure 4: Accuracy when adapting with different BN blocks in B → C. x = 0 corresponds to the result with non-adapt method, and 1, 2, 3a, 3b, 4a, 4b, 4c, 5a, 5b correspond to the nine different blocks in Inception-BN network..

Figure 5: Remote sensing images in different domains.

Single source domain adaptation results on Office-31(Saenko et al., 2010) dataset with standard unsupervised adaptation protocol.

Table content: <table><tr><td/><td>.7</td><td>96.1</td><td>98.4</td><td>71.3</td><td>57.8</td><td>57.8 74.9</td></tr><tr><td>CORAL (Sun et al., 2016)</td><td>70.9</td><td>95.7</td><td>99.8</td><td>71.9</td><td>59.0</td><td>60.2 76.3</td></tr><tr><td>AdaBN</td><td>74.2</td><td>95.7</td><td>99.8</td><td>73.1</td><td>59.8</td><td>57.4 76.7</td></tr><tr><td>AdaBN + CORAL</td><td>75.4</td><td>96.2</td><td>99.6</td><td>72.7</td><td>59.0</td><td>60.5 77.2</td></tr></table>

Multi-source domain adaptation results on Office-31(Saenko et al., 2010) dataset with standard unsupervised adaptation protocol.

Table content: <table><tr><td>.1</td><td>96.4</td><td>61.4</td><td>83.3</td></tr></table>

Single source domain adaptation results on Caltech-Bing(Bergamo & Torresani, 2010) dataset.

Table content: <table><tr><td>.3</td><td>67.2 51.3</td></tr></table>

Domain adaptation results (mIOU) on GF1 and Tianhui datasets training on GF2 datasets.

Table content: <table/>

Peer review (iclr2017):
This paper proposes a simple domain adaptation technique in which batch normalization is performed separately in each domain. Pros: The method is very simple and easy to understand and apply. The experiments demonstrate that the method compares favorably with existing methods on standard domain adaptation tasks. The analysis in section 4.3.2 shows that a very small number of target domain samples are needed for adaptation of the network. Cons: There is little novelty -- the method is arguably too simple to be called a “method.” Rather, it’s the most straightforward/intuitive approach when using a network with batch normalization for domain adaptation. The alternative -- using the BN statistics from the source domain for target domain examples -- is less natural, to me. (I guess this alternative is what’s done in the Inception BN results in Table 1-2?) The analysis in section 4.3.1 is superfluous except as a sanity check -- KL divergence between the distributions should be 0 when each distribution is shifted/scaled to N(0,1) by BN. Section 3.3: it’s not clear to me what point is being made here. Overall, there’s not much novelty here, but it’s hard to argue that simplicity is a bad thing when the method is clearly competitive with or outperforming prior work on the standard benchmarks (in a domain adaptation tradition that started with “Frustratingly Easy Domain Adaptation”). If accepted, Sections 4.3.1 and 3.3 should be removed or rewritten for clarity for a final version.