# Hands-On Fundamentals of 1D Convolutional Neural Networks--A Tutorial for Beginner Users
## Appendix A  
In this section, all the derivatives used for backpropagation are calculated by making use of the rule. Let us consider a vector \(y\) of length \(m\), which is calculated by forming the product of a matrix \(A\) with \(m\) rows and \(n\) columns:  
\[ \begin{array}{l}y_{1}=a_{11}x_{1}+a_{12}x_{2}+\ldots+a_{1n}x_{n}\\ y_{2}=a_{21}x_{1}+a_{22}x_{2}+\ldots+a_{2n}x_{n}\\ \vdots\\ y_{m}=a_{m1}x_{1}+a_{m2}x_{2}+\ldots+a_{mn}x_{n}\end{array}  \tag{1}\]  
in other words, each element of the vector \(y\) can be written as follows:  
\[y_{i}=\sum_{j=1}^{n}a_{ij}x_{j}. \tag{2}\]  
The derivative of \(y\) with respect to \(x\) requires calculating the partial derivative of each component of \(y\) with respect to each component of \(x\):  
\[\
abla_{x}y= \begin{bmatrix}\frac{\partial y_{1}}{\partial x_{1}}&\frac{ \partial y_{2}}{\partial x_{1}}&\ldots&\frac{\partial y_{m}}{\partial x_{1}}\\ \frac{\partial y_{1}}{\partial x_{2}}&\frac{\partial y_{2}}{\partial x_{2}}& \ldots&\frac{\partial y_{m}}{\partial x_{2}}\\ \vdots\\ \frac{\partial y_{1}}{\partial x_{n}}&\frac{\partial y_{2}}{\partial x_{n}}& \ldots&\frac{\partial y_{m}}{\partial x_{m}}\\ \end{bmatrix} = \begin{bmatrix}a_{11}&a_{21}&\cdots&a_{m1}\\ a_{12}&a_{22}&\cdots&a_{m2}\\ \vdots\\ a_{1n}&a_{2n}&\cdots&a_{mn}\\ \end{bmatrix} =A^{T}. \tag{3}\]  
The derivative of \(y\) with respect to \(A\) is calculated considering that \(\frac{\partial y_{i}}{\partial a_{jk}}\) vanishes for \(i\
eq j\), we obtain  
\[\
abla_{A}y=x^{T}. \tag{4}\]Let us now consider the vector \(z\) as a function of \(y=Ax\). In this case, the derivative with respect to \(x\) is represented by a vector \(n\times 1\) and can be calculated as follows:  
\[\
abla_{x}z=\
abla_{x}f(Ax)= \begin{bmatrix}\frac{\partial f(Ax)}{\partial x_{1}} \\ \frac{\partial f(Ax)}{\partial x_{2}}\\ \vdots\\ \frac{\partial f(Ax)}{\partial x_{n}}\end{bmatrix} = \begin{bmatrix}\frac{ \partial f(y_{1}y_{2},\cdots y_{m})}{\partial x_{1}}\\ \frac{\partial f(y_{1}y_{2},\cdots y_{m})}{\partial x_{2}}\\ \vdots\\ \frac{\partial f(y_{1}y_{2},\cdots y_{m})}{\partial x_{n}}\end{bmatrix} . \tag{10}\]  
Making use of the chain rule we obtain  
\[\
abla_{x}f(Ax)= \begin{bmatrix}\frac{\partial f}{\partial y_{1}} \frac{\partial y_{1}}{\partial x_{1}}+\frac{\partial f}{\partial y_{2}}\frac{ \partial y_{2}}{\partial x_{1}}+\cdots+\frac{\partial f}{\partial y_{m}}\frac {\partial y_{m}}{\partial x_{1}}\\ \frac{\partial f}{\partial y_{1}}\frac{\partial y_{1}}{\partial x_{2}}+ \frac{\partial f}{\partial y_{2}}\frac{\partial y_{2}}{\partial x_{2}}+ \cdots+\frac{\partial f}{\partial y_{m}}\frac{\partial y_{m}}{\partial x_{2}} \\ \vdots\\ \frac{\partial f}{\partial y_{1}}\frac{\partial y_{1}}{\partial x_{n}}+\frac{ \partial f}{\partial y_{2}}\frac{\partial y_{2}}{\partial x_{n}}+\cdots+\frac {\partial f}{\partial y_{m}}\frac{\partial y_{m}}{\partial x_{n}}\end{bmatrix} . \tag{11}\]  
Each entry of this matrix \(\left(\frac{\partial y_{j}}{\partial x_{k}}\right)\) is \(a_{jk}\); then Equation (11) can be rewritten as  
\[\
abla_{x}f(Ax)=A^{T}\frac{\partial f}{\partial y} \tag{12}\]  
where \(A^{T}\) is the transpose of the \(A\) matrix and  
\[\frac{\partial f}{\partial y}= \begin{bmatrix}\frac{\partial f}{\partial y_{j} }\\ \frac{\partial f}{\partial y_{2}}\\ \vdots\\ \frac{\partial f}{\partial y_{m}}\end{bmatrix} . \tag{13}\]  
Now, we are interested in calculating the derivative with respect to \(A\):  
\[\
abla_{A}f(Ax)= \begin{bmatrix}\frac{\partial f(Ax)}{\partial a_{11}}&\frac{ \partial f(Ax)}{\partial a_{12}}&\cdots&\frac{\partial f(Ax)}{\partial a_{1n} }\\ \frac{\partial f(Ax)}{\partial a_{21}}&\frac{\partial f(Ax)}{\partial a_{22}}& \cdots&\frac{\partial f(Ax)}{\partial a_{2n}}\\ \vdots\\ \frac{\partial f(Ax)}{\partial a_{m1}}&\frac{\partial f(Ax)}{\partial a_{m2}}& \cdots&\frac{\partial f(Ax)}{\partial a_{mm}}\end{bmatrix} .