## 2 Materials and Methods
### Non-Destructive Estimation of Nitrogen Using Convolutional Neural Networks  
Deep learning (DL) is a category of machine learning algorithms that uses multiple layers to extract high-level features from raw input [26]. These kind of networks use multiple layers of information processing, especially nonlinear information, to perform \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Category** & **Sum of Squares** & **Degrees of Freedom (df)** & **Mean Square** & **F-Score** & **Significance** \\ \hline Between Groups & \(8.15\times 10^{11}\) & 3 & \(2.72\times 10^{11}\) & & \\ Within Groups & \(1.91\times 10^{11}\) & 3996 & \(4.78\times 10^{7}\) & \(5.69\times 10^{3}\) & 0 \\ Total & \(1.01\times 10^{12}\) & 3999 & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 1: ANOVA analysis for spectral data of the four categories of treatments: control, \(\text{N}_{\text{307\%}}\), \(\text{N}_{\text{607\%}}\) and \(\text{N}_{\text{907\%}}\). The rows indicate the sum of squares between and within the classes, the number of degrees of freedom, the means of the squares between and within classes, the F-score (mean square between classes divided by mean square within classes), and the _p_-value of significance for an alpha of 0.05. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Treatment** & **Number** & \multicolumn{4}{c}{**Subset for Alpha = 0.05**} \\ \cline{3-5}  & & **Control** & \(\text{N}_{\text{30\%}}\) & \(\text{N}_{\text{60\%}}\) & \(\text{N}_{\text{90\%}}\) \\ \hline \(\text{N}_{\text{60\%}}\) & 1000 & \(9.2864\times 10^{2}\) & & & \\ \(\text{N}_{\text{30\%}}\) & 1000 & & \(1.7571\times 10^{3}\)  
the conversion or extraction of supervised or unsupervised features, generally for the purpose of pattern analysis or recognition, classification and clustering. Most deep learning methods use neural network structures, which is why DL models are often referred to as deep neural networks. Among them, convolutional neural networks (CNN) are one of the most popular techniques, since they do not require manual feature extraction. CNNs learn to recognize features from the samples using a large number of hidden layers. Each hidden layer increases the complexity of the features analyzed. Moreover, CNN networks do not change the structure of the input and pay attention to the connection between neighboring values. Until now, most of the research has been conducted by known CNN structures such as AlexNet, VGG Net, ZF Net, GoogLeNet and fully convolutional networks (FCN) [27]. But in this paper, we proposed our personalized structure. In fact, it has been developed by examining several personalized structures by trial and error. Finally, the structure with the highest prediction rate was selected and proposed in this work. More specifically, the proposed structure of the convolutional neural network used in this study is shown in Figure 4. The input vector of the algorithm contains the spectral data of a sample, and the output is the actual amount of nitrogen. Since, in our case, the input data is a one-dimensional (1D) spectrum, we used 1D convolutions. As shown, the architecture is similar to the well-known funnel design, where the size of the input is progressively reduced while the number of features increases. This is carried out by a succession of 1D convolutions and max-pooling layers. All the convolutions use the rectified linear (ReLu) activation function. The first part of the network contains 3 consecutive convolutional layers, then there are three steps of max-pooling and convolution. The second of these steps also includes a dropout layer, a method which is commonly used to avoid overfitting, since it randomly removes some weights in the previous convolutions, thus making the system more robust. The dropout rate was set to 0.1. Finally, the values of the last layer are flattened (producing 20,160 values) and a dense layer is responsible for producing the final estimation of nitrogen content.