Dynamic Scale Inference by Entropy Minimization

1 INTRODUCTION . The world is infinite in its variations , but our models are finite . While inputs differ in many dimensions and degrees , a deep network is only so deep and wide . To nevertheless cope with variation , there are two main strategies : static enumeration and dynamic adaptation . Static enumeration defines a set of variations , processes them all , and combines the results . For example , pyramids enumerate scales ( Burt & Adelson , 1983 ; Kanazawa et al. , 2014 ) and group-structured filters enumerate orientations ( Cohen & Welling , 2017 ) . Dynamic adaptation selects a single variation , conditioned on the input , and transforms processing accordingly . For example , scale-space search ( Lindeberg , 1994 ; Lowe , 2004 ) selects a scale transformation from input statistics and end-to-end dynamic networks select geometric transformations ( Jaderberg et al. , 2015 ; Dai et al. , 2017 ) , parameter transformations ( De Brabandere et al. , 2016 ) , and feature transformations ( Perez et al. , 2017 ) directly from the input . Enumeration and adaptation both help , but are limited by computation and supervision , because the sets enumerated and ranges selected are bounded by model size and training data . Deep networks for vision exploit enumeration and adaptation , but generalization is still limited . Networks are enumerative , by convolving with a set of filters to cover different variations then summing across them to pool the variants ( LeCun et al. , 1998 ; Krizhevsky et al. , 2012 ; Zeiler & Fergus , 2014 ) . For scale variation , image pyramids ( Burt & Adelson , 1983 ) and feature pyramids ( Shelhamer et al. , 2017 ; Lin et al. , 2017 ) enumerate scales , process each , and combine the outputs . However , static models have only so many filters and scales , and may lack the capacity or supervision for the full data distribution . Dynamic models instead adapt to each input ( Olshausen et al. , 1993 ) . The landmark scale invariant feature transform ( Lowe , 2004 ) extracts a representation adapted to scales and orientations predicted from input statistics . Dynamic networks , including spatial transformers ( Jaderberg et al. , 2015 ) and deformable convolution ( Dai et al. , 2017 ) , make these predictions and transformations end-to-end . Predictive dynamic inference is however insufficient : the predictor may be imperfect in its architecture or parameters , or may not generalize to data it was not designed or optimized for . Bottom-up prediction , with only one step of adaptation , can struggle to counter variations in scale and other factors that are too large or unfamiliar . To further address the kinds and degrees of variations , including extreme out-of-distribution shifts , we devise a complementary third strategy : unsupervised optimization during inference . We define an unsupervised objective and a constrained set of variables for effective gradient optimization . Our novel inference objective minimizes the entropy of the model output to optimize for confidence . The variables optimized over are task parameters for pixel-wise classification and structure parameters for receptive field adaptation , which are updated together to compensate for scale shifts . This optimization functions as top-down feedback to iteratively adjust feedforward inference . In effect , we update the trained model parameters to tune a custom model for each test input . Optimization during inference extends dynamic adaptation past the present limits of supervision and computation . Unsupervised optimization boosts generalization beyond training by top-down tuning during testing . Iterative updates decouple the amount of computation , and thus degree of adaptation , from the network architecture . Our main result is to demonstrate that adaptation by entropy optimization improves accuracy and generalization beyond adaptation by prediction ( see Figure 1 ) , which we show for semantic segmentation by inference time optimization of a dynamic Gaussian receptive field model ( Shelhamer et al. , 2019 ) on the PASCAL VOC ( Everingham et al. , 2010 ) dataset . 2 ITERATIVE DYNAMIC INFERENCE BY UNSUPERVISED OPTIMIZATION . Our approach extends dynamic scale inference from one-step prediction to multi-step iteration through optimization . For optimization during inference , we require an objective to optimize and variables to optimize over . Lacking task or scale supervision during inference , the objective must be unsupervised . For variables , there are many choices among parameters and features . Our main contribution is an unsupervised approach for adapting task and structure parameters via gradient optimization to minimize prediction entropy . Note that our inference optimization is distinct from the training optimization . We do not alter training in any way : the task loss , optimizer , and model are entirely unchanged . In the following , optimization refers to our inference optimization scheme , and not the usual training optimization . To optimize inference , a base dynamic inference method is needed . For scale , we choose local receptive field adaptation ( Dai et al. , 2017 ; Zhang et al. , 2017 ; Shelhamer et al. , 2019 ) , because scale varies locally even within a single image . In particular , we adopt dynamic Gaussian receptive fields ( Shelhamer et al. , 2019 ) that combine Gaussian scale-space structure with standard “ free-form ” filters for parameter-efficient spatial adaptation . These methods rely on feedforward regression to infer receptive fields that we further optimize . Figure 2 illustrates the approach . Optimization is initialized by feedforward dynamic inference of Gaussian receptive fields ( Shelhamer et al. , 2019 ) . At each following step , the model prediction and its entropy are computed , and the objective is taken as the sum of pixel-wise entropies . Model parameters are iteratively updated by the gradient of the objective , resulting in updated predictions and entropy . Optimization of the parameters for the Gaussian receptive fields is instrumental for adapting to scale . 2.1 OBJECTIVE : ENTROPY MINIMIZATION . Unsupervised inference objectives can be bottom-up , based on the input , or top-down , based on the output . To augment already bottom-up prediction , we choose the top-down objective of entropy minimization . In essence , the objective is to reduce model uncertainty . More precisely , for the pixel-wise output Ŷ ∈ [ 0 , 1 ] C×H×W for C classes and an image of height H and width W , we measure uncertainty by the Shannon entropy ( Shannon , 1948 ) : Hi , j ( Ŷ ) = − ∑ c P ( yi , j = c ) logP ( yi , j = c ) ( 1 ) for each pixel at index i , j to yield pixel-wise entropy of the same spatial dimensions as the output . Entropy is theoretically motivated and empirically supported . By inspection , we see that networks tend to be confident on in-distribution data from the training regime . ( Studying the probabilistic calibration of networks ( Guo et al. , 2017 ) confirms this . ) In our case , this holds for testing scales similar to the training scales , with high entropy on segment contours . On out-of-distribution data , such as scale shifts , the output entropy is higher and less structured . For qualitative examples , see Figures 1 and 2 . This objective is severe , in that its optimum demands perfect certainty ( that is , zero entropy ) . As a more stable alternative , we consider adaptively thresholding the objective by the average entropy across output pixels . We calculate the mean entropy at each iteration , and only take the gradient of pixels with above-average entropy . This mildly improves accuracy . Our final objective is then : L ( Ŷ ) = ∑ i , j∈S Hi , j ( Ŷ ) for S = { i , j : Hi , j > Hµ } ( 2 ) where S is the set of pixels with entropy above the average Hµ . At each step , we re-calculate the average entropy and re-select the set of violating pixels . In this way , optimization is focused on updating predictions where the model is the most uncertain . 2.2 VARIABLES : TASK AND STRUCTURE PARAMETERS . We need to pick the variables to optimize over so that there are enough degrees of freedom to adapt , but not so many that overfitting sets in . Furthermore , computation time and memory demand a minimal set of variables for efficiency . Choosing parameters in the deepest layers of the network satisfy these needs : capacity is constrained by keeping most of the model fixed , and computation is reduced by only updating a few layers . The alterantive of choosing all the parameters , and optimizing end-to-end during inference , is ineffective and inefficient : inference is slower and less accurate than feedforward prediction . We select the task parameters θscore of the output classification filter , for mapping from features to classes , and the structure parameters θscale of the scale regression filter , for mapping from features to receptive field scales . Optimizing over these parameters indirectly optimizes over the local predictions for classification scores Ŷ and scales Σ̂ . Why indirectly optimize the outputs and scales via these parameters , instead of direct optimization ? First , dimensionality is reduced for regularization and efficiency : the parameters are shared across the local predictions for the input image and have fixed dimension . Additionally , this preserves dependence on the data : optimizing directly over the classification predictions admits degenerate solutions that are independent of the input . 2.3 ALGORITHM : INITIALIZATION , ITERATION , AND TERMINATION . Initialization The unaltered forward pass of the base network gives scores Ŷ ( 0 ) and scales Σ̂ ( 0 ) . Iteration For each step t , the loss is the sum of thresholded entropies of the pixel-wise predictions Ŷ ( t ) . The gradient of the loss is taken for the parameters θ ( t ) score and θ ( t ) scale . The optimizer then updates both to yield θ ( t+1 ) score and θ ( t+1 ) scale . Given the new parameters , a partial forward pass re-infers the local scales and predictions for Ŷ ( t+1 ) and Σ̂ ( t+1 ) . This efficient computation is a small fraction of the initialization forward pass . Termination The number of iterations is set and fixed to control the amount of inference computation . We do so for simplicity , but note that in principle convergence rules such as relative tolerance could be used with the loss , output , or parameter changes each iteration for further adaptivity . Figure 3 shows the progress of our inference optimization across iterations . 3 EXPERIMENTS . We experiment with extending from predictive to iterative dynamic inference for semantic segmentation , because this task has a high degree of appearance and scale variation . In particular , we show results for iterative optimization of classifier and scale parameters in a dynamic Gaussian receptive field model ( Shelhamer et al. , 2019 ) on the PASCAL VOC ( Everingham et al. , 2010 ) dataset . By adapting both task and structure parameters , our approach improves accuracy on in-distribution inputs and generalizes better on out-of-distribution scale shifts . We ablate which variables to optimize and for how many steps , and analyze our choices by oracle and adversary results . These experiments establish the efficacy of entropy minimization during inference for scale adaptation , while oracle results show opportunity for further progress . Data and Metric PASCAL VOC ( Everingham et al. , 2010 ) is a well-established semantic segmentation benchmark with 20 semantic classes and a background class . The original dataset only has 1,464 , 1,449 and 1,456 images with segmentation annotations for training , validation , and testing , respectively . As is standard practice , we include the additional 9,118 images and annotations from Hariharan et al . ( 2011 ) , giving 10,582 training samples in total . We measure accuracy by the usual metric of mean intersection-over-union ( IoU ) . We report our results on the validation set . Architecture We choose deep layer aggregation ( DLA ) ( Yu et al. , 2018 ) as a strong , representative fully convolutional network ( Shelhamer et al. , 2017 ) architecture . DLA exploits the feature pyramid inside the network via iterative and hierarchical aggregation across layers . We will release code and the reference models implemented in PyTorch ( Paszke et al. , 2017 ) . Training We train our model on the original scale of the dataset . We optimize via stochastic gradient descent ( SGD ) with batch size 64 , initial learning rate 0.01 , momentum 0.9 , and weight decay 0.0001 for 500 epochs . We use the “ poly ” learning rate schedule ( Chen et al. , 2018 ) with power 0.9 . For the model with no data augmentation ( “ w/o aug ” ) , the input images are padded to 512× 512 . As for the “ w/ aug ” model , data augmentation includes ( 1 ) cropping to 512× 512 , ( 2 ) scaling in [ 0.5 , 2 ] , ( 3 ) rotation in [ −10◦ , 10◦ ] , ( 4 ) color distortion ( Howard , 2013 ) , and ( 5 ) horizontal flipping . Testing We test our model on different scales of the dataset in the [ 1.5 , 4.0 ] range . We optimize the model parameters for adaptation via Adam ( Kingma & Ba , 2015 ) , batching all image pixels together , and setting the learning rate to 0.001 . The model is optimized episodically to each input , and the parameters are reset between inputs . No data augmentation is used during inference to isolate the role of dynamic inference by the model .

Summary: The following work proposes a test-time optimization over scales to improve semantic segmentation. Specifically, at test time, they iteratively optimize over the score and scale parameters of Shellhamer et al 2019, where a Gaussian receptive field is used to allow for dynamic scale adaptation of each convolutional layer. They optimize the parameters with respect to an entropy minimization objective. Experiments on PASCAL VOC, reported at multiple scales, demonstrate improvements in IOU over the vanilla architecture.