<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>Unsupervised Adaptation of Spiking Networks in a Gradual Changing Environment</title></titleStmt>
			<publicationStmt>
				<publisher></publisher>
				<date>09/19/2022</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10451182</idno>
					<idno type="doi">10.1109/HPEC55821.2022.9926367</idno>
					<title level='j'>IEEE High Performance Extreme Computing Conference (HPEC)</title>
<idno></idno>
<biblScope unit="volume"></biblScope>
<biblScope unit="issue"></biblScope>					

					<author>Zaidao Mei</author><author>Mark Barnell</author><author>Qinru Qiu</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[Spiking neural networks(SNNs) have drawn broad research interests in recent years due to their high energy efficiency and biologically-plausibility. They have proven to be competitive in many machine learning tasks. Similar to all Artificial Neural Network(ANNs) machine learning models, the SNNs rely on the assumption that the training and testingdata are drawn from the same distribution. As the environment changes gradually, the input distribution will shift over time, and the performance of SNNs turns out to be brittle. To this end, we propose a unified framework that can adapt nonstationary streaming data by exploiting unlabeled intermediate domain, and fits with the in-hardware SNN learning algorithm Error-modulated STDP. Specifically, we propose a unique self training framework to generate pseudo labels to retrain the model for intermediate and target domains. In addition, we develop an online-normalization method with an auxiliary neuron to normalize the output of the hidden layers. By combining the normalization with self-training, our approach gains average classification improvements over 10% on MNIST, NMINST, and two other datasets.]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head>I. INTRODUCTION</head><p>Spiking neural networks(SNNs) on neuromorphic hardware has become a promising machine learning technique as it mimics the behavior of the human's biological neural systems <ref type="bibr">[1]</ref> in both spatial and temporal dynamics. Due to the sparse activities and event driven operation, SNNs is highly energy efficient when implemented in hardware. In recent studies, SNNs on neuromorphic hardware have made considerable progress in general machine learning tasks such as computer vision <ref type="bibr">[2]</ref>, object detection <ref type="bibr">[3]</ref> and speech recognition <ref type="bibr">[1]</ref>.</p><p>In dynamically changing and non-stationary environments, distribution shift is an inevitable problem <ref type="bibr">[4]</ref>. Such shift can be found in the operations of many autonomous edge devices that interact with physical world through sensors, where the input data distribution may alter slowly due to changes in the physical environment and sensor conditions, such as the sensor angle change or pixel damage due to aging. The shift of input distribution violates the condition of proper function of neural network models, which requires the testing and training data drawn from the same distribution, and will seriously degrade the model performance. Some existing works mitigate the performance degradation using supervised training <ref type="bibr">[5]</ref> [6] <ref type="bibr">[7]</ref>, by augmenting the training set with sufficient amount of data that cover all possible variations of testing domains. This usually associates with a high cost and unpredictable results as the actual testing environment is hard to anticipate, and annotated data in realworld settings is hard to obtain. Gradual domain adaptation, on the other hand, aims at unsupervised/semi-supervised model adaptation and self-calibration. It takes the advantage of the fact that the domain shift is a slow process. By leveraging unlabeled intermediate domains where subtle changes take place, it incrementally adapts the target model. In particular, given a model trained on limited data from the source domain D 0 , and unlabeled data drawn from the intermediate domain's D i , (1 &#8804; i &#8804; N -1), where i indicates their sequential order of occurrence. Gradual domain adaptation aims to assist the generalization of the pre-trained model when tested on target domain D N . Although the target domain is significantly different from the source domain, the shift takes place gradually, i.e., <ref type="bibr">)</ref>, measures the distance between two distributions and &#1013; is a very small number.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>D(D</head><p>While Domain shift and adaptation is a concern for both ANN and SNN, almost all of the existing works in this area targets at ANN <ref type="bibr">[6]</ref> [8] <ref type="bibr">[9]</ref>. Adaptation of SNNs has its own challenges and considerations. This work discusses unsupervised gradual domain adaption of SNN models. To make sure that the proposed framework supports truly online in-situ adaptation, we build it on top of Error-Mouldated Spike Timing Dependent plasticity <ref type="bibr">[10]</ref>(EMSTDP). EMSTDP is an SNN learning rule that incorporates the idea of difference target propagation <ref type="bibr">[11]</ref>. It updates the local weight with the difference between "target spikes" and the "propagated spikes". The simple weight update rule enables EMSTDP to be implemented on low power neuromorphic hardware such as Loihi <ref type="bibr">[12]</ref>.</p><p>We present a self-supervised framework. Our framework consists of a feature extractor that is trained on the source domain D 0 , and two "swapping" classifiers with different architecture, one of them will serve as the "teacher" model to generate pseudo labels, and the other serves as the "student" model trained with unlabeled input data and their corresponding pseudo labels in every self-training episode. The classifiers will exchange their roles once finishing a selftraining episode. Although domain adaptation using teacherstudent models has been studied for ANNs in <ref type="bibr">[13]</ref>, the spiking domain inference and online learning impose extra challenges. This paper discusses techniques that are necessary to mitigate those challenges, such as "swapping" teacher and student models, new label calibration algorithm and novel neuron circuits for online normalization, etc. Our contributions are summarized as follows:</p><p>&#8226; We present a self-training framework based on EMSTDP learning for Spiking Neural Networks to realize gradual domain generalization.</p><p>&#8226; We have demonstrated that techniques such as label calibration, online neuron normalization are necessary to regularize the firing activities of neurons for better adaptation.</p><p>&#8226; We test our approach on 4 different datasets. The results show that the gradual domain adaptation can enhance the robustness of the SNN model and improve the classification accuracy by over 10% on average.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>II. BACKGROUNDS</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>A. Spiking neurons and Error-modulated STDP learning</head><p>Different learning algorithms of SNNs have been explored. The majority of them are based on Backpropagation-Through-Time(BPTT) <ref type="bibr">[14]</ref> [15], they adopt similar neural network topology as traditional artificial neural networks(ANNs), but use surrogate activation functions to replace the nondifferentiable spike function. Another class of SNN learning algorithms are based on spike-timing-dependent plasticity (STDP) <ref type="bibr">[16]</ref>  <ref type="bibr">[17]</ref>, which is a local learning rule. According to the STDP rule, the change of the synaptic weight is determined by the timing of pre-synaptic and post-synaptic spikes, both of which can be obtained in a single neuron locally.</p><p>We use Error-modulated STDP (EMSTDP) <ref type="bibr">[10]</ref> as our learning rule. The neurons adopt integrate and fire model specified by the following equations:</p><p>where u l i (t) denotes the membrane potential of the ith neuron in layer l at time t, s l-1 j (t) is input at time t, w ji is the synaptic weight between the pre-synaptic neuron j in layer l -1, and the post-synaptic neuron i in layer l, b l i here denotes the bias. Equation 2 gives the Heaviside step activation functions. A spike will be generated once the membrane potential u l i (t) exceeds the threshold V th .</p><p>An SNN with EMSTDP learning consists of two networks, a feedforward network that performs the inference and learning, and a feedback network that propagate back errors (i.e., gradients). Feedback alignment is adopted, such that the two networks do not need to keep the same copy of weights. A set of random weight, B, is used in the feedback network. The error propagated in the feedback network is calculated as the following: e l i = j e l+1 j B i,j h &#8242; i (u l i ) where e l+1 j is the error of neuron j in layer l + 1 and h &#8242; i (u l i ) is the derivative of the output activation function of neuron i in layer l. The Heaviside step activation is not differentiable, gradient surrogation has to be adopted. Given that the relationship between the number of output spikes and neuron's accumulated sub-membrane potential can be approximated as a shifted ReLU function, h(u i ) = max( ui vth -1, 0), EMSTDP replaces h &#8242; i using the following equation:</p><p>The EMSTDP operates in two phases, free running phase and error correction phase. In the free running phase, the feedforward network makes prediction,h l j ,based on the received input. In the error correction phase, the prediction is compared with the target and the feedback network calculates errors for each layer. The error is then sent to the feedforward network to correct the prediction and generate the new prediction &#293;l i , where &#293;l</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>B. Gradual domain adaptation</head><p>The preliminary of gradual domain adaptation is that one has access to the source domain D 0 := {X 0 , Y 0 } with input x 0 and its label y 0 , where x 0 &#8712; X 0 , y 0 &#8712; Y 0 . The knowledge learned from the source domain must be applied to the target domain D N , which is notably different from the source domain, i.e., D(D N , D 0 ) &#8811; &#1013;, where &#1013; is a very small number. Due to the discrepancy between source and target domain, applying the model trained on source domain to target domain can cause severe accuracy degradation. The transition from the source domain to the target domain is gradual. A sequence of intermediate domains,</p><p>Both the intermediate domains and the target domain are unlabeled. Our goal is to adapt the knowledge learned in the source domain and apply it to the target domain during testing time by utilizing the unlabeled intermediate domains from the slow transition process. To address above issues, several ANN works investigate gradual domain adaptation <ref type="bibr">[8]</ref> [18] <ref type="bibr">[9]</ref>. The most relevant existing work in spiking domain is <ref type="bibr">[7]</ref>, which deploys transfer learning to SNN. However, <ref type="bibr">[7]</ref> requires labeled training data from the target domain, while we consider more realistic case where both target and intermediate domains are unlabeled.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>III. METHODS</head><p>We propose a self-training framework for gradual domain adaptation with a focus on its unique characteristics designed In most ANN self-training frameworks, the same network f (x; &#952;) is used as both teacher and student models in every self-training iteration, and the student model is adapted directly from the teacher model. However, the same strategy gives poorl results in SNN based implementation. Due to the similarity between the adjacent intermediate domains, each pair of teacher and student models are very similar. Which means the learning process operates on small error signals and low gradients all the time. With spike domain learning, the error signals e and the learning gradients must be represented using spiking activities, hence are highly quantized. When the values of error signal and gradients are too low, the rounding error will be more significant than the signal itself and cause the model to update inaccurately. In contrast to the conventional approach, we utilize networks with slightly different architectures as teacher and student models, and swap them for different intermediate domains, so that we can get sufficiently large error and gradient to keep the learning going on.</p><p>Specifically, our self-training framework consists of a convolutional spiking neural network G ( &#8226;; &#934;), which serves as a feature extractor and two 3-layer EMSTDP classifiers f a (&#8226;; &#952; i ) </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>B. Label calibration and Sharpening</head><p>The motivation behind label filtering is to filter noisy labels based on the confidence score <ref type="bibr">[9,</ref><ref type="bibr">26]</ref>. The confidence score is defined as the entropy of the classification output and is specified by <ref type="bibr">(5)</ref>, where h i denotes the spike count of the output neuron corresponding to output layer, and N is the size of output layer. A high enytropy means high uncertainty and low confidence. The label and its associated input will be discarded if the confidence score exceeds the threshold. We set the entropy threshold to 0.7 in this paper.</p><p>Instead of directly using the output of the teacher model as the target, we perform label sharpening to amplify error(gradient) for learning. Given the pseudo label t = arg max i h i , the target sequence of output neuron t is a spiking sequence with rate 1 and the target of all other neurons is expected to have no spikes. We further reduce the spiking threshold of error neurons in the feedback path to make them Algorithm 1 Self-training framework  Batch normalization is a go-to tool for training traditional ANNs and it mitigates covariance shifts of the inputs. As stated in <ref type="bibr">[8]</ref> the batch normalization also improves the performance of gradual domain adaptation. Several spiking-based batch normalization methods have been proposed recently, for example, <ref type="bibr">[19]</ref>   Time (BNTT) to every convolutional layer along the time axis with a given batch. More specifically, BNTT directly normalizes j w ij s t j in every time step within a batch. However, batch normalization is hardware expensive as it requires extra memories to store neuron's activities for the entire batch. Furthermore, it is not compatible with online learning , where batch size is set to 1. To solve this problem, we propose an online normalization technique that whitens the firing rates of a given layer for EMTDP.</p><p>The proposed online normalization has an auxiliary neuronbased normalization is inspired by NeuNorm network <ref type="bibr">[20]</ref>. The dynamics of the auxiliary neuron is stated in Eq.6, where x t+1,n is the membrane potential of the auxiliary neuron x at time step t + 1 for layer n, &#945; is the hyper coefficient of time constant, H is the number of neurons in layer n and s t+1,n j is the output spike at time t + 1 in layer n. In short, the membrane potential x t+1,n is a leaky integration of all the spiking activities of layer n. Eq.7 describes how the auxiliary neuron affects the neurons in the subsequent layer, where U n+1,t i is the membrane potential of the ith neuron in the (n + 1)th layer, g(&#8226;) is the Heaviside step function, which transforms auxiliary neuron's membrane potential to discrete spikes. C i is a trainable negative parameter. Intuitively, the auxiliary neuron can be regarded as a dynamic bias that regulates the spiking dynamics from the previous layer to the next layer. If the firing rate of the previous layer is too high, then the auxiliary neuron will assist to decrease the membrane potential and vice versa. Consequently, the auxiliary neuron normalizes the firing activity of the next layer by using the feature-wise statistics.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>IV. EXPERIMENT SETTINGS</head><p>We tested the proposed framework on both neuromorphic datasets (neuromorphic MNIST) and static datasets (MNIST, Potraits, and Fashion MNIST). For each dataset, parametric non-linear transformation is applied to the data to emulate domain shifting. By controlling the parameters in transformation, we generate different intermediate and target domains.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>A. MNIST dataset</head><p>MNIST <ref type="bibr">[21]</ref> is a popular dataset for classification task, it consists of handwritten digits from zero to nine. Two variations of MNIST dataset are generated to represent different domain shifts. 2) Cropped MNIST: In cropped MNIST dataset, we randomly set the pixels of images to 0 to emulate inputs from an aging camera with dead pixels. The partition of the source, intermediate, and target domains is the same as the Rotated MNST. The intermediate domains contain images with the ratio of dead pixels increasing from 0% to 60%. The target domain consists of images that have 60% dead pixels.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>B. MNIST</head><p>Fashion MNIST <ref type="bibr">[22]</ref> is a more complex dataset comprising of 28 &#215; 28 grayscale images of 70, 000 fashion products from 10 categories. We further generate rotated version where the setting is similar to Rotated MNIST, 20000 samples are chosen as the source domain, 50000 samples as the intermediate domains, which are also split into 5 runs. The target domain consists of 10000 30-degree rotated samples.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>C. N-MNIST dataset</head><p>The Neuromorphic-MNIST(N-MNIST) <ref type="bibr">[23]</ref> converts static MNIST images to 3 saccades by using the DVS camera. The first saccade starts from the first 105 ms (0-105 ms), the second saccade in the next 105 ms (105-210 ms), and the third saccade in the subsequent 105ms. To process this eventbased data, we rotate the sampled frames up to 30 degrees. The domain settings of Rotated N-MNIST are the same as Rotated MNIST, and the event based data transformation is the same as Rotated MNIST.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>D. Potraits</head><p>The portraits dataset <ref type="bibr">[24]</ref> consists of photos of high school students with different haircuts and facial features across decades. The hair cut and facial features of those people varies from time. For this dataset, we adopt settings from <ref type="bibr">[8]</ref>, where they build a binary classifier to classify genders of given images across ages. The source and target domains consist of 2000 images while the intermediate domains have 14000 images that are split into 5 runs.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>V. EXPERIMENTAL RESULT A. Training Details</head><p>The network comprises of 3 spiking convolutional layers <ref type="bibr">[25]</ref> for feature extraction and two fully connected layers for   </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>B. Results Analysis</head><p>we compare the classifiers with gradual domain adaptation to models without domain adaptation. We also compare gradual domain adaptation with target domain adaptation where model directly retrains on the target domain. Finally, we also list the accuracy of a model that is trained on the target domain with labels which is referred as oracle. Obviously, the oracle sets the upper bound of the accuracy of the domain adaptation. Table <ref type="table">II</ref> lists the accuracy of the gradual domain adaptation and three baseline models for the 5 datasets. We can see that our self-trained gradual domain adaptation model outperforms both the baseline models on all datasets. For Rotated MNIST dataset, it boosts accuracy for over 10%. Compared to the model without adaptation, the self-training with gradual domain adaptation improves the accuracy by more than 5% on every dataset. The result also indicates that our self-training approach can achieve competitive accuracy as the oracle model, which is trained supervisly on the target domain. The results in Table II demonstrate that the model is able to adapt to the shifted data distribution in the target domain.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>C. Ablation study</head><p>We further evaluate the impact of different enhancement techniques on the self-trained gradual domain adaptation.</p><p>Table <ref type="table">I</ref> shows the impact of using different teacher and student models. As we can see, compared to the baseline  where the same SNN architecture is used for both teacher and student, our approach improves accuracy by 3.3% to 16.3% Table <ref type="table">III</ref> compares the accuracy of self-training with and without online normalization. As we can see, using online normalization improves the accuracy by 1.47% on average over 5 datasets. Table <ref type="table">IV compares</ref>  </p></div></body>
		</text>
</TEI>
