{'fraction_non_alphanumeric': 0.034881972635693884, 'fraction_numerical': 0.008682904826341903, 'mean_word_length': 5.017869260348338, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Local Competition and Uncertainty for Adversarial Robustness in Deep Learning

This work attempts to address adversarial robustness of deep networks by means of novel learning arguments. Specifically, inspired from results in neuroscience, we propose a local competition principle as a means of adversarially-robust deep learning. We argue that novel local winner-takes-all (LWTA) nonlinearities, combined with posterior sampling schemes, can greatly improve the adversarial robustness of traditional deep networks against difficult adversarial attack schemes. We combine these LWTA arguments with tools from the field of Bayesian non-parametrics, specifically the stick-breaking construction of the Indian Buffet Process, to flexibly account for the inherent uncertainty in data-driven modeling. As we experimentally show, the new proposed model achieves high robustness to adversarial perturbations on MNIST and CIFAR10 datasets. Our model achieves state-of-the-art results in powerful white-box attacks, while at the same time retaining its benign accuracy to a high degree. Equally importantly, our approach achieves this result while requiring far less trainable model parameters than the existing state-of-the-art.


Introduction
In recent years, Deep Neural Networks (DNNs) have provided a variety of breakthroughs in numerous applications, especially in the Computer Vision Community, e.g., [18,42,3]. However, it is a wellknown fact, that DNNs are highly susceptible to adversarial attacks. In the adversarial context, adversarial examples, i.e., inputs comprising carefully design perturbations, aim to "fool" the considered model into misclassification. Even small perturbations in the original input, e.g. an L p norm, can successfully render the model vulnerable, highlighting the frailness of the commonly employed DNN approaches in more demanding tasks [35]. It is apparent, that this vulnerability, restricts their safe and confident employment in safety-critical applications, such as, autonomous driving [4,8,27], video recognition [21], healthcare [13] and other real-world scenarios [27]. To this end, significant research effort has been devoted in the Deep Learning community, in order to defend against various kinds of attacks, aspiring to make DNNs more robust to adversarial examples. Several approaches have been proposed to successfully tackle this task; however, each comes with its own disadvantages.
Adversarial attacks, as well as defense strategies, comprise many different approaches, sharing the same goal; making deep architectures more reliable and robust. In general, the adversarial defenses can be categorized as: (i) Adversarial Training, where a model is trained both with the original, as well as perturbed data, aspiring to make the model more robust during inference [32,45,38], (ii) Manifold Projections, where the original data are projected into a different subspace presuming that therein, the effects of the perturbations can be mitigated [19,37,39] (iii) Stochasticity, where some randomization of the input data and/or of the neuronal activations of each hidden layer is performed [36,9,47], and (iv) Preprocessing, where some aspect of either the data or of the neuronal activations are modified or transformed [5,17,22].
However, many of the currently considered approaches and architectures are particularly tailored to tackle a specific attack, restricting their generality to other potential adversarial schemes; thus, it is quite often the case that when the adversarial attack patterns change, the considered models fail completely. In this context, even though the commonly employed non-linearities, such as the Rectified Linear Units (ReLUs), provide a flexible computational tool for efficient training of DNNs, they do not exhibit any useful properties that may address the adversarial scenario; to overcome this deficiency of common neuronal activations, we may need to consider a radically different approach.
Recently, there is a new invigorated interest in DL community in the creation of more biologically plausible models. Indeed, there is an increasing body of evidence in the neuroscience community, that neurons in a biological system with similar functions, are aggregated together in groups and local competition takes place for their activations. Thus, in each block only one neuron can be active at a given time, while the rest are inhibited to silence [23,1,11,41,10,28], leading to a Local-Winner-Takes-All (LWTA) mechanism. Employing this mechanism to neural networks has been shown to provide promising results, introducing the ability to discover effective sparsely distributed representation of their inputs [30,33], while exhibiting automatic gain control, noise suppression and robustness to catastrophic forgetting [40,16,6]. These inherent properties of the competition-based mechanism, render LWTAs a potentially powerful biologically-inspired approach in the adversarial framework.
On the other hand, the inevitable overfitting tendencies of DNNs render them brittle against adversarial attacks; even small perturbations of the input data may easily fool an overfitted model. To this end, significant research effort has been devoted in attacking overfitting, aiming to develop methods in order to account for the uncertainty of the considered architectures. Thus, many regularization methods have been proposed in the literature, e.g., Dropout [14]. In this context, Chatzis [7] presented a novel approach, relying on the sparsity-inducing nonparametric Indian Buffet Process Prior (IBP) [15] in order to regularize the resulting architecture in a data-driven fashion. Using a set of auxiliary Bernoulli random variables, the utility of each architectural component was explicitly modeled, in an on-off fashion, intelligently inferring the necessary network complexity to represent the data. These approaches act as a source of inspiration for effectively addressing the adversarial scenario. We posit that the robustness of the model against adversarial examples may significantly increase, by accounting for the modeling uncertainty, while at the same time exploiting the benefits of the induced regularization.
Drawing upon these insights, we propose a new deep network design scheme that is particularly tailored to address the adversarial context. This capacity is effectuated via the combination of the LWTA mechanism and the nonparametric Bayesian IBP prior, allowing for potently addressing uncertainty. Moreover, we combine our proposed paradigm with Error Correcting Output Codes [46]. We evaluate our approach using well-known benchmark datasets and architectures. The provided empirical evidence vouch for the potency of our approach, yielding state-of-the-art robustness against powerful white-box-attacks.
The remainder of the paper is organized as follows: In Section 2, we introduce the necessary theoretical background. In Section 3, we introduce the proposed approach and describe its integrated IBP and competition-based mechanisms. In Section 4 we perform extensive experimental evaluations, providing insights for the behavior of the produced model, while in Section 5, we summarize the contribution of this work, and discuss potential future directions.

Theoretical Background
In the following, we briefly present both the two core components utilized in this work, namely the nonparametric Indian Buffet Process Prior and the Local Winner-Takes-All mechanism.

Indian Buffet Process
The Indian Buffet Process (IBP) [15] defines a probability distribution over infinite binary matrices. IBP can be used as a flexible prior, allowing the number of considered features to be unbounded and inferred in a data-driven fashion. Its construction, ensures sparsity in the obtained representation, while at the same time allowing for more features to emerge, as new observations appear. Here, we focus on the stick-breaking construction of the IBP proposed by [43], making the IBP amenable to Variational Inference. Let us consider N observations, and a binary matrix Z = [z i,k ] N,K i,k=1 ; each entry therein, indicates the existence of feature k in observation i. Taking the infinite limit K → ∞, we can construct the following hierarchical representation [43]: where α is non-negative parameter, called the strength or innovation parameter, and controls the induced sparsity. In practice, K is set to be equal to the input dimensionality to avoid the overcomplete feature representation when K → ∞.

Local Winner-Takes-All
Even though the commonly employed activations, such as ReLUs, constitute a convenient mathematical tool for training deep neural networks, they do not come with biological plausibility. In the following, we describe the general architecture when locally competing units are employed via the Local Winner-Takes-All (LWTA) mechanism.
Let us assume a single layer of an LWTA-based network comprising K LWTA blocks with U competing units therein. Each block produces an output y k , k = 1, . . . , K given some input x ∈ R N ×J . Each linear unit in each block, computes its activation h u k , u = 1, . . . U , and the output of the each block is decided via competition. Thus, for each block k and unit u therein, the output reads: where g(·) is the competition function. The activation of each individual neuron follows the conventional inner product computation h u k = w T ku x, where W ∈ R J×K×U is the weight matrix in this context. In the rigid LWTA network definition, the final output reads: To bypass the restrictive binary output, more expressive versions of the competition function have been proposed in the literature, e.g., [40]: It is apparent that, only the neuron with the strongest activation produces an output in each block, while the others are inhibited to silence, i.e., the zero value. In this way, the output of each layer of the network yields a sparse representation according to the competition outcome within each block. Both these competition functions are called the hard winner-takes-all function; in case of multiple winners the tie can be broken either by index or randomly. Panousis et al. [34], proposed a novel competition function, based on a competitive random sampling procedure, driven by the activations of each neuron in each block. In our work, we adopt the latter, explained in detail in the following.

Model Definition
In this work, we consider a principled way of designing deep neural networks that are particularly tailored to handle adversarial attacks. To this end, we combine the LWTA approach with appropriate arguments from the nonparametric Bayesian statistics. We aim to provide a more robust approach towards adversarial examples by flexibly accounting for the modeling uncertainty.
Let us assume an input dataset X ∈ R N ×J with N examples, comprising J features each. In conventional deep architectures, each hidden layer comprises nonlinear units; the input is presented to the layer, which then computes an affine transformation via the inner product of the input with weights W ∈ R J×K , producing outputs Y ∈ R N ×K . The described computation for each example n yields y n = σ(x n W + b) ∈ R K , n = 1, . . . , N , where b ∈ R K is a bias factor and σ(·) is a non-linear activation function, e.g. ReLU. An architecture comprises intermediate and output layers. We begin with the definition of an intermediate layer of our approach.
In the LWTA setting, the aforementioned procedure is modified; singular units are replaced by LWTA blocks, each containing a set of competing units. Thus, the layer input is now presented to each different block and each unit therein, via different weights. Assuming K number of LWTA blocks and U number of competing units, the weights are now represented via a three-dimensional matrix W ∈ R J×K×U .
As previously mentioned, we follow [34], where the local competition in each block is performed via a competitive random sampling procedure. Specifically, we define additional discrete latent vectors ξ n ∈ one_hot(U ) K , in order to encode the outcome of the local competition between the units in each block. For each datapoint n, the non-zero entry of the one-hot representation, denotes the winning unit among the U competitors in each of the K blocks of the layer.
To further account for the uncertainty and regularization of the resulting model, we turn to the nonparametric Bayesian framework. Specifically, we introduce a matrix of latent variables Z ∈ {0, 1} J×K , to explicitly regularize the model by inferring the utility of each synaptic weight connection in each layer. Each entry therein is set to one, if the j th dimension of the input is presented to the k th block, otherwise z j,k = 0. We impose the sparsity-inducing IBP prior over the latent variables Z and perform inference over them.
We can now define the output of a layer of the considered model, y n ∈ R K·U , as follows: In order to facilitate a competitive random sampling procedure in a data-driven fashion, the latent indicators ξ n are drawn from a posterior Categorical distribution that reads: The posteriors of the latent variables Z are drawn from Bernoulli posteriors, such that: Consequently, we impose a symmetric Discrete prior over the latent indicators, [ξ n ] k ∼ Discrete(1/U ), while we resort to fixed-point estimation for the weight matrices W . The definition of an intermediate layer of the considered approach is now complete.
For the output layer of our approach, we consider a similar variant based on the conventional feedforward layer. That is, we perform the standard inner product computation, while utilizing the IBP to further account for model uncertainty.
Specifically, we assume an input x ∈ R N ×J to a C-unit output layer with weights W ∈ R J×C . We introduce an analogous auxiliary matrix of latent variables Z ∈ {0, 1} J×C . Thus, the computation for the output y ∈ R N ×C yields: where the posterior latent variable Z are drawn independently from a Bernoulli distribution: The prior for Z, once again follows the SBP of the IBP, while we seek fix-point estimates for the weights. The formulation of the full network architecture is now complete. A graphical illustration of the proposed approach is depicted in Fig. 1a.

Convolutional Layers
In order to accommodate architectures comprising convolutional operations, we adopt the LWTA convolutional variant as defined in [34]. Specifically, let us assume an input tensor {X} N n=1 ∈ R H×L×C at a specific layer, where H, L, C are the height, length and channels of the input. We define a set of kernels, each with weights W k ∈ R h×l×C×U , where h, l, C, U are the kernel height, length, number of channels and competing features maps, and k = 1, . . . K. Thus, analogously to the grouping of linear units in the dense layers, in this case, local competition is performed among feature maps. Each kernel is treated as an LWTA block and each layer comprises multiple kernels competing for their outputs. We additionally consider an analogous auxiliary binary matrix Z ∈ {0, 1} K to further regularize the convolutional layers.
Thus, at a given layer of the corresponding convolutional variant, the output Y n ∈ R H×L×K·U is obtained via concatenation along the last dimension of the subtensors: where X n is the input tensor for the n th datapoint, " " denotes the convolution operation and [ξ n ] k ∈ one_hot(U ) is a one-hot vector representation with U components. Turning to the competition function, we follow the same rationale, such that the sampling procedure is driven from the outputs of the competing feature maps: We impose an IBP prior on Z, while the posteriors are drawn from a Bernoulli distribution, such that, q(z k ) = Bernoulli(z k |π k ). We impose an analogous symmetric prior for the latent winner indicators [ξ n ] k ∼ Discrete(1/U ). A graphical illustration of the defined layer is depicted in Fig. 1b.

Training & Inference
To train the proposed model, we resort to maximization of the Evidence Lower Bound (ELBO). To facilitate efficiency in the resulting procedures, we adopt the Stochastic Gradient Variational Bayes framework (SGVB) [24]. However, our model comprises latent variables that are not readily amenable to the reparameterization trick of SGVB, namely, the discrete latent variables Z and ξ, and the Beta-distributed stick variables u. To this end, we utilize the continuous relaxation based on the Gumbel-Softmax trick [31,20] for the discrete random variables and the Kumarawamy distribution [26] as an approximation to the Beta distribution. These approximations are only employed during training. At inference, we draw samples from the respective original distribution of the latent variables, i.e. the Discrete, Bernoulli and Beta distributions. We employ the mean-field assumption to facilitate efficient optimization.
Differently than similar approaches, the uncertainty modeling of our approach is based on two different sampling processes. On the one hand, contrary to the rigid competition function in the context of competition-based networks presented in [40], we implement a data-driven random sampling procedure to determine the winning units. On the other, we further account for the uncertainty of the learning process by sampling from a Bernoulli latent variable based on an IBP prior. Through the introduced latent variables, we can regularize the model by exploiting the sparsity inducing behavior of the IBP prior and the overall induced regularization via the maximization of the resulting ELBO.

Experimental Evaluation
We evaluate the capacity of our proposed approach against various adversarial attacks and under different setups. We follow the experimental framework as in [46]. To this end, we employ a modified decoding error-correcting output code strategy to the output of the proposed network, as described therein, and we examine the resulting modeling capabilities of an LWTA and IBP based DNN, both in classification accuracy, as well as in the classification confidence levels.

Implementation Details
Let us denote by C an M × N coding matrix, where M is the number of classes and N is the codeword length. Therein, the k th row, denotes the desired output of the network, when the input is from class k; in this work, we consider only cases with N = M or N > M . We employ coding matrices of varying length and explore multiple ways of transforming the logits of the last layer of the network to probabilities, including the Softmax, the Logistic, and the Hyperbolic Tangent Function. Both standard and ensemble architectures are considered [46]. We resort to SGVB for training the model, utilizing the Kumaraswamy ( [26]) and continuous relaxation of the Discrete distribution proposed in [20,31].

Experimental Setup
We consider two popular benchmark datasets for adversarial research, namely, MNIST [29] and CIFAR10 [25]. We employ the same architectures, as in [46], employing both Standard and Ensemble architectures. We consider two different splits for our approach: (i) an architecture comprising LWTA blocks with 2 competing units, and (ii) one with 4 competing units. In the case of ensemble architectures containing layers with less than 4 overall units, we employ a hybrid of our approach using both 2 and 4 way splits. We examine 5 different kinds of adversarial attacks: (i) Projected Gradient Descent (PGD), (ii) Carlini and Wagner (CW), (iii) Blind Spot Attack (BSA) ( [48]), (iv) a random attack (Rand) [46], and (v) an attack comprising additive uniform noise corruption (+U (−1, 1)). See the Supplementary Material for the detailed implementation details and experimental setup.

Experimental Results
In the following, we present the comparative experimental evaluations of our approach. In the provided tables, we select a subset of four different models (as defined in [46]) employing our proposed approach, which we compare with the Madry model [32] and the best-performing TanhEns16 and TanhEns64 models of [46], in order to unclutter the presentation of the experimental results. Detailed presentation of all the considered models and methods is included in the Supplementary.
MNIST. For the MNIST dataset, we train the network for a maximum of 50 epochs, using the same data augmentation as in [46]. In Table 1, the comparative results for each different architecture and adversarial attack are depicted. As we observe, our approach yields considerable improvements over the Madry [32] and TanhEns16 [46] architectures in three of the five considered attacks, while employing architectures with lower computational footprint. The differences in the rest of the experiments are negligible. For example, consider the Softmax model comprising LWTA blocks with 2 competing units and TanhEns16 model, which requires ≈ 20% more parameters. In the benign classification accuracy, we observe a 0.004% difference in favor of TanhEns16, while the Softmax LWTA model exhibits an improvement of 0.055% in the PGD and a significant 15.9% improvement in the uniform corruption noise attack. The empirical evidence suggest that our approach yields better performance than the alternatives, even when employing models with less parameters.  Table 1: Accuracy scores for various models and adversarial attacks on the MNIST dataset. All considered architectures for our approach are the the same as the ones proposed in [46]. Here, we report the best-performing adaptations.

CIFAR-10.
For the CIFAR-10 dataset, we follow an analogous procedure, utilizing the same architectures and procedures as in [46]. In Table 2, the obtained comparative effectiveness of our approach is depicted. In this case, the differences in the computational burden are more evident, since CIFAR-10 requires more involved architectures, considering its inherent complexity both for benign classification, as well as, for adversarial attacks. As in the previous experiments, we observe that our method presents significant improvements in three of the considered adversarial attacks, namely PGD, CW and BSA, utilizing networks with significantly less parameters (even 2 to 4 times) than the best performing alternative of [46].  Table 2: Accuracy scores for various models and adversarial attacks on the CIFAR10 dataset. Once again, we consider all the architectures proposed in [46] and report the best-performing adaptations.

Further Insights
We scrutinize the behavior of the LWTA mechanism in the performed experimental evaluations, in order to gain some insights by examining the resulting competition patterns, and assess that the competition does not collapse to singular "always-winning" units. To this end, we choose a random intermediate layer of a Tanh16 model comprising 8 or 4 LWTA blocks of 2 and 4 competing units respectively, and focus on the CIFAR-10 dataset. The probabilities of unit activations for each class are depicted in Fig. 2. For the former, the probabilities for benign test examples are illustrated in Fig. 2a, while the corresponding probabilities for the PGD method, are presented in Fig.2b. As we observe, the unit activation probabilities for each different setup are essentially the same, suggesting that the LWTA mechanism, succeeds in encoding salient discriminative patterns in the data, while also exhibiting in practice, the inherent property of noise suppression. The empirical evidence suggest that we can obtain networks with strong generalization value, able to defend against adversarial attacks in a principled way. In Fig. 2c and 2d, the corresponding probabilities when employing 4 competing units are depicted. We observe that in this case, the competition is uncertain about the winning unit  Fig. 2a and Fig. 2b,    Finally, we examine the uncertainty estimation capabilities of the introduced approach via the resulting confidence in the classification task. To this end, and similar to [46], we compare the probability distributions of class assignment over a randomly chosen set of test examples of the MNIST dataset for our best performing models with U = 2. Since our approach yields high classification accuracy in the benign case, we expect that the considered models should exhibit high confidence in label assignment. Indeed, we observe the expected behavior in Fig. 3a. Fig. 3b, depicts the models behavior on a PGD attack. We observe that in some cases the models are (correctly) less confident about the class label due to the adversarial perturbations. However, and contrary to [46,32], since our approach retains high classification accuracy, the models assign substantial probability mass in high confidence levels. The empirical evidence suggests, that by employing a careful blend of LWTA activations and the IBP, we can overcome the "irrational" overconfidence of the softmax activation. Softmax incorrectly assigns high confidence to the class with the largest logits, even in the presence of adversarial examples. Thus, we can overcome this flaw, even when employing small length error correcting output codes. Fig. 3c illustrates the resulting behavior in randomly generated inputs. In this case, all models correctly place most of the probability mass in the low spectrum. The experimental results vouch for the efficacy of our approach, flexibly accounting the inherent uncertainty in the adversarial context, thus retaining high classification rate against various attacks. The corresponding graphs for the CIFAR-10 dataset can be found in the Supplementary.

Conclusions and Future Work
In this paper, we proposed a novel approach towards adversarial robustness in deep networks, aiming to create networks that exhibit more robust and reliable behavior to white-box adversarial attacks. To this end, we utilized local competition between linear units, in the form of the Local-Winner-Takes-All mechanism, combined with the sparsity inducing IBP prior in order to account for the uncertainty and regularize the learning process. Our experimental evaluations have provided strong empirical evidence for the efficacy of our approach. The proposed method exhibits considerable improvements in various kinds of adversarial attacks, while retaining high accuracy in the benign context. It is noteworthy, that the competition mechanism yielded very similar competition patterns for benign and adversarial examples, suggesting that the considered approach succeeds in encoding differential essential sub-distributions of the data through specialization. In our future work, we aim to explore the potency of the LWTA and IBP integration in other challenging adversarial scenarios.