# Speed Bump and Pothole Detection Using Deep Neural Network with Images Captured through ZED Camera
## 2 Materials and Methods
### Convolutional Neural Network Architecture  
First, a color image is received from the camera with resolution \(k\times l\times c\) ( \(k=672\) columns, \(l=376\) rows, and \(c=3\) for RGB color index), with 8 bits of resolution for each pixel and the RGB color scheme expressed as:  
\[I(x,y,z)\in 0\leq\mathbb{Z}\leq 255\vee\{x|1\leq x\leq k\},\{y|1\leq y\leq k\}, \{z|1\leq z\leq k\} \tag{1}\]  
where \(I\) is a three-dimensional matrix. The first layer, named \"ImageInputLayer\", creates a data normalization function that subtracts the mean image (\(mean1\)) of the training set (for this case, the maximal \(n\) is 714) from each input image for color images with dimensions of 376 in height, 672 in width, and 3 for color in the RGB format, stored in a (376,672,3) tensor. \[mean1=\frac{(I_{1}+I_{2}+...+I_{n})}{n} \tag{2}\]  
\[I_{n}=I-mean1 \tag{3}\]  
The second layer, \"Convolution2 Dlayer\", is a convolutional layer with 37 convolution filters of width and height 3 \(\times\) 3 (\(f_{1}\), \(f_{2}\),\(\ldots\), \(f_{p=37}\)), with \(stride=1\) and without pooling, but with a padding \(type=\)_\"same\"_ to capture image details and avoid subsampling the scene information, stored in a (376,672,3,37) tensor. \[CONV_{p}(x,y,1)=\sum_{dx=-a}^{a}\sum_{dy=-b}^{b}f_{p}(dx,dy,1)\hat{I}_{n}(x-dy,y-dz,1) \tag{4}\]  
\[CONV_{p}(x,y,2)=\sum_{dx=-a}^{a}\sum_{dy=-b}^{b}f_{p}(dx,dy,2)\hat{I}_{n}(x-dy,y-dz,2) \tag{5}\]  
\[CONV_{p}(x,y,3)=\sum_{dx=-a}^{a}\sum_{dy=-b}^{b}f_{p}(dx,dy,3)\hat{I}_{n}(x-dy,y-dz,3) \tag{6}\]  
where \(f_{p}\) is a convolution window of size \((2a+1)\) by \((2b+1)\). And \(dx\) and \(dy\) are the indices that traverse the window on the \(x\) and \(y\) axes. The third layer, \"batchNormalizationLayer\", normalizes a mini-batch of data across all observations for each feature independently to accelerate training of the convolutional neural network and reduce sensitivity to network initialization. It is recommended to use  
Figure 7: In each four pixels neighborhood of a different color, there are two types of pooling, the one on the left is the one that chooses the maximum and the one on the right is the one that calculates the average. batch normalization layers between convolutional layers and non-linearities, as in our case, where we use a ReLU layer after a convolutional layer, stored in a (376,672,3,37) tensor. \[\hat{C}_{p}(x,y,z)=\frac{CONV_{p}(x,y,z)-\mu_{p}}{\sigma_{p}} \tag{7}\]  
\[\hat{CN}_{p}(x,y,z)=a_{p}\hat{C}_{p}(x,y,z)+\beta_{p} \tag{8}\]  
where \(\mu_{p}\) is the mean, \(\sigma_{p}\) the standard deviation, \(\alpha_{p}\) an amplification parameter, and \(\beta_{p}\) a bias value for each feature. The fourth layer, \"ReluLayer\", is a rectified linear unit (ReLU) that performs a thresholding operation on the input. Values less than zero are set to zero, and values greater than zero remain their value. Compared to the tanh (hyperbolic tangent) and sigmoidal functions, ReLU has no saturation zones. These saturation zones mean that the output of the neurons does not change significantly, which causes the training gradient to not change and network parameters to not undergo significant changes. This generates a stagnation in the training process. That is the reason why the ReLU function has gained relevance in current neural networks, stored in a (376,672,3,37) tensor. \[ReLU(x,y,z)=max(0,\hat{CN}_{p}(x,y,z)) \tag{9}\]  
The fifth layer, \"fullyConnectedLayer\", creates a fully connected neural network with an output size of 3 because it is being classified into that number of classes (\(i=1,2,3\)). The output of the ReLU layer is vectorized (\(vec()\)); that is, the matrix is converted to a vector with all the elements of the matrix, an operation also known as flattening. This layer multiplies its inputs by an array of weights \(W_{i}\) and then adds a bias vector \(b_{i}\); the result is applied to the input of a tansig function. It means that our full connected neural network has 28,046,592 inputs and 3 outputs (28046592,3).