## 2 Neural Network Architecture
### Building Blocks of the Network
#### 2.2.3 First Convolutional Layer (CL1)  
The task of the first convolutional layer (CL1) is to learn and detect the simplest and at the same time the most frequent spike patterns associated with the images of the training set. It consists of 33 VCSELs and its processing area, designated as the Convolutional Window (CW\({}_{1}\)) consists of a 3X3 pixel layout. Each VCSEL in the CL1 layer receives 9 inputs (one for every pixel of the CW\({}_{1}\)), has a dedicated Weight Bank (WB) and it is trained so as to detect a specific pattern (Figure 5). The training of the CL1 layer is based on STDP rule [37]. According to STDP, a neuron (post synaptic) updates its synaptic weights each time it produces a spike event. More specifically, if the neuron fires a spike event at \(t_{1}\), then all the synapses that provided spikes which arrived at the neuron before \(t_{1}\) will have their corresponding synaptic weights increased (Figure 6 PRE\({}_{1}\)). On the contrary, synapses that provided spikes that arrived after \(t_{1}\) will have their corresponding synaptic weights decreased (Figure 6 PRE\({}_{2}\)). Figure 5: Block diagram of the first convolutional layer network during training. A specific area of the image is scanned by the contrast detection layer in order to detect pixels with high contrast (1 for black pixels and 0 for white pixels). After that the generated spikes are synchronized and entered into the neuron-VCSELs. Each neuron has its weight stored in a weight bank. When a neuron detects a pattern (fires a spike) it sends a cancelling signal to all of the following neurons (dashed lines). The update of the synaptic weights is summarized by the following rule  
\[dw = \begin{cases}\exp(dt)&dt<0\\ -\exp(-dt)&dt>0\end{cases}  \tag{4}\]  
where \(dt=t_{X}-t_{1}\) and \(t_{X}\) is the timing of the spike associated with the \(X\)th synapse. After the application of the STDP rule, the new weights will be updated as  
\[w_{(n+1)X} = w_{nX}+dw_{X}a \tag{5}\]  
where \(w_{(n+1)X}\) is the updated weight of the \(X\)th synapse, \(w_{nX}\) is its previous weight value and \(a\) is the learning rate of the training procedure. It is worth mentioning that in our case STDP is implemented numerically, but the unsupervised nature of our scheme alongside the existence of photonic based STDP platforms [38, 41], can provide hardware realizations that can offer on-chip training in near future. After the synchronization stage, the inputs are weighted and inserted in the first neuron of the CL1. If the Input Spike Pattern (ISP) surpasses its neural threshold, then a spike will be produced. The spike event designates the recognition of the ISP by the first neuron and triggers two additional processes. The first one is the reconfiguration of its weight bank according to the STDP training algorithm. Secondly, the first neuron sends an inhibitory (cancelling) signal to all subsequent neurons in order to make them ignore this particular ISP. The cancelling signal lowers the bias of all subsequent neurons, pushing them away from the excitable regime, thus making spiking impossible for them. On the contrary, if the ISP is not recognized by the first neuron, then it is transmitted to the second neuron after \(T_{D}\), which is the time needed for neuron to process the ISP, update its weights and produce the corresponding cancelling signal. The 2 nd neuron then processes the ISP in a similar way as the first one. This process continues until the ISP is recognized by one of the 33 neurons of the CL1. After the ISP processing is completed, the CL1 scans the same CW\({}_{1}\) spatial area of the next image. When all images of the training set have been scanned, the CW\({}_{1}\) window is shifted by one pixel to the right and the whole process is repeated until all images are scanned. Finally, when the training of the CL1 layer is completed, a weight adjustment is needed in order to make the neurons more selective to their learned pattern.