Introspective Learning : A Two-Stage approach for Inference in Neural Networks

1 INTRODUCTION . Introspection is the act of looking into one ’ s own mind ( Boring , 1953 ) . Classical introspection has its roots in philosophy . Locke ( 1847 ) , the founder of empiricism , held that all human ideas come from experience . This experience is a result of both sensation and reflection . By sensation , one receives passive information using the sensory systems of sight , sound , and touch . Reflection is the objective observation of our own mental operations . Consider the task of differentiating a spoonbill from a flamingo and a crane . This task requires prior knowledge of some differentiating features between the birds . These features include the color and shape of the body , and beak of all birds . We first associate these features with our existing knowledge of birds and make a coarse decision that the given bird is a spoonbill . This is the sensing stage . Reflection involves questioning the coarse decision and asking why the bird can not be a flamingo or crane . If the answers are satisfactory , then an introspective decision that the bird is indeed a spoonbill is made . The observation of this reflection is introspection . In this paper , we adopt this differentiation between sensing and reflection to advocate for two-stage neural network architectures for perception-based applications . We first ground introspection based on existing neural networks . The above-mentioned task of differentiating a spoonbill from a flamingo and crane is provided in Fig . 1 for neural networks A network f ( · ) , is trained on a distribution X to classify data into N classes . The network learns notions about data samples when classifying them . These notions are stored as network weights W . Let yfeat be the logits projected before the final fully connected layer . We denote the final fully connected layer as fL , where L is the layer number . fL−1 is then the layer before the final fully connected layer . Using the weight parameters WL , the output of the network ŷ is given by , yfeat = fL−1 ( x ) , ∀yfeat ∈ < N×1 , ŷ = arg max ( WTL yfeat ) , ∀WL ∈ < dL−1×N , fL−1 ( x ) ∈ < dL−1×1 . ( 1 ) Hence , ŷ is the class in which the sensed features maximally correlate with the stored notion . This is the feed-forward prediction in Fig . 1 . Existing recognition architectures including VGG ( Simonyan & Zisserman , 2015 ) , ResNet ( He et al. , 2016 ) , and DenseNet ( Huang et al. , 2017 ) among others all sense and predict using Eq.1 . In Fig . 1 , we depict our proposed introspective learning framework . An additional reflection stage extracts the introspective features as Not Detect features from x . Let r1 and r2 be the two introspective features . In this case , r1 is the absence of the S-shaped neck in the spoonbill . And r2 is the lack of white feathers in the given input image . We use a post-hoc visual explanation to depict these features1 . Note that there can be N such features for a sensing network f ( · ) trained to differentiate between N classes . These features are then combined to obtain the final introspective feature rx . rx is characteristic of the input image x and is passed through an introspective network , H ( · ) , to obtain the introspective prediction ỹ . We term the combination of both f ( · ) andH ( · ) as introspective learning . Note that the proposed reflection stage does not require a predefined knowledge base of introspective features . Rather , ri , i ∈ [ 1 , N ] in the reflection stage , is extracted using the feed-forward prediction ŷ and the sensing network parameters . Hence , ri are Not Detect features based on f ( · ) ’ s notion of classes . H ( rx ) predicts ỹ explicitly based on the differences between f ( · ) ’ s notion of classes . Not only should the network sense the feed-forward patterns , it must also satisfy H ( · ) ’ s N notions of differences . In this paper , we show that the inference process is more generalizable due to these N additional inferential constraints . Specifically , the introspective network is more robust to noise and is less prone to calibration errors . The challenge is to implicitly extract features that answer introspective questions without explicitly training on said questions as is the norm in Visual Question Answering applications ( Antol et al. , 2015 ) . We show that gradients w.r.t network parameters store notions about the difference between classes and can be used as introspective features . We first describe the methodology of introspective feature extraction in Section 2 . We then analyzeH ( · ) in Section . 3 . We show thatH ( · ) as a simple multi-layer perceptron that introspects on ŷ is more generalizable for the application of recognition in Section 5 . We then illustrate the benefits of our two-stage architecture in other downstream tasks including out-of-distribution detection , active learning and image quality assessment in Section 6 . 2 INTROSPECTIVE FEATURES . In this section , we describe introspective features and implicitly extract them using the sensing network . We then analyze their extraction procedure and provide a methodology to accelerate it . Definition 2.1 ( Introspection ) . Given a network f ( · ) , a datum x , and the network ’ s prediction f ( x ) = ŷ , introspection in f ( · ) is the measurement of change induced in the network parameters when a label yI is introduced as the label for x . This measurement is the gradient induced by a loss function J ( yI , ŷ ) , w.r.t . the network parameters . This definition for introspection is in accordance with the sensing and reflection stages in Fig . 1 . The network ’ s prediction ŷ is the output of the sensing stage and the change induced by an introspective label , yI , is the network reflecting on its decision ŷ as opposed to yI . Combination of the two is introspection . Note that introspection can occur when ŷ is contrasted against any trained label yI , I ∈ [ 1 , N ] . For instance , in Fig . 1 , the network is asked to reflect on its decision of spoonbill by considering other yI that x can take - flamingo and crane . 1post-hoc explanations are justifications made by a neural network after a decision has been made . They require human interpretation . Further details are provided in Appendix A . Reflection is the empirical risk that the network has predicted x as ŷ instead of yI . Given the network parameters , this risk is measured through some loss function J ( yI , ŷ ) . yI is a one-hot vector with a one at the Ith location . The change that is induced in the network is given by the gradient of J ( yI , ŷ ) w.r.t . the network parameters . In this paper , we introspect based on reflecting on all possible classes . For an N -class classifier , there are N possible introspective classes and hence N possible gradients each given by , rI = ∇WJ ( yI , ŷ ) , I ∈ [ 1 , N ] . Here , rI are the introspective features . Since we introspect based on classes , we measure the change in network weights in the final fully connected layer . Hence the introspective features are given by , rI = ∇WLJ ( yI , ŷ ) , I ∈ [ 1 , N ] , rI ∈ < dL−1×N ( 2 ) where WL are the network weights for the final fully connected layer . Note that the final fully connected layer from Eq . 1 has a dimensionality of < dL−1×N . For every x , Eq . 2 is applied N times to obtain N separate rI . We first analyze these features before accelerating their extraction . 2.1 INTROSPECTIVE FEATURE ANALYSIS . Consider the extraction process in Eq . 2 . Each rI is a dL−1 ×N matrix . Expressing gradients in rI separately w.r.t . the different filters in WL , we have a row-wise concatenated set of gradients given by , rI = [ ∇WL,1J ( yI , ŷ ) ; ∇WL,2J ( yI , ŷ ) ; ∇WL,3J ( yI , ŷ ) . . .∇WL , NJ ( yI , ŷ ) ] ( 3 ) where each WL , j ∈ < dL−1×1 and rI ∈ < dL−1×N 2 . For all data x ∈ X the following lemma holds : Lemma 1 . Given a unique ordered pair ( x , ŷ ) and a trained network f ( · ) , the gradients for a loss function J ( yI , ŷ ) w.r.t . classes are pairwise orthogonal under the second-order Taylor series approximation , each class paired with the predicted class . Proof . Provided in Appendix B.1 . Lemma 1 states that backpropagating class yI does not provide any information to WL , j , j 6= I and hence there is no need to use ∇WL , jJ ( yj , ŷ ) , j 6= i as features when considering yI . In Appendix B.1 , we provide the complete proof when J ( yi , ŷ ) is the cross entropy loss . ∇WJ ( yI , ŷ ) for an introspective class reduces to , ∇WJ ( yI , ŷ ) = −∇W yI +∇W log ( y2ŷ 2 ) . ( 4 ) where yŷ is the logit associated with the predicted class . In Fig . 5 , we use a network trained on MNIST ( LeCun et al. , 1998 ) dataset to simulate a well-trained network and we visualize the gradients from the final fully connected layer to demonstrate Eq . 4 . Eq . 4 motivates the generalizable nature of our introspective features . Consider some noise added to x . To change the prediction ŷ , the noise must sufficiently decrease yŷ from Eq . 4 and increase the closest logit value , yI , to change the prediction . However , by constraining our final prediction ỹ from Fig . 1 on N such Eq . 4 , the noise needs to change the orthogonal relationship between N pairwise logits . This motivates a functionH ( · ) that is conditioned on N such pairwise logits . In Section . 5 , we empirically show the robustness of our feature set . 2.2 INTROSPECTIVE FEATURE EXTRACTION . From Lemma 1 , the introspective feature is only dependent on the predicted class ŷ and the introspective class yI making their span orthogonal to all other gradients . Hence rI = ∇WL , IJ ( yI , ŷ ) , I ∈ [ 1 , N ] , rI ∈ < dL−1×1 ( 5 ) Compare Eq . 5 against the introspective feature from Eq . 2 . Assuming that forward and backward passes through the final layer fL ( · ) are each ofO ( 1 ) time complexity , the feed-forward prediction for a given x is O ( 1 ) time complex . Given that f ( · ) is trained to classify between N classes , extracting N introspective features require N backpropagations and hence is O ( N ) complex . Each rI in Eq . 2 has a dimenisonality dL−1×N . Hence forN features , the space complexity isO ( N2×dL−1 ) . From Lemma 1 , the introspective feature is only dependent on the predicted class ŷ and the introspective class yI making their span orthogonal to all other gradients . For N introspective features in Eq . 5 , the space complexity of rI reduces from O ( dL−1 ×N2 ) to O ( dL−1 ×N ) . Note that the bottleneck in time complexity for N gradient extractions are the serial N backpropagations in Eq . 3 . Building on Lemma 1 , we present the following theorem . Theorem 1 . Given a unique ordered pair ( x , ŷ ) and a trained network f ( · ) , the gradients for a loss function J ( yI , f ( x ) ) , I ∈ [ 1 , N ] w.r.t . classes when yI are N orthogonal one-hot vectors is equivalent to when yI is a vector of all ones , under the second-order Taylor series approximation . Proof . Provided in Appendix B.2 . The proof follows Lemma 1 . Theorem 1 states that backpropagating a vector of all ones ( 1N ) is equivalent to backpropagating N one-hot vectors with ones at orthogonal positions . This reduces the time complexity from O ( N ) to a constant O ( 1 ) since we only require a single pass to backpropagate 1N . Hence , our introspective feature is given by , rx = ∇WLJ ( 1N , ŷ ) , rx ∈ < dL−1×N , 1N = 1N×1 ( 6 ) Note the LHS is now rx instead of rI from Eq . 5 . The final introspective feature is a matrix of the same size as WL extracted in O ( 1 ) with a space complexity of O ( dL−1 ×N ) . rx is vectorized and scaled between [ −1 , 1 ] before being used in Sections 5 and 6 as introspective features .

Summary: The authors present a novel 2-stage technique to improve the classification accuracy of feedforward ANNs.  In particular, after the feedforward pass, a so-called introspective stage occurs, the goal of which is to ascertain why the particular class label was provided rather than a different label.  This stage, which tends to improve the accuracy of the class predictions, is modular and can be added onto networks under varying task conditions.