# Training Spiking Neural Networks with Metaheuristic Algorithms
## 4 Experimental Results and Evaluation
### Liver  
The Liver dataset contains 345 samples belonging to two classes. It includes six quantitative variables. The dataset was divided into two parts, training and test datasets, with 200 and 145 samples, respectively. The dataset was encoded into spikes over simulation times. All the experiments and performance analyses were programmed in Python. This was run on an Intel corei7 CPU 1.60 GHz processor with 16 GB RAM. In this experiment, the threshold of all neurons in all layers was set to 100. We set the maximum simulation time as \(t_{max}=256\) and initialized the synaptic weights with random values drawn from uniform distributions in the range [0, 1]. There were also specific parameters associated with each metaheuristic algorithm, as presented in Table 3. We tested various values for each parameter and selected the one that led to the highest accuracy. Each algorithm was tested for 20 iterations. In this work, we present a metaheuristic-based supervised learning method for SNNs, as shown in Figure 5. The following sequential steps describe the learning procedure of the proposed method:  
1. The first step is to transform the analog input into a spike train. Here, we used temporal coding for the entry layer. These spikes are then fed to the first layer of the network, where the IF neuron receives incoming spikes through synaptic weights and emits a spike to the neurons in the next layer when it reaches the threshold \begin{table}
\begin{tabular}{c c} \hline
**Algorithm** & **Parameters** \\ \hline GA & Epoch = 20, Population size = 100, Crossover rate = 0.6, Mutation rate = 0.05 \\ DE & F = 0.9, CR = 0.8 \\ PSO & \(V_{max}=4\), \(V_{min}=-4\), \(c_{1}\) and \(c_{2}=2\), \(X_{max}=10\), \(X_{min}=-10\) \\ CS & Pa = 0.25, \(X_{max}=10\), \(X_{min}=-10\) \\ HS & Par = 0.4, \(HMCR=0.9\), \(BW=0.01\) \\ ABC & Population size = 100, MCN = 20, LIM = 100 \\ GE & Population size = 100, Boundaries \(\in\) [0, 255] \\ \hline \end{tabular}
\end{table} 
Table 3: Specific parameters of the metaheuristic algorithms. (Equation (1)). We initialized the input-hidden synaptic weights based on random values in the range \([0,1]\). 2. For the classification task with the N class, each output neuron was assigned to a different class. After the forward pass was completed, the output neuron in the readout layer that fired earlier determined the class of the stimulus. Thus, to be able to train the network in the backward pass, we defined a temporal fitness function for the output layer by comparing its actual firing time and the target firing time (Equation (3)). 3. During the training phase, we used metaheuristic algorithms to update the synaptic weights. The temporal fitness function was considered as the objective function to evaluate each individual. The next step is to calculate the squared error for N classes using Equation (4). This calculated error determines the fitness value of each individual and drives supervised learning based on metaheuristic algorithms. After completing the forward and backward steps on the current input, the membrane potentials of all the IF neurons are reset to zero, and the network gets ready to process the next input. In order to evaluate the performance of the system, after the training phase, the weights were updated, fixed, and the testing datasets were fed into the network so that the classification accuracy of the testing datasets could be calculated. The first output neuron to fire determines the decision of the network. The learning curve of the proposed method is illustrated in Figure 6. It illustrates the changes in the learning accuracy value over 20 iterations. It is clear that, as iterations  
Figure 5: The process of training an SNN using metaheuristic algorithms. increase, all algorithms eventually converge. The learning curve results of the algorithms are displayed in various colors.