Shape or Texture: Understanding Discriminative Features in CNNs

1 INTRODUCTION . Convolutional neural networks ( CNNs ) have achieved unprecedented performance in various computer vision tasks , such as image classification ( Krizhevsky et al. , 2012 ; Simonyan & Zisserman , 2015 ; He et al. , 2016 ) , object detection ( Ren et al. , 2015 ; He et al. , 2017 ) and semantic segmentation ( Long et al. , 2015 ; Chen et al. , 2017 ; Islam et al. , 2017 ) . Despite their black box nature , various studies have shown that early layers in CNNs activate for low-level patterns , like edges and blobs , while deeper layers activate for more complex and high-level patterns ( Zeiler & Fergus , 2014 ; Springenberg et al. , 2014 ) . The intuition is that this hierarchical learning of latent representations allows CNNs to recognize complex object shapes to correctly classify images ( Kriegeskorte , 2015 ) . In contrast , recent works ( Brendel & Bethge , 2019 ; Hermann & Lampinen , 2020 ) have argued that CNNs trained on ImageNet ( IN ) ( Deng et al. , 2009 ) classify images mainly according to their texture , rather than object shape . These conflicting results have large implications for the field of computer vision as it suggests that CNNs trained for image classification might be making decisions based largely off spurious correlations rather than a full understanding of different object categories . One example of these spurious correlations is how the Inception CNN ( Szegedy et al. , 2015 ) recognizes the difference between ‘ Wolf ’ and ‘ Husky ’ , based on whether there is snow in the background ( Tulio Ribeiro et al. , 2016 ) . Recognizing object shapes is important for the generalization to out-of-domain examples ( e.g. , few-shot learning ) , as shape is more discriminative than texture when texture-affecting phenomena arise , such as lighting , shading , weather , motion blur , or when switching between synthetic and real data . In addition to performance , identifying the discriminative features that CNNs use for decision making is critical for the transparency and further improvements of computer vision models . While the model may achieve good performance for a certain task , it can not communicate to the user about the reasons it made certain predictions . In other words , successful mod- els need to be good , and interpretable ( Lipton , 2019 ) . This is crucial for many domains where causal mechanisms should play a significant role in short or long-term decision making such as healthcare ( e.g. , what in the MRI indicates a patient has cancer ? ) . Additionally , if researchers intend for their algorithms to be deployed , there must be a certain degree of trust in the decision making algorithm . One downside of the increasing abstraction capabilities of deep CNNs is the lack of interpretability of the latent representations due to hidden layer activations coding semantic concepts in a distributed fashion ( Fong & Vedaldi , 2018 ) . It has therefore been difficult to precisely quantify the type of information contained in the latent representations of CNNs . Some methods have looked at ways to analyze the latent representations of CNNs on a neuron-to-neuron level . For instance , ( Bau et al. , 2017 ) quantify the number of interpretable neurons for a CNN by evaluating the semantic segmentation performance of an individual neuron from an upsampled latent representation . Later work ( Fong & Vedaldi , 2018 ) then removed the assumption that each neuron encodes a single semantic concept . These works successfully quantify the number of filters that recognize textures or specific objects in a CNN , but do not identify shape information within these representations . The most similar works to ours are those that aim to directly quantify the shape information in CNNs . For example , ( Geirhos et al. , 2018 ) analyzed the outputs of CNNs on images with conflicting shape and texture cues . By using image stylization ( Huang & Belongie , 2017 ) , they generated the Stylized ImageNet dataset ( SIN ) , where each image has an associated shape and texture label . They then measured the ‘ shape bias ’ and ‘ texture bias ’ of a CNN by calculating the percentage of images a CNN predicts as either the shape or texture label , respectively . They conclude that CNNs are ‘ texture biased ’ and make predictions mainly from texture in an image . This metric has been used in subsequent work exploring shape and texture bias in CNNs ( Hermann & Kornblith , 2019 ) ; however , the method only compares the output of a CNN , and fails to robustly quantify the amount of shape information contained in the latent representations ( note that they refer to ‘ shape ’ as the entire 3D form of an object , including contours that are not part of the silhouette , while in our work , we define ‘ shape ’ as the 2D class-agnostic silhouette of an object ) . Thus , the method from ( Hermann & Kornblith , 2019 ) can not answer a question of focus in our paper : ‘ What fraction of the object ’ s shape is actually encoded in the latent representation ? ’ . Further , as their metric for shape relies solely on the semantic class label , it precludes them from evaluating the encoded shape and associated categorical information on a per-pixel level . For instance , we show in Fig . 1 that shape biased models ( i.e. , trained on stylized images ) do not classify images based on the entire object shape : even though the CNN correctly classifies the image as a bird , only the partial binary mask ( i.e. , ‘ shape ’ ) can be extracted from the latent representations and it can not attribute the correct class label to the entire object region ( i.e. , semantic segmentation mask ) . Contributions . To address these issues , we perform an empirical study on the ability of CNNs to encode shape information on a neuron-to-neuron and per-pixel level . To quantify these two aspects , we first approximate the mutual information of latent representations between pairs of semantically related images which allows us to estimate the number of dimensions in the feature space dedicated to encoding shape and texture . We then propose a simple strategy to evaluate the amount of shape information contained in the internal representations of a CNN , on a per-pixel level . The latter technique is utilized to distinguish the quality of different shape encodings , regardless of the number of neurons used in each encoding . After showing the efficacy of the two methods , we reveal a number of meaningful properties of CNNs with respect to their ability to encode shape information , including the following : ( i ) Biasing a CNN towards shape predominantly changes the number of shape encoding neurons in the last feature encoding stage . ( ii ) When a CNN is trained on ImageNet , the majority of shape information is learned during the first few epochs . ( iii ) A significant amount of shape is encoded in the early layers of CNNs , which can be utilized to extract additional shape information from the network , by combining with shape encodings from deeper layers . ( iv ) Encoding the shape and class of an object does not imply the useful encoding of localized per-pixel categorical information . All code will be released to reproduce data and results . 2 DO CNNS SPEND MORE LEARNING CAPACITY ON SHAPE OR TEXTURE ? . With the goal of revealing the characteristics of where , when , and how much shape information is encoded in CNNs , we first aim to quantify the number of dimensions which encode shape in a CNN ’ s latent representation . This analysis on the latent representations will allow us to determine where the network spends learning capacity on shape , while other methods that focus solely on the network outputs have difficulty measuring the difference in shape information between convolutional layers . 2.1 ESTIMATING SHAPE AND TEXTURE DIMENSIONALITY . Previous works ( Bau et al. , 2017 ; Esser et al. , 2020 ) proposed various mechanisms to reveal the semantic concepts encoded in latent representations of CNNs . To quantify the amount of texture and shape information , we follow the approach of ( Esser et al. , 2020 ) , where the number of neurons that represent a certain semantic concept is estimated . Given a pretrained CNN encoder , E ( I ) = z , where z is a latent representation , we aim to estimate the dimensionality of the semantic concepts shape and texture within z . The main idea is that the mutual information between image pairs , Ia and Ib , which are similar in a semantic concept , will be preserved in a neuron zi only if the neuron encodes that specific semantic concept . Hence , the mutual information between the corresponding neuron pairs , zai = E ( I a ) and zbi = E ( I b ) , can be used to quantify the degree to which a semantic concept is represented by the neuron . A simple and efficient estimate for their mutual information MI ( zai , z b i ) can be obtained based on the correlation coefficient ρi . Indeed , under the assumption that the marginal distribution of the neuron zi is Gaussian , the correlation coefficient ρi provides a lower bound on the true mutual information through the following relationship which becomes tight for jointly Gaussian zai , z b i ( Kraskov et al. , 2004 ; Foster & Grassberger , 2011 ) . MI ( zai , z b i ) ≥ − 1 2 log ( 1− ρ2i ) , where ρi = Cov ( zai , z b i ) √ Var ( zai ) Var ( z b i ) . ( 1 ) To quantify how well a concept k is represented in terms of the number of neurons |zk| that encode the concept , we compute a score for each concept and the relative number of neurons is determined with a softmax over these scores and a baseline score . The latter is given by the number of neurons |z| , and shape and texture scores are given by the sum of their respective correlation coefficients ρshapei and ρ texture i , which are computed according to Eq . 1 with statistics taken over image pairs that are similar in shape and texture , respectively . Note that k ∈ { 1 , 2 } in our case , and the remaining dimensions not captured in any of the two semantic factors are allocated to the residual semantic factor , which by definition captures all other variability in the latent representation , z. Stylized PASCAL VOC 2012 Dataset . Our goal is to estimate the dimensionality of two semantic concepts : ( i ) shape and ( ii ) texture , and analyze pixel-wise shape information . Therefore we must generate a dataset that we can sample image pairs which share the semantic factors shape or texture , and have per-pixel object annotations . To accomplish this goal , we create the Stylized PASCAL VOC 2012 ( SVOC ) dataset . Similar to SIN , we use the AdaIN style transfer algorithm ( Huang & Belongie , 2017 ) to generate stylized images from the PASCAL VOC 2012 dataset ( Everingham et al. , 2010 ) with the same settings and hyperparameters as in the original paper ( Huang & Belongie , 2017 ) . We choose five random textures from the Describable Textures Dataset ( Cimpoi et al. , 2014 ) as the styles and we stylize every PASCAL VOC image with all five of these textures . For a fair comparison with models trained on ImageNet variants , we take only the images from PASCAL VOC which contain a single object . With the SVOC dataset , we can now sample image pairs which are similar in texture , by using two images from different categories but stylized with the same texture ( Fig . 2 ( A ) left ) , or shape , by using the same image stylized with two different textures ( Fig . 2 ( A ) right ) .

Summary: The method provides two measures for assessing the degree at which shape is represented in CNNs. The first measure attempts to asses, within a given representation layer, the dimentionality required to encoder shape information. The second, evaluates the per-pixel shape representation, by attempting to generate the input's segmentation mask from the given representation (activation of the image at that layer).